diff --git a/packages/coln-compiler/src/Coln/Backend/IR.hs b/packages/coln-compiler/src/Coln/Backend/IR.hs index afa4d3b9..6267125f 100644 --- a/packages/coln-compiler/src/Coln/Backend/IR.hs +++ b/packages/coln-compiler/src/Coln/Backend/IR.hs @@ -49,7 +49,7 @@ data Entity = Entity { entityVariant :: EntityVariant , -- , columns :: Trie ColType columns :: [(ColName, ColType)] - , primaryKey :: Maybe (Set.Set ColName) + , primaryKey :: Maybe (Set.Set ColName) -- Should these just be integers instead of names? } deriving (Show, Eq, Generic) diff --git a/packages/coln-compiler/src/Coln/Backend/Lower.hs b/packages/coln-compiler/src/Coln/Backend/Lower.hs index c0a72346..837f6798 100644 --- a/packages/coln-compiler/src/Coln/Backend/Lower.hs +++ b/packages/coln-compiler/src/Coln/Backend/Lower.hs @@ -1,15 +1,19 @@ -- SPDX-FileCopyrightText: 2026 Coln contributors -- -- SPDX-License-Identifier: Apache-2.0 OR MIT +{-# OPTIONS_GHC -Wno-unused-imports #-} module Coln.Backend.Lower where import Control.Arrow (first, second) -import Control.Monad (forM_) +import Control.Monad (forM, forM_, when) +import Control.Monad.RWS +import Control.Monad.Reader.Class +import Control.Monad.State.Class import Data.Aeson qualified as AE -import Data.Foldable qualified as F import Data.Map.Ordered (OMap, (>|)) import Data.Map.Ordered qualified as OMap +import Data.Map.Strict qualified as Map import Data.Set qualified as Set import Data.Traversable (mapAccumL) import Prettyprinter.Render.Text (hPutDoc) @@ -32,6 +36,18 @@ data Shape | Unit deriving (Show) +projShape :: Shape -> Name -> Shape +projShape sh x = case sh of + Tuple fields -> elemAt fields x + _ -> panic "expected a tuple shape" + +storedWidth :: Shape -> Int +storedWidth = \case + RowId _ -> 1 + BuiltinTy _ -> 1 + Tuple fields -> sum $ storedWidth <$> fields + Unit -> 0 + data Term = Var BId | Lookup TableName (Dict Term) @@ -42,6 +58,7 @@ data Term data Pred = EltOf Term TableName (Dict Term) + | Holds TableName (Dict Term) -- Alternatively, `EltOf (Maybe Term) ...`? | And (Dict Pred) | Equal Term Term | PTrue @@ -64,9 +81,11 @@ instance Lower V.Spine (Term -> Term) where V.Proj sp x -> \t -> Proj (lower n sp t) x instance Lower V.Neutral Term where - lower n ne = case ne.expansion of - V.IntoCons fields -> Cons (lower n <$> fields) - V.NotApplicable -> lower n ne.spine $ lower n ne.head + lower n ne = case ne.head of + V.Lookup{} -> lower n ne.spine $ lower n ne.head + _ -> case ne.expansion of + V.IntoCons fields -> Cons (lower n <$> fields) + V.NotApplicable -> lower n ne.spine $ lower n ne.head instance Lower (V.El N) Term where lower :: CtxLen -> V.El N -> Term @@ -103,10 +122,13 @@ separate n = \case V.Function _ -> panic "lowering non-set-level type: Function" V.Eq et -> \_ -> Ty Unit (Equal (lower n et.lhs) (lower n et.rhs)) V.BuiltinTy t -> \_ -> Ty (BuiltinTy t) PTrue - V.EltOf x ts -> \v -> Ty (RowId x) (EltOf (lower n v) x (lower n <$> ts)) + V.EltOf x ts u -> case u of + SetU -> \v -> Ty (RowId x) (EltOf (lower n v) x (lower n <$> ts)) + PropU -> \_ -> Ty Unit (Holds x (lower n <$> ts)) + TheoryU -> \_ -> panic "element of a non-set relation" data Generator - = Rel [Name] [Ty] + = Rel [Name] [Ty] Universe | Fun [Name] [Ty] Ty lowerAtFresh :: CtxLen -> V.Ty N -> Ty @@ -126,290 +148,223 @@ lowerGen :: C.Generator -> Generator lowerGen (C.Fun xs ts t) = do let (ts', vs) = lowerTele ts Fun xs ts' (lowerAtFresh (length ts) (eval vs t)) -lowerGen (C.Rel xs ts) = do +lowerGen (C.Rel xs ts u) = do let (ts', _) = lowerTele ts - Rel xs ts' - -type EnvTerm = Trie I.Term - -noTerms :: EnvTerm -noTerms = Node $ fromList [] - -data LocalCtx = LocalCtx - { localLen :: CtxLen - , totalLen :: CtxLen - , localNames :: Bwd I.ColName - , localTys :: Bwd I.ColType - , conditions :: Bwd I.Prop - } - -data RuleFragment = RuleFragment - { ruleCtx :: LocalCtx - , heads :: [(I.ColName, I.Prop)] - } + Rel xs ts' u -data DisaggState = DisaggState - { funShapes :: OMap TableName Shape - , oldLen :: CtxLen - , oldNames :: Bwd Name - , oldTys :: Bwd Ty - , oldEnv :: Bwd EnvTerm - , newLen :: CtxLen - , newNames :: Bwd I.ColName - , newTys :: Bwd I.ColType - , frags :: Bwd RuleFragment - } +data TableInfo = TableInfo + {tableShapes :: OMap TableName Generator} -data PredState = PredState - { parent :: DisaggState - , localCtx :: LocalCtx +data VarInfo = VarInfo + { vars :: Bwd (I.ColName, I.ColType) + , length :: Int + , usedRoots :: Set.Set Name } -steal :: Bwd a -> CtxLen -> Bwd a -> Bwd a -steal base 0 _ = base -steal base n (xs :> x) = steal base (n - 1) xs :> x -steal _ _ _ = panic "not enough local variables" - -renumberTerm :: (Int -> Int) -> I.Term -> I.Term -renumberTerm f (I.Var (FId i)) = I.Var . FId $ f i -renumberTerm _ x = x - -renumberProp :: (Int -> Int) -> I.Prop -> I.Prop -renumberProp f (I.PAtom atom) = - I.PAtom $ - atom - { I.rowId = fmap (renumberTerm f) atom.rowId - , I.values = fmap (renumberTerm f) atom.values - } -renumberProp f (I.PEq lhs rhs) = - I.PEq - (renumberTerm f lhs) - (renumberTerm f rhs) - --- the global variables of the second must be a prefix of the global variables --- of the first -mergeFrag :: RuleFragment -> RuleFragment -> RuleFragment -mergeFrag base add = do - let basec = base.ruleCtx - let addc = add.ruleCtx - let renum n = if n >= addc.totalLen - addc.localLen then n - addc.totalLen + addc.localLen + basec.totalLen else n - RuleFragment - { ruleCtx = - LocalCtx - { localLen = basec.localLen + addc.localLen - , totalLen = basec.totalLen + addc.localLen - , localNames = steal basec.localNames addc.localLen addc.localNames - , localTys = steal basec.localTys addc.localLen addc.localTys - , conditions = basec.conditions <> fmap (renumberProp renum) addc.conditions - } - , heads = base.heads ++ fmap (second $ renumberProp renum) add.heads +newtype FlatM a = FlatM {unFlatM :: RWS TableInfo (Bwd I.Prop) VarInfo a} + deriving (Functor, Applicative, Monad, MonadState VarInfo, MonadWriter (Bwd I.Prop), MonadReader TableInfo) + +runFlatM :: TableInfo -> FlatM a -> (a, Bwd (I.ColName, I.ColType), Bwd I.Prop) +runFlatM ti action = do + let (res, s, w) = runRWS action.unFlatM ti (VarInfo BwdNil 0 Set.empty) + (res, s.vars, w) + +scalarShape :: Shape -> Maybe I.ColType +scalarShape = \case + RowId x -> Just $ I.RowId x + BuiltinTy t -> Just $ I.BuiltinTy t + _ -> Nothing + +fresh :: Path -> Shape -> FlatM (Trie I.Term) +fresh p = \case + (scalarShape -> Just colTy) -> do + ni <- get + let i = ni.length + put $ ni{vars = (ni.vars :> (p, colTy)), length = (i + 1)} + pure $ Leaf $ I.Var $ FId i + (RowId _; BuiltinTy _) -> panic "should have been covered by scalarShape" + Tuple fields -> do + fields' <- forM (toList fields) $ \(x, sh) -> do + v <- fresh (p :> x) sh + pure (x, v) + pure $ Node $ fromList fields' + Unit -> pure $ Node (fromList []) + +freshName :: FlatM Name +freshName = do + ni <- get + let x = freshNameFor ni.usedRoots + put $ ni{usedRoots = Set.insert x ni.usedRoots} + pure x + +emit :: I.Prop -> FlatM () +emit = tell . (BwdNil :>) + +retShapeOf :: TableName -> FlatM Shape +retShapeOf tn = do + ti <- ask + case OMap.lookup tn ti.tableShapes of + Just (Fun _ _ ret) -> pure ret.shape + _ -> panic "can only lookup from function" + +type FlatEnv = Bwd (Trie I.Term) + +class Flatten a b | a -> b where + flatten :: FlatEnv -> a -> FlatM b + +instance Flatten Term (Trie I.Term) where + flatten e = \case + Var i -> pure $ elemAt e i + Lookup x ts -> do + retSh <- retShapeOf x + retName <- freshName + ret <- fresh (BwdNil :> retName) retSh + args <- mapM (flatten e) $ toList ts.values + when (storedWidth retSh /= 0) $ + emit $ I.PAtom $ I.Atom x Nothing $ OMap.fromList $ (zip [0.. ] (flattenTries (args ++ [ret]))) + pure ret + Proj t x -> do + v <- flatten e t + pure $ projTrie v x + Lit l -> pure $ Leaf $ I.Lit l + Cons ts -> Node <$> traverse (flatten e) ts + +instance Flatten Pred [I.Prop] where + flatten e = \case + EltOf t x ts -> do + v <- flatten e t + vs <- traverse (flatten e) $ toList ts.values + pure [I.PAtom $ I.Atom x (Just (unwrapLeaf v)) (OMap.fromList $ (zip [0 ..] (flattenTries vs)))] + Holds x ts -> do + vs <- traverse (flatten e . snd) $ toList ts + pure [I.PAtom $ I.Atom x Nothing (OMap.fromList $ (zip [0 ..] (flattenTries vs)))] + And ts -> do + pss <- mapM (flatten e) ts.values + pure $ concat pss + Equal t0 t1 -> do + v0 <- flatten e t0 + v1 <- flatten e t1 + pure [I.PEq c0 c1 | (c0, c1) <- zip (flattenTrie v0) (flattenTrie v1)] + PTrue -> pure [] + +useRoot :: Name -> FlatM () +useRoot x = modify $ \ni -> ni{usedRoots = Set.insert x ni.usedRoots} + +validity :: [(Name, Ty)] -> FlatM (Bwd (Trie I.Term), [I.Prop]) +validity = go BwdNil BwdNil + where + go e ps [] = pure (e, toList ps) + go e ps ((x, ty) : tys) = do + v <- fresh (BwdNil :> x) ty.shape + let e' = e :> v + useRoot x + p <- flatten e' ty.pred + go e' (ps ++> p) tys + +flattenArg :: I.ColName -> Shape -> [(I.ColName, I.ColType)] +flattenArg p sh = case sh of + (scalarShape -> Just colTy) -> [(p, colTy)] + (RowId _; BuiltinTy _) -> panic "should have been covered by scalarShape" + Tuple fields -> concat [flattenArg (p :> x) sh' | (x, sh') <- toList fields] + Unit -> [] + +flattenArgs :: [(Name, Ty)] -> [(I.ColName, I.ColType)] +flattenArgs args = concat [flattenArg (BwdNil :> x) ty.shape | (x, ty) <- args] + +createRule :: TableInfo -> I.RuleVariant -> FlatM ([I.Prop], [I.Prop]) -> I.Rule +createRule ti variant action = do + let ((ante, cons), vars, props) = runFlatM ti action + let (varNames, varTypes) = unzip $ toList vars + I.Rule + { I.ruleVariant = variant + , I.varNames = fromList varNames + , I.varTypes = fromList varTypes + , I.antecedents = toList (props ++> ante) + , I.consequents = cons } -pushNew :: DisaggState -> (I.ColName, I.ColType) -> (DisaggState, EnvTerm) -pushNew ds (cn, ct) = do - let et = Leaf $ I.Var $ FId $ ds.newLen - let ds' = - ds - { newLen = ds.newLen + 1 - , newNames = ds.newNames :> cn - , newTys = ds.newTys :> ct - } - (ds', et) - -pushShape :: DisaggState -> (I.ColName, Shape) -> (DisaggState, EnvTerm) -pushShape ds = uncurry $ \x -> \case - RowId y -> pushNew ds (x, I.RowId y) - BuiltinTy bt -> pushNew ds (x, I.BuiltinTy bt) - Tuple d -> second (Node . withHead d) . mapAccumL pushShape ds . fmap (first (x :>)) $ toList d - Unit -> (ds, noTerms) - -pushOld :: DisaggState -> (Name, Ty, EnvTerm) -> DisaggState -pushOld ds (x, ty, et) = ds{oldLen = ds.oldLen + 1, oldNames = ds.oldNames :> x, oldTys = ds.oldTys :> ty, oldEnv = ds.oldEnv :> et} - -openPred :: DisaggState -> PredState -openPred ds = - PredState ds $ - LocalCtx - { localLen = 0 - , totalLen = ds.newLen - , localNames = ds.newNames - , localTys = ds.newTys - , conditions = BwdNil - } - -pushFrag :: PredState -> I.ColName -> [I.Prop] -> DisaggState -pushFrag ps x h = ps.parent{frags = ps.parent.frags :> RuleFragment ps.localCtx (fmap (\y -> (x, y)) h)} - -pushLocal :: PredState -> (I.ColName, I.ColType) -> (PredState, EnvTerm) -pushLocal ps (cn, ct) = do - let et = Leaf $ I.Var $ FId $ ps.localCtx.totalLen - let ctx' = - ps.localCtx - { localLen = ps.localCtx.localLen + 1 - , totalLen = ps.localCtx.totalLen + 1 - , localNames = ps.localCtx.localNames :> cn - , localTys = ps.localCtx.localTys :> ct - } - (ps{localCtx = ctx'}, et) - -pushVars :: PredState -> (I.ColName, Shape) -> (PredState, EnvTerm) -pushVars ps = uncurry $ \x -> \case - RowId tn -> pushLocal ps (x, I.RowId tn) - BuiltinTy bt -> pushLocal ps (x, I.BuiltinTy bt) - Tuple d -> second (Node . withHead d) . mapAccumL pushVars ps . fmap (first (x :>)) $ toList d - Unit -> (ps, noTerms) - -pushTerm' :: PredState -> (I.ColName, Term) -> (PredState, Trie I.Term) -pushTerm' ps = uncurry $ \x -> \case - Var b -> (ps, elemAt ps.parent.oldEnv b) - Lookup tn d -> case OMap.lookup tn ps.parent.funShapes of - Nothing -> panic "unknown function" - Just s -> do - let (ps', ts) = pushVars ps (x, s) - let ps'' = pushCond ps' x tn d ts - (ps'', ts) - Cons d -> second (Node . withHead d) . mapAccumL pushTerm' ps . fmap (first (x :>)) $ toList d - Proj y f -> do - let (ps', ts) = pushTerm' ps (x, y) - case ts of - Leaf _ -> panic "projection of non-record value" - Node d -> case lookup d f of - Nothing -> panic "nonexistent field" - Just z -> (ps', z) - Lit l -> (ps, Leaf $ I.Lit l) - -pushTerm :: PredState -> (I.ColName, Term) -> (PredState, [I.Term]) -pushTerm ps a = second F.toList $ pushTerm' ps a - -pushCond :: PredState -> I.ColName -> TableName -> Dict Term -> Trie I.Term -> PredState -pushCond ps x tn d ts' = do - let (ps', ts) = mapAccumL pushTerm ps . fmap (first (x :>)) $ toList d - let c = I.PAtom . I.Atom tn Nothing . OMap.fromList . zip [0 ..] $ foldr (++) (F.toList ts') ts - ps'{localCtx = ps'.localCtx{conditions = ps'.localCtx.conditions :> c}} - --- XXX actual state monad? -pushPred :: DisaggState -> (I.ColName, Pred) -> DisaggState -pushPred ds = uncurry $ \x -> \case - EltOf t n ts -> do - let ps1 = openPred ds - let (ps2, elts) = pushTerm' ps1 (x, t) - let elt = case elts of Leaf x -> x; _ -> panic "EltOf lhs was not an entity" - let (ps3, fields) = mapAccumL pushTerm ps2 . fmap (first (x :>)) $ toList ts - let fields' = OMap.fromList . zip [0 ..] $ concat fields - pushFrag ps3 x [I.PAtom $ I.Atom n (Just elt) fields'] - And d -> foldl' pushPred ds . fmap (first (x :>)) $ toList d - Equal lhs rhs -> do - let ps = openPred ds - let (ps', lhs') = pushTerm ps (x :> "lhs", lhs) - let (ps'', rhs') = pushTerm ps' (x :> "rhs", rhs) - pushFrag ps'' x $ zipWith I.PEq lhs' rhs' - PTrue -> ds - -pushTy :: DisaggState -> (Name, Ty) -> DisaggState -pushTy ds (x, ty) = do - let (ds', et) = pushShape ds (BwdNil :> x, ty.shape) - let ds'' = pushOld ds' (x, ty, et) - pushPred ds'' (BwdNil :> x, ty.pred) - -disaggregateTele :: OMap TableName Shape -> [Name] -> [Ty] -> DisaggState -disaggregateTele fs xs tys = do - let ds = - DisaggState - { funShapes = fs - , oldLen = 0 - , oldNames = BwdNil - , oldTys = BwdNil - , oldEnv = BwdNil - , newLen = 0 - , newNames = BwdNil - , newTys = BwdNil - , frags = BwdNil - } - foldl' pushTy ds $ zip xs tys - -mergeFrags :: DisaggState -> RuleFragment -mergeFrags ds = do - let base = - RuleFragment - { ruleCtx = - LocalCtx - { localLen = 0 - , totalLen = ds.newLen - , localNames = ds.newNames - , localTys = ds.newTys - , conditions = BwdNil - } - , heads = [] - } - foldl' mergeFrag base $ toList ds.frags - -disaggregateGen :: OMap TableName Shape -> TableName -> Generator -> I.FlatRealm -> I.FlatRealm -disaggregateGen fs tn (Rel xs ts) fr = do - let ds = disaggregateTele fs xs ts - let rf = mergeFrags ds - let foreignKey = - I.Rule - { I.ruleVariant = I.Enforced - , I.varNames = rf.ruleCtx.localNames - , I.varTypes = rf.ruleCtx.localTys - , I.antecedents = (I.PAtom $ I.Atom tn Nothing $ OMap.fromList $ map (\n -> (n, I.Var $ FId n)) [0 .. ds.newLen - 1]) : toList rf.ruleCtx.conditions - , I.consequents = fmap snd rf.heads - } - let table = - I.Entity - { I.entityVariant = I.Table - , I.columns = zip (toList ds.newNames) (toList ds.newTys) - , primaryKey = Nothing - } +flattenGen :: TableInfo -> TableName -> Generator -> (Maybe I.Entity, [(TableName, I.Rule)]) +flattenGen ti tn = \case + Rel xs tys u -> do + let args = zip xs tys + let cols = flattenArgs args + let pkey = case u of + SetU -> Nothing + PropU -> Just $ Set.fromList $ fst <$> cols + _ -> panic "generator must be of a set or smaller universe" + let entity = I.Entity I.Table cols pkey + let foreignKeyRule = createRule ti I.Enforced $ do + (e, cons) <- validity args + let vs = flattenTries $ toList e + let ante = [I.PAtom (I.Atom tn Nothing (OMap.fromList $ zip [0 ..] vs))] + pure (ante, cons) + (Just entity, [(tn{path = tn.path :> "foreignKey"}, foreignKeyRule)]) + Fun xs argTys retTy -> case storedWidth retTy.shape of + 0 -> do + let args = zip xs argTys + let retRoot = freshNameFor xs + let retName = BwdNil :> retRoot + let rule = createRule ti I.Monitored $ do + useRoot retRoot + (e, argPreds) <- validity args + ret <- fresh retName retTy.shape + let e' = e :> ret + retPred <- flatten e' retTy.pred + pure (argPreds, retPred) + (Nothing, [(tn, rule)]) + _ -> do + let args = zip xs argTys + let argCols = flattenArgs args + let pkey = Just $ Set.fromList $ fst <$> argCols + let retRoot = freshNameFor xs + let retName = BwdNil :> retRoot + let retCols = flattenArg retName retTy.shape + let cols = argCols ++ retCols + let entity = I.Entity I.Table cols pkey + let foreignKeyRule = createRule ti I.Enforced $ do + useRoot retRoot + (e, argPreds) <- validity args + ret <- fresh retName retTy.shape + let e' = e :> ret + retPred <- flatten e' retTy.pred + let vs = flattenTries $ toList e' + let ante = [I.PAtom (I.Atom tn Nothing (OMap.fromList $ zip [0 ..] vs))] + pure (ante, argPreds ++ retPred) + let totalityRule = createRule ti I.Monitored $ do + (e, argPreds) <- validity args + let vs = flattenTries $ toList e + let cons = [I.PAtom (I.Atom tn Nothing (OMap.fromList $ zip [0 ..] vs))] + pure (argPreds, cons) + ( Just entity + , + [ (tn{path = tn.path :> "foreignKey"}, foreignKeyRule) + , (tn{path = tn.path :> "total"}, totalityRule) + ] + ) + +addFlatGenerator :: TableInfo -> I.FlatRealm -> TableName -> Generator -> I.FlatRealm +addFlatGenerator ti fr x g = do + let (me, rules) = flattenGen ti x g fr - { I.entities = fr.entities >| (tn, table) - , I.rules = fr.rules >| (tn{path = tn.path :> "foreignKey"}, foreignKey) - } -disaggregateGen fs tn (Fun xs ts t) fr = do - let ds = disaggregateTele fs xs ts - let rf = mergeFrags ds - let totality = - I.Rule - { I.ruleVariant = I.Monitored -- XXX do Enforced when appropriate - , I.varNames = rf.ruleCtx.localNames - , I.varTypes = rf.ruleCtx.localTys - , I.antecedents = toList rf.ruleCtx.conditions ++ fmap snd rf.heads - , I.consequents = [I.PAtom $ I.Atom tn Nothing $ OMap.fromList $ map (\n -> (n, I.Var $ FId n)) [0 .. ds.newLen - 1]] - } - let x = freshNameFor xs - let ds' = pushTy ds (x, t) - let rf' = mergeFrags ds' - let foreignKey = - I.Rule - { I.ruleVariant = I.Enforced - , I.varNames = rf'.ruleCtx.localNames - , I.varTypes = rf'.ruleCtx.localTys - , I.antecedents = (I.PAtom $ I.Atom tn Nothing $ OMap.fromList $ map (\n -> (n, I.Var $ FId n)) [0 .. ds'.newLen - 1]) : toList rf'.ruleCtx.conditions - , I.consequents = fmap snd rf'.heads - } - let table = - I.Entity - { I.entityVariant = I.Table - , I.columns = zip (toList ds'.newNames) (toList ds'.newTys) - , I.primaryKey = Just . Set.fromList $ toList ds.newNames - } - fr - { I.entities = fr.entities >| (tn, table) - , I.rules = fr.rules >| (tn{path = tn.path :> "foreignKey"}, foreignKey) >| (tn{path = tn.path :> "total"}, totality) + { I.entities = case me of + Just e -> fr.entities OMap.>| (x, e) + Nothing -> fr.entities + , I.rules = fr.rules OMap.<>| (OMap.fromList rules) } lowerRealm :: Name -> C.Realm -> I.FlatRealm -lowerRealm realmName r = go OMap.empty I.emptyFlatRealm (toList r.generators) +lowerRealm realmName r = go I.emptyFlatRealm $ OMap.assocs generators where - go _ fr [] = fr - go fs fr ((xs, g) : rest) = do - let tn = TableName realmName xs - let lg = lowerGen g - let fr' = disaggregateGen fs tn lg fr - let fs' = case lg of - Fun _ _ t -> fs >| (tn, t.shape) - _ -> fs - go fs' fr' rest + generators = + OMap.fromList $ + for (toList r.generators) $ \(path, generator) -> + (TableName realmName path, lowerGen generator) + + tableInfo = TableInfo generators + + go fr [] = fr + go fr ((tn, generator) : rest) = + go (addFlatGenerator tableInfo fr tn generator) rest writeIRFor :: C.Globals -> FilePath -> IO () writeIRFor ge fp = do diff --git a/packages/coln-compiler/src/Coln/Backend/TypeScript/Generate.hs b/packages/coln-compiler/src/Coln/Backend/TypeScript/Generate.hs index 35e39753..3d8fd0da 100644 --- a/packages/coln-compiler/src/Coln/Backend/TypeScript/Generate.hs +++ b/packages/coln-compiler/src/Coln/Backend/TypeScript/Generate.hs @@ -44,7 +44,7 @@ genTy access n = \case V.Function ft -> do let v = V.local (FId n) ft.dom TS.Fun (TS.Binding (TS.Id "x") (TS.runtime Value)) (genTy access (n + 1) (V.appClo ft.cod v)) - V.EltOf _ _ -> TS.runtime $ ColnRef access + V.EltOf _ _ _ -> TS.runtime $ ColnRef access V.Decode n -> tyFromHead access n.head V.BuiltinTy _ -> TS.runtime $ ColnRef access _ -> error "not yet supported" @@ -102,7 +102,7 @@ class TrackGlobals a where -- trackGlobals et.rhs -- S.BuiltinTy _ -> pure () -- S.IsTy a -> trackGlobals a --- S.EltOf _ _ -> pure () +-- S.EltOf _ _ _ -> pure () genTypeDef :: Access -> CtxLen -> V.Ty N -> TS.TypeDef genTypeDef access n a = TS.TypeDef (fromShow access) (genTy access n a) @@ -139,7 +139,7 @@ tableNameDoc tn = concatWith (surround dot) (dpretty <$> (tn.realm : toList tn.p genTyVal :: Access -> TSCtxShape -> V.Ty N -> TS.El genTyVal access cs = \case - V.EltOf x vs -> do + V.EltOf x vs _ -> do let params = TS.List $ genEl access cs <$> F.toList vs let transactionArg = case access of View -> [] diff --git a/packages/coln-compiler/src/Coln/Common.hs b/packages/coln-compiler/src/Coln/Common.hs index 3e87ed48..c719fff3 100644 --- a/packages/coln-compiler/src/Coln/Common.hs +++ b/packages/coln-compiler/src/Coln/Common.hs @@ -22,6 +22,7 @@ module Coln.Common ( PartialOrd (..), Reverse (..), Bwd (..), + (++>), BId (..), Fwd (..), FId (..), @@ -31,6 +32,10 @@ module Coln.Common ( getKeyIndex, withHead, Trie (..), + projTrie, + unwrapLeaf, + flattenTrie, + flattenTries, HasNames (..), alphaStrings, alphaNames, @@ -98,6 +103,9 @@ class Contains a i | a -> i where class ToList a e | a -> e where toList :: a -> [e] +instance ToList (Vector a) a where + toList = V.toList + class FromList a e | a -> e where fromList :: [e] -> a @@ -152,6 +160,10 @@ instance Semigroup (Bwd a) where instance Monoid (Bwd a) where mempty = BwdNil +(++>) :: Bwd a -> [a] -> Bwd a +xs ++> [] = xs +xs ++> (y : ys) = (xs :> y) ++> ys + infixr 5 :< data Fwd a = FwdNil | a :< Fwd a @@ -251,6 +263,22 @@ instance ToList (Trie a) (Bwd Name, a) where Leaf x -> [(prefix, x)] Node ts -> concat $ [go (prefix :> x) t | (x, t) <- toList ts] +projTrie :: Trie a -> Name -> Trie a +projTrie (Node fields) x = elemAt fields x +projTrie (Leaf _) _ = panic "tried to project from leaf node" + +unwrapLeaf :: Trie a -> a +unwrapLeaf (Leaf v) = v +unwrapLeaf (Node _) = panic "tried to unwrap a non-leaf" + +flattenTrie :: Trie a -> [a] +flattenTrie = \case + Leaf t -> [t] + Node ts -> flattenTries $ snd <$> toList ts + +flattenTries :: [Trie a] -> [a] +flattenTries = (>>= flattenTrie) + -- Fresh Variable Names -------------------------------------------------------------------------------- @@ -273,6 +301,9 @@ instance HasNames (Dict a) where instance HasNames [Name] where namesIn xs = Set.fromList xs +instance HasNames (Set.Set Name) where + namesIn = id + freshNamesFor :: (HasNames a) => a -> [Name] freshNamesFor a = flip filter alphaNames $ flip Set.notMember $ namesIn a diff --git a/packages/coln-compiler/src/Coln/Core/Conversion.hs b/packages/coln-compiler/src/Coln/Core/Conversion.hs index a7184b70..8df5187b 100644 --- a/packages/coln-compiler/src/Coln/Core/Conversion.hs +++ b/packages/coln-compiler/src/Coln/Core/Conversion.hs @@ -84,8 +84,9 @@ instance DefEq (V.Ty N) where V.BuiltinTy b' -> unless (b == b') $ throwUnequalTys cs a a' $ Just "unequal builtin types" _ -> throwUnequalTys cs a a' Nothing - V.EltOf x vs -> case a' of - V.EltOf x' vs' -> do + V.EltOf x vs u -> case a' of + V.EltOf x' vs' u' -> do + unless (u == u') $ throwUnequalTys cs a a' $ Just "unequal universes" unless (x == x') $ throwUnequalTys cs a a' $ Just "unequal table names" zipWithM_ (defEq cs) (F.toList vs) (F.toList vs') _ -> throwUnequalTys cs a a' Nothing diff --git a/packages/coln-compiler/src/Coln/Core/Evaluation.hs b/packages/coln-compiler/src/Coln/Core/Evaluation.hs index d5bdab05..5e3033a6 100644 --- a/packages/coln-compiler/src/Coln/Core/Evaluation.hs +++ b/packages/coln-compiler/src/Coln/Core/Evaluation.hs @@ -86,6 +86,6 @@ instance Compile S.Ty V.Ty where S.IsTy a -> do let k = compile a V.Become . k - S.EltOf x ts -> do + S.EltOf x ts u -> do let k = compile <$> ts - \vs -> V.EltOf x $ ($ vs) <$> k + \vs -> V.EltOf x (($ vs) <$> k) u diff --git a/packages/coln-compiler/src/Coln/Core/Globals.hs b/packages/coln-compiler/src/Coln/Core/Globals.hs index 32eb487c..dbc1c38b 100644 --- a/packages/coln-compiler/src/Coln/Core/Globals.hs +++ b/packages/coln-compiler/src/Coln/Core/Globals.hs @@ -32,7 +32,7 @@ mkDefinition x ty tm m = do -------------------------------------------------------------------------------- data Generator - = Rel [Name] [S.Ty N] + = Rel [Name] [S.Ty N] Universe | Fun [Name] [S.Ty N] (S.Ty N) data Realm = Realm diff --git a/packages/coln-compiler/src/Coln/Core/Layout.hs b/packages/coln-compiler/src/Coln/Core/Layout.hs index 5b5b4997..758c1617 100644 --- a/packages/coln-compiler/src/Coln/Core/Layout.hs +++ b/packages/coln-compiler/src/Coln/Core/Layout.hs @@ -65,10 +65,9 @@ layout p sc a let (gts, ms) = go rt.capture (toList rt.fieldTypes) let m = M.cons (Dict rt.fieldTypes.head (Vector.fromList ms)) (Node $ Dict rt.fieldTypes.head (Vector.fromList gts), m) - V.LikeU (SetU; PropU) -> do - -- TODO: layout Prop correctly - let gt = Leaf (Rel (toList sc.names) (toList sc.ctx)) - let a = V.EltOf (TableName sc.realm p) (fromList $ zip (toList sc.names) (toList sc.bound)) + V.LikeU u@(SetU; PropU) -> do + let gt = Leaf (Rel (toList sc.names) (toList sc.ctx) u) + let a = V.EltOf (TableName sc.realm p) (fromList $ zip (toList sc.names) (toList sc.bound)) u (gt, M.code (M.fromVTy sc.len a)) V.NoRules -> panic "cannot layout type with no rules" V.LikeBuiltinTy _; V.LikeU _; V.LikeInductive _ -> panic "non-theory type" diff --git a/packages/coln-compiler/src/Coln/Core/Print.hs b/packages/coln-compiler/src/Coln/Core/Print.hs index b44526a2..b053e46b 100644 --- a/packages/coln-compiler/src/Coln/Core/Print.hs +++ b/packages/coln-compiler/src/Coln/Core/Print.hs @@ -96,7 +96,7 @@ instance ToNotation (Ty e) where (toNotation xs eq.rhs) BuiltinTy a -> N.Keyword (fromString $ show a) () IsTy a -> toNotation xs a - EltOf x ts -> N.Juxt (toNotation xs x) (N.Tuple (field <$> toList ts) ()) + EltOf x ts _ -> N.Juxt (toNotation xs x) (N.Tuple (field <$> toList ts) ()) where field (y, t) = N.Infix (N.Ident y ()) (N.Keyword ":=" ()) (toNotation xs t) @@ -119,7 +119,7 @@ toNotationTele xs tys = go xs BwdNil tys go _ _ _ = panic "mismatched lengths" instance ToNotationTop Generator where - toNotationTop (Rel xs tys) = + toNotationTop (Rel xs tys _) = N.Juxt (N.Keyword "rel" ()) (N.Tuple (toNotationTele xs tys) ()) toNotationTop (Fun xs tys ret) = N.Infix diff --git a/packages/coln-compiler/src/Coln/Core/Readback.hs b/packages/coln-compiler/src/Coln/Core/Readback.hs index 2b720af5..697ed1d0 100644 --- a/packages/coln-compiler/src/Coln/Core/Readback.hs +++ b/packages/coln-compiler/src/Coln/Core/Readback.hs @@ -100,7 +100,7 @@ instance (V.HasEvaluation c) => Readback (V.Ty c) (S.Ty c) where V.Record r -> S.Record $ readb n r V.Eq eq -> S.Eq $ readb n eq V.BuiltinTy b -> S.BuiltinTy b - V.EltOf x vs -> S.EltOf x (readb n <$> vs) + V.EltOf x vs u -> S.EltOf x (readb n <$> vs) u instance Readback V.TypeBehavior S.TypeBehavior where readb n = \case diff --git a/packages/coln-compiler/src/Coln/Core/Syntax.hs b/packages/coln-compiler/src/Coln/Core/Syntax.hs index 813ceb0b..023caedb 100644 --- a/packages/coln-compiler/src/Coln/Core/Syntax.hs +++ b/packages/coln-compiler/src/Coln/Core/Syntax.hs @@ -53,7 +53,7 @@ data Ty :: Case -> Type where Eq :: EqualityType El Ty -> Ty N BuiltinTy :: BuiltinTy -> Ty N IsTy :: Ty N -> Ty D - EltOf :: TableName -> Dict (El N) -> Ty N + EltOf :: TableName -> Dict (El N) -> Universe -> Ty N data TypeBehavior = LikeU Universe diff --git a/packages/coln-compiler/src/Coln/Core/Value.hs b/packages/coln-compiler/src/Coln/Core/Value.hs index d08c76ae..6e5b6048 100644 --- a/packages/coln-compiler/src/Coln/Core/Value.hs +++ b/packages/coln-compiler/src/Coln/Core/Value.hs @@ -235,7 +235,7 @@ data Ty :: Case -> Type where Record :: RecordType -> Ty D Eq :: EqualityType -> Ty N BuiltinTy :: BuiltinTy -> Ty N - EltOf :: TableName -> Dict (El N) -> Ty N + EltOf :: TableName -> Dict (El N) -> Universe -> Ty N instance DebugVal (Ty c) where debugVal = \case @@ -246,7 +246,7 @@ instance DebugVal (Ty c) where Record _ -> "Record" Eq _ -> "Eq" BuiltinTy _ -> "BuiltinTy" - EltOf _ _ -> "EltOf" + EltOf _ _ _ -> "EltOf" instance LevelOf (Ty c) where levelOf = \case @@ -257,7 +257,7 @@ instance LevelOf (Ty c) where InitDecode _ -> Level Set HSet Eq ety -> Level (levelOf ety.at).mlevel (equalityHLevelOf (levelOf ety.at).hlevel) BuiltinTy _ -> Level Set HSet -- Only Int/String so far - EltOf _ _ -> Level Set HSet -- TODO + EltOf _ _ u -> decodesInto u behavior :: Ty c -> TypeBehavior behavior = \case @@ -270,7 +270,7 @@ behavior = \case Record rt -> LikeRecord rt Eq _ -> NoRules BuiltinTy bty -> LikeBuiltinTy bty - EltOf _ _ -> NoRules + EltOf _ _ _ -> NoRules decode :: (HasEvaluation c) => El c -> Evaluation Ty c decode (Code a) = epure a diff --git a/packages/coln-compiler/test/Main.hs b/packages/coln-compiler/test/Main.hs index 083eb8e0..e15061c4 100644 --- a/packages/coln-compiler/test/Main.hs +++ b/packages/coln-compiler/test/Main.hs @@ -35,7 +35,13 @@ knownFailingElaboratorTests :: [String] knownFailingElaboratorTests = [] knownFailingTypeScriptTests :: [String] -knownFailingTypeScriptTests = ["equality", "equality-prop", "rule-literals"] +knownFailingTypeScriptTests = + [ "equality" + , "equality-prop" + , "equality-record" + , "equality-record-nested" + , "rule-literals" + ] main :: IO () main = defaultMain =<< goldenTests diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.coln new file mode 100644 index 00000000..4fa9c1b1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Prop + B : A -> Prop + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.output new file mode 100644 index 00000000..f91dba6f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.output @@ -0,0 +1,41 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.C := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.C.foreignKey := ℜ.C [] ⊢ ℜ.A [] ∧ ℜ.B [] + monitored ℜ.f := ℜ.A [] ∧ ℜ.B [] ⊢ ℜ.C [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..6b280c66 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.coln new file mode 100644 index 00000000..512fd386 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Prop + B : A -> Prop + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.output new file mode 100644 index 00000000..fcc4724c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.output @@ -0,0 +1,43 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.C := [] + table ℜ.f := [.c : ℜ.C] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.C.foreignKey := ℜ.C [] ⊢ ℜ.A [] ∧ ℜ.B [] + enforced ℜ.f.foreignKey c := ℜ.f [.c ↦ c] ⊢ ℜ.A [] ∧ ℜ.B [] ∧ c ∈ ℜ.C [] + monitored ℜ.f.total := ℜ.A [] ∧ ℜ.B [] ⊢ ℜ.f [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..27d39667 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.coln new file mode 100644 index 00000000..fd903fb1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Prop + B : A -> Set + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.output new file mode 100644 index 00000000..1312d871 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.output @@ -0,0 +1,41 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.C := [.b : ℜ.B] primarykey [.b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.C.foreignKey b := ℜ.C [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + monitored ℜ.f b := ℜ.A [] ∧ b ∈ ℜ.B [] ⊢ ℜ.C [.b ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..37426d9b --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.coln new file mode 100644 index 00000000..e4be848b --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Prop + B : A -> Set + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.output new file mode 100644 index 00000000..e92dd72f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.C := [.b : ℜ.B] + table ℜ.f := [.b : ℜ.B, .c : ℜ.C] primarykey [.b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.C.foreignKey b := ℜ.C [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + enforced ℜ.f.foreignKey b c := ℜ.f [ + .b ↦ b, + .c ↦ c + ] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] ∧ c ∈ ℜ.C [.b ↦ b] + monitored ℜ.f.total b := ℜ.A [] ∧ b ∈ ℜ.B [] ⊢ ℜ.f [.b ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.json new file mode 100644 index 00000000..2755d281 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.coln new file mode 100644 index 00000000..b0cf207d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Set + B : A -> Prop + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.output new file mode 100644 index 00000000..5dea906e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.output @@ -0,0 +1,41 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.C := [.a : ℜ.A] primarykey [.a] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.C.foreignKey a := ℜ.C [.a ↦ a] ⊢ a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] + monitored ℜ.f a := a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] ⊢ ℜ.C [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..104a7c42 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.coln new file mode 100644 index 00000000..94f0f3d8 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Set + B : A -> Prop + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.output new file mode 100644 index 00000000..04ce31fc --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.output @@ -0,0 +1,45 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.C := [.a : ℜ.A] + table ℜ.f := [.a : ℜ.A, .c : ℜ.C] primarykey [.a] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.C.foreignKey a := ℜ.C [.a ↦ a] ⊢ a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] + enforced ℜ.f.foreignKey a c := ℜ.f [.a ↦ a, .c ↦ c] ⊢ a ∈ ℜ.A [] ∧ ℜ.B [ + .a ↦ a + ] ∧ c ∈ ℜ.C [.a ↦ a] + monitored ℜ.f.total a := a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] ⊢ ℜ.f [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..a1bcaa8c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.coln new file mode 100644 index 00000000..7490d23f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Set + B : A -> Set + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.output new file mode 100644 index 00000000..0d92dcde --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.output @@ -0,0 +1,43 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + C : (a : A) -> B a -> Prop + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.C := [.a : ℜ.A, .b : ℜ.B] primarykey [.a, .b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.C.foreignKey a b := ℜ.C [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [ + .a ↦ a + ] + monitored ℜ.f a b := a ∈ ℜ.A [] ∧ b ∈ ℜ.B [.a ↦ a] ⊢ ℜ.C [.a ↦ a, .b ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..b03d27c2 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]],[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.coln new file mode 100644 index 00000000..276f3f76 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.coln @@ -0,0 +1,9 @@ +theory T := sig + A : Set + B : A -> Set + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.output new file mode 100644 index 00000000..0edd41a6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.output @@ -0,0 +1,52 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + C : (a : A) -> B a -> Set + f : (a : A) -> (b : B a) -> C a b +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + C = rel [a : TRealm.A [], b : TRealm.B [a := a]] + f = (fun [a : TRealm.A [], b : TRealm.B [a := a]] -> TRealm.C [ + a := a, + b := b + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.C := [.a : ℜ.A, .b : ℜ.B] + table ℜ.f := [.a : ℜ.A, .b : ℜ.B, .c : ℜ.C] primarykey [.a, .b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.C.foreignKey a b := ℜ.C [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [ + .a ↦ a + ] + enforced ℜ.f.foreignKey a b c := ℜ.f [ + .a ↦ a, + .b ↦ b, + .c ↦ c + ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [.a ↦ a] ∧ c ∈ ℜ.C [.a ↦ a, .b ↦ b] + monitored ℜ.f.total a b := a ∈ ℜ.A [] ∧ b ∈ ℜ.B [.a ↦ a] ⊢ ℜ.f [ + .a ↦ a, + .b ↦ b + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/T.ts new file mode 100644 index 00000000..c765b892 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + C: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.json new file mode 100644 index 00000000..8b098795 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["a"]],[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":2},"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.ts new file mode 100644 index 00000000..8a4b907c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.ts @@ -0,0 +1,69 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.C", [a, b])); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + C: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.C", + [a, b], + transaction + )); + }; + }, + f: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.coln new file mode 100644 index 00000000..729dcd82 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Prop + f : (a : A) -> B a +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.output new file mode 100644 index 00000000..05946e2c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.output @@ -0,0 +1,34 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + f : (a : A) -> B a +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + f = (fun [a : TRealm.A []] -> TRealm.B [a := a]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + monitored ℜ.f := ℜ.A [] ⊢ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..34d4081c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..662e1e96 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..b720e351 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,50 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.coln new file mode 100644 index 00000000..6f2a626e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Set + f : (a : A) -> B a +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.output new file mode 100644 index 00000000..f4ddb7ce --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.output @@ -0,0 +1,36 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + f : (a : A) -> B a +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + f = (fun [a : TRealm.A []] -> TRealm.B [a := a]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.f := [.b : ℜ.B] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.f.foreignKey b := ℜ.f [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + monitored ℜ.f.total := ℜ.A [] ⊢ ℜ.f [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/T.ts new file mode 100644 index 00000000..34d4081c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..b366ecb7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..b720e351 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.ts @@ -0,0 +1,50 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.coln new file mode 100644 index 00000000..d8a36c75 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Prop + f : (a : A) -> B a +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.output new file mode 100644 index 00000000..49948523 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.output @@ -0,0 +1,34 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + f : (a : A) -> B a +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + f = (fun [a : TRealm.A []] -> TRealm.B [a := a]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + monitored ℜ.f a := a ∈ ℜ.A [] ⊢ ℜ.B [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/T.ts new file mode 100644 index 00000000..34d4081c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..51ad5ca5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..b720e351 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.ts @@ -0,0 +1,50 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function.coln b/packages/coln-compiler/test/golden/basic-ir/dependent-function.coln new file mode 100644 index 00000000..eec801fd --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Set + f : (a : A) -> B a +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function.output b/packages/coln-compiler/test/golden/basic-ir/dependent-function.output new file mode 100644 index 00000000..4636664c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function.output @@ -0,0 +1,38 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + f : (a : A) -> B a +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + f = (fun [a : TRealm.A []] -> TRealm.B [a := a]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.f := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.f.foreignKey a b := ℜ.f [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [ + .a ↦ a + ] + monitored ℜ.f.total a := a ∈ ℜ.A [] ⊢ ℜ.f [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/T.ts new file mode 100644 index 00000000..34d4081c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.json new file mode 100644 index 00000000..c4ed98b1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.ts new file mode 100644 index 00000000..b720e351 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.ts @@ -0,0 +1,50 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.coln b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.coln new file mode 100644 index 00000000..b18b8a1a --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.coln @@ -0,0 +1,10 @@ +def Truth : Prop := sig +end + +theory T := sig + X : Set + trivial : (x : X) -> Truth +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.output b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.output new file mode 100644 index 00000000..8e677fbf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named Truth +in mode: Conjunctive +type: Prop +value: sig +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + trivial : (x : X) -> Truth +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + trivial = (fun [x : TRealm.X []] -> Truth) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + monitored ℜ.trivial x := x ∈ ℜ.X [] ⊢ ⊤ + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/T.ts new file mode 100644 index 00000000..8a679781 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + trivial: (x: runtime.Value) => Truth.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + trivial: (x: runtime.Value) => Truth.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.json new file mode 100644 index 00000000..1b82d622 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["trivial"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.ts new file mode 100644 index 00000000..46e80df1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.ts @@ -0,0 +1,39 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + trivial: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.trivial", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + trivial: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.trivial", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.output b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.output index ec41de27..f55c83fd 100644 --- a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.output +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.output @@ -22,11 +22,9 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.truth := [] primarykey [] end rules - enforced ℜ.truth.foreignKey := ℜ.truth [] ⊢ ⊤ - monitored ℜ.truth.total := ⊤ ⊢ ℜ.truth [] + monitored ℜ.truth := ⊤ ⊢ ⊤ end end diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.ts.output/TRealm.json index ad227477..7eeaeb0d 100644 --- a/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/empty-prop-record.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["truth"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["truth"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["truth"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["truth"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["truth"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file +{"entities":[],"rules":[{"path":[["TRealm"],["truth"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-record.output b/packages/coln-compiler/test/golden/basic-ir/empty-record.output index 76f31b80..c172c074 100644 --- a/packages/coln-compiler/test/golden/basic-ir/empty-record.output +++ b/packages/coln-compiler/test/golden/basic-ir/empty-record.output @@ -22,11 +22,9 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.unit := [] primarykey [] end rules - enforced ℜ.unit.foreignKey := ℜ.unit [] ⊢ ⊤ - monitored ℜ.unit.total := ⊤ ⊢ ℜ.unit [] + monitored ℜ.unit := ⊤ ⊢ ⊤ end end diff --git a/packages/coln-compiler/test/golden/basic-ir/empty-record.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/empty-record.ts.output/TRealm.json index ad96b0d8..dfd2be2d 100644 --- a/packages/coln-compiler/test/golden/basic-ir/empty-record.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/empty-record.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["unit"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["unit"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["unit"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["unit"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["unit"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file +{"entities":[],"rules":[{"path":[["TRealm"],["unit"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/equality-prop.output b/packages/coln-compiler/test/golden/basic-ir/equality-prop.output index b24bf5f5..c67b0503 100644 --- a/packages/coln-compiler/test/golden/basic-ir/equality-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/equality-prop.output @@ -23,21 +23,13 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.P := [] - table ℜ.x := [.a : ℜ.P] primarykey [] - table ℜ.y := [.a : ℜ.P] primarykey [] - table ℜ.eq := [] primarykey [] + table ℜ.P := [] primarykey [] end rules enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ - enforced ℜ.x.foreignKey a := ℜ.x [.a ↦ a] ⊢ a ∈ ℜ.P [] - monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] - enforced ℜ.y.foreignKey a := ℜ.y [.a ↦ a] ⊢ a ∈ ℜ.P [] - monitored ℜ.y.total := ⊤ ⊢ ℜ.y [] - enforced ℜ.eq.foreignKey a.lhs a.rhs := ℜ.eq [] ∧ ℜ.x [.a ↦ a.lhs] ∧ ℜ.y [ - .a ↦ a.rhs - ] ⊢ a.lhs = a.rhs - monitored ℜ.eq.total := ⊤ ⊢ ℜ.eq [] + monitored ℜ.x := ⊤ ⊢ ℜ.P [] + monitored ℜ.y := ⊤ ⊢ ℜ.P [] + monitored ℜ.eq := ⊤ ⊢ ⊤ end end diff --git a/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.coln b/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.coln new file mode 100644 index 00000000..bd7c83be --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.coln @@ -0,0 +1,24 @@ +def Unit : Set := sig +end + +def Inner (X : Set) (P : Prop) : Set := sig + value : X + evidence : P +end + +def Outer (X : Set) (P : Prop) : Set := sig + unit : Unit + inner : Inner X P + trailing : X +end + +theory T := sig + X : Set + P : Prop + first : Outer X P + second : Outer X P + same : first = second +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.output b/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.output new file mode 100644 index 00000000..70dd3863 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/equality-record-nested.output @@ -0,0 +1,76 @@ +-- elaborated +global entry named Unit +in mode: Conjunctive +type: Set +value: sig +end +global entry named Inner +in mode: Conjunctive +type: (X : Set) -> (P : Prop) -> Set +value: X => P => sig + value : X + evidence : P +end +global entry named Outer +in mode: Conjunctive +type: (X : Set) -> (P : Prop) -> Set +value: X => P => sig + unit : Unit + inner : Inner X P + trailing : X +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + P : Prop + first : Outer X P + second : Outer X P + same : first = second +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + P = rel [] + first = (fun [] -> Outer (TRealm.X []) (TRealm.P [])) + second = (fun [] -> Outer (TRealm.X []) (TRealm.P [])) + same = (fun [] -> TRealm.first [] = TRealm.second []) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.P := [] primarykey [] + table ℜ.first := [.a.inner.value : ℜ.X, .a.trailing : ℜ.X] primarykey [] + table ℜ.second := [.a.inner.value : ℜ.X, .a.trailing : ℜ.X] primarykey [] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ + enforced ℜ.first.foreignKey a.inner.value a.trailing := ℜ.first [ + .a.inner.value ↦ a.inner.value, + .a.trailing ↦ a.trailing + ] ⊢ a.inner.value ∈ ℜ.X [] ∧ ℜ.P [] ∧ a.trailing ∈ ℜ.X [] + monitored ℜ.first.total := ⊤ ⊢ ℜ.first [] + enforced ℜ.second.foreignKey a.inner.value a.trailing := ℜ.second [ + .a.inner.value ↦ a.inner.value, + .a.trailing ↦ a.trailing + ] ⊢ a.inner.value ∈ ℜ.X [] ∧ ℜ.P [] ∧ a.trailing ∈ ℜ.X [] + monitored ℜ.second.total := ⊤ ⊢ ℜ.second [] + monitored ℜ.same b.inner.value b.trailing c.inner.value c.trailing := ℜ.first [ + .a.inner.value ↦ b.inner.value, + .a.trailing ↦ b.trailing + ] ∧ ℜ.second [ + .a.inner.value ↦ c.inner.value, + .a.trailing ↦ c.trailing + ] ⊢ b.inner.value = c.inner.value ∧ b.trailing = c.trailing + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/equality-record.coln b/packages/coln-compiler/test/golden/basic-ir/equality-record.coln new file mode 100644 index 00000000..7712a7a5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/equality-record.coln @@ -0,0 +1,14 @@ +def Pair (X : Set) : Set := sig + left : X + right : X +end + +theory T := sig + X : Set + first : Pair X + second : Pair X + same : first = second +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/equality-record.output b/packages/coln-compiler/test/golden/basic-ir/equality-record.output new file mode 100644 index 00000000..af7bbf44 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/equality-record.output @@ -0,0 +1,59 @@ +-- elaborated +global entry named Pair +in mode: Conjunctive +type: (X : Set) -> Set +value: X => sig + left : X + right : X +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + first : Pair X + second : Pair X + same : first = second +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + first = (fun [] -> Pair (TRealm.X [])) + second = (fun [] -> Pair (TRealm.X [])) + same = (fun [] -> TRealm.first [] = TRealm.second []) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.first := [.a.left : ℜ.X, .a.right : ℜ.X] primarykey [] + table ℜ.second := [.a.left : ℜ.X, .a.right : ℜ.X] primarykey [] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.first.foreignKey a.left a.right := ℜ.first [ + .a.left ↦ a.left, + .a.right ↦ a.right + ] ⊢ a.left ∈ ℜ.X [] ∧ a.right ∈ ℜ.X [] + monitored ℜ.first.total := ⊤ ⊢ ℜ.first [] + enforced ℜ.second.foreignKey a.left a.right := ℜ.second [ + .a.left ↦ a.left, + .a.right ↦ a.right + ] ⊢ a.left ∈ ℜ.X [] ∧ a.right ∈ ℜ.X [] + monitored ℜ.second.total := ⊤ ⊢ ℜ.second [] + monitored ℜ.same b.left b.right c.left c.right := ℜ.first [ + .a.left ↦ b.left, + .a.right ↦ b.right + ] ∧ ℜ.second [ + .a.left ↦ c.left, + .a.right ↦ c.right + ] ⊢ b.left = c.left ∧ b.right = c.right + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/equality.output b/packages/coln-compiler/test/golden/basic-ir/equality.output index e21da83e..42f6e4af 100644 --- a/packages/coln-compiler/test/golden/basic-ir/equality.output +++ b/packages/coln-compiler/test/golden/basic-ir/equality.output @@ -26,7 +26,6 @@ lowered: flatrealm table ℜ.V := [] table ℜ.x := [.a : ℜ.V] primarykey [] table ℜ.y := [.a : ℜ.V] primarykey [] - table ℜ.eq := [] primarykey [] end rules enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ @@ -34,10 +33,7 @@ lowered: flatrealm monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] enforced ℜ.y.foreignKey a := ℜ.y [.a ↦ a] ⊢ a ∈ ℜ.V [] monitored ℜ.y.total := ⊤ ⊢ ℜ.y [] - enforced ℜ.eq.foreignKey a.lhs a.rhs := ℜ.eq [] ∧ ℜ.x [.a ↦ a.lhs] ∧ ℜ.y [ - .a ↦ a.rhs - ] ⊢ a.lhs = a.rhs - monitored ℜ.eq.total := ⊤ ⊢ ℜ.eq [] + monitored ℜ.eq b c := ℜ.x [.a ↦ b] ∧ ℜ.y [.a ↦ c] ⊢ b = c end end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.coln new file mode 100644 index 00000000..424b4bb6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Prop + R : (a : A) -> B a -> Prop +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.output new file mode 100644 index 00000000..429c3ed3 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + R : (a : A) -> B a -> Prop +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.R := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.R.foreignKey := ℜ.R [] ⊢ ℜ.A [] ∧ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..b914e794 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.coln new file mode 100644 index 00000000..a814948d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Prop + R : (a : A) -> B a -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.output new file mode 100644 index 00000000..bd582c4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + R : (a : A) -> B a -> Set +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.R := [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.R.foreignKey := ℜ.R [] ⊢ ℜ.A [] ∧ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..b7b4fd90 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.coln new file mode 100644 index 00000000..24b827fc --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Set + R : (a : A) -> B a -> Prop +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.output new file mode 100644 index 00000000..e755540d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + R : (a : A) -> B a -> Prop +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.R := [.b : ℜ.B] primarykey [.b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.R.foreignKey b := ℜ.R [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..f1441794 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.coln new file mode 100644 index 00000000..301576ec --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Prop + B : A -> Set + R : (a : A) -> B a -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.output new file mode 100644 index 00000000..6c0ef028 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + R : (a : A) -> B a -> Set +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.R := [.b : ℜ.B] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.R.foreignKey b := ℜ.R [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.json new file mode 100644 index 00000000..5f2d83b9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.coln new file mode 100644 index 00000000..bb5e4d71 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Prop + R : (a : A) -> B a -> Prop +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.output new file mode 100644 index 00000000..d7f2e062 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + R : (a : A) -> B a -> Prop +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.R := [.a : ℜ.A] primarykey [.a] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.R.foreignKey a := ℜ.R [.a ↦ a] ⊢ a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..856bf38d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.coln new file mode 100644 index 00000000..213f13a1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Prop + R : (a : A) -> B a -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.output new file mode 100644 index 00000000..f314a821 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.output @@ -0,0 +1,35 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + R : (a : A) -> B a -> Set +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.R := [.a : ℜ.A] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.R.foreignKey a := ℜ.R [.a ↦ a] ⊢ a ∈ ℜ.A [] ∧ ℜ.B [.a ↦ a] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..f73f637e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.coln new file mode 100644 index 00000000..86b33d04 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Set + R : (a : A) -> B a -> Prop +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.output new file mode 100644 index 00000000..81ebe21f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.output @@ -0,0 +1,37 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + R : (a : A) -> B a -> Prop +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.R := [.a : ℜ.A, .b : ℜ.B] primarykey [.a, .b] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.R.foreignKey a b := ℜ.R [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [ + .a ↦ a + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..3c411ef3 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]],[["b"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument.coln b/packages/coln-compiler/test/golden/basic-ir/family-argument.coln new file mode 100644 index 00000000..75f85bcb --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument.coln @@ -0,0 +1,8 @@ +theory T := sig + A : Set + B : A -> Set + R : (a : A) -> B a -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument.output b/packages/coln-compiler/test/golden/basic-ir/family-argument.output new file mode 100644 index 00000000..14f71106 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument.output @@ -0,0 +1,37 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + R : (a : A) -> B a -> Set +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + R = rel [a : TRealm.A [], b : TRealm.B [a := a]] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.R := [.a : ℜ.A, .b : ℜ.B] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.R.foreignKey a b := ℜ.R [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [ + .a ↦ a + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/T.ts new file mode 100644 index 00000000..2cbb5a3f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.json new file mode 100644 index 00000000..74020abb --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.ts new file mode 100644 index 00000000..4141562c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.ts @@ -0,0 +1,54 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.output index a6c180dc..9d430936 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.output @@ -19,12 +19,12 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.V := [] - table ℜ.E := [.a : ℜ.V] + table ℜ.V := [] primarykey [] + table ℜ.E := [] primarykey [] end rules enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.V [] + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.V [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.ts.output/TRealm.json index 07751e49..32073990 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["V"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["V"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.output index c6836b3e..170da929 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.output +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.output @@ -19,12 +19,12 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.V := [] - table ℜ.E := [.a : ℜ.V] + table ℜ.V := [] primarykey [] + table ℜ.E := [] end rules enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.V [] + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.V [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.ts.output/TRealm.json index 07751e49..76329ff1 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-prop-set.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["V"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["V"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.output index e007a7d1..4adfaa08 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.output @@ -20,7 +20,7 @@ end lowered: flatrealm entities table ℜ.V := [] - table ℜ.E := [.a : ℜ.V] + table ℜ.E := [.a : ℜ.V] primarykey [.a] end rules enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ diff --git a/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.ts.output/TRealm.json index 07751e49..a102e44c 100644 --- a/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/foreign-key-set-prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["V"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["V"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["V"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["V"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.coln deleted file mode 100644 index b73eb6df..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.coln +++ /dev/null @@ -1,9 +0,0 @@ -theory T := sig - X : Set - P : Prop - Y : Set - choose : X -> P -> Y -end - -realm TRealm @ T -end diff --git a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/T.ts deleted file mode 100644 index dfcd1682..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/T.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - X: runtime.ColnSet.View; - P: runtime.ColnSet.View; - Y: runtime.ColnSet.View; - choose: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - X: runtime.ColnSet.Transaction; - P: runtime.ColnSet.Transaction; - Y: runtime.ColnSet.Transaction; - choose: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.json deleted file mode 100644 index 134d1e5d..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["choose"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":[[["a"]],[["b"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["choose"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["choose"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":2},"values":[]}}]}},{"path":[["TRealm"],["choose"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["P"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":1},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["choose"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.coln b/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.coln deleted file mode 100644 index b34114bb..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.coln +++ /dev/null @@ -1,9 +0,0 @@ -theory T := sig - X : Set - P : Prop - Q : Prop - f : P -> X -> Q -end - -realm TRealm @ T -end diff --git a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/T.ts deleted file mode 100644 index f1b7bcbb..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/T.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - X: runtime.ColnSet.View; - P: runtime.ColnSet.View; - Q: runtime.ColnSet.View; - f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - X: runtime.ColnSet.Transaction; - P: runtime.ColnSet.Transaction; - Q: runtime.ColnSet.Transaction; - f: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.json deleted file mode 100644 index 527a075b..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["Q"]]}}],"primaryKey":[[["a"]],[["b"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":2},"values":[]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.output index d61d949d..b2ab8b1c 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.output @@ -21,18 +21,13 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.X := [] - table ℜ.Y := [] - table ℜ.next := [.a : ℜ.X, .b : ℜ.Y] primarykey [.a] + table ℜ.X := [] primarykey [] + table ℜ.Y := [] primarykey [] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ enforced ℜ.Y.foreignKey := ℜ.Y [] ⊢ ⊤ - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.Y [] - monitored ℜ.next.total a := a ∈ ℜ.X [] ⊢ ℜ.next [.a ↦ a] + monitored ℜ.next := ℜ.X [] ⊢ ℜ.Y [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.ts.output/TRealm.json index e6d3a7d7..05ef84cb 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/function-prop-prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/function-prop-set.output index 7e6def04..238f1bb1 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-prop-set.output +++ b/packages/coln-compiler/test/golden/basic-ir/function-prop-set.output @@ -21,18 +21,15 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.X := [] + table ℜ.X := [] primarykey [] table ℜ.Y := [] - table ℜ.next := [.a : ℜ.X, .b : ℜ.Y] primarykey [.a] + table ℜ.next := [.b : ℜ.Y] primarykey [] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ enforced ℜ.Y.foreignKey := ℜ.Y [] ⊢ ⊤ - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.Y [] - monitored ℜ.next.total a := a ∈ ℜ.X [] ⊢ ℜ.next [.a ↦ a] + enforced ℜ.next.foreignKey b := ℜ.next [.b ↦ b] ⊢ ℜ.X [] ∧ b ∈ ℜ.Y [] + monitored ℜ.next.total := ℜ.X [] ⊢ ℜ.next [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/function-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/function-prop-set.ts.output/TRealm.json index e6d3a7d7..d312bcdd 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-prop-set.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/function-prop-set.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/function-set-prop.output index 2929160b..bf8cf7c5 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-set-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/function-set-prop.output @@ -22,17 +22,12 @@ end lowered: flatrealm entities table ℜ.X := [] - table ℜ.Y := [] - table ℜ.next := [.a : ℜ.X, .b : ℜ.Y] primarykey [.a] + table ℜ.Y := [] primarykey [] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ enforced ℜ.Y.foreignKey := ℜ.Y [] ⊢ ⊤ - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.Y [] - monitored ℜ.next.total a := a ∈ ℜ.X [] ⊢ ℜ.next [.a ↦ a] + monitored ℜ.next a := a ∈ ℜ.X [] ⊢ ℜ.Y [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/function-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/function-set-prop.ts.output/TRealm.json index e6d3a7d7..13af08d5 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-set-prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/function-set-prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.coln new file mode 100644 index 00000000..b0621cda --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Prop + B : A -> Prop + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.output new file mode 100644 index 00000000..2df76adf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.output @@ -0,0 +1,44 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.A [] ∧ ℜ.B [] + monitored ℜ.next := ℜ.A [] ⊢ ℜ.B [] + monitored ℜ.nextedge := ℜ.A [] ⊢ ℜ.E [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..5d96f156 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["nextedge"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.coln new file mode 100644 index 00000000..be344082 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Prop + B : A -> Prop + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.output new file mode 100644 index 00000000..379054cf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.output @@ -0,0 +1,48 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Prop + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] + table ℜ.nextedge := [.a : ℜ.E] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.A [] ∧ ℜ.B [] + monitored ℜ.next := ℜ.A [] ⊢ ℜ.B [] + enforced ℜ.nextedge.foreignKey a := ℜ.nextedge [ + .a ↦ a + ] ⊢ ℜ.A [] ∧ a ∈ ℜ.E [] + monitored ℜ.nextedge.total := ℜ.A [] ⊢ ℜ.nextedge [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..a3f898cb --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.coln new file mode 100644 index 00000000..fd636b02 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Prop + B : A -> Set + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.output new file mode 100644 index 00000000..589bee00 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.E := [.a : ℜ.B] primarykey [.a] + table ℜ.next := [.a : ℜ.B] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ℜ.A [] ∧ a ∈ ℜ.B [] + enforced ℜ.next.foreignKey a := ℜ.next [.a ↦ a] ⊢ ℜ.A [] ∧ a ∈ ℜ.B [] + monitored ℜ.next.total := ℜ.A [] ⊢ ℜ.next [] + monitored ℜ.nextedge b := ℜ.next [.a ↦ b] ∧ ℜ.A [] ⊢ ℜ.E [.a ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..7e746675 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["nextedge"]],"value":{"ruleVariant":"monitored","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.coln new file mode 100644 index 00000000..88220b03 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Prop + B : A -> Set + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.output new file mode 100644 index 00000000..03eb9b5f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.output @@ -0,0 +1,50 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : A -> Set + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.E := [.a : ℜ.B] + table ℜ.next := [.a : ℜ.B] primarykey [] + table ℜ.nextedge := [.a : ℜ.E] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ℜ.A [] + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ℜ.A [] ∧ a ∈ ℜ.B [] + enforced ℜ.next.foreignKey a := ℜ.next [.a ↦ a] ⊢ ℜ.A [] ∧ a ∈ ℜ.B [] + monitored ℜ.next.total := ℜ.A [] ⊢ ℜ.next [] + enforced ℜ.nextedge.foreignKey a b := ℜ.next [.a ↦ b] ∧ ℜ.nextedge [ + .a ↦ a + ] ⊢ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ b] + monitored ℜ.nextedge.total := ℜ.A [] ⊢ ℜ.nextedge [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.json new file mode 100644 index 00000000..ebe548c1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.coln new file mode 100644 index 00000000..64e2fa75 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Set + B : A -> Prop + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.output new file mode 100644 index 00000000..f5ebebc0 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.output @@ -0,0 +1,44 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.E := [.x : ℜ.A] primarykey [.x] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.E.foreignKey x := ℜ.E [.x ↦ x] ⊢ x ∈ ℜ.A [] ∧ ℜ.B [.a ↦ x] + monitored ℜ.next x := x ∈ ℜ.A [] ⊢ ℜ.B [.a ↦ x] + monitored ℜ.nextedge x := x ∈ ℜ.A [] ⊢ ℜ.E [.x ↦ x] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..91d39072 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.coln new file mode 100644 index 00000000..7bbe7ca1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Set + B : A -> Prop + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.output new file mode 100644 index 00000000..0ad1b2df --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.output @@ -0,0 +1,49 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Prop + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] primarykey [.a] + table ℜ.E := [.x : ℜ.A] + table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.E.foreignKey x := ℜ.E [.x ↦ x] ⊢ x ∈ ℜ.A [] ∧ ℜ.B [.a ↦ x] + monitored ℜ.next x := x ∈ ℜ.A [] ⊢ ℜ.B [.a ↦ x] + enforced ℜ.nextedge.foreignKey x a := ℜ.nextedge [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.x ↦ x] + monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..3feb4d87 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.coln new file mode 100644 index 00000000..3c0b05ca --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Set + B : A -> Set + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.output new file mode 100644 index 00000000..17d4754d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.output @@ -0,0 +1,54 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + E : (x : A) -> B x -> Prop + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.E := [.x : ℜ.A, .a : ℜ.B] primarykey [.a, .x] + table ℜ.next := [.x : ℜ.A, .a : ℜ.B] primarykey [.x] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.E.foreignKey x a := ℜ.E [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.B [ + .a ↦ x + ] + enforced ℜ.next.foreignKey x a := ℜ.next [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.B [.a ↦ x] + monitored ℜ.next.total x := x ∈ ℜ.A [] ⊢ ℜ.next [.x ↦ x] + monitored ℜ.nextedge x b := ℜ.next [.x ↦ x, .a ↦ b] ∧ x ∈ ℜ.A [] ⊢ ℜ.E [ + .x ↦ x, + .a ↦ b + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..07f13a27 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]],[["x"]]]}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.coln new file mode 100644 index 00000000..9c1f763b --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.coln @@ -0,0 +1,10 @@ +theory T := sig + A : Set + B : A -> Set + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.output b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.output new file mode 100644 index 00000000..169cc941 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.output @@ -0,0 +1,56 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : A -> Set + E : (x : A) -> B x -> Set + next : (x : A) -> B x + nextedge : (x : A) -> E x (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [a : TRealm.A []] + E = rel [x : TRealm.A [], a : TRealm.B [a := x]] + next = (fun [x : TRealm.A []] -> TRealm.B [a := x]) + nextedge = (fun [x : TRealm.A []] -> TRealm.E [ + x := x, + a := TRealm.next [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [.a : ℜ.A] + table ℜ.E := [.x : ℜ.A, .a : ℜ.B] + table ℜ.next := [.x : ℜ.A, .a : ℜ.B] primarykey [.x] + table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey a := ℜ.B [.a ↦ a] ⊢ a ∈ ℜ.A [] + enforced ℜ.E.foreignKey x a := ℜ.E [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.B [ + .a ↦ x + ] + enforced ℜ.next.foreignKey x a := ℜ.next [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.B [.a ↦ x] + monitored ℜ.next.total x := x ∈ ℜ.A [] ⊢ ℜ.next [.x ↦ x] + enforced ℜ.nextedge.foreignKey x a b := ℜ.next [ + .x ↦ x, + .a ↦ b + ] ∧ ℜ.nextedge [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.x ↦ x, .a ↦ b] + monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/T.ts new file mode 100644 index 00000000..84e31f4e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/T.ts @@ -0,0 +1,17 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: (x: runtime.Value) => runtime.ColnSet.View; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + nextedge: (x: runtime.Value) => runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: (x: runtime.Value) => runtime.ColnSet.Transaction; + E: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.json new file mode 100644 index 00000000..772f6cd2 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["x"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.ts new file mode 100644 index 00000000..04305db5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.ts @@ -0,0 +1,76 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.B", [a])); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [x, a])); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [x])); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.B", + [a], + transaction + )); + }, + E: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [x, a], + transaction + )); + }; + }, + next: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [x], + transaction + )); + }, + nextedge: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.nextedge", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.output b/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.output index 5ef56fdb..fcb8cb36 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.output @@ -33,10 +33,10 @@ lowered: flatrealm enforced ℜ.rank.foreignKey a b := ℜ.rank [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.X [] monitored ℜ.rank.total a := a ∈ ℜ.X [] ⊢ ℜ.rank [.a ↦ a] enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ⊤ - enforced ℜ.edge.foreignKey x a a.a := ℜ.edge [.x ↦ x, .a ↦ a] ∧ ℜ.rank [ - .a ↦ x, - .b ↦ a.a - ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ a.a] + enforced ℜ.edge.foreignKey x a b := ℜ.rank [.a ↦ x, .b ↦ b] ∧ ℜ.edge [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ b] monitored ℜ.edge.total x := x ∈ ℜ.X [] ⊢ ℜ.edge [.x ↦ x] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.ts.output/TRealm.json index 6e1e4452..755ffa8e 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-builtin.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["rank"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["rank"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["rank"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["rank"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["rank"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["rank"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["rank"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.coln similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.coln diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.output new file mode 100644 index 00000000..141878a0 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.output @@ -0,0 +1,50 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : Prop + C : Prop + E : C -> Prop + first : A -> B + second : B -> C + edge : (x : A) -> E (second (first x)) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + C = rel [] + E = rel [a : TRealm.C []] + first = (fun [a : TRealm.A []] -> TRealm.B []) + second = (fun [a : TRealm.B []] -> TRealm.C []) + edge = (fun [x : TRealm.A []] -> TRealm.E [ + a := TRealm.second [a := TRealm.first [a := x]] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.C := [] primarykey [] + table ℜ.E := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.C.foreignKey := ℜ.C [] ⊢ ⊤ + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.C [] + monitored ℜ.first := ℜ.A [] ⊢ ℜ.B [] + monitored ℜ.second := ℜ.B [] ⊢ ℜ.C [] + monitored ℜ.edge := ℜ.A [] ⊢ ℜ.E [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/T.ts similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/T.ts diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..66fd3692 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["first"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["second"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.ts similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.ts diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.output deleted file mode 100644 index 4b9a54aa..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.output +++ /dev/null @@ -1,68 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Prop - B : Prop - C : Prop - E : C -> Prop - first : A -> B - second : B -> C - edge : (x : A) -> E (second (first x)) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - C = rel [] - E = rel [a : TRealm.C []] - first = (fun [a : TRealm.A []] -> TRealm.B []) - second = (fun [a : TRealm.B []] -> TRealm.C []) - edge = (fun [x : TRealm.A []] -> TRealm.E [ - a := TRealm.second [a := TRealm.first [a := x]] - ]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.C := [] - table ℜ.E := [.a : ℜ.C] - table ℜ.first := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.second := [.a : ℜ.B, .b : ℜ.C] primarykey [.a] - table ℜ.edge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.C.foreignKey := ℜ.C [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.C [] - enforced ℜ.first.foreignKey a b := ℜ.first [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.first.total a := a ∈ ℜ.A [] ⊢ ℜ.first [.a ↦ a] - enforced ℜ.second.foreignKey a b := ℜ.second [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.B [] ∧ b ∈ ℜ.C [] - monitored ℜ.second.total a := a ∈ ℜ.B [] ⊢ ℜ.second [.a ↦ a] - enforced ℜ.edge.foreignKey x a a.a a.a.a := ℜ.edge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.first [.a ↦ x, .b ↦ a.a.a] ∧ ℜ.second [ - .a ↦ a.a.a, - .b ↦ a.a - ] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.edge.total x := x ∈ ℜ.A [] ⊢ ℜ.edge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.json deleted file mode 100644 index e8ef3adb..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":null}},{"path":[["TRealm"],["first"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["second"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["first"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["first"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["second"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["second"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]],[["a"],["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["C"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":3}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition.output b/packages/coln-compiler/test/golden/basic-ir/lookup-composition.output index 55f9e162..ec40886d 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-composition.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-composition.output @@ -54,13 +54,10 @@ lowered: flatrealm .b ↦ b ] ⊢ a ∈ ℜ.B [] ∧ b ∈ ℜ.C [] monitored ℜ.second.total a := a ∈ ℜ.B [] ⊢ ℜ.second [.a ↦ a] - enforced ℜ.edge.foreignKey x a a.a a.a.a := ℜ.edge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.first [.a ↦ x, .b ↦ a.a.a] ∧ ℜ.second [ - .a ↦ a.a.a, - .b ↦ a.a - ] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] + enforced ℜ.edge.foreignKey x a b c := ℜ.first [.a ↦ x, .b ↦ c] ∧ ℜ.second [ + .a ↦ c, + .b ↦ b + ] ∧ ℜ.edge [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ b] monitored ℜ.edge.total x := x ∈ ℜ.A [] ⊢ ℜ.edge [.x ↦ x] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-composition.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-composition.ts.output/TRealm.json index e8ef3adb..611cb007 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-composition.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-composition.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":null}},{"path":[["TRealm"],["first"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["second"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["first"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["first"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["second"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["second"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]],[["a"],["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["C"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":3}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["C"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":null}},{"path":[["TRealm"],["first"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["second"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["C"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["C"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["first"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["first"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["second"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["C"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["C"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["second"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["C"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["first"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["second"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":3}},{"column":1,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.coln similarity index 73% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.coln index f58d9884..48439cb4 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.coln @@ -2,8 +2,9 @@ theory T := sig A : Prop B : Prop E : B -> Prop + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.output new file mode 100644 index 00000000..d34bd398 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.output @@ -0,0 +1,44 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : Prop + E : B -> Prop + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.B [] + monitored ℜ.x := ⊤ ⊢ ℜ.A [] + monitored ℜ.next := ℜ.A [] ⊢ ℜ.B [] + monitored ℜ.edge := ⊤ ⊢ ℜ.E [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/T.ts similarity index 78% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/T.ts index 9325f06c..bbe3a9b7 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/T.ts @@ -4,14 +4,16 @@ export interface View { A: runtime.ColnSet.View; B: runtime.ColnSet.View; E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; } export interface Transaction extends View { A: runtime.ColnSet.Transaction; B: runtime.ColnSet.Transaction; E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..62cbe9a2 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["x"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.ts similarity index 77% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.ts index a09d0576..36b5c3a9 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.ts @@ -13,12 +13,11 @@ export class View { E: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), next: (a: runtime.Value) => { return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) }; } } @@ -42,6 +41,12 @@ export class Transaction extends View { transaction )); }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), next: (a: runtime.Value) => { return (new runtime.TableCellRef.Transaction( store, @@ -50,14 +55,12 @@ export class Transaction extends View { transaction )); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) }; } } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.coln similarity index 73% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.coln index 6426811c..9fa82593 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.coln @@ -2,8 +2,9 @@ theory T := sig A : Prop B : Prop E : B -> Set + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.output new file mode 100644 index 00000000..cb475a53 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : Prop + E : B -> Set + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] + table ℜ.edge := [.a : ℜ.E] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.B [] + monitored ℜ.x := ⊤ ⊢ ℜ.A [] + monitored ℜ.next := ℜ.A [] ⊢ ℜ.B [] + enforced ℜ.edge.foreignKey a := ℜ.edge [.a ↦ a] ⊢ a ∈ ℜ.E [] + monitored ℜ.edge.total := ⊤ ⊢ ℜ.edge [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/T.ts similarity index 78% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/T.ts index 9325f06c..bbe3a9b7 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/T.ts @@ -4,14 +4,16 @@ export interface View { A: runtime.ColnSet.View; B: runtime.ColnSet.View; E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; } export interface Transaction extends View { A: runtime.ColnSet.Transaction; B: runtime.ColnSet.Transaction; E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..921a87f6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["x"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.ts similarity index 77% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.ts index a09d0576..36b5c3a9 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.ts @@ -13,12 +13,11 @@ export class View { E: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), next: (a: runtime.Value) => { return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) }; } } @@ -42,6 +41,12 @@ export class Transaction extends View { transaction )); }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), next: (a: runtime.Value) => { return (new runtime.TableCellRef.Transaction( store, @@ -50,14 +55,12 @@ export class Transaction extends View { transaction )); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) }; } } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.coln similarity index 73% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.coln index a73408cd..08f635b9 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.coln @@ -2,8 +2,9 @@ theory T := sig A : Prop B : Set E : B -> Prop + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.output new file mode 100644 index 00000000..613bdd71 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : Set + E : B -> Prop + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.E := [.a : ℜ.B] primarykey [.a] + table ℜ.next := [.b : ℜ.B] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] + monitored ℜ.x := ⊤ ⊢ ℜ.A [] + enforced ℜ.next.foreignKey b := ℜ.next [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + monitored ℜ.next.total := ℜ.A [] ⊢ ℜ.next [] + monitored ℜ.edge b := ℜ.next [.b ↦ b] ⊢ ℜ.E [.a ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/T.ts similarity index 78% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/T.ts index 9325f06c..bbe3a9b7 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/T.ts @@ -4,14 +4,16 @@ export interface View { A: runtime.ColnSet.View; B: runtime.ColnSet.View; E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; } export interface Transaction extends View { A: runtime.ColnSet.Transaction; B: runtime.ColnSet.Transaction; E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..94d5ce79 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"]],"value":{"ruleVariant":"monitored","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.ts similarity index 77% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.ts index a09d0576..36b5c3a9 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.ts @@ -13,12 +13,11 @@ export class View { E: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), next: (a: runtime.Value) => { return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) }; } } @@ -42,6 +41,12 @@ export class Transaction extends View { transaction )); }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), next: (a: runtime.Value) => { return (new runtime.TableCellRef.Transaction( store, @@ -50,14 +55,12 @@ export class Transaction extends View { transaction )); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) }; } } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.coln similarity index 72% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.coln index c948bf71..c957f084 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.coln @@ -2,8 +2,9 @@ theory T := sig A : Prop B : Set E : B -> Set + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.output new file mode 100644 index 00000000..f8da6f97 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.output @@ -0,0 +1,50 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Prop + B : Set + E : B -> Set + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] primarykey [] + table ℜ.B := [] + table ℜ.E := [.a : ℜ.B] + table ℜ.next := [.b : ℜ.B] primarykey [] + table ℜ.edge := [.a : ℜ.E] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] + monitored ℜ.x := ⊤ ⊢ ℜ.A [] + enforced ℜ.next.foreignKey b := ℜ.next [.b ↦ b] ⊢ ℜ.A [] ∧ b ∈ ℜ.B [] + monitored ℜ.next.total := ℜ.A [] ⊢ ℜ.next [] + enforced ℜ.edge.foreignKey a b := ℜ.next [.b ↦ b] ∧ ℜ.edge [ + .a ↦ a + ] ⊢ a ∈ ℜ.E [.a ↦ b] + monitored ℜ.edge.total := ⊤ ⊢ ℜ.edge [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/T.ts similarity index 78% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/T.ts index 9325f06c..bbe3a9b7 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/T.ts @@ -4,14 +4,16 @@ export interface View { A: runtime.ColnSet.View; B: runtime.ColnSet.View; E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; } export interface Transaction extends View { A: runtime.ColnSet.Transaction; B: runtime.ColnSet.Transaction; E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.json new file mode 100644 index 00000000..05a39ad9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.ts similarity index 77% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.ts index a09d0576..36b5c3a9 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.ts @@ -13,12 +13,11 @@ export class View { E: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), next: (a: runtime.Value) => { return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) }; } } @@ -42,6 +41,12 @@ export class Transaction extends View { transaction )); }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), next: (a: runtime.Value) => { return (new runtime.TableCellRef.Transaction( store, @@ -50,14 +55,12 @@ export class Transaction extends View { transaction )); }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) }; } } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.coln similarity index 73% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.coln index 5d1f80cb..d3584d0a 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.coln @@ -2,8 +2,9 @@ theory T := sig A : Set B : Prop E : B -> Prop + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.output new file mode 100644 index 00000000..b4faf041 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : Prop + E : B -> Prop + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] primarykey [] + table ℜ.x := [.a : ℜ.A] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.B [] + enforced ℜ.x.foreignKey a := ℜ.x [.a ↦ a] ⊢ a ∈ ℜ.A [] + monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] + monitored ℜ.next a := a ∈ ℜ.A [] ⊢ ℜ.B [] + monitored ℜ.edge c := ℜ.x [.a ↦ c] ⊢ ℜ.E [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/T.ts new file mode 100644 index 00000000..bbe3a9b7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/T.ts @@ -0,0 +1,19 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: runtime.ColnSet.View; + E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: runtime.ColnSet.Transaction; + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.json new file mode 100644 index 00000000..80e70c46 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["x"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["x"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"]],"value":{"ruleVariant":"monitored","varNames":[[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..36b5c3a9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.ts @@ -0,0 +1,66 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); + }, + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [a], + transaction + )); + }, + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.coln similarity index 72% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.coln index 05f60abe..0992b49f 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.coln @@ -2,8 +2,9 @@ theory T := sig A : Set B : Prop E : B -> Set + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.output new file mode 100644 index 00000000..677d8b45 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.output @@ -0,0 +1,50 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : Prop + E : B -> Set + x : A + next : A -> B + edge : E (next x) +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) + next = (fun [a : TRealm.A []] -> TRealm.B []) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [] primarykey [] + table ℜ.E := [] + table ℜ.x := [.a : ℜ.A] primarykey [] + table ℜ.edge := [.a : ℜ.E] primarykey [] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.E.foreignKey := ℜ.E [] ⊢ ℜ.B [] + enforced ℜ.x.foreignKey a := ℜ.x [.a ↦ a] ⊢ a ∈ ℜ.A [] + monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] + monitored ℜ.next a := a ∈ ℜ.A [] ⊢ ℜ.B [] + enforced ℜ.edge.foreignKey a c := ℜ.x [.a ↦ c] ∧ ℜ.edge [ + .a ↦ a + ] ⊢ a ∈ ℜ.E [] + monitored ℜ.edge.total := ⊤ ⊢ ℜ.edge [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/T.ts new file mode 100644 index 00000000..bbe3a9b7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/T.ts @@ -0,0 +1,19 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: runtime.ColnSet.View; + E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: runtime.ColnSet.Transaction; + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.json new file mode 100644 index 00000000..a0e55b0e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["x"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["x"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.ts new file mode 100644 index 00000000..36b5c3a9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.ts @@ -0,0 +1,66 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); + }, + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [a], + transaction + )); + }, + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.coln similarity index 72% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.coln index 11a76db2..bf9cee65 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.coln @@ -2,8 +2,9 @@ theory T := sig A : Set B : Set E : B -> Prop + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.output similarity index 65% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.output rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.output index a91fbbd6..4f4e40a4 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.output @@ -6,8 +6,9 @@ value: sig A : Set B : Set E : B -> Prop + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm named TRealm elaborated: realm @@ -16,8 +17,9 @@ elaborated: realm A = rel [] B = rel [] E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) end end definitions @@ -27,24 +29,24 @@ lowered: flatrealm entities table ℜ.A := [] table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] + table ℜ.E := [.a : ℜ.B] primarykey [.a] + table ℜ.x := [.a : ℜ.A] primarykey [] table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] end rules enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] + enforced ℜ.x.foreignKey a := ℜ.x [.a ↦ a] ⊢ a ∈ ℜ.A [] + monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] enforced ℜ.next.foreignKey a b := ℜ.next [ .a ↦ a, .b ↦ b ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] + monitored ℜ.edge b c := ℜ.x [.a ↦ c] ∧ ℜ.next [.a ↦ c, .b ↦ b] ⊢ ℜ.E [ + .a ↦ b + ] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/T.ts new file mode 100644 index 00000000..bbe3a9b7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/T.ts @@ -0,0 +1,19 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: runtime.ColnSet.View; + E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: runtime.ColnSet.Transaction; + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.json new file mode 100644 index 00000000..464358bc --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["x"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["edge"]],"value":{"ruleVariant":"monitored","varNames":[[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}},{"column":1,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..36b5c3a9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.ts @@ -0,0 +1,66 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); + }, + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [a], + transaction + )); + }, + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.coln b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.coln similarity index 72% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection.coln rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.coln index 2c473ca2..8f81f791 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.coln +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.coln @@ -2,8 +2,9 @@ theory T := sig A : Set B : Set E : B -> Set + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.output b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.output similarity index 62% rename from packages/coln-compiler/test/golden/basic-ir/lookup-projection.output rename to packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.output index 660c5aa7..0615327f 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.output @@ -6,8 +6,9 @@ value: sig A : Set B : Set E : B -> Set + x : A next : A -> B - nextedge : (x : A) -> E (next x) + edge : E (next x) end realm named TRealm elaborated: realm @@ -16,8 +17,9 @@ elaborated: realm A = rel [] B = rel [] E = rel [a : TRealm.B []] + x = (fun [] -> TRealm.A []) next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) + edge = (fun [] -> TRealm.E [a := TRealm.next [a := TRealm.x []]]) end end definitions @@ -28,23 +30,26 @@ lowered: flatrealm table ℜ.A := [] table ℜ.B := [] table ℜ.E := [.a : ℜ.B] + table ℜ.x := [.a : ℜ.A] primarykey [] table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] + table ℜ.edge := [.a : ℜ.E] primarykey [] end rules enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] + enforced ℜ.x.foreignKey a := ℜ.x [.a ↦ a] ⊢ a ∈ ℜ.A [] + monitored ℜ.x.total := ⊤ ⊢ ℜ.x [] enforced ℜ.next.foreignKey a b := ℜ.next [ .a ↦ a, .b ↦ b ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] + enforced ℜ.edge.foreignKey a b c := ℜ.x [.a ↦ c] ∧ ℜ.next [ + .a ↦ c, + .b ↦ b + ] ∧ ℜ.edge [.a ↦ a] ⊢ a ∈ ℜ.E [.a ↦ b] + monitored ℜ.edge.total := ⊤ ⊢ ℜ.edge [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/T.ts new file mode 100644 index 00000000..bbe3a9b7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/T.ts @@ -0,0 +1,19 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: runtime.ColnSet.View; + E: (x: runtime.Value) => runtime.ColnSet.View; + x: runtime.ColnRef.View; + next: (x: runtime.Value) => runtime.ColnRef.View; + edge: runtime.ColnRef.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: runtime.ColnSet.Transaction; + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + x: runtime.ColnRef.Transaction; + next: (x: runtime.Value) => runtime.ColnRef.Transaction; + edge: runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.json new file mode 100644 index 00000000..a53df433 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["x"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["x"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]},{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["x"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":2}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.ts new file mode 100644 index 00000000..36b5c3a9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.ts @@ -0,0 +1,66 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + x: (new runtime.TableCellRef.View(store, "TRealm.x", [])), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); + }, + edge: (new runtime.TableCellRef.View(store, "TRealm.edge", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + x: (new runtime.TableCellRef.Transaction( + store, + "TRealm.x", + [], + transaction + )), + next: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.next", + [a], + transaction + )); + }, + edge: (new runtime.TableCellRef.Transaction( + store, + "TRealm.edge", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.output index 60afea69..5d7d6729 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.output @@ -23,22 +23,14 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.IntFact := [.a : Int] - table ℜ.StringFact := [.a : String] - table ℜ.intFact := [.a : ℜ.IntFact] primarykey [] - table ℜ.stringFact := [.a : ℜ.StringFact] primarykey [] + table ℜ.IntFact := [.a : Int] primarykey [.a] + table ℜ.StringFact := [.a : String] primarykey [.a] end rules enforced ℜ.IntFact.foreignKey a := ℜ.IntFact [.a ↦ a] ⊢ ⊤ enforced ℜ.StringFact.foreignKey a := ℜ.StringFact [.a ↦ a] ⊢ ⊤ - enforced ℜ.intFact.foreignKey a := ℜ.intFact [.a ↦ a] ⊢ a ∈ ℜ.IntFact [ - .a ↦ 19 - ] - monitored ℜ.intFact.total := ⊤ ⊢ ℜ.intFact [] - enforced ℜ.stringFact.foreignKey a := ℜ.stringFact [ - .a ↦ a - ] ⊢ a ∈ ℜ.StringFact [.a ↦ "zombocom"] - monitored ℜ.stringFact.total := ⊤ ⊢ ℜ.stringFact [] + monitored ℜ.intFact := ⊤ ⊢ ℜ.IntFact [.a ↦ 19] + monitored ℜ.stringFact := ⊤ ⊢ ℜ.StringFact [.a ↦ "zombocom"] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.ts.output/TRealm.json index d5f4a2d5..4373d096 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-literal-prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["IntFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["StringFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}},{"path":[["TRealm"],["intFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["IntFact"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["stringFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["StringFact"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["IntFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["IntFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["StringFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["StringFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["intFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["IntFact"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["intFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["IntFact"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"lit","lit":{"tag":"int","value":19}}}]}}]}},{"path":[["TRealm"],["intFact"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["intFact"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["stringFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["StringFact"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["stringFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["StringFact"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"lit","lit":{"tag":"string","value":"zombocom"}}}]}}]}},{"path":[["TRealm"],["stringFact"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["stringFact"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["IntFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["StringFact"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["IntFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["IntFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["StringFact"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["StringFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["intFact"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["IntFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"lit","lit":{"tag":"int","value":19}}}]}}]}},{"path":[["TRealm"],["stringFact"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["StringFact"]],"rowId":null,"values":[{"column":0,"term":{"tag":"lit","lit":{"tag":"string","value":"zombocom"}}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.output deleted file mode 100644 index 210b2831..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Prop - B : Prop - E : B -> Prop - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.output deleted file mode 100644 index 86f41ea5..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Prop - B : Prop - E : B -> Set - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.output deleted file mode 100644 index 93a6fd31..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Prop - B : Set - E : B -> Prop - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.output deleted file mode 100644 index bef715d8..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Prop - B : Set - E : B -> Set - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.output deleted file mode 100644 index cfe02af7..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Set - B : Prop - E : B -> Prop - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/T.ts deleted file mode 100644 index 9325f06c..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/T.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - A: runtime.ColnSet.View; - B: runtime.ColnSet.View; - E: (x: runtime.Value) => runtime.ColnSet.View; - next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - A: runtime.ColnSet.Transaction; - B: runtime.ColnSet.Transaction; - E: (x: runtime.Value) => runtime.ColnSet.Transaction; - next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.ts deleted file mode 100644 index a09d0576..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.ts +++ /dev/null @@ -1,63 +0,0 @@ -import schema from "./TRealm.json"; -export {schema}; -import * as runtime from "@coln-project/runtime"; -import * as T from "./T.ts"; - -export class View { - root: T.View; - - constructor(store: runtime.StoreHandle) { - this.root = { - A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), - B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } - }; - } -} - -export class Transaction extends View { - root: T.Transaction; - - constructor( - store: runtime.StoreHandle, - transaction: runtime.TransactionHandle - ) { - super(store); - this.root = { - A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), - B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.Transaction( - store, - "TRealm.E", - [a], - transaction - )); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.next", - [a], - transaction - )); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } - }; - } -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.output b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.output deleted file mode 100644 index 84fddc34..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.output +++ /dev/null @@ -1,51 +0,0 @@ --- elaborated -global entry named T -in mode: Conjunctive -type: Theory -value: sig - A : Set - B : Prop - E : B -> Set - next : A -> B - nextedge : (x : A) -> E (next x) -end -realm named TRealm -elaborated: realm - generators - node - A = rel [] - B = rel [] - E = rel [a : TRealm.B []] - next = (fun [a : TRealm.A []] -> TRealm.B []) - nextedge = (fun [x : TRealm.A []] -> TRealm.E [a := TRealm.next [a := x]]) - end - end - definitions - end -end -lowered: flatrealm - entities - table ℜ.A := [] - table ℜ.B := [] - table ℜ.E := [.a : ℜ.B] - table ℜ.next := [.a : ℜ.A, .b : ℜ.B] primarykey [.a] - table ℜ.nextedge := [.x : ℜ.A, .a : ℜ.E] primarykey [.x] - end - rules - enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ - enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ - enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.B [] - enforced ℜ.next.foreignKey a b := ℜ.next [ - .a ↦ a, - .b ↦ b - ] ⊢ a ∈ ℜ.A [] ∧ b ∈ ℜ.B [] - monitored ℜ.next.total a := a ∈ ℜ.A [] ⊢ ℜ.next [.a ↦ a] - enforced ℜ.nextedge.foreignKey x a a.a := ℜ.nextedge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.next [.a ↦ x, .b ↦ a.a] ⊢ x ∈ ℜ.A [] ∧ a ∈ ℜ.E [.a ↦ a.a] - monitored ℜ.nextedge.total x := x ∈ ℜ.A [] ⊢ ℜ.nextedge [.x ↦ x] - end -end - --- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/T.ts deleted file mode 100644 index 9325f06c..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/T.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - A: runtime.ColnSet.View; - B: runtime.ColnSet.View; - E: (x: runtime.Value) => runtime.ColnSet.View; - next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - A: runtime.ColnSet.Transaction; - B: runtime.ColnSet.Transaction; - E: (x: runtime.Value) => runtime.ColnSet.Transaction; - next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.ts deleted file mode 100644 index a09d0576..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.ts +++ /dev/null @@ -1,63 +0,0 @@ -import schema from "./TRealm.json"; -export {schema}; -import * as runtime from "@coln-project/runtime"; -import * as T from "./T.ts"; - -export class View { - root: T.View; - - constructor(store: runtime.StoreHandle) { - this.root = { - A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), - B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } - }; - } -} - -export class Transaction extends View { - root: T.Transaction; - - constructor( - store: runtime.StoreHandle, - transaction: runtime.TransactionHandle - ) { - super(store); - this.root = { - A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), - B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.Transaction( - store, - "TRealm.E", - [a], - transaction - )); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.next", - [a], - transaction - )); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } - }; - } -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/T.ts deleted file mode 100644 index 9325f06c..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/T.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - A: runtime.ColnSet.View; - B: runtime.ColnSet.View; - E: (x: runtime.Value) => runtime.ColnSet.View; - next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - A: runtime.ColnSet.Transaction; - B: runtime.ColnSet.Transaction; - E: (x: runtime.Value) => runtime.ColnSet.Transaction; - next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.ts deleted file mode 100644 index a09d0576..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.ts +++ /dev/null @@ -1,63 +0,0 @@ -import schema from "./TRealm.json"; -export {schema}; -import * as runtime from "@coln-project/runtime"; -import * as T from "./T.ts"; - -export class View { - root: T.View; - - constructor(store: runtime.StoreHandle) { - this.root = { - A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), - B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } - }; - } -} - -export class Transaction extends View { - root: T.Transaction; - - constructor( - store: runtime.StoreHandle, - transaction: runtime.TransactionHandle - ) { - super(store); - this.root = { - A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), - B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.Transaction( - store, - "TRealm.E", - [a], - transaction - )); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.next", - [a], - transaction - )); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } - }; - } -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/T.ts deleted file mode 100644 index 9325f06c..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/T.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as runtime from "@coln-project/runtime"; - -export interface View { - A: runtime.ColnSet.View; - B: runtime.ColnSet.View; - E: (x: runtime.Value) => runtime.ColnSet.View; - next: (x: runtime.Value) => runtime.ColnRef.View; - nextedge: (x: runtime.Value) => runtime.ColnRef.View; -} - -export interface Transaction extends View { - A: runtime.ColnSet.Transaction; - B: runtime.ColnSet.Transaction; - E: (x: runtime.Value) => runtime.ColnSet.Transaction; - next: (x: runtime.Value) => runtime.ColnRef.Transaction; - nextedge: (x: runtime.Value) => runtime.ColnRef.Transaction; -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.json deleted file mode 100644 index 6be3fdae..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}},{"path":[["TRealm"],["next"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["nextedge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["A"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["next"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["next"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["nextedge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["next"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["nextedge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["A"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nextedge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.ts deleted file mode 100644 index a09d0576..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.ts +++ /dev/null @@ -1,63 +0,0 @@ -import schema from "./TRealm.json"; -export {schema}; -import * as runtime from "@coln-project/runtime"; -import * as T from "./T.ts"; - -export class View { - root: T.View; - - constructor(store: runtime.StoreHandle) { - this.root = { - A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), - B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.next", [a])); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.nextedge", [x])); - } - }; - } -} - -export class Transaction extends View { - root: T.Transaction; - - constructor( - store: runtime.StoreHandle, - transaction: runtime.TransactionHandle - ) { - super(store); - this.root = { - A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), - B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), - E: (a: runtime.Value) => { - return (new runtime.RowIdSet.Transaction( - store, - "TRealm.E", - [a], - transaction - )); - }, - next: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.next", - [a], - transaction - )); - }, - nextedge: (x: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.nextedge", - [x], - transaction - )); - } - }; - } -} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-proof-result-argument.output b/packages/coln-compiler/test/golden/basic-ir/lookup-proof-result-argument.output new file mode 100644 index 00000000..a937f880 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-proof-result-argument.output @@ -0,0 +1,56 @@ +-- elaborated +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + P : X -> Prop + witness : (x : X) -> P x + R : (x : X) -> P x -> Prop + use : (x : X) -> R x (witness x) +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + P = rel [a : TRealm.X []] + witness = (fun [x : TRealm.X []] -> TRealm.P [a := x]) + R = rel [x : TRealm.X [], a : TRealm.P [a := x]] + use = (fun [x : TRealm.X []] -> TRealm.R [ + x := x, + a := TRealm.witness [x := x] + ]) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.P := [.a : ℜ.X] + table ℜ.witness := [.x : ℜ.X, .a : ℜ.P] primarykey [.x] + table ℜ.R := [.x : ℜ.X, .a : ℜ.P] + table ℜ.use := [.x : ℜ.X, .a : ℜ.R] primarykey [.x] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.P.foreignKey a := ℜ.P [.a ↦ a] ⊢ a ∈ ℜ.X [] + enforced ℜ.witness.foreignKey x a := ℜ.witness [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.P [.a ↦ x] + monitored ℜ.witness.total x := x ∈ ℜ.X [] ⊢ ℜ.witness [.x ↦ x] + enforced ℜ.R.foreignKey x a := ℜ.R [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.P [ + .a ↦ x + ] + enforced ℜ.use.foreignKey x a a.a := ℜ.use [.x ↦ x, .a ↦ a] ∧ ℜ.witness [ + .x ↦ x, + .a ↦ a.a + ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.R [.x ↦ x, .a ↦ a.a] + monitored ℜ.use.total x := x ∈ ℜ.X [] ⊢ ℜ.use [.x ↦ x] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.output b/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.output index 9804fc6a..50e803e0 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.output @@ -68,10 +68,10 @@ lowered: flatrealm ] ⊢ a ∈ ℜ.X [] monitored ℜ.key.total a := a ∈ ℜ.X [] ⊢ ℜ.key [.a ↦ a] enforced ℜ.PayloadAt.foreignKey a := ℜ.PayloadAt [.a ↦ a] ⊢ ⊤ - enforced ℜ.slot.foreignKey x a a.a.rank := ℜ.slot [.x ↦ x, .a ↦ a] ∧ ℜ.key [ + enforced ℜ.slot.foreignKey x a b.rank := ℜ.key [ .a ↦ x, - .b.rank ↦ a.a.rank - ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.PayloadAt [.a ↦ a.a.rank] + .b.rank ↦ b.rank + ] ∧ ℜ.slot [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.PayloadAt [.a ↦ b.rank] monitored ℜ.slot.total x := x ∈ ℜ.X [] ⊢ ℜ.slot [.x ↦ x] enforced ℜ.payload.foreignKey rank a b.name := ℜ.payload [ .rank ↦ rank, @@ -82,17 +82,14 @@ lowered: flatrealm .a ↦ rank ] ⊢ ℜ.payload [.rank ↦ rank, .a ↦ a] enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ⊤ - enforced ℜ.edge.foreignKey x a a.a.name a.a.rank.rank a.a.a := ℜ.edge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.key [.a ↦ x, .b.rank ↦ a.a.rank.rank] ∧ ℜ.slot [ - .x ↦ x, - .a ↦ a.a.a - ] ∧ ℜ.payload [ - .rank ↦ a.a.rank.rank, - .a ↦ a.a.a, - .b.name ↦ a.a.name - ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ a.a.name] + enforced ℜ.edge.foreignKey x a b.name c.rank d := ℜ.key [ + .a ↦ x, + .b.rank ↦ c.rank + ] ∧ ℜ.slot [.x ↦ x, .a ↦ d] ∧ ℜ.payload [ + .rank ↦ c.rank, + .a ↦ d, + .b.name ↦ b.name + ] ∧ ℜ.edge [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ b.name] monitored ℜ.edge.total x := x ∈ ℜ.X [] ⊢ ℜ.edge [.x ↦ x] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.ts.output/TRealm.json index 8e79bddf..a86f249a 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-composition.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["key"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["PayloadAt"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["slot"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}}],"primaryKey":[[["x"]]]}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["rank"]],"type":{"tag":"builtin","type":"builtinInt"}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":[[["a"]],[["rank"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["key"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["key"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["PayloadAt"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["slot"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["slot"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["rank"]],[["a"]],[["b"],["name"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["rank"]],[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"],["name"]],[["a"],["a"],["rank"],["rank"]],[["a"],["a"],["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":4}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":3}},{"column":1,"term":{"tag":"var","index":4}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["key"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["PayloadAt"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["slot"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}}],"primaryKey":[[["x"]]]}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["rank"]],"type":{"tag":"builtin","type":"builtinInt"}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":[[["a"]],[["rank"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["key"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["key"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["PayloadAt"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["slot"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["slot"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["rank"]],[["a"]],[["b"],["name"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["rank"]],[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["PayloadAt"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"],["name"]],[["c"],["rank"]],[["d"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["PayloadAt"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["slot"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":4}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":3}},{"column":1,"term":{"tag":"var","index":4}},{"column":2,"term":{"tag":"var","index":2}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.output b/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.output index c753bc95..54069bb1 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.output @@ -49,18 +49,14 @@ lowered: flatrealm .a.name ↦ a.name, .a.rank ↦ a.rank ] ⊢ ⊤ - enforced ℜ.edge.foreignKey x a a.a.name.name a.a.name.rank a.a.rank.name a.a.rank.rank := ℜ.edge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.payload [ + enforced ℜ.edge.foreignKey x a b.name b.rank := ℜ.payload [ .a ↦ x, - .b.name ↦ a.a.name.name, - .b.rank ↦ a.a.name.rank - ] ∧ ℜ.payload [ - .a ↦ x, - .b.name ↦ a.a.rank.name, - .b.rank ↦ a.a.rank.rank - ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a.name ↦ a.a.name.name, .a.rank ↦ a.a.rank.rank] + .b.name ↦ b.name, + .b.rank ↦ b.rank + ] ∧ ℜ.edge [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [ + .a.name ↦ b.name, + .a.rank ↦ b.rank + ] monitored ℜ.edge.total x := x ∈ ℜ.X [] ⊢ ℜ.edge [.x ↦ x] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.ts.output/TRealm.json index e056645d..1cf69dad 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-expansion.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["a"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["name"]],[["a"],["rank"]]],"varTypes":[{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"],["name"],["name"]],[["a"],["a"],["name"],["rank"]],[["a"],["a"],["rank"],["name"]],[["a"],["a"],["rank"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}},{"column":2,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":4}},{"column":2,"term":{"tag":"var","index":5}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}},{"column":1,"term":{"tag":"var","index":5}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["a"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["name"]],[["a"],["rank"]]],"varTypes":[{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}},{"column":2,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":2}},{"column":1,"term":{"tag":"var","index":3}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.output b/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.output index 247c8c92..8009e65a 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.output +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.output @@ -48,14 +48,11 @@ lowered: flatrealm ] ⊢ a ∈ ℜ.X [] monitored ℜ.payload.total a := a ∈ ℜ.X [] ⊢ ℜ.payload [.a ↦ a] enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ⊤ - enforced ℜ.edge.foreignKey x a a.a.name a.a.rank := ℜ.edge [ - .x ↦ x, - .a ↦ a - ] ∧ ℜ.payload [ + enforced ℜ.edge.foreignKey x a b.name b.rank := ℜ.payload [ .a ↦ x, - .b.name ↦ a.a.name, - .b.rank ↦ a.a.rank - ] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ a.a.rank] + .b.name ↦ b.name, + .b.rank ↦ b.rank + ] ∧ ℜ.edge [.x ↦ x, .a ↦ a] ⊢ x ∈ ℜ.X [] ∧ a ∈ ℜ.E [.a ↦ b.rank] monitored ℜ.edge.total x := x ∈ ℜ.X [] ⊢ ℜ.edge [.x ↦ x] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.ts.output/TRealm.json index 2ba406ea..9ed520ab 100644 --- a/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/lookup-record-field.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["a"],["a"],["name"]],[["a"],["a"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}},{"column":2,"term":{"tag":"var","index":3}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":3}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["b"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["edge"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["edge"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]],[["b"],["name"]],[["b"],["rank"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":2}},{"column":2,"term":{"tag":"var","index":3}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":3}}]}}]}},{"path":[["TRealm"],["edge"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["edge"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.coln b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.coln new file mode 100644 index 00000000..d978ab54 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.coln @@ -0,0 +1,13 @@ +theory SetAlias := Set + +def Box (X : SetAlias) : Set := sig + value : X +end + +theory T := sig + X : SetAlias + boxed : Box X -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.output b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.output new file mode 100644 index 00000000..d166b759 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.output @@ -0,0 +1,43 @@ +-- elaborated +global entry named SetAlias +in mode: Conjunctive +type: Theory +value: Set +global entry named Box +in mode: Conjunctive +type: (X : Set) -> Set +value: X => sig + value : X +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : SetAlias + boxed : Box X -> Set +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + boxed = rel [a : Box (TRealm.X [])] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.boxed := [.a.value : ℜ.X] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.boxed.foreignKey a.value := ℜ.boxed [ + .a.value ↦ a.value + ] ⊢ a.value ∈ ℜ.X [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/SetAlias.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/SetAlias.ts new file mode 100644 index 00000000..1fbce54e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/SetAlias.ts @@ -0,0 +1,5 @@ +import * as runtime from "@coln-project/runtime"; + +export type View = runtime.ColnSet.View; + +export type Transaction = runtime.ColnSet.Transaction; \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/T.ts new file mode 100644 index 00000000..8aa5eb2c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/T.ts @@ -0,0 +1,12 @@ +import * as runtime from "@coln-project/runtime"; +import * as SetAlias from "./SetAlias.ts"; + +export interface View { + X: runtime.ColnSet.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.json new file mode 100644 index 00000000..afd84e7d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["value"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["value"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.ts new file mode 100644 index 00000000..e1a7677f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.ts @@ -0,0 +1,40 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as SetAlias from "./SetAlias.ts"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.coln b/packages/coln-compiler/test/golden/basic-ir/param-alias.coln new file mode 100644 index 00000000..c7c13f96 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.coln @@ -0,0 +1,19 @@ +theory Model := sig + X : Set +end + +theory Alias := Model + +def Box (X : Set) (M : Alias) (Y : Set) : Set := sig + key : X + modelValue : M.X + value : Y +end + +theory T := sig + model : Alias + boxed : Box Int model String -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.output b/packages/coln-compiler/test/golden/basic-ir/param-alias.output new file mode 100644 index 00000000..b4eb0314 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.output @@ -0,0 +1,59 @@ +-- elaborated +global entry named Model +in mode: Conjunctive +type: Theory +value: sig + X : Set +end +global entry named Alias +in mode: Conjunctive +type: Theory +value: Model +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (M : Model) -> (Y : Set) -> Set +value: X => M => Y => sig + key : X + modelValue : M.X + value : Y +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + model : Alias + boxed : Box Int model String -> Set +end +realm named TRealm +elaborated: realm + generators + node + model = node + X = rel [] + end + boxed = rel [a : Box Int [X := TRealm.model.X []] String] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.model.X := [] + table ℜ.boxed := [ + .a.key : Int, + .a.modelValue : ℜ.model.X, + .a.value : String + ] + end + rules + enforced ℜ.model.X.foreignKey := ℜ.model.X [] ⊢ ⊤ + enforced ℜ.boxed.foreignKey a.key a.modelValue a.value := ℜ.boxed [ + .a.key ↦ a.key, + .a.modelValue ↦ a.modelValue, + .a.value ↦ a.value + ] ⊢ a.modelValue ∈ ℜ.model.X [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Alias.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Alias.ts new file mode 100644 index 00000000..6ae9a74d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Alias.ts @@ -0,0 +1,6 @@ +import * as runtime from "@coln-project/runtime"; +import * as Model from "./Model.ts"; + +export type View = Model.View; + +export type Transaction = Model.Transaction; \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Model.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Model.ts new file mode 100644 index 00000000..f8c182ce --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/Model.ts @@ -0,0 +1,9 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/T.ts new file mode 100644 index 00000000..69c4549d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; +import * as Model from "./Model.ts"; +import * as Alias from "./Alias.ts"; + +export interface View { + model: Model.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + model: Model.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.json new file mode 100644 index 00000000..9dd8ca0f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["model"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["key"]],"type":{"tag":"builtin","type":"builtinInt"}},{"path":[["a"],["modelValue"]],"type":{"tag":"rowId","path":[["TRealm"],["model"],["X"]]}},{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["model"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["key"]],[["a"],["modelValue"]],[["a"],["value"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"rowId","path":[["TRealm"],["model"],["X"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.ts new file mode 100644 index 00000000..7d9eae22 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.ts @@ -0,0 +1,48 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as Model from "./Model.ts"; +import * as Alias from "./Alias.ts"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + model: { X: (new runtime.RowIdSet.View(store, "TRealm.model.X", [])) }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + model: { + X: (new runtime.RowIdSet.Transaction( + store, + "TRealm.model.X", + [], + transaction + )) + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.coln new file mode 100644 index 00000000..3f01d3a5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.coln @@ -0,0 +1,18 @@ +def PointAt (X : Set) (x : X) : Set := sig +end + +def Box (X : Set) (x : X) (E : X -> Set) (f : (x : X) -> E x) (p : PointAt (E x) (f x)) : Set := sig + image : E x +end + +theory T := sig + Key : Set + key : Key + E : Key -> Set + f : (x : Key) -> E x + point : PointAt (E key) (f key) + boxed : Box Key key E f point -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.output b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.output new file mode 100644 index 00000000..e7f8f95d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.output @@ -0,0 +1,70 @@ +-- elaborated +global entry named PointAt +in mode: Conjunctive +type: (X : Set) -> (x : X) -> Set +value: X => x => sig +end +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (x : X) -> (E : X -> Set) -> (f : (x : X) -> E x) -> (p : PointAt (E x) (f x)) -> Set +value: X => x => E => f => p => sig + image : E x +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + Key : Set + key : Key + E : Key -> Set + f : (x : Key) -> E x + point : PointAt (E key) (f key) + boxed : Box Key key E f point -> Set +end +realm named TRealm +elaborated: realm + generators + node + Key = rel [] + key = (fun [] -> TRealm.Key []) + E = rel [a : TRealm.Key []] + f = (fun [x : TRealm.Key []] -> TRealm.E [a := x]) + point = (fun [] -> PointAt (TRealm.E [a := TRealm.key []]) (TRealm.f [ + x := TRealm.key [] + ])) + boxed = rel [ + a : Box (TRealm.Key []) (TRealm.key []) (a => TRealm.E [ + a := a + ]) (x => TRealm.f [x := x]) (TRealm.point []) + ] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.Key := [] + table ℜ.key := [.a : ℜ.Key] primarykey [] + table ℜ.E := [.a : ℜ.Key] + table ℜ.f := [.x : ℜ.Key, .a : ℜ.E] primarykey [.x] + table ℜ.boxed := [.a.image : ℜ.E] + end + rules + enforced ℜ.Key.foreignKey := ℜ.Key [] ⊢ ⊤ + enforced ℜ.key.foreignKey a := ℜ.key [.a ↦ a] ⊢ a ∈ ℜ.Key [] + monitored ℜ.key.total := ⊤ ⊢ ℜ.key [] + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ a ∈ ℜ.Key [] + enforced ℜ.f.foreignKey x a := ℜ.f [ + .x ↦ x, + .a ↦ a + ] ⊢ x ∈ ℜ.Key [] ∧ a ∈ ℜ.E [.a ↦ x] + monitored ℜ.f.total x := x ∈ ℜ.Key [] ⊢ ℜ.f [.x ↦ x] + monitored ℜ.point := ⊤ ⊢ ⊤ + enforced ℜ.boxed.foreignKey a.image b := ℜ.key [.a ↦ b] ∧ ℜ.boxed [ + .a.image ↦ a.image + ] ⊢ a.image ∈ ℜ.E [.a ↦ b] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/T.ts new file mode 100644 index 00000000..5ce3d59f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/T.ts @@ -0,0 +1,19 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + Key: runtime.ColnSet.View; + key: runtime.ColnRef.View; + E: (x: runtime.Value) => runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; + point: PointAt.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + Key: runtime.ColnSet.Transaction; + key: runtime.ColnRef.Transaction; + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; + point: PointAt.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.json new file mode 100644 index 00000000..0d6323dd --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["Key"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["key"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}}],"primaryKey":[]}},{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}}],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}},{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":[[["x"]]]}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["image"]],"type":{"tag":"rowId","path":[["TRealm"],["E"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["Key"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["key"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["key"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]},{"tag":"rowId","path":[["TRealm"],["E"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":1},"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["point"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["image"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["E"]]},{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["key"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":1}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":{"tag":"var","index":0},"values":[{"column":0,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.ts new file mode 100644 index 00000000..2fa0ac50 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.ts @@ -0,0 +1,80 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + Key: (new runtime.RowIdSet.View(store, "TRealm.Key", [])), + key: (new runtime.TableCellRef.View(store, "TRealm.key", [])), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + f: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [x])); + }, + point: (new runtime.TableCellRef.View(store, "TRealm.point", [])), + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + Key: (new runtime.RowIdSet.Transaction( + store, + "TRealm.Key", + [], + transaction + )), + key: (new runtime.TableCellRef.Transaction( + store, + "TRealm.key", + [], + transaction + )), + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + f: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [x], + transaction + )); + }, + point: (new runtime.TableCellRef.Transaction( + store, + "TRealm.point", + [], + transaction + )), + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.coln new file mode 100644 index 00000000..1a335a43 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.coln @@ -0,0 +1,20 @@ +theory PointOf (X : Set) := sig + point : X +end + +def Key : Set := sig + rank : Int +end + +def Box (X : Set) (p : PointOf X) (Y : Set) : Set := sig + key : X + value : Y +end + +theory T := sig + pointed : PointOf Key + boxed : Box Key pointed String -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.output b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.output new file mode 100644 index 00000000..e3f37bf6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.output @@ -0,0 +1,58 @@ +-- elaborated +global entry named PointOf +in mode: Conjunctive +type: (X : Set) -> Theory +value: X => sig + point : X +end +global entry named Key +in mode: Conjunctive +type: Set +value: sig + rank : Int +end +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (p : PointOf X) -> (Y : Set) -> Set +value: X => p => Y => sig + key : X + value : Y +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + pointed : PointOf Key + boxed : Box Key pointed String -> Set +end +realm named TRealm +elaborated: realm + generators + node + pointed = node + point = (fun [] -> Key) + end + boxed = rel [a : Box Key [point := TRealm.pointed.point []] String] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.pointed.point := [.a.rank : Int] primarykey [] + table ℜ.boxed := [.a.key.rank : Int, .a.value : String] + end + rules + enforced ℜ.pointed.point.foreignKey a.rank := ℜ.pointed.point [ + .a.rank ↦ a.rank + ] ⊢ ⊤ + monitored ℜ.pointed.point.total := ⊤ ⊢ ℜ.pointed.point [] + enforced ℜ.boxed.foreignKey a.key.rank a.value := ℜ.boxed [ + .a.key.rank ↦ a.key.rank, + .a.value ↦ a.value + ] ⊢ ⊤ + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/PointOf.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/PointOf.ts new file mode 100644 index 00000000..09e73697 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/PointOf.ts @@ -0,0 +1,9 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + point: runtime.ColnRef.View; +} + +export interface Transaction extends View { + point: runtime.ColnRef.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/T.ts new file mode 100644 index 00000000..ca51d3cf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/T.ts @@ -0,0 +1,12 @@ +import * as runtime from "@coln-project/runtime"; +import * as PointOf from "./PointOf.ts"; + +export interface View { + pointed: PointOf.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + pointed: PointOf.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.json new file mode 100644 index 00000000..e10a083f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["pointed"],["point"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[]}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["key"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}},{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["pointed"],["point"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["rank"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["pointed"],["point"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["pointed"],["point"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["pointed"],["point"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["key"],["rank"]],[["a"],["value"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.ts new file mode 100644 index 00000000..c2681fbf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.ts @@ -0,0 +1,53 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as PointOf from "./PointOf.ts"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + pointed: { + point: (new runtime.TableCellRef.View( + store, + "TRealm.pointed.point", + [] + )) + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + pointed: { + point: (new runtime.TableCellRef.Transaction( + store, + "TRealm.pointed.point", + [], + transaction + )) + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-function.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-function.coln new file mode 100644 index 00000000..1ee091c7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-function.coln @@ -0,0 +1,13 @@ +def Box (X : Set) (f : X -> X) (Y : Set) : Set := sig + key : X + value : Y +end + +theory T := sig + Key : Set + f : Key -> Key + boxed : Box Key f String -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-function.output b/packages/coln-compiler/test/golden/basic-ir/param-record-function.output new file mode 100644 index 00000000..a3c7dbcb --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-function.output @@ -0,0 +1,49 @@ +-- elaborated +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (f : X -> X) -> (Y : Set) -> Set +value: X => f => Y => sig + key : X + value : Y +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + Key : Set + f : Key -> Key + boxed : Box Key f String -> Set +end +realm named TRealm +elaborated: realm + generators + node + Key = rel [] + f = (fun [a : TRealm.Key []] -> TRealm.Key []) + boxed = rel [a : Box (TRealm.Key []) (a => TRealm.f [a := a]) String] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.Key := [] + table ℜ.f := [.a : ℜ.Key, .b : ℜ.Key] primarykey [.a] + table ℜ.boxed := [.a.key : ℜ.Key, .a.value : String] + end + rules + enforced ℜ.Key.foreignKey := ℜ.Key [] ⊢ ⊤ + enforced ℜ.f.foreignKey a b := ℜ.f [ + .a ↦ a, + .b ↦ b + ] ⊢ a ∈ ℜ.Key [] ∧ b ∈ ℜ.Key [] + monitored ℜ.f.total a := a ∈ ℜ.Key [] ⊢ ℜ.f [.a ↦ a] + enforced ℜ.boxed.foreignKey a.key a.value := ℜ.boxed [ + .a.key ↦ a.key, + .a.value ↦ a.value + ] ⊢ a.key ∈ ℜ.Key [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/T.ts new file mode 100644 index 00000000..86dd4380 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + Key: runtime.ColnSet.View; + f: (x: runtime.Value) => runtime.ColnRef.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + Key: runtime.ColnSet.Transaction; + f: (x: runtime.Value) => runtime.ColnRef.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.json new file mode 100644 index 00000000..8de3d7fe --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["Key"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["f"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["key"]],"type":{"tag":"rowId","path":[["TRealm"],["Key"]]}},{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["Key"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["f"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]},{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["f"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["f"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["key"]],[["a"],["value"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["Key"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Key"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.ts new file mode 100644 index 00000000..822be1ed --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.ts @@ -0,0 +1,55 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + Key: (new runtime.RowIdSet.View(store, "TRealm.Key", [])), + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.f", [a])); + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + Key: (new runtime.RowIdSet.Transaction( + store, + "TRealm.Key", + [], + transaction + )), + f: (a: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.f", + [a], + transaction + )); + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-model.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-model.coln index 69bf902a..8c10ef45 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-model.coln +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-model.coln @@ -2,10 +2,6 @@ theory Model := sig X : Set end -def Payload : Set := sig - name : String -end - def Box (M : Model) (Y : Set) : Set := sig modelValue : M.X value : Y @@ -13,7 +9,7 @@ end theory T := sig model : Model - boxed : Box model Payload -> Set + boxed : Box model String -> Set end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-model.output b/packages/coln-compiler/test/golden/basic-ir/param-record-model.output index 9f9951cb..625bd20d 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-model.output +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-model.output @@ -5,12 +5,6 @@ type: Theory value: sig X : Set end -global entry named Payload -in mode: Conjunctive -type: Set -value: sig - name : String -end global entry named Box in mode: Conjunctive type: (M : Model) -> (Y : Set) -> Set @@ -23,7 +17,7 @@ in mode: Conjunctive type: Theory value: sig model : Model - boxed : Box model Payload -> Set + boxed : Box model String -> Set end realm named TRealm elaborated: realm @@ -32,7 +26,7 @@ elaborated: realm model = node X = rel [] end - boxed = rel [a : Box [X := TRealm.model.X []] Payload] + boxed = rel [a : Box [X := TRealm.model.X []] String] end end definitions @@ -41,13 +35,13 @@ end lowered: flatrealm entities table ℜ.model.X := [] - table ℜ.boxed := [.a.modelValue : ℜ.model.X, .a.value.name : String] + table ℜ.boxed := [.a.modelValue : ℜ.model.X, .a.value : String] end rules enforced ℜ.model.X.foreignKey := ℜ.model.X [] ⊢ ⊤ - enforced ℜ.boxed.foreignKey a.modelValue a.value.name := ℜ.boxed [ + enforced ℜ.boxed.foreignKey a.modelValue a.value := ℜ.boxed [ .a.modelValue ↦ a.modelValue, - .a.value.name ↦ a.value.name + .a.value ↦ a.value ] ⊢ a.modelValue ∈ ℜ.model.X [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-model.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-model.ts.output/TRealm.json index 3857e386..b763f87f 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-model.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-model.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["model"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["modelValue"]],"type":{"tag":"rowId","path":[["TRealm"],["model"],["X"]]}},{"path":[["a"],["value"],["name"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["model"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["modelValue"]],[["a"],["value"],["name"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["model"],["X"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["model"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["modelValue"]],"type":{"tag":"rowId","path":[["TRealm"],["model"],["X"]]}},{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["model"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["modelValue"]],[["a"],["value"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["model"],["X"]]},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["model"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.coln index bced53d0..e2a2e6a2 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.coln +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.coln @@ -4,13 +4,11 @@ end def Nested (X : Set) : Set := sig inner : Box X - sibling : X end theory T := sig X : Set nested : Nested X -> Set - selected : Nested X -> X end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.output b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.output index cb9a5934..d6bdb83b 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.output +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.output @@ -10,7 +10,6 @@ in mode: Conjunctive type: (X : Set) -> Set value: X => sig inner : Box X - sibling : X end global entry named T in mode: Conjunctive @@ -18,7 +17,6 @@ type: Theory value: sig X : Set nested : Nested X -> Set - selected : Nested X -> X end realm named TRealm elaborated: realm @@ -26,7 +24,6 @@ elaborated: realm node X = rel [] nested = rel [a : Nested (TRealm.X [])] - selected = (fun [a : Nested (TRealm.X [])] -> TRealm.X []) end end definitions @@ -35,28 +32,13 @@ end lowered: flatrealm entities table ℜ.X := [] - table ℜ.nested := [.a.inner.value : ℜ.X, .a.sibling : ℜ.X] - table ℜ.selected := [ - .a.inner.value : ℜ.X, - .a.sibling : ℜ.X, - .b : ℜ.X - ] primarykey [.a.sibling, .a.inner.value] + table ℜ.nested := [.a.inner.value : ℜ.X] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ - enforced ℜ.nested.foreignKey a.inner.value a.sibling := ℜ.nested [ - .a.inner.value ↦ a.inner.value, - .a.sibling ↦ a.sibling - ] ⊢ a.inner.value ∈ ℜ.X [] ∧ a.sibling ∈ ℜ.X [] - enforced ℜ.selected.foreignKey a.inner.value a.sibling b := ℜ.selected [ - .a.inner.value ↦ a.inner.value, - .a.sibling ↦ a.sibling, - .b ↦ b - ] ⊢ a.inner.value ∈ ℜ.X [] ∧ a.sibling ∈ ℜ.X [] ∧ b ∈ ℜ.X [] - monitored ℜ.selected.total a.inner.value a.sibling := a.inner.value ∈ ℜ.X [] ∧ a.sibling ∈ ℜ.X [] ⊢ ℜ.selected [ - .a.inner.value ↦ a.inner.value, - .a.sibling ↦ a.sibling - ] + enforced ℜ.nested.foreignKey a.inner.value := ℜ.nested [ + .a.inner.value ↦ a.inner.value + ] ⊢ a.inner.value ∈ ℜ.X [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/T.ts index ec08ec40..1a7337de 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/T.ts @@ -3,11 +3,9 @@ import * as runtime from "@coln-project/runtime"; export interface View { X: runtime.ColnSet.View; nested: (x: runtime.Value) => runtime.ColnSet.View; - selected: (x: runtime.Value) => runtime.ColnRef.View; } export interface Transaction extends View { X: runtime.ColnSet.Transaction; nested: (x: runtime.Value) => runtime.ColnSet.Transaction; - selected: (x: runtime.Value) => runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.json index 80357910..d9534daf 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["nested"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["inner"],["value"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["sibling"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":null}},{"path":[["TRealm"],["selected"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["inner"],["value"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["sibling"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"],["sibling"]],[["a"],["inner"],["value"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["nested"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["inner"],["value"]],[["a"],["sibling"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nested"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["selected"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["inner"],["value"]],[["a"],["sibling"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["selected"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}}]}},{"path":[["TRealm"],["selected"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"],["inner"],["value"]],[["a"],["sibling"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["selected"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["nested"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["inner"],["value"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["nested"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["inner"],["value"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["nested"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.ts index 5870a915..6e14e4ed 100644 --- a/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.ts @@ -11,9 +11,6 @@ export class View { X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), nested: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.nested", [a])); - }, - selected: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.selected", [a])); } }; } @@ -36,14 +33,6 @@ export class Transaction extends View { [a], transaction )); - }, - selected: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.selected", - [a], - transaction - )); } }; } diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.coln new file mode 100644 index 00000000..ea5046de --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.coln @@ -0,0 +1,12 @@ +def Shadowed (X : Set) (X : Set) : Set := sig + value : X +end + +theory T := sig + A : Set + B : Set + shadowed : Shadowed A B -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.output b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.output new file mode 100644 index 00000000..ade5e757 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.output @@ -0,0 +1,43 @@ +-- elaborated +global entry named Shadowed +in mode: Conjunctive +type: (X : Set) -> (X : Set) -> Set +value: X => X => sig + value : X +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + A : Set + B : Set + shadowed : Shadowed A B -> Set +end +realm named TRealm +elaborated: realm + generators + node + A = rel [] + B = rel [] + shadowed = rel [a : Shadowed (TRealm.A []) (TRealm.B [])] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.A := [] + table ℜ.B := [] + table ℜ.shadowed := [.a.value : ℜ.B] + end + rules + enforced ℜ.A.foreignKey := ℜ.A [] ⊢ ⊤ + enforced ℜ.B.foreignKey := ℜ.B [] ⊢ ⊤ + enforced ℜ.shadowed.foreignKey a.value := ℜ.shadowed [ + .a.value ↦ a.value + ] ⊢ a.value ∈ ℜ.B [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/T.ts new file mode 100644 index 00000000..3c259686 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + A: runtime.ColnSet.View; + B: runtime.ColnSet.View; + shadowed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + A: runtime.ColnSet.Transaction; + B: runtime.ColnSet.Transaction; + shadowed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.json new file mode 100644 index 00000000..d63a2d00 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["A"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["B"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["shadowed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["value"]],"type":{"tag":"rowId","path":[["TRealm"],["B"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["A"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["A"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["B"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["shadowed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["value"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["B"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["shadowed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["B"]],"rowId":{"tag":"var","index":0},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.ts new file mode 100644 index 00000000..1da46dc5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.ts @@ -0,0 +1,41 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + A: (new runtime.RowIdSet.View(store, "TRealm.A", [])), + B: (new runtime.RowIdSet.View(store, "TRealm.B", [])), + shadowed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.shadowed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + A: (new runtime.RowIdSet.Transaction(store, "TRealm.A", [], transaction)), + B: (new runtime.RowIdSet.Transaction(store, "TRealm.B", [], transaction)), + shadowed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.shadowed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.coln new file mode 100644 index 00000000..2d863e62 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.coln @@ -0,0 +1,10 @@ +def Box (X : Set) (x : X) (E : X -> Set) : Set := sig + value : E x +end + +theory T := sig + boxed : (x : Int) -> Box Int x (y => String) -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.output b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.output new file mode 100644 index 00000000..6fe5fa81 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.output @@ -0,0 +1,36 @@ +-- elaborated +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (x : X) -> (E : X -> Set) -> Set +value: X => x => E => sig + value : E x +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + boxed : (x : Int) -> Box Int x (y => String) -> Set +end +realm named TRealm +elaborated: realm + generators + node + boxed = rel [x : Int, a : Box Int x (y => String)] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.boxed := [.x : Int, .a.value : String] + end + rules + enforced ℜ.boxed.foreignKey x a.value := ℜ.boxed [ + .x ↦ x, + .a.value ↦ a.value + ] ⊢ ⊤ + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/T.ts new file mode 100644 index 00000000..be00308c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/T.ts @@ -0,0 +1,9 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + boxed: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + boxed: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.json new file mode 100644 index 00000000..39d0d8e8 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"builtin","type":"builtinInt"}},{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinString"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["a"],["value"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"},{"tag":"builtin","type":"builtinString"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.ts new file mode 100644 index 00000000..beab66d7 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.ts @@ -0,0 +1,41 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + boxed: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [x, a])); + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + boxed: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [x, a], + transaction + )); + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.coln new file mode 100644 index 00000000..a240d226 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.coln @@ -0,0 +1,13 @@ +def Cell (X : Set) (Y : Set) (R : X -> Y -> Set) (x : X) (y : Y) : Set := sig + entry : R x y +end + +theory T := sig + X : Set + Y : Set + R : X -> Y -> Set + cells : (x : X) -> (y : Y) -> Cell X Y R x y -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.output b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.output new file mode 100644 index 00000000..6a7c42a2 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.output @@ -0,0 +1,59 @@ +-- elaborated +global entry named Cell +in mode: Conjunctive +type: (X : Set) -> (Y : Set) -> (R : X -> Y -> Set) -> (x : X) -> (y : Y) -> Set +value: X => Y => R => x => y => sig + entry : R x y +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + Y : Set + R : X -> Y -> Set + cells : (x : X) -> (y : Y) -> Cell X Y R x y -> Set +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + Y = rel [] + R = rel [a : TRealm.X [], b : TRealm.Y []] + cells = rel [ + x : TRealm.X [], + y : TRealm.Y [], + a : Cell (TRealm.X []) (TRealm.Y []) (a => b => TRealm.R [ + a := a, + b := b + ]) x y + ] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.Y := [] + table ℜ.R := [.a : ℜ.X, .b : ℜ.Y] + table ℜ.cells := [.x : ℜ.X, .y : ℜ.Y, .a.entry : ℜ.R] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.Y.foreignKey := ℜ.Y [] ⊢ ⊤ + enforced ℜ.R.foreignKey a b := ℜ.R [ + .a ↦ a, + .b ↦ b + ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.Y [] + enforced ℜ.cells.foreignKey x y a.entry := ℜ.cells [ + .x ↦ x, + .y ↦ y, + .a.entry ↦ a.entry + ] ⊢ x ∈ ℜ.X [] ∧ y ∈ ℜ.Y [] ∧ a.entry ∈ ℜ.R [.a ↦ x, .b ↦ y] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/T.ts new file mode 100644 index 00000000..56e70124 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + Y: runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + cells: (x: runtime.Value) => (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + Y: runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + cells: (x: runtime.Value) => (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.json new file mode 100644 index 00000000..1ba8743f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":null}},{"path":[["TRealm"],["cells"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["y"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}},{"path":[["a"],["entry"]],"type":{"tag":"rowId","path":[["TRealm"],["R"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["cells"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["y"]],[["a"],["entry"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]},{"tag":"rowId","path":[["TRealm"],["R"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["cells"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":{"tag":"var","index":2},"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.ts similarity index 53% rename from packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.ts index 984ab33a..593bfdd6 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.ts @@ -9,15 +9,21 @@ export class View { constructor(store: runtime.StoreHandle) { this.root = { X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), - P: (new runtime.RowIdSet.View(store, "TRealm.P", [])), Y: (new runtime.RowIdSet.View(store, "TRealm.Y", [])), - choose: (a: runtime.Value) => { + R: (a: runtime.Value) => { return (b: runtime.Value) => { - return (new runtime.TableCellRef.View( - store, - "TRealm.choose", - [a, b] - )); + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + }, + cells: (x: runtime.Value) => { + return (y: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View( + store, + "TRealm.cells", + [x, y, a] + )); + }; }; } }; @@ -34,17 +40,28 @@ export class Transaction extends View { super(store); this.root = { X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), - P: (new runtime.RowIdSet.Transaction(store, "TRealm.P", [], transaction)), Y: (new runtime.RowIdSet.Transaction(store, "TRealm.Y", [], transaction)), - choose: (a: runtime.Value) => { + R: (a: runtime.Value) => { return (b: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( + return (new runtime.RowIdSet.Transaction( store, - "TRealm.choose", + "TRealm.R", [a, b], transaction )); }; + }, + cells: (x: runtime.Value) => { + return (y: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.cells", + [x, y, a], + transaction + )); + }; + }; } }; } diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.coln new file mode 100644 index 00000000..4f435691 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.coln @@ -0,0 +1,13 @@ +def Slice (Y : Set) (S : Y -> Set) (y : Y) : Set := sig + entry : S y +end + +theory T := sig + X : Set + Y : Set + R : X -> Y -> Set + slices : (x : X) -> (y : Y) -> Slice Y (R x) y -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.output b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.output new file mode 100644 index 00000000..8d78f3f6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.output @@ -0,0 +1,56 @@ +-- elaborated +global entry named Slice +in mode: Conjunctive +type: (Y : Set) -> (S : Y -> Set) -> (y : Y) -> Set +value: Y => S => y => sig + entry : S y +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + Y : Set + R : X -> Y -> Set + slices : (x : X) -> (y : Y) -> Slice Y (R x) y -> Set +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + Y = rel [] + R = rel [a : TRealm.X [], b : TRealm.Y []] + slices = rel [ + x : TRealm.X [], + y : TRealm.Y [], + a : Slice (TRealm.Y []) (b => TRealm.R [a := x, b := b]) y + ] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.Y := [] + table ℜ.R := [.a : ℜ.X, .b : ℜ.Y] + table ℜ.slices := [.x : ℜ.X, .y : ℜ.Y, .a.entry : ℜ.R] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.Y.foreignKey := ℜ.Y [] ⊢ ⊤ + enforced ℜ.R.foreignKey a b := ℜ.R [ + .a ↦ a, + .b ↦ b + ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.Y [] + enforced ℜ.slices.foreignKey x y a.entry := ℜ.slices [ + .x ↦ x, + .y ↦ y, + .a.entry ↦ a.entry + ] ⊢ x ∈ ℜ.X [] ∧ y ∈ ℜ.Y [] ∧ a.entry ∈ ℜ.R [.a ↦ x, .b ↦ y] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/T.ts new file mode 100644 index 00000000..4862097f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + Y: runtime.ColnSet.View; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; + slices: (x: runtime.Value) => (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + Y: runtime.ColnSet.Transaction; + R: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; + slices: (x: runtime.Value) => (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.json new file mode 100644 index 00000000..b8e6992a --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Y"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}}],"primaryKey":null}},{"path":[["TRealm"],["slices"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["y"]],"type":{"tag":"rowId","path":[["TRealm"],["Y"]]}},{"path":[["a"],["entry"]],"type":{"tag":"rowId","path":[["TRealm"],["R"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Y"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}}]}},{"path":[["TRealm"],["slices"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]],[["y"]],[["a"],["entry"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["Y"]]},{"tag":"rowId","path":[["TRealm"],["R"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["slices"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Y"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":{"tag":"var","index":2},"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.ts new file mode 100644 index 00000000..44a9a5a3 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.ts @@ -0,0 +1,68 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + Y: (new runtime.RowIdSet.View(store, "TRealm.Y", [])), + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.R", [a, b])); + }; + }, + slices: (x: runtime.Value) => { + return (y: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View( + store, + "TRealm.slices", + [x, y, a] + )); + }; + }; + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + Y: (new runtime.RowIdSet.Transaction(store, "TRealm.Y", [], transaction)), + R: (a: runtime.Value) => { + return (b: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.R", + [a, b], + transaction + )); + }; + }, + slices: (x: runtime.Value) => { + return (y: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.slices", + [x, y, a], + transaction + )); + }; + }; + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.coln new file mode 100644 index 00000000..ddc76a4c --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.coln @@ -0,0 +1,12 @@ +def Evidence (X : Set) (P : X -> Prop) (x : X) : Set := sig + proof : P x +end + +theory T := sig + X : Set + P : X -> Prop + evidence : (x : X) -> Evidence X P x -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.output b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.output new file mode 100644 index 00000000..b99788a4 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.output @@ -0,0 +1,46 @@ +-- elaborated +global entry named Evidence +in mode: Conjunctive +type: (X : Set) -> (P : X -> Prop) -> (x : X) -> Set +value: X => P => x => sig + proof : P x +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + P : X -> Prop + evidence : (x : X) -> Evidence X P x -> Set +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + P = rel [a : TRealm.X []] + evidence = rel [ + x : TRealm.X [], + a : Evidence (TRealm.X []) (a => TRealm.P [a := a]) x + ] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.P := [.a : ℜ.X] primarykey [.a] + table ℜ.evidence := [.x : ℜ.X] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.P.foreignKey a := ℜ.P [.a ↦ a] ⊢ a ∈ ℜ.X [] + enforced ℜ.evidence.foreignKey x := ℜ.evidence [.x ↦ x] ⊢ x ∈ ℜ.X [] ∧ ℜ.P [ + .a ↦ x + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/T.ts new file mode 100644 index 00000000..b91204c6 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/T.ts @@ -0,0 +1,13 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + P: (x: runtime.Value) => runtime.ColnSet.View; + evidence: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + P: (x: runtime.Value) => runtime.ColnSet.Transaction; + evidence: (x: runtime.Value) => (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.json new file mode 100644 index 00000000..09c1de89 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["evidence"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["evidence"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["evidence"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.ts similarity index 52% rename from packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.ts index 23c86773..354ac7b5 100644 --- a/packages/coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.ts @@ -9,11 +9,12 @@ export class View { constructor(store: runtime.StoreHandle) { this.root = { X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), - P: (new runtime.RowIdSet.View(store, "TRealm.P", [])), - Q: (new runtime.RowIdSet.View(store, "TRealm.Q", [])), - f: (a: runtime.Value) => { - return (b: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.f", [a, b])); + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.P", [a])); + }, + evidence: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.evidence", [x, a])); }; } }; @@ -30,14 +31,20 @@ export class Transaction extends View { super(store); this.root = { X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), - P: (new runtime.RowIdSet.Transaction(store, "TRealm.P", [], transaction)), - Q: (new runtime.RowIdSet.Transaction(store, "TRealm.Q", [], transaction)), - f: (a: runtime.Value) => { - return (b: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.P", + [a], + transaction + )); + }, + evidence: (x: runtime.Value) => { + return (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( store, - "TRealm.f", - [a, b], + "TRealm.evidence", + [x, a], transaction )); }; diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.coln b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.coln new file mode 100644 index 00000000..863b1cef --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.coln @@ -0,0 +1,11 @@ +def Box (X : Set) (E : X -> Set) : Set := sig + value : X +end + +theory T := sig + E : Int -> Set + boxed : Box Int E -> Set +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.output b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.output new file mode 100644 index 00000000..48493f20 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.output @@ -0,0 +1,37 @@ +-- elaborated +global entry named Box +in mode: Conjunctive +type: (X : Set) -> (E : X -> Set) -> Set +value: X => E => sig + value : X +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + E : Int -> Set + boxed : Box Int E -> Set +end +realm named TRealm +elaborated: realm + generators + node + E = rel [a : Int] + boxed = rel [a : Box Int (a => TRealm.E [a := a])] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.E := [.a : Int] + table ℜ.boxed := [.a.value : Int] + end + rules + enforced ℜ.E.foreignKey a := ℜ.E [.a ↦ a] ⊢ ⊤ + enforced ℜ.boxed.foreignKey a.value := ℜ.boxed [.a.value ↦ a.value] ⊢ ⊤ + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/T.ts new file mode 100644 index 00000000..71faf34d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + E: (x: runtime.Value) => runtime.ColnSet.View; + boxed: (x: runtime.Value) => runtime.ColnSet.View; +} + +export interface Transaction extends View { + E: (x: runtime.Value) => runtime.ColnSet.Transaction; + boxed: (x: runtime.Value) => runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.json new file mode 100644 index 00000000..33bf4c2b --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["E"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}},{"path":[["TRealm"],["boxed"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["E"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["E"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["boxed"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["value"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["boxed"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.ts new file mode 100644 index 00000000..8c561f59 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.ts @@ -0,0 +1,48 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.E", [a])); + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.boxed", [a])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + E: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.E", + [a], + transaction + )); + }, + boxed: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.boxed", + [a], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.coln similarity index 86% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.coln rename to packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.coln index d3ff28bd..9768bd4f 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.coln +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.coln @@ -8,7 +8,6 @@ end theory T := sig X : Set Accepted : EqualTriple X -> Prop - select : EqualTriple X -> X end realm TRealm @ T diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.output similarity index 53% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.output rename to packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.output index 2d456724..ac147372 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.output +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.output @@ -14,7 +14,6 @@ type: Theory value: sig X : Set Accepted : EqualTriple X -> Prop - select : EqualTriple X -> X end realm named TRealm elaborated: realm @@ -22,7 +21,6 @@ elaborated: realm node X = rel [] Accepted = rel [a : EqualTriple (TRealm.X [])] - select = (fun [a : EqualTriple (TRealm.X [])] -> TRealm.X []) end end definitions @@ -31,12 +29,10 @@ end lowered: flatrealm entities table ℜ.X := [] - table ℜ.Accepted := [.a.first : ℜ.X, .a.second : ℜ.X, .a.trailing : ℜ.X] - table ℜ.select := [ + table ℜ.Accepted := [ .a.first : ℜ.X, .a.second : ℜ.X, - .a.trailing : ℜ.X, - .b : ℜ.X + .a.trailing : ℜ.X ] primarykey [.a.first, .a.second, .a.trailing] end rules @@ -46,17 +42,6 @@ lowered: flatrealm .a.second ↦ a.second, .a.trailing ↦ a.trailing ] ⊢ a.first ∈ ℜ.X [] ∧ a.second ∈ ℜ.X [] ∧ a.first = a.second ∧ a.trailing ∈ ℜ.X [] - enforced ℜ.select.foreignKey a.first a.second a.trailing b := ℜ.select [ - .a.first ↦ a.first, - .a.second ↦ a.second, - .a.trailing ↦ a.trailing, - .b ↦ b - ] ⊢ a.first ∈ ℜ.X [] ∧ a.second ∈ ℜ.X [] ∧ a.first = a.second ∧ a.trailing ∈ ℜ.X [] ∧ b ∈ ℜ.X [] - monitored ℜ.select.total a.first a.second a.trailing := a.first ∈ ℜ.X [] ∧ a.second ∈ ℜ.X [] ∧ a.first = a.second ∧ a.trailing ∈ ℜ.X [] ⊢ ℜ.select [ - .a.first ↦ a.first, - .a.second ↦ a.second, - .a.trailing ↦ a.trailing - ] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/T.ts similarity index 72% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/T.ts index c2b18964..69069613 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/T.ts +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/T.ts @@ -3,11 +3,9 @@ import * as runtime from "@coln-project/runtime"; export interface View { X: runtime.ColnSet.View; Accepted: (x: runtime.Value) => runtime.ColnSet.View; - select: (x: runtime.Value) => runtime.ColnRef.View; } export interface Transaction extends View { X: runtime.ColnSet.Transaction; Accepted: (x: runtime.Value) => runtime.ColnSet.Transaction; - select: (x: runtime.Value) => runtime.ColnRef.Transaction; } \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.json new file mode 100644 index 00000000..654f265f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Accepted"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["first"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["second"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["trailing"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Accepted"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Accepted"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":1}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.ts similarity index 74% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.ts index 91ed30e4..14a1cbf8 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.ts +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.ts @@ -11,9 +11,6 @@ export class View { X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), Accepted: (a: runtime.Value) => { return (new runtime.RowIdSet.View(store, "TRealm.Accepted", [a])); - }, - select: (a: runtime.Value) => { - return (new runtime.TableCellRef.View(store, "TRealm.select", [a])); } }; } @@ -36,14 +33,6 @@ export class Transaction extends View { [a], transaction )); - }, - select: (a: runtime.Value) => { - return (new runtime.TableCellRef.Transaction( - store, - "TRealm.select", - [a], - transaction - )); } }; } diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.coln similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.coln rename to packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.coln diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.output similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.output rename to packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.output diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/T.ts similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/T.ts rename to packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/T.ts diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/TRealm.json similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/TRealm.json rename to packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/TRealm.json diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/TRealm.ts similarity index 100% rename from packages/coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/TRealm.ts rename to packages/coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/TRealm.ts diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.coln new file mode 100644 index 00000000..c984cb41 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.coln @@ -0,0 +1,16 @@ +def Evidence (X : Set) (actual : X) (expected : X) : Set := sig + proof : actual = expected +end + +def Result (X : Set) (expected : X) : Set := sig + actual : X + evidence : Evidence X actual expected +end + +theory T := sig + X : Set + result : (^c expected : X) -> Result X expected +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.output new file mode 100644 index 00000000..ab0577df --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.output @@ -0,0 +1,50 @@ +-- elaborated +global entry named Evidence +in mode: Conjunctive +type: (X : Set) -> (actual : X) -> (expected : X) -> Set +value: X => actual => expected => sig + proof : actual = expected +end +global entry named Result +in mode: Conjunctive +type: (X : Set) -> (expected : X) -> Set +value: X => expected => sig + actual : X + evidence : Evidence X actual expected +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + result : (expected : X) -> Result X expected +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + result = (fun [expected : TRealm.X []] -> Result (TRealm.X []) expected) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.result := [.expected : ℜ.X, .a.actual : ℜ.X] primarykey [.expected] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.result.foreignKey expected a.actual := ℜ.result [ + .expected ↦ expected, + .a.actual ↦ a.actual + ] ⊢ expected ∈ ℜ.X [] ∧ a.actual ∈ ℜ.X [] ∧ a.actual = expected + monitored ℜ.result.total expected := expected ∈ ℜ.X [] ⊢ ℜ.result [ + .expected ↦ expected + ] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/T.ts new file mode 100644 index 00000000..4b0bc9f1 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + result: (x: runtime.Value) => Result.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + result: (x: runtime.Value) => Result.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.json new file mode 100644 index 00000000..ae9c23bb --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["result"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["expected"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["actual"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["expected"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["result"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["expected"]],[["a"],["actual"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["result"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"eq","left":{"tag":"var","index":1},"right":{"tag":"var","index":0}}]}},{"path":[["TRealm"],["result"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["expected"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["result"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.ts new file mode 100644 index 00000000..37aca1f8 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.ts @@ -0,0 +1,43 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + result: (expected: runtime.Value) => { + return (new runtime.TableCellRef.View( + store, + "TRealm.result", + [expected] + )); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + result: (expected: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.result", + [expected], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.coln new file mode 100644 index 00000000..9c9d3a52 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.coln @@ -0,0 +1,16 @@ +def Evidence (P : Prop) : Set := sig + proof : P +end + +def Package (P : Int -> Prop) : Set := sig + value : Int + evidence : Evidence (P value) +end + +theory T := sig + P : Int -> Prop + package : Package P +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.output new file mode 100644 index 00000000..49e90950 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.output @@ -0,0 +1,47 @@ +-- elaborated +global entry named Evidence +in mode: Conjunctive +type: (P : Prop) -> Set +value: P => sig + proof : P +end +global entry named Package +in mode: Conjunctive +type: (P : Int -> Prop) -> Set +value: P => sig + value : Int + evidence : Evidence (P value) +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + P : Int -> Prop + package : Package P +end +realm named TRealm +elaborated: realm + generators + node + P = rel [a : Int] + package = (fun [] -> Package (a => TRealm.P [a := a])) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.P := [.a : Int] primarykey [.a] + table ℜ.package := [.a.value : Int] primarykey [] + end + rules + enforced ℜ.P.foreignKey a := ℜ.P [.a ↦ a] ⊢ ⊤ + enforced ℜ.package.foreignKey a.value := ℜ.package [ + .a.value ↦ a.value + ] ⊢ ℜ.P [.a ↦ a.value] + monitored ℜ.package.total := ⊤ ⊢ ℜ.package [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/T.ts new file mode 100644 index 00000000..f36c9d64 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + P: (x: runtime.Value) => runtime.ColnSet.View; + package: Package.View; +} + +export interface Transaction extends View { + P: (x: runtime.Value) => runtime.ColnSet.Transaction; + package: Package.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.json new file mode 100644 index 00000000..f0db6027 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["package"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["value"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[]}},{"path":[["TRealm"],["package"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["value"]]],"varTypes":[{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["package"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}},{"path":[["TRealm"],["package"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["package"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.ts new file mode 100644 index 00000000..5756c997 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.ts @@ -0,0 +1,44 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.P", [a])); + }, + package: (new runtime.TableCellRef.View(store, "TRealm.package", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.P", + [a], + transaction + )); + }, + package: (new runtime.TableCellRef.Transaction( + store, + "TRealm.package", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.json deleted file mode 100644 index 2c807669..00000000 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.json +++ /dev/null @@ -1 +0,0 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Accepted"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["first"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["second"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["trailing"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":null}},{"path":[["TRealm"],["select"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["first"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["second"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["trailing"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Accepted"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Accepted"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":1}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}}]}},{"path":[["TRealm"],["select"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["select"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}},{"column":3,"term":{"tag":"var","index":3}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":1}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":3},"values":[]}}]}},{"path":[["TRealm"],["select"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"],["first"]],[["a"],["second"]],[["a"],["trailing"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":1}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["select"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.coln new file mode 100644 index 00000000..eaae8172 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.coln @@ -0,0 +1,11 @@ +def Evidence (P : Prop) : Set := sig + proof : P +end + +theory T := sig + P : Prop + evidence : Evidence P +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.output new file mode 100644 index 00000000..c794dadc --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.output @@ -0,0 +1,36 @@ +-- elaborated +global entry named Evidence +in mode: Conjunctive +type: (P : Prop) -> Set +value: P => sig + proof : P +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + P : Prop + evidence : Evidence P +end +realm named TRealm +elaborated: realm + generators + node + P = rel [] + evidence = (fun [] -> Evidence (TRealm.P [])) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.P := [] primarykey [] + end + rules + enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ + monitored ℜ.evidence := ⊤ ⊢ ℜ.P [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/T.ts new file mode 100644 index 00000000..76f5d21f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + P: runtime.ColnSet.View; + evidence: Evidence.View; +} + +export interface Transaction extends View { + P: runtime.ColnSet.Transaction; + evidence: Evidence.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.json new file mode 100644 index 00000000..2cc95768 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["evidence"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.ts new file mode 100644 index 00000000..c0a628a5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.ts @@ -0,0 +1,35 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + P: (new runtime.RowIdSet.View(store, "TRealm.P", [])), + evidence: (new runtime.TableCellRef.View(store, "TRealm.evidence", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + P: (new runtime.RowIdSet.Transaction(store, "TRealm.P", [], transaction)), + evidence: (new runtime.TableCellRef.Transaction( + store, + "TRealm.evidence", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.coln b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.coln new file mode 100644 index 00000000..7846de2f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.coln @@ -0,0 +1,18 @@ +def Pair (X : Set) : Set := sig + left : X + right : X +end + +def Comparison (X : Set) : Set := sig + first : Pair X + second : Pair X + same : first = second +end + +theory T := sig + X : Set + comparison : Comparison X +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.output b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.output new file mode 100644 index 00000000..eb88734a --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.output @@ -0,0 +1,57 @@ +-- elaborated +global entry named Pair +in mode: Conjunctive +type: (X : Set) -> Set +value: X => sig + left : X + right : X +end +global entry named Comparison +in mode: Conjunctive +type: (X : Set) -> Set +value: X => sig + first : Pair X + second : Pair X + same : first = second +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + comparison : Comparison X +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + comparison = (fun [] -> Comparison (TRealm.X [])) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.comparison := [ + .a.first.left : ℜ.X, + .a.first.right : ℜ.X, + .a.second.left : ℜ.X, + .a.second.right : ℜ.X + ] primarykey [] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.comparison.foreignKey a.first.left a.first.right a.second.left a.second.right := ℜ.comparison [ + .a.first.left ↦ a.first.left, + .a.first.right ↦ a.first.right, + .a.second.left ↦ a.second.left, + .a.second.right ↦ a.second.right + ] ⊢ a.first.left ∈ ℜ.X [] ∧ a.first.right ∈ ℜ.X [] ∧ a.second.left ∈ ℜ.X [] ∧ a.second.right ∈ ℜ.X [] ∧ a.first.left = a.second.left ∧ a.first.right = a.second.right + monitored ℜ.comparison.total := ⊤ ⊢ ℜ.comparison [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/T.ts new file mode 100644 index 00000000..97ac7fce --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + comparison: Comparison.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + comparison: Comparison.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.json new file mode 100644 index 00000000..87c4c6aa --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["comparison"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["first"],["left"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["first"],["right"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["second"],["left"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["a"],["second"],["right"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["comparison"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["first"],["left"]],[["a"],["first"],["right"]],[["a"],["second"],["left"]],[["a"],["second"],["right"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["comparison"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}},{"column":3,"term":{"tag":"var","index":3}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":2},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":3},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":2}},{"tag":"eq","left":{"tag":"var","index":1},"right":{"tag":"var","index":3}}]}},{"path":[["TRealm"],["comparison"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["comparison"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.ts new file mode 100644 index 00000000..665e7d34 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.ts @@ -0,0 +1,39 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + comparison: (new runtime.TableCellRef.View( + store, + "TRealm.comparison", + [] + )) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + comparison: (new runtime.TableCellRef.Transaction( + store, + "TRealm.comparison", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record.output b/packages/coln-compiler/test/golden/basic-ir/proof-record.output index 3ba1d9df..bee0921a 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record.output +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record.output @@ -26,12 +26,10 @@ end lowered: flatrealm entities table ℜ.X := [] - table ℜ.witness := [.x : ℜ.X] primarykey [.x] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ - enforced ℜ.witness.foreignKey x := ℜ.witness [.x ↦ x] ⊢ x ∈ ℜ.X [] ∧ x = x - monitored ℜ.witness.total x := x ∈ ℜ.X [] ⊢ ℜ.witness [.x ↦ x] + monitored ℜ.witness x := x ∈ ℜ.X [] ⊢ x = x end end diff --git a/packages/coln-compiler/test/golden/basic-ir/proof-record.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/proof-record.ts.output/TRealm.json index 6b600e3b..5e79d35b 100644 --- a/packages/coln-compiler/test/golden/basic-ir/proof-record.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/proof-record.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["witness"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["x"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["x"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["witness"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["witness"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":0}}]}},{"path":[["TRealm"],["witness"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["witness"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["witness"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"eq","left":{"tag":"var","index":0},"right":{"tag":"var","index":0}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.coln b/packages/coln-compiler/test/golden/basic-ir/prop-alias.coln new file mode 100644 index 00000000..82dfe8cf --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.coln @@ -0,0 +1,8 @@ +theory PropAlias := Prop + +theory T := sig + V : PropAlias +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.output b/packages/coln-compiler/test/golden/basic-ir/prop-alias.output new file mode 100644 index 00000000..f528730a --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.output @@ -0,0 +1,31 @@ +-- elaborated +global entry named PropAlias +in mode: Conjunctive +type: Theory +value: Prop +global entry named T +in mode: Conjunctive +type: Theory +value: sig + V : PropAlias +end +realm named TRealm +elaborated: realm + generators + node + V = rel [] + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.V := [] primarykey [] + end + rules + enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/PropAlias.ts b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/PropAlias.ts new file mode 100644 index 00000000..1fbce54e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/PropAlias.ts @@ -0,0 +1,5 @@ +import * as runtime from "@coln-project/runtime"; + +export type View = runtime.ColnSet.View; + +export type Transaction = runtime.ColnSet.Transaction; \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/T.ts new file mode 100644 index 00000000..0e874d07 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/T.ts @@ -0,0 +1,10 @@ +import * as runtime from "@coln-project/runtime"; +import * as PropAlias from "./PropAlias.ts"; + +export interface View { + V: runtime.ColnSet.View; +} + +export interface Transaction extends View { + V: runtime.ColnSet.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.json new file mode 100644 index 00000000..78122c5d --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.ts new file mode 100644 index 00000000..ea15e199 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.ts @@ -0,0 +1,27 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as PropAlias from "./PropAlias.ts"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { V: (new runtime.RowIdSet.View(store, "TRealm.V", [])) }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + V: (new runtime.RowIdSet.Transaction(store, "TRealm.V", [], transaction)) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.output b/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.output index c3d2fb9b..1696f744 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.output +++ b/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.output @@ -24,19 +24,15 @@ end lowered: flatrealm entities table ℜ.X := [] - table ℜ.P := [] - table ℜ.Q := [] - table ℜ.R := [.a : ℜ.X, .b : ℜ.P, .c : ℜ.Q] + table ℜ.P := [] primarykey [] + table ℜ.Q := [] primarykey [] + table ℜ.R := [.a : ℜ.X] primarykey [.a] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ enforced ℜ.Q.foreignKey := ℜ.Q [] ⊢ ⊤ - enforced ℜ.R.foreignKey a b c := ℜ.R [ - .a ↦ a, - .b ↦ b, - .c ↦ c - ] ⊢ a ∈ ℜ.X [] ∧ b ∈ ℜ.P [] ∧ c ∈ ℜ.Q [] + enforced ℜ.R.foreignKey a := ℜ.R [.a ↦ a] ⊢ a ∈ ℜ.X [] ∧ ℜ.P [] ∧ ℜ.Q [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.ts.output/TRealm.json index 73c65117..f7b10f3e 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/prop-multi-argument.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["c"]],"type":{"tag":"rowId","path":[["TRealm"],["Q"]]}}],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]},{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":2},"values":[]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["R"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["R"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["R"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.coln b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.coln new file mode 100644 index 00000000..452fb164 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.coln @@ -0,0 +1,13 @@ +def Witness (P : Prop) : Prop := sig + first : P + second : P + same : first = second +end + +theory T := sig + P : Prop + witness : Witness P +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.output b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.output new file mode 100644 index 00000000..1cae4a75 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.output @@ -0,0 +1,38 @@ +-- elaborated +global entry named Witness +in mode: Conjunctive +type: (P : Prop) -> Prop +value: P => sig + first : P + second : P + same : first = second +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + P : Prop + witness : Witness P +end +realm named TRealm +elaborated: realm + generators + node + P = rel [] + witness = (fun [] -> Witness (TRealm.P [])) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.P := [] primarykey [] + end + rules + enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ + monitored ℜ.witness := ⊤ ⊢ ℜ.P [] ∧ ℜ.P [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/T.ts new file mode 100644 index 00000000..cfc10962 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/T.ts @@ -0,0 +1,11 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + P: runtime.ColnSet.View; + witness: Witness.View; +} + +export interface Transaction extends View { + P: runtime.ColnSet.Transaction; + witness: Witness.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.json new file mode 100644 index 00000000..5639e9a3 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["witness"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.ts new file mode 100644 index 00000000..72295060 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.ts @@ -0,0 +1,35 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + P: (new runtime.RowIdSet.View(store, "TRealm.P", [])), + witness: (new runtime.TableCellRef.View(store, "TRealm.witness", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + P: (new runtime.RowIdSet.Transaction(store, "TRealm.P", [], transaction)), + witness: (new runtime.TableCellRef.Transaction( + store, + "TRealm.witness", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.coln b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.coln new file mode 100644 index 00000000..96aeace5 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.coln @@ -0,0 +1,18 @@ +def Inner (P : Prop) : Prop := sig + proof : P +end + +def Outer (P : Prop) (Q : Prop) : Prop := sig + nested : Inner P + direct : Q +end + +theory T := sig + X : Set + P : X -> Prop + Q : X -> Prop + make : (x : X) -> Outer (P x) (Q x) +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.output b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.output new file mode 100644 index 00000000..978f400a --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.output @@ -0,0 +1,53 @@ +-- elaborated +global entry named Inner +in mode: Conjunctive +type: (P : Prop) -> Prop +value: P => sig + proof : P +end +global entry named Outer +in mode: Conjunctive +type: (P : Prop) -> (Q : Prop) -> Prop +value: P => Q => sig + nested : Inner P + direct : Q +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + X : Set + P : X -> Prop + Q : X -> Prop + make : (x : X) -> Outer (P x) (Q x) +end +realm named TRealm +elaborated: realm + generators + node + X = rel [] + P = rel [a : TRealm.X []] + Q = rel [a : TRealm.X []] + make = (fun [x : TRealm.X []] -> Outer (TRealm.P [a := x]) (TRealm.Q [ + a := x + ])) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.X := [] + table ℜ.P := [.a : ℜ.X] primarykey [.a] + table ℜ.Q := [.a : ℜ.X] primarykey [.a] + end + rules + enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ + enforced ℜ.P.foreignKey a := ℜ.P [.a ↦ a] ⊢ a ∈ ℜ.X [] + enforced ℜ.Q.foreignKey a := ℜ.Q [.a ↦ a] ⊢ a ∈ ℜ.X [] + monitored ℜ.make x := x ∈ ℜ.X [] ⊢ ℜ.P [.a ↦ x] ∧ ℜ.Q [.a ↦ x] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/T.ts new file mode 100644 index 00000000..4d22d8e3 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/T.ts @@ -0,0 +1,15 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + X: runtime.ColnSet.View; + P: (x: runtime.Value) => runtime.ColnSet.View; + Q: (x: runtime.Value) => runtime.ColnSet.View; + make: (x: runtime.Value) => Outer.View; +} + +export interface Transaction extends View { + X: runtime.ColnSet.Transaction; + P: (x: runtime.Value) => runtime.ColnSet.Transaction; + Q: (x: runtime.Value) => runtime.ColnSet.Transaction; + make: (x: runtime.Value) => Outer.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.json new file mode 100644 index 00000000..61a3a97f --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["X"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"]]]}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["X"]]}}],"primaryKey":[[["a"]]]}}],"rules":[{"path":[["TRealm"],["X"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}]}},{"path":[["TRealm"],["make"]],"value":{"ruleVariant":"monitored","varNames":[[["x"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["X"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["X"]],"rowId":{"tag":"var","index":0},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}}]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.ts new file mode 100644 index 00000000..0f53a2f0 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.ts @@ -0,0 +1,61 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + X: (new runtime.RowIdSet.View(store, "TRealm.X", [])), + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.P", [a])); + }, + Q: (a: runtime.Value) => { + return (new runtime.RowIdSet.View(store, "TRealm.Q", [a])); + }, + make: (x: runtime.Value) => { + return (new runtime.TableCellRef.View(store, "TRealm.make", [x])); + } + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + X: (new runtime.RowIdSet.Transaction(store, "TRealm.X", [], transaction)), + P: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.P", + [a], + transaction + )); + }, + Q: (a: runtime.Value) => { + return (new runtime.RowIdSet.Transaction( + store, + "TRealm.Q", + [a], + transaction + )); + }, + make: (x: runtime.Value) => { + return (new runtime.TableCellRef.Transaction( + store, + "TRealm.make", + [x], + transaction + )); + } + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record.output b/packages/coln-compiler/test/golden/basic-ir/prop-record.output index 1e3fe9dc..4dc8bafb 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop-record.output +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record.output @@ -33,42 +33,14 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.P := [] - table ℜ.Q := [] - table ℜ.make := [ - .a : ℜ.P, - .b : ℜ.Q, - .c.left : ℜ.P, - .c.right : ℜ.Q - ] primarykey [.a, .b] - table ℜ.projectLeft := [ - .a.left : ℜ.P, - .a.right : ℜ.Q, - .b : ℜ.P - ] primarykey [.a.left, .a.right] + table ℜ.P := [] primarykey [] + table ℜ.Q := [] primarykey [] end rules enforced ℜ.P.foreignKey := ℜ.P [] ⊢ ⊤ enforced ℜ.Q.foreignKey := ℜ.Q [] ⊢ ⊤ - enforced ℜ.make.foreignKey a b c.left c.right := ℜ.make [ - .a ↦ a, - .b ↦ b, - .c.left ↦ c.left, - .c.right ↦ c.right - ] ⊢ a ∈ ℜ.P [] ∧ b ∈ ℜ.Q [] ∧ c.left ∈ ℜ.P [] ∧ c.right ∈ ℜ.Q [] - monitored ℜ.make.total a b := a ∈ ℜ.P [] ∧ b ∈ ℜ.Q [] ⊢ ℜ.make [ - .a ↦ a, - .b ↦ b - ] - enforced ℜ.projectLeft.foreignKey a.left a.right b := ℜ.projectLeft [ - .a.left ↦ a.left, - .a.right ↦ a.right, - .b ↦ b - ] ⊢ a.left ∈ ℜ.P [] ∧ a.right ∈ ℜ.Q [] ∧ b ∈ ℜ.P [] - monitored ℜ.projectLeft.total a.left a.right := a.left ∈ ℜ.P [] ∧ a.right ∈ ℜ.Q [] ⊢ ℜ.projectLeft [ - .a.left ↦ a.left, - .a.right ↦ a.right - ] + monitored ℜ.make := ℜ.P [] ∧ ℜ.Q [] ⊢ ℜ.P [] ∧ ℜ.Q [] + monitored ℜ.projectLeft := ℜ.P [] ∧ ℜ.Q [] ⊢ ℜ.P [] end end diff --git a/packages/coln-compiler/test/golden/basic-ir/prop-record.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop-record.ts.output/TRealm.json index fbc84775..320e382b 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop-record.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/prop-record.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}},{"path":[["TRealm"],["make"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["Q"]]}},{"path":[["c"],["left"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["c"],["right"]],"type":{"tag":"rowId","path":[["TRealm"],["Q"]]}}],"primaryKey":[[["a"]],[["b"]]]}},{"path":[["TRealm"],["projectLeft"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["left"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}},{"path":[["a"],["right"]],"type":{"tag":"rowId","path":[["TRealm"],["Q"]]}},{"path":[["b"]],"type":{"tag":"rowId","path":[["TRealm"],["P"]]}}],"primaryKey":[[["a"],["left"]],[["a"],["right"]]]}}],"rules":[{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["make"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"]],[["b"]],[["c"],["left"]],[["c"],["right"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]},{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["make"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}},{"column":3,"term":{"tag":"var","index":3}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":2},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":3},"values":[]}}]}},{"path":[["TRealm"],["make"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":1},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["make"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}},{"path":[["TRealm"],["projectLeft"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["left"]],[["a"],["right"]],[["b"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]},{"tag":"rowId","path":[["TRealm"],["P"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["projectLeft"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}},{"column":2,"term":{"tag":"var","index":2}}]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":1},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":2},"values":[]}}]}},{"path":[["TRealm"],["projectLeft"],["total"]],"value":{"ruleVariant":"monitored","varNames":[[["a"],["left"]],[["a"],["right"]]],"varTypes":[{"tag":"rowId","path":[["TRealm"],["P"]]},{"tag":"rowId","path":[["TRealm"],["Q"]]}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":{"tag":"var","index":0},"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":{"tag":"var","index":1},"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["projectLeft"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["P"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}},{"path":[["TRealm"],["Q"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["P"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["Q"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[]}},{"path":[["TRealm"],["make"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}]}},{"path":[["TRealm"],["projectLeft"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}},{"tag":"atom","atom":{"entity":[["TRealm"],["Q"]],"rowId":null,"values":[]}}],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["P"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/prop.output b/packages/coln-compiler/test/golden/basic-ir/prop.output index c6baded9..d66610ff 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop.output +++ b/packages/coln-compiler/test/golden/basic-ir/prop.output @@ -17,7 +17,7 @@ elaborated: realm end lowered: flatrealm entities - table ℜ.V := [] + table ℜ.V := [] primarykey [] end rules enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ diff --git a/packages/coln-compiler/test/golden/basic-ir/prop.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/prop.ts.output/TRealm.json index 6cbfda78..78122c5d 100644 --- a/packages/coln-compiler/test/golden/basic-ir/prop.ts.output/TRealm.json +++ b/packages/coln-compiler/test/golden/basic-ir/prop.ts.output/TRealm.json @@ -1 +1 @@ -{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":null}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}}]} \ No newline at end of file +{"entities":[{"path":[["TRealm"],["V"]],"value":{"entityVariant":{"tag":"table"},"columns":[],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["V"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[],"varTypes":[],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["V"]],"rowId":null,"values":[]}}],"consequents":[]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/record-nested.coln b/packages/coln-compiler/test/golden/basic-ir/record-nested.coln new file mode 100644 index 00000000..f656b11b --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/record-nested.coln @@ -0,0 +1,15 @@ +def Inner : Set := sig + rank : Int +end + +def Outer : Set := sig + name : String + inner : Inner +end + +theory T := sig + payload : Outer +end + +realm TRealm @ T +end diff --git a/packages/coln-compiler/test/golden/basic-ir/record-nested.output b/packages/coln-compiler/test/golden/basic-ir/record-nested.output new file mode 100644 index 00000000..6f58c7d9 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/record-nested.output @@ -0,0 +1,44 @@ +-- elaborated +global entry named Inner +in mode: Conjunctive +type: Set +value: sig + rank : Int +end +global entry named Outer +in mode: Conjunctive +type: Set +value: sig + name : String + inner : Inner +end +global entry named T +in mode: Conjunctive +type: Theory +value: sig + payload : Outer +end +realm named TRealm +elaborated: realm + generators + node + payload = (fun [] -> Outer) + end + end + definitions + end +end +lowered: flatrealm + entities + table ℜ.payload := [.a.name : String, .a.inner.rank : Int] primarykey [] + end + rules + enforced ℜ.payload.foreignKey a.name a.inner.rank := ℜ.payload [ + .a.name ↦ a.name, + .a.inner.rank ↦ a.inner.rank + ] ⊢ ⊤ + monitored ℜ.payload.total := ⊤ ⊢ ℜ.payload [] + end +end + +-- messages diff --git a/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/T.ts b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/T.ts new file mode 100644 index 00000000..5926016e --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/T.ts @@ -0,0 +1,9 @@ +import * as runtime from "@coln-project/runtime"; + +export interface View { + payload: Outer.View; +} + +export interface Transaction extends View { + payload: Outer.Transaction; +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.json b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.json new file mode 100644 index 00000000..fcfc69fd --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.json @@ -0,0 +1 @@ +{"entities":[{"path":[["TRealm"],["payload"]],"value":{"entityVariant":{"tag":"table"},"columns":[{"path":[["a"],["name"]],"type":{"tag":"builtin","type":"builtinString"}},{"path":[["a"],["inner"],["rank"]],"type":{"tag":"builtin","type":"builtinInt"}}],"primaryKey":[]}}],"rules":[{"path":[["TRealm"],["payload"],["foreignKey"]],"value":{"ruleVariant":"enforced","varNames":[[["a"],["name"]],[["a"],["inner"],["rank"]]],"varTypes":[{"tag":"builtin","type":"builtinString"},{"tag":"builtin","type":"builtinInt"}],"antecedents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[{"column":0,"term":{"tag":"var","index":0}},{"column":1,"term":{"tag":"var","index":1}}]}}],"consequents":[]}},{"path":[["TRealm"],["payload"],["total"]],"value":{"ruleVariant":"monitored","varNames":[],"varTypes":[],"antecedents":[],"consequents":[{"tag":"atom","atom":{"entity":[["TRealm"],["payload"]],"rowId":null,"values":[]}}]}}]} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.ts b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.ts new file mode 100644 index 00000000..5d80b8e8 --- /dev/null +++ b/packages/coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.ts @@ -0,0 +1,33 @@ +import schema from "./TRealm.json"; +export {schema}; +import * as runtime from "@coln-project/runtime"; +import * as T from "./T.ts"; + +export class View { + root: T.View; + + constructor(store: runtime.StoreHandle) { + this.root = { + payload: (new runtime.TableCellRef.View(store, "TRealm.payload", [])) + }; + } +} + +export class Transaction extends View { + root: T.Transaction; + + constructor( + store: runtime.StoreHandle, + transaction: runtime.TransactionHandle + ) { + super(store); + this.root = { + payload: (new runtime.TableCellRef.Transaction( + store, + "TRealm.payload", + [], + transaction + )) + }; + } +} \ No newline at end of file diff --git a/packages/coln-compiler/test/golden/basic-ir/rule-literals.output b/packages/coln-compiler/test/golden/basic-ir/rule-literals.output index e54edf20..0fe8085f 100644 --- a/packages/coln-compiler/test/golden/basic-ir/rule-literals.output +++ b/packages/coln-compiler/test/golden/basic-ir/rule-literals.output @@ -30,8 +30,6 @@ lowered: flatrealm table ℜ.X := [] table ℜ.count := [.a : ℜ.X, .b : Int] primarykey [.a] table ℜ.label := [.a : ℜ.X, .b : String] primarykey [.a] - table ℜ.countIs19 := [.x : ℜ.X] primarykey [.x] - table ℜ.labelIsZombocom := [.x : ℜ.X] primarykey [.x] end rules enforced ℜ.X.foreignKey := ℜ.X [] ⊢ ⊤ @@ -39,17 +37,11 @@ lowered: flatrealm monitored ℜ.count.total a := a ∈ ℜ.X [] ⊢ ℜ.count [.a ↦ a] enforced ℜ.label.foreignKey a b := ℜ.label [.a ↦ a, .b ↦ b] ⊢ a ∈ ℜ.X [] monitored ℜ.label.total a := a ∈ ℜ.X [] ⊢ ℜ.label [.a ↦ a] - enforced ℜ.countIs19.foreignKey x a.lhs := ℜ.countIs19 [.x ↦ x] ∧ ℜ.count [ + monitored ℜ.countIs19 x b := ℜ.count [.a ↦ x, .b ↦ b] ∧ x ∈ ℜ.X [] ⊢ b = 19 + monitored ℜ.labelIsZombocom x b := ℜ.label [ .a ↦ x, - .b ↦ a.lhs - ] ⊢ x ∈ ℜ.X [] ∧ a.lhs = 19 - monitored ℜ.countIs19.total x := x ∈ ℜ.X [] ⊢ ℜ.countIs19 [.x ↦ x] - enforced ℜ.labelIsZombocom.foreignKey x a.lhs := ℜ.labelIsZombocom [ - .x ↦ x - ] ∧ ℜ.label [.a ↦ x, .b ↦ a.lhs] ⊢ x ∈ ℜ.X [] ∧ a.lhs = "zombocom" - monitored ℜ.labelIsZombocom.total x := x ∈ ℜ.X [] ⊢ ℜ.labelIsZombocom [ - .x ↦ x - ] + .b ↦ b + ] ∧ x ∈ ℜ.X [] ⊢ b = "zombocom" end end diff --git a/packages/coln-compiler/test/golden/graph-of-graphs.coln b/packages/coln-compiler/test/golden/graph-of-graphs.coln index 460f310c..75c1c88c 100644 --- a/packages/coln-compiler/test/golden/graph-of-graphs.coln +++ b/packages/coln-compiler/test/golden/graph-of-graphs.coln @@ -5,9 +5,9 @@ end realm GraphRealm @ Graph def free-edge : Set := sig - v0 : self.V - v1 : self.V - f : self.E v0 v1 + v0 : root.V + v1 : root.V + f : root.E v0 v1 end end diff --git a/packages/coln-compiler/test/golden/graph-of-graphs.output b/packages/coln-compiler/test/golden/graph-of-graphs.output index 2f362b37..520f520c 100644 --- a/packages/coln-compiler/test/golden/graph-of-graphs.output +++ b/packages/coln-compiler/test/golden/graph-of-graphs.output @@ -21,6 +21,35 @@ value: sig fiber : base.V -> Graph action : (v0 : base.V) -> (v1 : base.V) -> base.E v0 v1 -> Graph/hom (fiber v0) (fiber v1) end +realm named GraphRealm +elaborated: realm + generators + node + V = rel [] + E = rel [a : GraphRealm.V [], b : GraphRealm.V []] + end + end + definitions + def free-edge : Set := sig + v0 : root.V + v1 : root.V + f : root.E v0 v1 + end + end +end +lowered: flatrealm + entities + table ℜ.V := [] + table ℜ.E := [.a : ℜ.V, .b : ℜ.V] + end + rules + enforced ℜ.V.foreignKey := ℜ.V [] ⊢ ⊤ + enforced ℜ.E.foreignKey a b := ℜ.E [ + .a ↦ a, + .b ↦ b + ] ⊢ a ∈ ℜ.V [] ∧ b ∈ ℜ.V [] + end +end realm named GraphOfGraphsRealm elaborated: realm generators @@ -129,26 +158,26 @@ lowered: flatrealm .a ↦ a, .b ↦ b ] - enforced ℜ.action.E.foreignKey v0 v1 a v0/a v1/a b c c.b c.c := ℜ.action.E [ + enforced ℜ.action.E.foreignKey v0 v1 a v0/a v1/a b c d e := ℜ.action.V [ .v0 ↦ v0, .v1 ↦ v1, .a ↦ a, - .v0/a ↦ v0/a, - .v1/a ↦ v1/a, - .b ↦ b, - .c ↦ c + .b ↦ v0/a, + .c ↦ d ] ∧ ℜ.action.V [ .v0 ↦ v0, .v1 ↦ v1, .a ↦ a, - .b ↦ v0/a, - .c ↦ c.b - ] ∧ ℜ.action.V [ + .b ↦ v1/a, + .c ↦ e + ] ∧ ℜ.action.E [ .v0 ↦ v0, .v1 ↦ v1, .a ↦ a, - .b ↦ v1/a, - .c ↦ c.c + .v0/a ↦ v0/a, + .v1/a ↦ v1/a, + .b ↦ b, + .c ↦ c ] ⊢ v0 ∈ ℜ.base.V [] ∧ v1 ∈ ℜ.base.V [] ∧ a ∈ ℜ.base.E [ .a ↦ v0, .b ↦ v1 @@ -156,8 +185,8 @@ lowered: flatrealm .a ↦ v0 ] ∧ b ∈ ℜ.fiber.E [.a ↦ v0, .b ↦ v0/a, .c ↦ v1/a] ∧ c ∈ ℜ.fiber.E [ .a ↦ v1, - .b ↦ c.b, - .c ↦ c.c + .b ↦ d, + .c ↦ e ] monitored ℜ.action.E.total v0 v1 a v0/a v1/a b := v0 ∈ ℜ.base.V [] ∧ v1 ∈ ℜ.base.V [] ∧ a ∈ ℜ.base.E [ .a ↦ v0, @@ -176,7 +205,3 @@ lowered: flatrealm end -- messages - -error[E0314]: no such variable self in scope -8 | v0 : self.V -8 | ^^^^ diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-prop.test.ts new file mode 100644 index 00000000..29682f06 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-prop.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-prop-prop-prop", () => { + const realm = beginRealm(DependentFunctionArgumentPropPropPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-set.test.ts new file mode 100644 index 00000000..d108efd4 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-prop-set.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentPropPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-prop-prop-set", () => { + const realm = beginRealm(DependentFunctionArgumentPropPropSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-prop.test.ts new file mode 100644 index 00000000..f77dd5a4 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-prop.test.ts @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentPropSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-prop-set-prop", () => { + const realm = beginRealm(DependentFunctionArgumentPropSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); + +test("dependent-function-argument-prop-set-prop is vacuous when its proof domain is empty", () => { + const realm = beginRealm(DependentFunctionArgumentPropSetPropRealm); + + realm.commit(); +}); + +test("dependent-function-argument-prop-set-prop requires an output when its codomain is uninhabited", { expectFailure: true }, () => { + const realm = beginRealm(DependentFunctionArgumentPropSetPropRealm); + const a = realm.root.A.add(); + realm.root.B(a).add(); + + assert.throws(() => realm.commit(), /rule TRealm\.f/); +}); + +test("dependent-function-argument-prop-set-prop infers its output from an inhabited codomain", { expectFailure: true }, () => { + const realm = beginRealm(DependentFunctionArgumentPropSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-set.test.ts new file mode 100644 index 00000000..606d413e --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-prop-set-set.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentPropSetSetRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-prop-set-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-prop-set-set", () => { + const realm = beginRealm(DependentFunctionArgumentPropSetSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-prop.test.ts new file mode 100644 index 00000000..bb73346c --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-prop.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentSetPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-set-prop-prop", () => { + const realm = beginRealm(DependentFunctionArgumentSetPropPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-set.test.ts new file mode 100644 index 00000000..d634afbc --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-prop-set.test.ts @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentSetPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-set-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-set-prop-set", () => { + const realm = beginRealm(DependentFunctionArgumentSetPropSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); + +test("dependent-function-argument-set-prop-set is vacuous when its dependent proof domain is empty", () => { + const realm = beginRealm(DependentFunctionArgumentSetPropSetRealm); + realm.root.A.add(); + + realm.commit(); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-set-prop.test.ts new file mode 100644 index 00000000..09e44bde --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument-set-set-prop.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentSetSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument-set-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument-set-set-prop", () => { + const realm = beginRealm(DependentFunctionArgumentSetSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument.test.ts new file mode 100644 index 00000000..f4f580f2 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-argument.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-argument.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-argument", () => { + const realm = beginRealm(DependentFunctionArgumentRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const c = realm.root.C(a)(b).add(); + realm.root.f(a)(b).set(c); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a)(b).get(), c), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-prop.test.ts new file mode 100644 index 00000000..d0840aa1 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-prop.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-prop-prop", () => { + const realm = beginRealm(DependentFunctionPropPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + realm.root.f(a).set(b); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a).get(), b), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-set.test.ts new file mode 100644 index 00000000..2b8a7418 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-prop-set.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-prop-set", () => { + const realm = beginRealm(DependentFunctionPropSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + realm.root.f(a).set(b); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a).get(), b), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function-set-prop.test.ts new file mode 100644 index 00000000..b7a9999a --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function-set-prop.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function-set-prop", () => { + const realm = beginRealm(DependentFunctionSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + realm.root.f(a).set(b); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a).get(), b), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/dependent-function.test.ts b/packages/coln-js-runtime/tests/basic-ir/dependent-function.test.ts new file mode 100644 index 00000000..48c78e45 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/dependent-function.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as DependentFunctionRealm from "../../../coln-compiler/test/golden/basic-ir/dependent-function.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("dependent-function", () => { + const realm = beginRealm(DependentFunctionRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + realm.root.f(a).set(b); + const view = realm.commit(); + + assert.equal(valueEqual(view.f(a).get(), b), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/empty-prop-record-function.test.ts b/packages/coln-js-runtime/tests/basic-ir/empty-prop-record-function.test.ts new file mode 100644 index 00000000..c8084a15 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/empty-prop-record-function.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as EmptyPropRecordFunctionRealm from "../../../coln-compiler/test/golden/basic-ir/empty-prop-record-function.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("empty-prop-record-function", { expectFailure: true }, () => { + const realm = beginRealm(EmptyPropRecordFunctionRealm); + const value = realm.root.X.add(); + + assert.deepEqual(realm.root.trivial(value), {}); + + const view = realm.commit(); + + assert.deepEqual(view.trivial(value), {}); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/empty-prop-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/empty-prop-record.test.ts index 69692306..2e86d93a 100644 --- a/packages/coln-js-runtime/tests/basic-ir/empty-prop-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/empty-prop-record.test.ts @@ -8,14 +8,7 @@ import test from "node:test"; import * as EmptyPropRecordRealm from "../../../coln-compiler/test/golden/basic-ir/empty-prop-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "empty proposition records are exposed as table cells", - match: /Expected values to be strictly deep-equal/, - }, -}; - -test("empty-prop-record", expectedFailure, () => { +test("empty-prop-record", { expectFailure: true }, () => { const realm = beginRealm(EmptyPropRecordRealm); assert.deepEqual(realm.root.truth, {}); diff --git a/packages/coln-js-runtime/tests/basic-ir/empty-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/empty-record.test.ts index a9e2f2be..4eacc176 100644 --- a/packages/coln-js-runtime/tests/basic-ir/empty-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/empty-record.test.ts @@ -5,75 +5,11 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as EmptyRecordRealm from "../../../coln-compiler/test/golden/basic-ir/empty-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "empty records are emitted as table cells rather than sets", - match: /realm\.root\.unit\.add is not a function/, - }, -}; - -const expectedImplicitInhabitantFailure = { - expectFailure: { - label: "the empty record is not inhabited automatically", - match: /\.unit\.total/, - }, -}; - -test("empty-record is inhabited without add", expectedImplicitInhabitantFailure, () => { - const realm = beginRealm(EmptyRecordRealm); - const view = realm.commit(); - const values = view.unit.values(); - - assert.equal(values.next().done, false); - assert.equal(values.next().done, true); -}); - -test("empty-record", expectedFailure, () => { - const realm = beginRealm(EmptyRecordRealm); - const value = realm.root.unit.add(); - const view = realm.commit(); - - assert.equal(view.unit.has(value), true); -}); - -test("empty-record canonicalizes values", expectedFailure, () => { - const realm = beginRealm(EmptyRecordRealm); - const first = realm.root.unit.add(); - const second = realm.root.unit.add(); - realm.commit(); - - assert.equal(valueEqual(first, second), true); -}); - -test("empty-record canonicalizes pending values", expectedFailure, () => { - const realm = beginRealm(EmptyRecordRealm); - const first = realm.root.unit.add(); - const second = realm.root.unit.add(); - - assert.equal(valueEqual(first, second), true); -}); - -test("empty-record keeps canonical value handles valid", expectedFailure, () => { +test("empty-record is inhabited without a write", { expectFailure: true }, () => { const realm = beginRealm(EmptyRecordRealm); - const first = realm.root.unit.add(); - const second = realm.root.unit.add(); const view = realm.commit(); - - assert.equal(view.unit.has(first), true); - assert.equal(view.unit.has(second), true); -}); - -test("empty-record has exactly one value", expectedFailure, () => { - const realm = beginRealm(EmptyRecordRealm); - realm.root.unit.add(); - realm.root.unit.add(); - const view = realm.commit(); - const values = view.unit.values(); - - assert.equal(values.next().done, false); - assert.equal(values.next().done, true); + assert.deepEqual(view.unit, {}); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/equality-prop.pending.ts b/packages/coln-js-runtime/tests/basic-ir/equality-prop.pending.ts index c8e1b4c0..8fd1908a 100644 --- a/packages/coln-js-runtime/tests/basic-ir/equality-prop.pending.ts +++ b/packages/coln-js-runtime/tests/basic-ir/equality-prop.pending.ts @@ -2,85 +2,17 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as EqualityPropRealm from "../../../coln-compiler/test/golden/basic-ir/equality-prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -test("equality-prop is inhabited without add", () => { - const realm = beginRealm(EqualityPropRealm); - const firstProof = realm.root.P.add(); - const secondProof = realm.root.P.add(); - realm.root.x.set(firstProof); - realm.root.y.set(secondProof); - const view = realm.commit(); - const equalityProofs = view.eq.values(); - - assert.equal(equalityProofs.next().done, false); - assert.equal(equalityProofs.next().done, true); -}); - -test("equality-prop accepts equality between proof handles", () => { - const realm = beginRealm(EqualityPropRealm); - const firstProof = realm.root.P.add(); - const secondProof = realm.root.P.add(); - realm.root.x.set(firstProof); - realm.root.y.set(secondProof); - const equalityProof = realm.root.eq.add(); - const view = realm.commit(); - - assert.equal(valueEqual(view.x.get(), view.y.get()), true); - assert.equal(view.eq.has(equalityProof), true); -}); - -test("equality-prop canonicalizes equality proofs", () => { - const realm = beginRealm(EqualityPropRealm); - const proof = realm.root.P.add(); - realm.root.x.set(proof); - realm.root.y.set(proof); - const first = realm.root.eq.add(); - const second = realm.root.eq.add(); - realm.commit(); - - assert.equal(valueEqual(first, second), true); -}); - -test("equality-prop canonicalizes pending equality proofs", () => { - const realm = beginRealm(EqualityPropRealm); - const proof = realm.root.P.add(); - realm.root.x.set(proof); - realm.root.y.set(proof); - const first = realm.root.eq.add(); - const second = realm.root.eq.add(); - - assert.equal(valueEqual(first, second), true); -}); - -test("equality-prop keeps canonical equality proof handles valid", () => { - const realm = beginRealm(EqualityPropRealm); - const proof = realm.root.P.add(); - realm.root.x.set(proof); - realm.root.y.set(proof); - const first = realm.root.eq.add(); - const second = realm.root.eq.add(); - const view = realm.commit(); - - assert.equal(view.eq.has(first), true); - assert.equal(view.eq.has(second), true); -}); - -test("equality-prop has exactly one equality proof", () => { +test("equality-prop compares erased proof operands", () => { const realm = beginRealm(EqualityPropRealm); const proof = realm.root.P.add(); realm.root.x.set(proof); realm.root.y.set(proof); - realm.root.eq.add(); - realm.root.eq.add(); const view = realm.commit(); - const equalityProofs = view.eq.values(); - assert.equal(equalityProofs.next().done, false); - assert.equal(equalityProofs.next().done, true); + view.eq.get(); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/equality-record-nested.pending.ts b/packages/coln-js-runtime/tests/basic-ir/equality-record-nested.pending.ts new file mode 100644 index 00000000..854ad718 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/equality-record-nested.pending.ts @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as EqualityRecordNestedRealm from "../../../coln-compiler/test/golden/basic-ir/equality-record-nested.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("equality-record-nested compares empty, stored, and proof fields", () => { + const realm = beginRealm(EqualityRecordNestedRealm); + realm.root.P.add(); + const inner = realm.root.X.add(); + const trailing = realm.root.X.add(); + realm.root.first.inner.value.set(inner); + realm.root.first.trailing.set(trailing); + realm.root.second.inner.value.set(inner); + realm.root.second.trailing.set(trailing); + const view = realm.commit(); + + view.same.get(); +}); + +test("equality-record-nested rejects a nested stored difference", () => { + const realm = beginRealm(EqualityRecordNestedRealm); + realm.root.P.add(); + const first = realm.root.X.add(); + const second = realm.root.X.add(); + const trailing = realm.root.X.add(); + realm.root.first.inner.value.set(first); + realm.root.first.trailing.set(trailing); + realm.root.second.inner.value.set(second); + realm.root.second.trailing.set(trailing); + + assert.throws(() => realm.commit(), /rule TRealm\.same/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/equality-record.pending.ts b/packages/coln-js-runtime/tests/basic-ir/equality-record.pending.ts new file mode 100644 index 00000000..11eb25c3 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/equality-record.pending.ts @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as EqualityRecordRealm from "../../../coln-compiler/test/golden/basic-ir/equality-record.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("equality-record compares every stored field", () => { + const realm = beginRealm(EqualityRecordRealm); + const left = realm.root.X.add(); + const right = realm.root.X.add(); + realm.root.first.left.set(left); + realm.root.first.right.set(right); + realm.root.second.left.set(left); + realm.root.second.right.set(right); + const view = realm.commit(); + + view.same.get(); +}); + +test("equality-record rejects a difference in one field", () => { + const realm = beginRealm(EqualityRecordRealm); + const first = realm.root.X.add(); + const second = realm.root.X.add(); + realm.root.first.left.set(first); + realm.root.first.right.set(first); + realm.root.second.left.set(first); + realm.root.second.right.set(second); + + assert.throws(() => realm.commit(), /rule TRealm\.same/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/equality.pending.ts b/packages/coln-js-runtime/tests/basic-ir/equality.pending.ts index 3b3ce5f7..c82514cd 100644 --- a/packages/coln-js-runtime/tests/basic-ir/equality.pending.ts +++ b/packages/coln-js-runtime/tests/basic-ir/equality.pending.ts @@ -5,54 +5,25 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as EqualityRealm from "../../../coln-compiler/test/golden/basic-ir/equality.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -test("equality is inhabited without add for equal values", () => { +test("equality produces a proof for equal values", () => { const realm = beginRealm(EqualityRealm); const value = realm.root.V.add(); realm.root.x.set(value); realm.root.y.set(value); const view = realm.commit(); - const proofs = view.eq.values(); - assert.equal(proofs.next().done, false); - assert.equal(proofs.next().done, true); + view.eq.get(); }); -test("equality is not inhabited for unequal values", () => { +test("equality rejects unequal values", () => { const realm = beginRealm(EqualityRealm); const first = realm.root.V.add(); const second = realm.root.V.add(); realm.root.x.set(first); realm.root.y.set(second); - assert.throws(() => realm.commit(), /\.eq\.total/); -}); - -test("equality canonicalizes proofs", () => { - const realm = beginRealm(EqualityRealm); - const value = realm.root.V.add(); - realm.root.x.set(value); - realm.root.y.set(value); - const first = realm.root.eq.add(); - const second = realm.root.eq.add(); - const view = realm.commit(); - const proofs = view.eq.values(); - - assert.equal(valueEqual(first, second), true); - assert.equal(proofs.next().done, false); - assert.equal(proofs.next().done, true); -}); - -test("equality rejects a proof of unequal values", () => { - const realm = beginRealm(EqualityRealm); - const first = realm.root.V.add(); - const second = realm.root.V.add(); - realm.root.x.set(first); - realm.root.y.set(second); - realm.root.eq.add(); - - assert.throws(() => realm.commit(), /\.eq\.foreignKey/); + assert.throws(() => realm.commit(), /rule TRealm\.eq/); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-prop.test.ts new file mode 100644 index 00000000..828765be --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-prop.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-prop-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-prop-prop-prop", () => { + const realm = beginRealm(FamilyArgumentPropPropPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-set.test.ts new file mode 100644 index 00000000..e705a06c --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-prop-set.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentPropPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-prop-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-prop-prop-set", () => { + const realm = beginRealm(FamilyArgumentPropPropSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-prop.test.ts new file mode 100644 index 00000000..ff96dcc2 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-prop.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentPropSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-prop-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-prop-set-prop", () => { + const realm = beginRealm(FamilyArgumentPropSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-set.test.ts new file mode 100644 index 00000000..376e0f1a --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-prop-set-set.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentPropSetSetRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-prop-set-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-prop-set-set", () => { + const realm = beginRealm(FamilyArgumentPropSetSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-prop.test.ts new file mode 100644 index 00000000..55949ef3 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-prop.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentSetPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-set-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-set-prop-prop", () => { + const realm = beginRealm(FamilyArgumentSetPropPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-set.test.ts new file mode 100644 index 00000000..ab01c9b2 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-prop-set.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentSetPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-set-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-set-prop-set", () => { + const realm = beginRealm(FamilyArgumentSetPropSetRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument-set-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-set-prop.test.ts new file mode 100644 index 00000000..e2ce076e --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument-set-set-prop.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentSetSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument-set-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument-set-set-prop", () => { + const realm = beginRealm(FamilyArgumentSetSetPropRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/family-argument.test.ts b/packages/coln-js-runtime/tests/basic-ir/family-argument.test.ts new file mode 100644 index 00000000..3134043e --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/family-argument.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as FamilyArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/family-argument.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("family-argument", () => { + const realm = beginRealm(FamilyArgumentRealm); + const a = realm.root.A.add(); + const b = realm.root.B(a).add(); + const r = realm.root.R(a)(b).add(); + const view = realm.commit(); + + assert.equal(view.R(a)(b).has(r), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-prop.test.ts index 531327e4..815972c7 100644 --- a/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-prop.test.ts @@ -5,43 +5,14 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as ForeignKeyPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/foreign-key-prop-prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "proof parameters and results are not canonicalized", - match: /false !== true/, - }, -}; - test("foreign-key-prop-prop", () => { const realm = beginRealm(ForeignKeyPropPropRealm); const vertex = realm.root.V.add(); const edge = realm.root.E(vertex).add(); const view = realm.commit(); - assert.equal(view.V.has(vertex), true); assert.equal(view.E(vertex).has(edge), true); }); - -test("foreign-key-prop-prop rejects a parameter from the wrong table", () => { - const realm = beginRealm(ForeignKeyPropPropRealm); - const vertex = realm.root.V.add(); - const edge = realm.root.E(vertex).add(); - realm.root.E(edge).add(); - - assert.throws(() => realm.commit(), /\.E\.foreignKey/); -}); - -test("foreign-key-prop-prop ignores proof identity in its parameter", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(ForeignKeyPropPropRealm); - const firstVertex = realm.root.V.add(); - const secondVertex = realm.root.V.add(); - const firstEdge = realm.root.E(firstVertex).add(); - const secondEdge = realm.root.E(secondVertex).add(); - realm.commit(); - - assert.equal(valueEqual(firstEdge, secondEdge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-set.test.ts index 6661065a..cf4e7913 100644 --- a/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-set.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/foreign-key-prop-set.test.ts @@ -8,38 +8,11 @@ import test from "node:test"; import * as ForeignKeyPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/foreign-key-prop-set.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "sets indexed by equal proofs are treated as distinct", - match: /false !== true/, - }, -}; - test("foreign-key-prop-set", () => { const realm = beginRealm(ForeignKeyPropSetRealm); const vertex = realm.root.V.add(); const edge = realm.root.E(vertex).add(); const view = realm.commit(); - assert.equal(view.V.has(vertex), true); assert.equal(view.E(vertex).has(edge), true); }); - -test("foreign-key-prop-set rejects a parameter from the wrong table", () => { - const realm = beginRealm(ForeignKeyPropSetRealm); - const vertex = realm.root.V.add(); - const edge = realm.root.E(vertex).add(); - realm.root.E(edge).add(); - - assert.throws(() => realm.commit(), /\.E\.foreignKey/); -}); - -test("foreign-key-prop-set ignores proof identity in its parameter", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(ForeignKeyPropSetRealm); - const firstVertex = realm.root.V.add(); - const secondVertex = realm.root.V.add(); - const edge = realm.root.E(firstVertex).add(); - const view = realm.commit(); - - assert.equal(view.E(secondVertex).has(edge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/foreign-key-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/foreign-key-set-prop.test.ts index a5526023..e1a239ff 100644 --- a/packages/coln-js-runtime/tests/basic-ir/foreign-key-set-prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/foreign-key-set-prop.test.ts @@ -9,76 +9,15 @@ import { valueEqual } from "@coln-project/runtime"; import * as ForeignKeySetPropRealm from "../../../coln-compiler/test/golden/basic-ir/foreign-key-set-prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedCanonicalizationFailure = { - expectFailure: { - label: "multiple proofs with the same parameter tuple are not canonicalized", - match: /false !== true/, - }, -}; - -const expectedPendingCanonicalizationFailure = { - expectFailure: { - label: "pending proofs with the same parameter tuple are not canonicalized", - match: /false !== true/, - }, -}; - -const expectedCardinalityFailure = { - expectFailure: { - label: "a proposition can contain multiple proof rows for one parameter tuple", - match: /false !== true/, - }, -}; - test("foreign-key-set-prop", () => { const realm = beginRealm(ForeignKeySetPropRealm); const vertex = realm.root.V.add(); const edge = realm.root.E(vertex).add(); const view = realm.commit(); - assert.equal(view.V.has(vertex), true); assert.equal(view.E(vertex).has(edge), true); }); -test("foreign-key-set-prop rejects a parameter from the wrong table", () => { - const realm = beginRealm(ForeignKeySetPropRealm); - const vertex = realm.root.V.add(); - const edge = realm.root.E(vertex).add(); - realm.root.E(edge).add(); - - assert.throws(() => realm.commit(), /\.E\.foreignKey/); -}); - -test("foreign-key-set-prop canonicalizes proofs with the same parameter tuple", expectedCanonicalizationFailure, () => { - const realm = beginRealm(ForeignKeySetPropRealm); - const vertex = realm.root.V.add(); - const first = realm.root.E(vertex).add(); - const second = realm.root.E(vertex).add(); - realm.commit(); - - assert.equal(valueEqual(first, second), true); -}); - -test("foreign-key-set-prop canonicalizes pending proofs with the same parameter tuple", expectedPendingCanonicalizationFailure, () => { - const realm = beginRealm(ForeignKeySetPropRealm); - const vertex = realm.root.V.add(); - const first = realm.root.E(vertex).add(); - const second = realm.root.E(vertex).add(); - - assert.equal(valueEqual(first, second), true); -}); - -test("foreign-key-set-prop keeps canonical proof handles valid", () => { - const realm = beginRealm(ForeignKeySetPropRealm); - const vertex = realm.root.V.add(); - const first = realm.root.E(vertex).add(); - const second = realm.root.E(vertex).add(); - const view = realm.commit(); - - assert.equal(view.E(vertex).has(first), true); - assert.equal(view.E(vertex).has(second), true); -}); - test("foreign-key-set-prop keeps proofs for different parameter tuples distinct", () => { const realm = beginRealm(ForeignKeySetPropRealm); const firstVertex = realm.root.V.add(); @@ -90,7 +29,7 @@ test("foreign-key-set-prop keeps proofs for different parameter tuples distinct" assert.equal(valueEqual(first, second), false); }); -test("foreign-key-set-prop has at most one proof per parameter tuple", expectedCardinalityFailure, () => { +test("foreign-key-set-prop has at most one proof per parameter tuple", { expectFailure: true }, () => { const realm = beginRealm(ForeignKeySetPropRealm); const vertex = realm.root.V.add(); realm.root.E(vertex).add(); diff --git a/packages/coln-js-runtime/tests/basic-ir/foreign-key.test.ts b/packages/coln-js-runtime/tests/basic-ir/foreign-key.test.ts index cc0321f9..67dab518 100644 --- a/packages/coln-js-runtime/tests/basic-ir/foreign-key.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/foreign-key.test.ts @@ -14,7 +14,6 @@ test("foreign-key", () => { const edge = realm.root.E(vertex).add(); const view = realm.commit(); - assert.equal(view.V.has(vertex), true); assert.equal(view.E(vertex).has(edge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/function-mixed-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/function-mixed-prop-set.test.ts deleted file mode 100644 index 71a2a22e..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/function-mixed-prop-set.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as FunctionMixedPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/function-mixed-prop-set.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedProofKeyFailure = { - expectFailure: { - label: "proof arguments remain part of material function keys", - match: /3 !== 2/, - }, -}; - -test("function-mixed-prop-set", () => { - const realm = beginRealm(FunctionMixedPropSetRealm); - const input = realm.root.X.add(); - const proof = realm.root.P.add(); - const output = realm.root.Y.add(); - realm.root.choose(input)(proof).set(output); - const view = realm.commit(); - - assert.equal(valueEqual(view.choose(input)(proof).get(), output), true); -}); - -test("function-mixed-prop-set retains its erased proof premise", () => { - const realm = beginRealm(FunctionMixedPropSetRealm); - const input = realm.root.X.add(); - const output = realm.root.Y.add(); - realm.root.choose(input)(input).set(output); - - assert.throws(() => realm.commit(), /\.choose\.foreignKey/); -}); - -test( - "function-mixed-prop-set erases its proof argument column", - expectedProofKeyFailure, - () => { - const choose = FunctionMixedPropSetRealm.schema.entities.find( - (entity) => entity.path.flat().join(".") === "TRealm.choose", - ); - - assert.equal(choose?.value.columns.length, 2); - }, -); diff --git a/packages/coln-js-runtime/tests/basic-ir/function-multi-argument.test.ts b/packages/coln-js-runtime/tests/basic-ir/function-multi-argument.test.ts deleted file mode 100644 index ca0e1506..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/function-multi-argument.test.ts +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as FunctionMultiArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/function-multi-argument.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedImplicitOutputFailure = { - expectFailure: { - label: "a multi-argument function into an inhabited proposition is not synthesized", - match: /\.f\.total/, - }, -}; - -const expectedParameterFailure = { - expectFailure: { - label: "a function treats equal proof parameters as distinct", - match: /\.f\.total/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "a proof-valued function can return a noncanonical proof", - match: /false !== true/, - }, -}; - -test("function-multi-argument", () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - const value = realm.root.X.add(); - const inputProof = realm.root.P.add(); - const outputProof = realm.root.Q.add(); - realm.root.f(inputProof)(value).set(outputProof); - const view = realm.commit(); - - assert.equal(valueEqual(view.f(inputProof)(value).get(), outputProof), true); -}); - -test("function-multi-argument rejects parameters in the wrong order", () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - const value = realm.root.X.add(); - const inputProof = realm.root.P.add(); - const outputProof = realm.root.Q.add(); - realm.root.f(value)(inputProof).set(outputProof); - - assert.throws(() => realm.commit(), /\.f\.foreignKey/); -}); - -test("function-multi-argument is vacuous when its proof domain is empty", () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - realm.root.X.add(); - const view = realm.commit(); - - assert.equal(view.P.values().next().done, true); - assert.equal(view.Q.values().next().done, true); -}); - -test("function-multi-argument requires an output when its codomain is uninhabited", () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - realm.root.X.add(); - realm.root.P.add(); - - assert.throws(() => realm.commit(), /\.f\.total/); -}); - -test("function-multi-argument infers its output from an inhabited codomain", expectedImplicitOutputFailure, () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - const value = realm.root.X.add(); - const inputProof = realm.root.P.add(); - const outputProof = realm.root.Q.add(); - const view = realm.commit(); - - assert.equal(valueEqual(view.f(inputProof)(value).get(), outputProof), true); -}); - -test("function-multi-argument ignores proof identity in its parameter", expectedParameterFailure, () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - const value = realm.root.X.add(); - const firstInputProof = realm.root.P.add(); - const secondInputProof = realm.root.P.add(); - const outputProof = realm.root.Q.add(); - realm.root.f(firstInputProof)(value).set(outputProof); - const view = realm.commit(); - - assert.equal(valueEqual(view.f(secondInputProof)(value).get(), outputProof), true); -}); - -test("function-multi-argument returns a canonical proof", expectedOutputFailure, () => { - const realm = beginRealm(FunctionMultiArgumentRealm); - const value = realm.root.X.add(); - const inputProof = realm.root.P.add(); - const firstOutputProof = realm.root.Q.add(); - const secondOutputProof = realm.root.Q.add(); - realm.root.f(inputProof)(value).set(firstOutputProof); - const view = realm.commit(); - - assert.equal(valueEqual(view.f(inputProof)(value).get(), secondOutputProof), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/function-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/function-prop-prop.test.ts index f5ec6ac4..5cfb3d50 100644 --- a/packages/coln-js-runtime/tests/basic-ir/function-prop-prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/function-prop-prop.test.ts @@ -9,28 +9,6 @@ import { valueEqual } from "@coln-project/runtime"; import * as FunctionPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/function-prop-prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "a function can return distinct proofs of the same proposition", - match: /false !== true/, - }, -}; - -const expectedImplicitOutputFailure = { - expectFailure: { - label: "a function into an inhabited proposition is not synthesized", - match: /\.next\.total/, - }, -}; - -test("function-prop-prop is vacuous when its domain is empty", () => { - const realm = beginRealm(FunctionPropPropRealm); - const view = realm.commit(); - - assert.equal(view.X.values().next().done, true); - assert.equal(view.Y.values().next().done, true); -}); - test("function-prop-prop", () => { const realm = beginRealm(FunctionPropPropRealm); const input = realm.root.X.add(); @@ -41,42 +19,25 @@ test("function-prop-prop", () => { assert.equal(valueEqual(view.next(input).get(), output), true); }); -test("function-prop-prop requires an output when its codomain is uninhabited", () => { +test("function-prop-prop is vacuous when its domain is empty", () => { const realm = beginRealm(FunctionPropPropRealm); - realm.root.X.add(); + const view = realm.commit(); - assert.throws(() => realm.commit(), /\.next\.total/); + assert.equal(view.Y.values().next().done, true); }); -test("function-prop-prop infers its output from an inhabited codomain", expectedImplicitOutputFailure, () => { +test("function-prop-prop requires an output when its codomain is uninhabited", () => { const realm = beginRealm(FunctionPropPropRealm); - const input = realm.root.X.add(); - const output = realm.root.Y.add(); - const view = realm.commit(); + realm.root.X.add(); - assert.equal(valueEqual(view.next(input).get(), output), true); + assert.throws(() => realm.commit(), /rule TRealm\.next/); }); -test("function-prop-prop rejects an output from the wrong table", () => { +test("function-prop-prop infers its output from an inhabited codomain", { expectFailure: true }, () => { const realm = beginRealm(FunctionPropPropRealm); const input = realm.root.X.add(); - const wrongOutput = realm.root.X.add(); const output = realm.root.Y.add(); - realm.root.next(input).set(wrongOutput); - realm.root.next(wrongOutput).set(output); - - assert.throws(() => realm.commit(), /\.next\.foreignKey/); -}); - -test("function-prop-prop returns equal proofs for equal proof inputs", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(FunctionPropPropRealm); - const firstInput = realm.root.X.add(); - const secondInput = realm.root.X.add(); - const firstOutput = realm.root.Y.add(); - const secondOutput = realm.root.Y.add(); - realm.root.next(firstInput).set(firstOutput); - realm.root.next(secondInput).set(secondOutput); const view = realm.commit(); - assert.equal(valueEqual(view.next(firstInput).get(), view.next(secondInput).get()), true); + assert.equal(valueEqual(view.next(input).get(), output), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/function-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/function-prop-set.test.ts index 8ffc6e36..a14d548d 100644 --- a/packages/coln-js-runtime/tests/basic-ir/function-prop-set.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/function-prop-set.test.ts @@ -9,13 +9,6 @@ import { valueEqual } from "@coln-project/runtime"; import * as FunctionPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/function-prop-set.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "a function treats equal proof inputs as distinct", - match: /\.next\.total/, - }, -}; - test("function-prop-set", () => { const realm = beginRealm(FunctionPropSetRealm); const input = realm.root.X.add(); @@ -32,25 +25,3 @@ test("function-prop-set requires an output for every input", () => { assert.throws(() => realm.commit(), /\.next\.total/); }); - -test("function-prop-set rejects an output from the wrong table", () => { - const realm = beginRealm(FunctionPropSetRealm); - const input = realm.root.X.add(); - const wrongOutput = realm.root.X.add(); - const output = realm.root.Y.add(); - realm.root.next(input).set(wrongOutput); - realm.root.next(wrongOutput).set(output); - - assert.throws(() => realm.commit(), /\.next\.foreignKey/); -}); - -test("function-prop-set ignores proof identity in its input", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(FunctionPropSetRealm); - const firstInput = realm.root.X.add(); - const secondInput = realm.root.X.add(); - const output = realm.root.Y.add(); - realm.root.next(firstInput).set(output); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(secondInput).get(), output), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/function-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/function-set-prop.test.ts index f9810a2c..ae4499ac 100644 --- a/packages/coln-js-runtime/tests/basic-ir/function-set-prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/function-set-prop.test.ts @@ -9,27 +9,6 @@ import { valueEqual } from "@coln-project/runtime"; import * as FunctionSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/function-set-prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedCanonicalizationFailure = { - expectFailure: { - label: "a function can return distinct proofs of the same proposition", - match: /false !== true/, - }, -}; - -const expectedCardinalityFailure = { - expectFailure: { - label: "the proposition codomain can contain multiple proof rows", - match: /false !== true/, - }, -}; - -const expectedImplicitOutputFailure = { - expectFailure: { - label: "a function into an inhabited proposition is not synthesized", - match: /\.next\.total/, - }, -}; - test("function-set-prop", () => { const realm = beginRealm(FunctionSetPropRealm); const input = realm.root.X.add(); @@ -44,10 +23,10 @@ test("function-set-prop requires an output when its codomain is uninhabited", () const realm = beginRealm(FunctionSetPropRealm); realm.root.X.add(); - assert.throws(() => realm.commit(), /\.next\.total/); + assert.throws(() => realm.commit(), /rule TRealm\.next/); }); -test("function-set-prop infers its output from an inhabited codomain", expectedImplicitOutputFailure, () => { +test("function-set-prop infers its output from an inhabited codomain", { expectFailure: true }, () => { const realm = beginRealm(FunctionSetPropRealm); const input = realm.root.X.add(); const output = realm.root.Y.add(); @@ -56,18 +35,7 @@ test("function-set-prop infers its output from an inhabited codomain", expectedI assert.equal(valueEqual(view.next(input).get(), output), true); }); -test("function-set-prop rejects an output from the wrong table", () => { - const realm = beginRealm(FunctionSetPropRealm); - const input = realm.root.X.add(); - const wrongOutput = realm.root.X.add(); - const output = realm.root.Y.add(); - realm.root.next(input).set(wrongOutput); - realm.root.next(wrongOutput).set(output); - - assert.throws(() => realm.commit(), /\.next\.foreignKey/); -}); - -test("function-set-prop returns equal proofs for different inputs", expectedCanonicalizationFailure, () => { +test("function-set-prop returns equal proofs for different inputs", { expectFailure: true }, () => { const realm = beginRealm(FunctionSetPropRealm); const firstInput = realm.root.X.add(); const secondInput = realm.root.X.add(); @@ -79,14 +47,3 @@ test("function-set-prop returns equal proofs for different inputs", expectedCano assert.equal(valueEqual(view.next(firstInput).get(), view.next(secondInput).get()), true); }); - -test("function-set-prop codomain has at most one proof", expectedCardinalityFailure, () => { - const realm = beginRealm(FunctionSetPropRealm); - realm.root.Y.add(); - realm.root.Y.add(); - const view = realm.commit(); - const proofs = view.Y.values(); - - assert.equal(proofs.next().done, false); - assert.equal(proofs.next().done, true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/inventory.test.ts b/packages/coln-js-runtime/tests/basic-ir/inventory.test.ts index 345375e1..34c51d07 100644 --- a/packages/coln-js-runtime/tests/basic-ir/inventory.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/inventory.test.ts @@ -16,6 +16,8 @@ const goldenDirectory = resolve( const missingRealms = [ "equality", "equality-prop", + "equality-record", + "equality-record-nested", "rule-literals", ]; const testSuffix = /\.(?:pending|test)\.ts$/; diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-prop.test.ts new file mode 100644 index 00000000..75a948b6 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-prop.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-prop-prop-prop", () => { + const realm = beginRealm(LookupArgumentProjectionPropPropPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-set.test.ts new file mode 100644 index 00000000..85c5794f --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-prop-set.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionPropPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-prop-prop-set", () => { + const realm = beginRealm(LookupArgumentProjectionPropPropSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-prop.test.ts new file mode 100644 index 00000000..18447be3 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-prop.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionPropSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-prop-set-prop", () => { + const realm = beginRealm(LookupArgumentProjectionPropSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-set.test.ts new file mode 100644 index 00000000..101db3d6 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-prop-set-set.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionPropSetSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-prop-set-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-prop-set-set", () => { + const realm = beginRealm(LookupArgumentProjectionPropSetSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-prop.test.ts new file mode 100644 index 00000000..85dfb184 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-prop.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionSetPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-set-prop-prop", () => { + const realm = beginRealm(LookupArgumentProjectionSetPropPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-set.test.ts new file mode 100644 index 00000000..eecb1733 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-prop-set.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionSetPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-set-prop-set", () => { + const realm = beginRealm(LookupArgumentProjectionSetPropSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-set-prop.test.ts new file mode 100644 index 00000000..e41c1463 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection-set-set-prop.test.ts @@ -0,0 +1,62 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionSetSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection-set-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection-set-set-prop", () => { + const realm = beginRealm(LookupArgumentProjectionSetSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); + +test("lookup-argument-projection-set-set-prop rejects an edge at a different target", () => { + const realm = beginRealm(LookupArgumentProjectionSetSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const otherTarget = realm.root.B(source).add(); + const edge = realm.root.E(source)(otherTarget).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + + assert.throws(() => realm.commit(), /rule TRealm\.nextedge/); +}); + +test("lookup-argument-projection-set-set-prop infers its output from an inhabited proposition", { expectFailure: true }, () => { + const realm = beginRealm(LookupArgumentProjectionSetSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); + +test("lookup-argument-projection-set-set-prop keeps proofs for different lookup results distinct", () => { + const realm = beginRealm(LookupArgumentProjectionSetSetPropRealm); + const firstSource = realm.root.A.add(); + const secondSource = realm.root.A.add(); + const firstTarget = realm.root.B(firstSource).add(); + const secondTarget = realm.root.B(secondSource).add(); + const firstEdge = realm.root.E(firstSource)(firstTarget).add(); + const secondEdge = realm.root.E(secondSource)(secondTarget).add(); + realm.root.next(firstSource).set(firstTarget); + realm.root.next(secondSource).set(secondTarget); + realm.root.nextedge(firstSource).set(firstEdge); + realm.root.nextedge(secondSource).set(secondEdge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(firstSource).get(), view.nextedge(secondSource).get()), false); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection.test.ts new file mode 100644 index 00000000..51c52678 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-argument-projection.test.ts @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupArgumentProjectionRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-argument-projection.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-argument-projection", () => { + const realm = beginRealm(LookupArgumentProjectionRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const edge = realm.root.E(source)(target).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.nextedge(source).get(), edge), true); +}); + +test("lookup-argument-projection rejects an edge at a different target", () => { + const realm = beginRealm(LookupArgumentProjectionRealm); + const source = realm.root.A.add(); + const target = realm.root.B(source).add(); + const otherTarget = realm.root.B(source).add(); + const edge = realm.root.E(source)(otherTarget).add(); + realm.root.next(source).set(target); + realm.root.nextedge(source).set(edge); + + assert.throws(() => realm.commit(), /\.nextedge\.foreignKey/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-builtin.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-builtin.test.ts index 5e9a2108..006e2c65 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-builtin.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-builtin.test.ts @@ -18,9 +18,6 @@ test("lookup-builtin", () => { realm.root.edge(source).set(edge); const view = realm.commit(); - assert.equal(view.X.has(source), true); - assert.equal(view.E(rank).has(edge), true); - assert.equal(valueEqual(view.rank(source).get(), rank), true); assert.equal(valueEqual(view.edge(source).get(), edge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop-prop-prop-prop.test.ts new file mode 100644 index 00000000..58cd9c62 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop-prop-prop-prop.test.ts @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupCompositionPropPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-composition-prop-prop-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-composition-prop-prop-prop-prop", () => { + const realm = beginRealm(LookupCompositionPropPropPropPropRealm); + const source = realm.root.A.add(); + const intermediate = realm.root.B.add(); + const target = realm.root.C.add(); + const edge = realm.root.E(target).add(); + realm.root.first(source).set(intermediate); + realm.root.second(intermediate).set(target); + realm.root.edge(source).set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge(source).get(), edge), true); +}); + +test("lookup-composition-prop-prop-prop-prop infers an inhabited composition", { expectFailure: true }, () => { + const realm = beginRealm(LookupCompositionPropPropPropPropRealm); + const source = realm.root.A.add(); + const intermediate = realm.root.B.add(); + const target = realm.root.C.add(); + const edge = realm.root.E(target).add(); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge(source).get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop.test.ts deleted file mode 100644 index fe720277..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-composition-prop.test.ts +++ /dev/null @@ -1,140 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupCompositionPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-composition-prop.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedInputFailure = { - expectFailure: { - label: "composition treats equal source proofs as distinct", - match: /\.first\.total/, - }, -}; - -const expectedIntermediateFailure = { - expectFailure: { - label: "composition treats equal intermediate proofs as distinct", - match: /\.second\.total/, - }, -}; - -const expectedEqualTargetFailure = { - expectFailure: { - label: "equal composed target proofs identify different propositions", - match: /\.edge\.foreignKey/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "proof-valued composition can return a distinct proof", - match: /false !== true/, - }, -}; - -const expectedImplicitCompositionFailure = { - expectFailure: { - label: "composition through inhabited propositions is not synthesized", - match: /\.first\.total/, - }, -}; - -test("lookup-composition-prop", () => { - const realm = beginRealm(LookupCompositionPropRealm); - const source = realm.root.A.add(); - const intermediate = realm.root.B.add(); - const target = realm.root.C.add(); - const edge = realm.root.E(target).add(); - realm.root.first(source).set(intermediate); - realm.root.second(intermediate).set(target); - realm.root.edge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(intermediate), true); - assert.equal(view.C.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.first(source).get(), intermediate), true); - assert.equal(valueEqual(view.second(intermediate).get(), target), true); - assert.equal(valueEqual(view.edge(source).get(), edge), true); -}); - -test("lookup-composition-prop ignores proof identity in its source", expectedInputFailure, () => { - const realm = beginRealm(LookupCompositionPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const intermediate = realm.root.B.add(); - const target = realm.root.C.add(); - const edge = realm.root.E(target).add(); - realm.root.first(firstSource).set(intermediate); - realm.root.second(intermediate).set(target); - realm.root.edge(firstSource).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.first(secondSource).get(), intermediate), true); - assert.equal(valueEqual(view.edge(secondSource).get(), edge), true); -}); - -test("lookup-composition-prop ignores proof identity at its intermediate lookup", expectedIntermediateFailure, () => { - const realm = beginRealm(LookupCompositionPropRealm); - const source = realm.root.A.add(); - const firstIntermediate = realm.root.B.add(); - const secondIntermediate = realm.root.B.add(); - const target = realm.root.C.add(); - const edge = realm.root.E(target).add(); - realm.root.first(source).set(firstIntermediate); - realm.root.second(secondIntermediate).set(target); - realm.root.edge(source).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.second(firstIntermediate).get(), target), true); - assert.equal(valueEqual(view.edge(source).get(), edge), true); -}); - -test("lookup-composition-prop accepts an edge at an equal composed target", expectedEqualTargetFailure, () => { - const realm = beginRealm(LookupCompositionPropRealm); - const source = realm.root.A.add(); - const intermediate = realm.root.B.add(); - const firstTarget = realm.root.C.add(); - const secondTarget = realm.root.C.add(); - const edge = realm.root.E(secondTarget).add(); - realm.root.first(source).set(intermediate); - realm.root.second(intermediate).set(firstTarget); - realm.root.edge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.E(firstTarget).has(edge), true); -}); - -test("lookup-composition-prop returns a canonical edge proof", expectedOutputFailure, () => { - const realm = beginRealm(LookupCompositionPropRealm); - const source = realm.root.A.add(); - const intermediate = realm.root.B.add(); - const target = realm.root.C.add(); - const firstEdge = realm.root.E(target).add(); - const secondEdge = realm.root.E(target).add(); - realm.root.first(source).set(intermediate); - realm.root.second(intermediate).set(target); - realm.root.edge(source).set(firstEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.edge(source).get(), secondEdge), true); -}); - -test("lookup-composition-prop infers an inhabited composition", expectedImplicitCompositionFailure, () => { - const realm = beginRealm(LookupCompositionPropRealm); - const source = realm.root.A.add(); - const intermediate = realm.root.B.add(); - const target = realm.root.C.add(); - const edge = realm.root.E(target).add(); - const view = realm.commit(); - - assert.equal(valueEqual(view.first(source).get(), intermediate), true); - assert.equal(valueEqual(view.second(intermediate).get(), target), true); - assert.equal(valueEqual(view.edge(source).get(), edge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-composition.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-composition.test.ts index a984ac0d..1fd56d3b 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-composition.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-composition.test.ts @@ -20,12 +20,6 @@ test("lookup-composition", () => { realm.root.edge(source).set(edge); const view = realm.commit(); - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(intermediate), true); - assert.equal(view.C.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.first(source).get(), intermediate), true); - assert.equal(valueEqual(view.second(intermediate).get(), target), true); assert.equal(valueEqual(view.edge(source).get(), edge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-prop.test.ts new file mode 100644 index 00000000..32c2def2 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-prop.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-prop-prop-prop", () => { + const realm = beginRealm(LookupFieldProjectionPropPropPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-set.test.ts new file mode 100644 index 00000000..fc2cb1d4 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-prop-set.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionPropPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-prop-prop-set", () => { + const realm = beginRealm(LookupFieldProjectionPropPropSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-prop.test.ts new file mode 100644 index 00000000..4a94268f --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-prop.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionPropSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-prop-set-prop", () => { + const realm = beginRealm(LookupFieldProjectionPropSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-set.test.ts new file mode 100644 index 00000000..beb6a394 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-prop-set-set.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionPropSetSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-prop-set-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-prop-set-set", () => { + const realm = beginRealm(LookupFieldProjectionPropSetSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-prop.test.ts new file mode 100644 index 00000000..37b3b2b7 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-prop.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionSetPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-set-prop-prop", () => { + const realm = beginRealm(LookupFieldProjectionSetPropPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-set.test.ts new file mode 100644 index 00000000..e17aa087 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-prop-set.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionSetPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-set-prop-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-set-prop-set", () => { + const realm = beginRealm(LookupFieldProjectionSetPropSetRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-set-prop.test.ts new file mode 100644 index 00000000..4ff4faac --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection-set-set-prop.test.ts @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionSetSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection-set-set-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection-set-set-prop", () => { + const realm = beginRealm(LookupFieldProjectionSetSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); + +test("lookup-field-projection-set-set-prop rejects an edge at a different target", () => { + const realm = beginRealm(LookupFieldProjectionSetSetPropRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const otherTarget = realm.root.B.add(); + const edge = realm.root.E(otherTarget).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + + assert.throws(() => realm.commit(), /rule TRealm\.edge/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection.test.ts new file mode 100644 index 00000000..5a5a7fc4 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-field-projection.test.ts @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as LookupFieldProjectionRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-field-projection.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("lookup-field-projection", () => { + const realm = beginRealm(LookupFieldProjectionRealm); + const source = realm.root.A.add(); + const target = realm.root.B.add(); + const edge = realm.root.E(target).add(); + realm.root.x.set(source); + realm.root.next(source).set(target); + realm.root.edge.set(edge); + const view = realm.commit(); + + assert.equal(valueEqual(view.edge.get(), edge), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-literal-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-literal-prop.test.ts index 36103a69..a78f4b7c 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-literal-prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-literal-prop.test.ts @@ -11,19 +11,6 @@ import { beginRealm } from "./helpers.ts"; const intIndex = { tag: "int", value: 19 } as const; const stringIndex = { tag: "string", value: "zombocom" } as const; -const expectedCanonicalizationFailure = { - expectFailure: { - label: "multiple proofs at a literal index are not canonicalized", - match: /false !== true/, - }, -}; - -const expectedCardinalityFailure = { - expectFailure: { - label: "a proposition can contain multiple proofs at one literal index", - match: /false !== true/, - }, -}; test("lookup-literal-prop", () => { const realm = beginRealm(LookupLiteralPropRealm); @@ -33,8 +20,6 @@ test("lookup-literal-prop", () => { realm.root.stringFact.set(stringProof); const view = realm.commit(); - assert.equal(view.IntFact(intIndex).has(intProof), true); - assert.equal(view.StringFact(stringIndex).has(stringProof), true); assert.equal(valueEqual(view.intFact.get(), intProof), true); assert.equal(valueEqual(view.stringFact.get(), stringProof), true); }); @@ -46,7 +31,7 @@ test("lookup-literal-prop rejects a proof at a different integer", () => { realm.root.intFact.set(intProof); realm.root.stringFact.set(stringProof); - assert.throws(() => realm.commit(), /\.intFact\.foreignKey/); + assert.throws(() => realm.commit(), /rule TRealm\.intFact/); }); test("lookup-literal-prop rejects a proof at a different string", () => { @@ -59,57 +44,5 @@ test("lookup-literal-prop rejects a proof at a different string", () => { realm.root.intFact.set(intProof); realm.root.stringFact.set(stringProof); - assert.throws(() => realm.commit(), /\.stringFact\.foreignKey/); -}); - -test("lookup-literal-prop canonicalizes proofs at the same index", expectedCanonicalizationFailure, () => { - const realm = beginRealm(LookupLiteralPropRealm); - const firstIntProof = realm.root.IntFact(intIndex).add(); - const secondIntProof = realm.root.IntFact(intIndex).add(); - const firstStringProof = realm.root.StringFact(stringIndex).add(); - const secondStringProof = realm.root.StringFact(stringIndex).add(); - realm.root.intFact.set(firstIntProof); - realm.root.stringFact.set(firstStringProof); - const view = realm.commit(); - - assert.equal(valueEqual(firstIntProof, secondIntProof), true); - assert.equal(valueEqual(firstStringProof, secondStringProof), true); - assert.equal(view.IntFact(intIndex).has(firstIntProof), true); - assert.equal(view.StringFact(stringIndex).has(firstStringProof), true); -}); - -test("lookup-literal-prop keeps proofs at different indexes distinct", () => { - const realm = beginRealm(LookupLiteralPropRealm); - const firstIntProof = realm.root.IntFact(intIndex).add(); - const secondIntProof = realm.root.IntFact({ tag: "int", value: 20 }).add(); - const firstStringProof = realm.root.StringFact(stringIndex).add(); - const secondStringProof = realm.root.StringFact({ - tag: "string", - value: "not-zombocom", - }).add(); - realm.root.intFact.set(firstIntProof); - realm.root.stringFact.set(firstStringProof); - realm.commit(); - - assert.equal(valueEqual(firstIntProof, secondIntProof), false); - assert.equal(valueEqual(firstStringProof, secondStringProof), false); -}); - -test("lookup-literal-prop has at most one proof at each index", expectedCardinalityFailure, () => { - const realm = beginRealm(LookupLiteralPropRealm); - const intProof = realm.root.IntFact(intIndex).add(); - realm.root.IntFact(intIndex).add(); - const stringProof = realm.root.StringFact(stringIndex).add(); - realm.root.StringFact(stringIndex).add(); - realm.root.intFact.set(intProof); - realm.root.stringFact.set(stringProof); - const view = realm.commit(); - - const intProofs = view.IntFact(intIndex).values(); - assert.equal(intProofs.next().done, false); - assert.equal(intProofs.next().done, true); - - const stringProofs = view.StringFact(stringIndex).values(); - assert.equal(stringProofs.next().done, false); - assert.equal(stringProofs.next().done, true); + assert.throws(() => realm.commit(), /rule TRealm\.stringFact/); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-literal.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-literal.test.ts index 6af6fa88..3dcb9924 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-literal.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-literal.test.ts @@ -20,8 +20,6 @@ test("lookup-literal", () => { realm.root.stringEdge.set(stringEdge); const view = realm.commit(); - assert.equal(view.IntEdge(intIndex).has(intEdge), true); - assert.equal(view.StringEdge(stringIndex).has(stringEdge), true); assert.equal(valueEqual(view.intEdge.get(), intEdge), true); assert.equal(valueEqual(view.stringEdge.get(), stringEdge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-prop.test.ts deleted file mode 100644 index cfc03616..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-prop.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionPropPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-prop.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedInputFailure = { - expectFailure: { - label: "lookups treat equal proof inputs as distinct", - match: /\.next\.total/, - }, -}; - -const expectedEqualTargetFailure = { - expectFailure: { - label: "equal lookup proofs identify different propositions", - match: /\.nextedge\.foreignKey/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "proof-valued lookups can return distinct proofs", - match: /false !== true/, - }, -}; - -test("lookup-projection-prop-prop-prop", () => { - const realm = beginRealm(LookupProjectionPropPropPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-prop-prop-prop ignores proof identity in its input", expectedInputFailure, () => { - const realm = beginRealm(LookupProjectionPropPropPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(firstSource).set(target); - realm.root.nextedge(firstSource).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(secondSource).get(), target), true); - assert.equal(valueEqual(view.nextedge(secondSource).get(), edge), true); -}); - -test("lookup-projection-prop-prop-prop accepts an edge at an equal proof target", expectedEqualTargetFailure, () => { - const realm = beginRealm(LookupProjectionPropPropPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.E(target).has(edge), true); -}); - -test("lookup-projection-prop-prop-prop returns a canonical target proof", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionPropPropPropRealm); - const source = realm.root.A.add(); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const edge = realm.root.E(firstTarget).add(); - realm.root.next(source).set(firstTarget); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(source).get(), secondTarget), true); -}); - -test("lookup-projection-prop-prop-prop returns a canonical edge proof", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionPropPropPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const firstEdge = realm.root.E(target).add(); - const secondEdge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(firstEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(source).get(), secondEdge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-set.test.ts deleted file mode 100644 index 0638e9b6..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-prop-set.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionPropPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-prop-prop-set.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedInputFailure = { - expectFailure: { - label: "lookups treat equal proof inputs as distinct", - match: /\.next\.total/, - }, -}; - -const expectedEqualTargetFailure = { - expectFailure: { - label: "equal lookup proofs identify different edge sets", - match: /\.nextedge\.foreignKey/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "a proof-valued lookup can return distinct proofs", - match: /false !== true/, - }, -}; - -test("lookup-projection-prop-prop-set", () => { - const realm = beginRealm(LookupProjectionPropPropSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-prop-prop-set ignores proof identity in its input", expectedInputFailure, () => { - const realm = beginRealm(LookupProjectionPropPropSetRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(firstSource).set(target); - realm.root.nextedge(firstSource).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(secondSource).get(), target), true); - assert.equal(valueEqual(view.nextedge(secondSource).get(), edge), true); -}); - -test("lookup-projection-prop-prop-set accepts an edge at an equal proof target", expectedEqualTargetFailure, () => { - const realm = beginRealm(LookupProjectionPropPropSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.E(target).has(edge), true); -}); - -test("lookup-projection-prop-prop-set returns an equal target proof", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionPropPropSetRealm); - const source = realm.root.A.add(); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const edge = realm.root.E(firstTarget).add(); - realm.root.next(source).set(firstTarget); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(source).get(), secondTarget), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-prop.test.ts deleted file mode 100644 index c67baddd..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-prop.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionPropSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-prop.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedInputFailure = { - expectFailure: { - label: "lookups treat equal proof inputs as distinct", - match: /\.next\.total/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "a proposition at one lookup target can contain distinct proofs", - match: /false !== true/, - }, -}; - -test("lookup-projection-prop-set-prop", () => { - const realm = beginRealm(LookupProjectionPropSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-prop-set-prop rejects an edge at a different target", () => { - const realm = beginRealm(LookupProjectionPropSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - - assert.throws(() => realm.commit(), /\.nextedge\.foreignKey/); -}); - -test("lookup-projection-prop-set-prop ignores proof identity in its input", expectedInputFailure, () => { - const realm = beginRealm(LookupProjectionPropSetPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(firstSource).set(target); - realm.root.nextedge(firstSource).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(secondSource).get(), target), true); - assert.equal(valueEqual(view.nextedge(secondSource).get(), edge), true); -}); - -test("lookup-projection-prop-set-prop returns a canonical edge proof", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionPropSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const firstEdge = realm.root.E(target).add(); - const secondEdge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(firstEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(source).get(), secondEdge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-set.test.ts deleted file mode 100644 index 17acdffa..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-prop-set-set.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionPropSetSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-prop-set-set.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "lookups treat equal proof inputs as distinct", - match: /\.next\.total/, - }, -}; - -test("lookup-projection-prop-set-set", () => { - const realm = beginRealm(LookupProjectionPropSetSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-prop-set-set rejects an edge at a different target", () => { - const realm = beginRealm(LookupProjectionPropSetSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - - assert.throws(() => realm.commit(), /\.nextedge\.foreignKey/); -}); - -test("lookup-projection-prop-set-set ignores proof identity in lookups", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(LookupProjectionPropSetSetRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(firstSource).set(target); - realm.root.nextedge(firstSource).set(edge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(secondSource).get(), target), true); - assert.equal(valueEqual(view.nextedge(secondSource).get(), edge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-prop.test.ts deleted file mode 100644 index 8bdcce5e..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-prop.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionSetPropPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-prop.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedEqualTargetFailure = { - expectFailure: { - label: "equal lookup proofs identify different propositions", - match: /\.nextedge\.foreignKey/, - }, -}; - -const expectedOutputFailure = { - expectFailure: { - label: "proof-valued lookups can return distinct proofs of equal propositions", - match: /false !== true/, - }, -}; - -test("lookup-projection-set-prop-prop", () => { - const realm = beginRealm(LookupProjectionSetPropPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-set-prop-prop accepts an edge at an equal proof target", expectedEqualTargetFailure, () => { - const realm = beginRealm(LookupProjectionSetPropPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.E(target).has(edge), true); -}); - -test("lookup-projection-set-prop-prop returns equal target proofs", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionSetPropPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const firstEdge = realm.root.E(firstTarget).add(); - const secondEdge = realm.root.E(secondTarget).add(); - realm.root.next(firstSource).set(firstTarget); - realm.root.next(secondSource).set(secondTarget); - realm.root.nextedge(firstSource).set(firstEdge); - realm.root.nextedge(secondSource).set(secondEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.next(firstSource).get(), view.next(secondSource).get()), true); -}); - -test("lookup-projection-set-prop-prop returns equal edge proofs", expectedOutputFailure, () => { - const realm = beginRealm(LookupProjectionSetPropPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const firstEdge = realm.root.E(firstTarget).add(); - const secondEdge = realm.root.E(secondTarget).add(); - realm.root.next(firstSource).set(firstTarget); - realm.root.next(secondSource).set(secondTarget); - realm.root.nextedge(firstSource).set(firstEdge); - realm.root.nextedge(secondSource).set(secondEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(firstSource).get(), view.nextedge(secondSource).get()), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-set.test.ts deleted file mode 100644 index ed0d3f0d..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-prop-set.test.ts +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionSetPropSetRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-set-prop-set.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "sets indexed by equal lookup proofs are treated as distinct", - match: /false !== true/, - }, -}; - -const expectedEqualTargetFailure = { - expectFailure: { - label: "equal lookup proofs identify different edge sets", - match: /\.nextedge\.foreignKey/, - }, -}; - -test("lookup-projection-set-prop-set", () => { - const realm = beginRealm(LookupProjectionSetPropSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-set-prop-set accepts an edge at an equal proof target", expectedEqualTargetFailure, () => { - const realm = beginRealm(LookupProjectionSetPropSetRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-set-prop-set ignores proof identity in lookup results", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(LookupProjectionSetPropSetRealm); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const edge = realm.root.E(firstTarget).add(); - const view = realm.commit(); - - assert.equal(view.E(secondTarget).has(edge), true); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-set-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-set-prop.test.ts deleted file mode 100644 index 407a5484..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection-set-set-prop.test.ts +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionSetSetPropRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection-set-set-prop.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedProofIrrelevanceFailure = { - expectFailure: { - label: "lookups can return distinct proofs of the same proposition", - match: /false !== true/, - }, -}; - -const expectedImplicitOutputFailure = { - expectFailure: { - label: "a dependent function into an inhabited proposition is not synthesized", - match: /\.nextedge\.total/, - }, -}; - -test("lookup-projection-set-set-prop", () => { - const realm = beginRealm(LookupProjectionSetSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-set-set-prop rejects an edge at a different target", () => { - const realm = beginRealm(LookupProjectionSetSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - - assert.throws(() => realm.commit(), /\.nextedge\.foreignKey/); -}); - -test("lookup-projection-set-set-prop infers its output from an inhabited proposition", expectedImplicitOutputFailure, () => { - const realm = beginRealm(LookupProjectionSetSetPropRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection-set-set-prop returns equal proofs for equal lookup results", expectedProofIrrelevanceFailure, () => { - const realm = beginRealm(LookupProjectionSetSetPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const target = realm.root.B.add(); - const firstEdge = realm.root.E(target).add(); - const secondEdge = realm.root.E(target).add(); - realm.root.next(firstSource).set(target); - realm.root.next(secondSource).set(target); - realm.root.nextedge(firstSource).set(firstEdge); - realm.root.nextedge(secondSource).set(secondEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(firstSource).get(), view.nextedge(secondSource).get()), true); -}); - -test("lookup-projection-set-set-prop keeps proofs for different lookup results distinct", () => { - const realm = beginRealm(LookupProjectionSetSetPropRealm); - const firstSource = realm.root.A.add(); - const secondSource = realm.root.A.add(); - const firstTarget = realm.root.B.add(); - const secondTarget = realm.root.B.add(); - const firstEdge = realm.root.E(firstTarget).add(); - const secondEdge = realm.root.E(secondTarget).add(); - realm.root.next(firstSource).set(firstTarget); - realm.root.next(secondSource).set(secondTarget); - realm.root.nextedge(firstSource).set(firstEdge); - realm.root.nextedge(secondSource).set(secondEdge); - const view = realm.commit(); - - assert.equal(valueEqual(view.nextedge(firstSource).get(), view.nextedge(secondSource).get()), false); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-projection.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-projection.test.ts deleted file mode 100644 index afc11432..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-projection.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as LookupProjectionRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-projection.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -test("lookup-projection", () => { - const realm = beginRealm(LookupProjectionRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const edge = realm.root.E(target).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - const view = realm.commit(); - - assert.equal(view.A.has(source), true); - assert.equal(view.B.has(target), true); - assert.equal(view.E(target).has(edge), true); - assert.equal(valueEqual(view.next(source).get(), target), true); - assert.equal(valueEqual(view.nextedge(source).get(), edge), true); -}); - -test("lookup-projection rejects an edge at a different target", () => { - const realm = beginRealm(LookupProjectionRealm); - const source = realm.root.A.add(); - const target = realm.root.B.add(); - const otherTarget = realm.root.B.add(); - const edge = realm.root.E(otherTarget).add(); - realm.root.next(source).set(target); - realm.root.nextedge(source).set(edge); - - assert.throws(() => realm.commit(), /\.nextedge\.foreignKey/); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-record-composition.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-record-composition.test.ts index a859ec45..9bf5a233 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-record-composition.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-record-composition.test.ts @@ -9,14 +9,7 @@ import { valueEqual } from "@coln-project/runtime"; import * as LookupRecordCompositionRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-record-composition.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record fields are not exposed through generated table cells", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -test("lookup-record-composition", expectedFailure, () => { +test("lookup-record-composition", { expectFailure: true }, () => { const realm = beginRealm(LookupRecordCompositionRealm); const source = realm.root.X.add(); const rank = { tag: "int", value: 1 } as const; @@ -29,10 +22,5 @@ test("lookup-record-composition", expectedFailure, () => { realm.root.edge(source).set(edge); const view = realm.commit(); - assert.equal(valueEqual(view.key(source).rank.get(), rank), true); - assert.equal(view.PayloadAt(rank).has(slot), true); - assert.equal(valueEqual(view.slot(source).get(), slot), true); - assert.equal(valueEqual(view.payload(rank)(slot).name.get(), name), true); - assert.equal(view.E(name).has(edge), true); assert.equal(valueEqual(view.edge(source).get(), edge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-record-expansion.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-record-expansion.test.ts index 57339fe5..650ed81d 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-record-expansion.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-record-expansion.test.ts @@ -9,14 +9,7 @@ import { valueEqual } from "@coln-project/runtime"; import * as LookupRecordExpansionRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-record-expansion.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record fields are not exposed through the generated table cell", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -test("lookup-record-expansion", expectedFailure, () => { +test("lookup-record-expansion", { expectFailure: true }, () => { const realm = beginRealm(LookupRecordExpansionRealm); const source = realm.root.X.add(); const name = { tag: "string", value: "example" } as const; @@ -28,8 +21,5 @@ test("lookup-record-expansion", expectedFailure, () => { realm.root.edge(source).set(edge); const view = realm.commit(); - assert.equal(valueEqual(view.payload(source).name.get(), name), true); - assert.equal(valueEqual(view.payload(source).rank.get(), rank), true); - assert.equal(view.E(payload).has(edge), true); assert.equal(valueEqual(view.edge(source).get(), edge), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-record-field.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-record-field.test.ts index 381ad7e8..b8c2b4e0 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-record-field.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-record-field.test.ts @@ -9,14 +9,7 @@ import { valueEqual } from "@coln-project/runtime"; import * as LookupRecordFieldRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-record-field.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record fields are not exposed through the generated table cell", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -test("lookup-record-field", expectedFailure, () => { +test("lookup-record-field", { expectFailure: true }, () => { const realm = beginRealm(LookupRecordFieldRealm); const source = realm.root.X.add(); const name = { tag: "string", value: "example" } as const; @@ -28,14 +21,10 @@ test("lookup-record-field", expectedFailure, () => { realm.root.edge(source).set(edge); const view = realm.commit(); - assert.equal(view.X.has(source), true); - assert.equal(view.E(rank).has(edge), true); - assert.equal(valueEqual(view.payload(source).name.get(), name), true); - assert.equal(valueEqual(view.payload(source).rank.get(), rank), true); assert.equal(valueEqual(view.edge(source).get(), edge), true); }); -test("lookup-record-field rejects an edge at a different payload rank", expectedFailure, () => { +test("lookup-record-field rejects an edge at a different payload rank", { expectFailure: true }, () => { const realm = beginRealm(LookupRecordFieldRealm); const source = realm.root.X.add(); const name = { tag: "string", value: "example" } as const; diff --git a/packages/coln-js-runtime/tests/basic-ir/lookup-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/lookup-record.test.ts index 73747280..21a6c6ca 100644 --- a/packages/coln-js-runtime/tests/basic-ir/lookup-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/lookup-record.test.ts @@ -9,14 +9,7 @@ import { valueEqual } from "@coln-project/runtime"; import * as LookupRecordRealm from "../../../coln-compiler/test/golden/basic-ir/lookup-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("lookup-record", expectedFailure, () => { +test("lookup-record", { expectFailure: true }, () => { const realm = beginRealm(LookupRecordRealm); const fixed = { name: { tag: "string", value: "fixed" }, @@ -26,6 +19,5 @@ test("lookup-record", expectedFailure, () => { realm.root.selected.set(selected); const view = realm.commit(); - assert.equal(view.E(fixed).has(selected), true); assert.equal(valueEqual(view.selected.get(), selected), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-alias-set.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-alias-set.test.ts new file mode 100644 index 00000000..f0192832 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-alias-set.test.ts @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamAliasSetRealm from "../../../coln-compiler/test/golden/basic-ir/param-alias-set.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-alias-set", { expectFailure: true }, () => { + const realm = beginRealm(ParamAliasSetRealm); + const box = { value: realm.root.X.add() }; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-alias.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-alias.test.ts new file mode 100644 index 00000000..045d3444 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-alias.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamAliasRealm from "../../../coln-compiler/test/golden/basic-ir/param-alias.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-alias", { expectFailure: true }, () => { + const realm = beginRealm(ParamAliasRealm); + const box = { + key: { tag: "int", value: 1 }, + modelValue: realm.root.model.X.add(), + value: { tag: "string", value: "payload" }, + } as const; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-concrete.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-concrete.test.ts index db052bbb..6f2ce007 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-record-concrete.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-concrete.test.ts @@ -8,14 +8,7 @@ import test from "node:test"; import * as ParamRecordConcreteRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-concrete.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "concrete nested record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("param-record-concrete", expectedFailure, () => { +test("param-record-concrete", { expectFailure: true }, () => { const realm = beginRealm(ParamRecordConcreteRealm); const box = { value: { diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-function.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-function.test.ts new file mode 100644 index 00000000..2b589797 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-function.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordDependentFunctionRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-dependent-function.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-dependent-function", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordDependentFunctionRealm); + const key = realm.root.Key.add(); + realm.root.key.set(key); + const image = realm.root.E(key).add(); + realm.root.f(key).set(image); + const box = { image }; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-model.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-model.test.ts new file mode 100644 index 00000000..d4c6d6d5 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-dependent-model.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordDependentModelRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-dependent-model.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-dependent-model", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordDependentModelRealm); + const rank = { tag: "int", value: 1 } as const; + const key = { rank }; + const value = { tag: "string", value: "payload" } as const; + realm.root.pointed.point.rank.set(rank); + const box = { key, value }; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-function.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-function.test.ts new file mode 100644 index 00000000..cff908ac --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-function.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordFunctionRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-function.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-function", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordFunctionRealm); + const key = realm.root.Key.add(); + const value = { tag: "string", value: "payload" } as const; + realm.root.f(key).set(key); + const box = { key, value }; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-model.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-model.test.ts index 999b7852..b99884f4 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-record-model.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-model.test.ts @@ -8,23 +8,15 @@ import test from "node:test"; import * as ParamRecordModelRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-model.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "model-parameterized record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("param-record-model", expectedFailure, () => { +test("param-record-model", { expectFailure: true }, () => { const realm = beginRealm(ParamRecordModelRealm); const modelValue = realm.root.model.X.add(); const box = { modelValue, - value: {name: {tag: "string", value: "payload"}}, + value: { tag: "string", value: "payload" }, } as const; const boxed = realm.root.boxed(box).add(); const view = realm.commit(); - assert.equal(view.model.X.has(modelValue), true); assert.equal(view.boxed(box).has(boxed), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-nested.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-nested.test.ts index 51fb139e..5804e28a 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-record-nested.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-nested.test.ts @@ -5,34 +5,15 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as ParamRecordNestedRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-nested.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "nested record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("param-record-nested", expectedFailure, () => { +test("param-record-nested", { expectFailure: true }, () => { const realm = beginRealm(ParamRecordNestedRealm); - const first = realm.root.X.add(); - const second = realm.root.X.add(); - const firstFirst = { inner: { value: first }, sibling: first }; - const firstSecond = { inner: { value: first }, sibling: second }; - const secondFirst = { inner: { value: second }, sibling: first }; - const secondSecond = { inner: { value: second }, sibling: second }; - realm.root.selected(firstFirst).set(first); - realm.root.selected(firstSecond).set(first); - realm.root.selected(secondFirst).set(second); - realm.root.selected(secondSecond).set(second); - const value = realm.root.nested(firstSecond).add(); + const inner = realm.root.X.add(); + const nested = { inner: { value: inner } }; + const value = realm.root.nested(nested).add(); const view = realm.commit(); - assert.equal(view.X.has(first), true); - assert.equal(view.X.has(second), true); - assert.equal(view.nested(firstSecond).has(value), true); - assert.equal(valueEqual(view.selected(firstSecond).get(), first), true); + assert.equal(view.nested(nested).has(value), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-repeated-binders.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-repeated-binders.test.ts new file mode 100644 index 00000000..f5beac53 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-repeated-binders.test.ts @@ -0,0 +1,5 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import "../../../coln-compiler/test/golden/basic-ir/param-record-repeated-binders.ts.output/TRealm.ts"; diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-lambda.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-lambda.test.ts new file mode 100644 index 00000000..dd682123 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-lambda.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordTypeFamilyLambdaRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-type-family-lambda.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-type-family-lambda", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordTypeFamilyLambdaRealm); + const x = { tag: "int", value: 1 } as const; + const box = { + value: { tag: "string", value: "payload" }, + } as const; + const boxed = realm.root.boxed(x)(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(x)(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-multi-argument.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-multi-argument.test.ts new file mode 100644 index 00000000..9d7fed96 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-multi-argument.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordTypeFamilyMultiArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-type-family-multi-argument.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-type-family-multi-argument", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordTypeFamilyMultiArgumentRealm); + const x = realm.root.X.add(); + const y = realm.root.Y.add(); + const entry = realm.root.R(x)(y).add(); + const cell = { entry }; + const value = realm.root.cells(x)(y)(cell).add(); + const view = realm.commit(); + + assert.equal(view.cells(x)(y)(cell).has(value), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-partial.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-partial.test.ts new file mode 100644 index 00000000..9fe240bb --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-partial.test.ts @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordTypeFamilyPartialRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-type-family-partial.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-type-family-partial", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordTypeFamilyPartialRealm); + const x = realm.root.X.add(); + const y = realm.root.Y.add(); + const entry = realm.root.R(x)(y).add(); + const slice = { entry }; + const value = realm.root.slices(x)(y)(slice).add(); + const view = realm.commit(); + + assert.equal(view.slices(x)(y)(slice).has(value), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-prop.test.ts new file mode 100644 index 00000000..ad20e734 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-prop.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordTypeFamilyPropRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-type-family-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-type-family-prop", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordTypeFamilyPropRealm); + const x = realm.root.X.add(); + const proof = realm.root.P(x).add(); + const evidence = { proof }; + const value = realm.root.evidence(x)(evidence).add(); + const view = realm.commit(); + + assert.equal(view.evidence(x)(evidence).has(value), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-unused.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-unused.test.ts new file mode 100644 index 00000000..ba1447f4 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/param-record-type-family-unused.test.ts @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ParamRecordTypeFamilyUnusedRealm from "../../../coln-compiler/test/golden/basic-ir/param-record-type-family-unused.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("param-record-type-family-unused", { expectFailure: true }, () => { + const realm = beginRealm(ParamRecordTypeFamilyUnusedRealm); + const box = { + value: { tag: "int", value: 1 }, + } as const; + const boxed = realm.root.boxed(box).add(); + const view = realm.commit(); + + assert.equal(view.boxed(box).has(boxed), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-record.test.ts index 0f022e1c..371647d7 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-record.test.ts @@ -8,20 +8,12 @@ import test from "node:test"; import * as ParamRecordRealm from "../../../coln-compiler/test/golden/basic-ir/param-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("param-record", expectedFailure, () => { +test("param-record", { expectFailure: true }, () => { const realm = beginRealm(ParamRecordRealm); const value = realm.root.X.add(); const box = { value }; const boxed = realm.root.boxed(box).add(); const view = realm.commit(); - assert.equal(view.X.has(value), true); assert.equal(view.boxed(box).has(boxed), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-theory-model.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-theory-model.test.ts index 27be47c8..3d5250ea 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-theory-model.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-theory-model.test.ts @@ -15,6 +15,5 @@ test("param-theory-model", () => { realm.root.pointed.point.set(point); const view = realm.commit(); - assert.equal(view.model.X.has(point), true); assert.equal(valueEqual(view.pointed.point.get(), point), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-theory-nested.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-theory-nested.test.ts index 7f5b4906..1c2481c9 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-theory-nested.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-theory-nested.test.ts @@ -15,6 +15,5 @@ test("param-theory-nested", () => { realm.root.outer.inner.point.set(point); const view = realm.commit(); - assert.equal(view.X.has(point), true); assert.equal(valueEqual(view.outer.inner.point.get(), point), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/param-theory.test.ts b/packages/coln-js-runtime/tests/basic-ir/param-theory.test.ts index cf19f1b6..2ce5432d 100644 --- a/packages/coln-js-runtime/tests/basic-ir/param-theory.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/param-theory.test.ts @@ -15,6 +15,5 @@ test("param-theory", () => { realm.root.P.point.set(point); const view = realm.commit(); - assert.equal(view.X.has(point), true); assert.equal(valueEqual(view.P.point.get(), point), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/projection.test.ts b/packages/coln-js-runtime/tests/basic-ir/projection.test.ts index 6cd521cf..6871e7d3 100644 --- a/packages/coln-js-runtime/tests/basic-ir/projection.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/projection.test.ts @@ -9,42 +9,34 @@ import { valueEqual } from "@coln-project/runtime"; import * as ProjectionRealm from "../../../coln-compiler/test/golden/basic-ir/projection.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("projection", expectedFailure, () => { +test("projection", { expectFailure: true }, () => { const realm = beginRealm(ProjectionRealm); - const first = realm.root.X.add(); - const second = realm.root.X.add(); - const firstValue = realm.root.E(first).add(); - const secondValue = realm.root.E(second).add(); - realm.root.r({ first, second: first }).set(firstValue); - realm.root.r({ first, second }).set(secondValue); - realm.root.r({ first: second, second: first }).set(firstValue); - realm.root.r({ first: second, second }).set(secondValue); + const a = realm.root.X.add(); + const b = realm.root.X.add(); + const valueForA = realm.root.E(a).add(); + const valueForB = realm.root.E(b).add(); + realm.root.r({ first: a, second: a }).set(valueForA); + realm.root.r({ first: a, second: b }).set(valueForB); + realm.root.r({ first: b, second: a }).set(valueForA); + realm.root.r({ first: b, second: b }).set(valueForB); const view = realm.commit(); - assert.equal(view.X.has(first), true); - assert.equal(view.X.has(second), true); - assert.equal(view.E(first).has(firstValue), true); - assert.equal(view.E(second).has(secondValue), true); - assert.equal(valueEqual(view.r({ first, second }).get(), secondValue), true); + assert.equal( + valueEqual(view.r({ first: a, second: b }).get(), valueForB), + true, + ); }); -test("projection rejects a value at a different projected value", expectedFailure, () => { +test("projection rejects a value at a different projected value", { expectFailure: true }, () => { const realm = beginRealm(ProjectionRealm); - const first = realm.root.X.add(); - const second = realm.root.X.add(); - const firstValue = realm.root.E(first).add(); - const secondValue = realm.root.E(second).add(); - realm.root.r({ first, second: first }).set(firstValue); - realm.root.r({ first, second }).set(firstValue); - realm.root.r({ first: second, second: first }).set(firstValue); - realm.root.r({ first: second, second }).set(secondValue); + const a = realm.root.X.add(); + const b = realm.root.X.add(); + const valueForA = realm.root.E(a).add(); + const valueForB = realm.root.E(b).add(); + realm.root.r({ first: a, second: a }).set(valueForA); + realm.root.r({ first: a, second: b }).set(valueForA); + realm.root.r({ first: b, second: a }).set(valueForA); + realm.root.r({ first: b, second: b }).set(valueForB); assert.throws(() => realm.commit(), /\.r\.foreignKey/); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-function-argument.pending.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-function-argument.pending.ts new file mode 100644 index 00000000..9450946b --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-function-argument.pending.ts @@ -0,0 +1,65 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { proveEquality, valueEqual } from "@coln-project/runtime"; +import * as ProofRecordFunctionArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-function-argument.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("proof-record-function-argument", () => { + const realm = beginRealm(ProofRecordFunctionArgumentRealm); + const equal = realm.root.X.add(); + const value = { + first: equal, + second: equal, + proof: proveEquality(equal, equal), + trailing: equal, + }; + const accepted = realm.root.Accepted(value).add(); + const view = realm.commit(); + + assert.equal(view.Accepted(value).has(accepted), true); +}); + +test( + "proof-record-function-argument ignores nested proof identity", + () => { + const realm = beginRealm(ProofRecordFunctionArgumentRealm); + const equal = realm.root.X.add(); + const trailing = realm.root.X.add(); + const firstValue = { + first: equal, + second: equal, + proof: proveEquality(equal, equal), + trailing, + }; + const secondValue = { + ...firstValue, + proof: proveEquality(equal, equal), + }; + const firstProof = realm.root.Accepted(firstValue).add(); + const secondProof = realm.root.Accepted(secondValue).add(); + realm.commit(); + + assert.equal(valueEqual(firstProof, secondProof), true); + }, +); + +test("proof-record-function-argument retains its erased equality", () => { + const realm = beginRealm(ProofRecordFunctionArgumentRealm); + const first = realm.root.X.add(); + const second = realm.root.X.add(); + const trailing = realm.root.X.add(); + const value = { + first, + second, + proof: proveEquality(first, first), + trailing, + }; + realm.root.Accepted(value).add(); + + assert.throws(() => realm.commit(), /\.Accepted\.foreignKey/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-mixed.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-mixed-fields.test.ts similarity index 53% rename from packages/coln-js-runtime/tests/basic-ir/proof-record-mixed.test.ts rename to packages/coln-js-runtime/tests/basic-ir/proof-record-mixed-fields.test.ts index 4d5496f8..93fb8f07 100644 --- a/packages/coln-js-runtime/tests/basic-ir/proof-record-mixed.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-mixed-fields.test.ts @@ -6,39 +6,29 @@ import assert from "node:assert/strict"; import test from "node:test"; import { valueEqual } from "@coln-project/runtime"; -import * as ProofRecordMixedRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-mixed.ts.output/TRealm.ts"; +import * as ProofRecordMixedFieldsRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-mixed-fields.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record fields are not exposed through the generated table cell", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -test("proof-record-mixed", expectedFailure, () => { - const realm = beginRealm(ProofRecordMixedRealm); +test("proof-record-mixed-fields", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordMixedFieldsRealm); const equal = realm.root.X.add(); const trailing = realm.root.X.add(); realm.root.value.first.set(equal); realm.root.value.second.set(equal); - realm.root.value.proof.set(equal); realm.root.value.trailing.set(trailing); const view = realm.commit(); - assert.equal(valueEqual(view.value.first.get(), equal), true); - assert.equal(valueEqual(view.value.second.get(), equal), true); + view.value.proof.get(); assert.equal(valueEqual(view.value.trailing.get(), trailing), true); }); -test("proof-record-mixed retains its erased equality", expectedFailure, () => { - const realm = beginRealm(ProofRecordMixedRealm); +test("proof-record-mixed-fields retains its erased equality", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordMixedFieldsRealm); const first = realm.root.X.add(); const second = realm.root.X.add(); const trailing = realm.root.X.add(); realm.root.value.first.set(first); realm.root.value.second.set(second); - realm.root.value.proof.set(first); realm.root.value.trailing.set(trailing); assert.throws(() => realm.commit(), /\.value\.foreignKey/); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-equality.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-equality.test.ts new file mode 100644 index 00000000..cdcac608 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-equality.test.ts @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ProofRecordNestedDependentEqualityRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-equality.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("proof-record-nested-dependent-equality", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordNestedDependentEqualityRealm); + const expected = realm.root.X.add(); + const result = realm.root.result(expected); + result.actual.set(expected); + const view = realm.commit(); + + view.result(expected).evidence.proof.get(); +}); + +test("proof-record-nested-dependent-equality retains its equality", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordNestedDependentEqualityRealm); + const expected = realm.root.X.add(); + const actual = realm.root.X.add(); + const result = realm.root.result(expected); + result.actual.set(actual); + + assert.throws(() => realm.commit(), /\.result\.foreignKey/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-prop.test.ts new file mode 100644 index 00000000..7085a429 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-nested-dependent-prop.test.ts @@ -0,0 +1,28 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as ProofRecordNestedDependentPropRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-nested-dependent-prop.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("proof-record-nested-dependent-prop", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordNestedDependentPropRealm); + const value = { tag: "int", value: 1 } as const; + const proof = realm.root.P(value).add(); + realm.root.package.value.set(value); + const view = realm.commit(); + + assert.equal(valueEqual(view.package.evidence.proof.get(), proof), true); +}); + +test("proof-record-nested-dependent-prop retains its proof obligation", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordNestedDependentPropRealm); + const value = { tag: "int", value: 1 } as const; + realm.root.package.value.set(value); + + assert.throws(() => realm.commit(), /\.package\.foreignKey/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-parameter.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-parameter.test.ts deleted file mode 100644 index 87b67c56..00000000 --- a/packages/coln-js-runtime/tests/basic-ir/proof-record-parameter.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Coln contributors -// -// SPDX-License-Identifier: Apache-2.0 OR MIT - -import assert from "node:assert/strict"; -import test from "node:test"; - -import { valueEqual } from "@coln-project/runtime"; -import * as ProofRecordParameterRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-parameter.ts.output/TRealm.ts"; -import { beginRealm } from "./helpers.ts"; - -const expectedFailure = { - expectFailure: { - label: "record arguments are passed as unflattened runtime values", - match: /missing field `tag`/, - }, -}; - -test("proof-record-parameter", expectedFailure, () => { - const realm = beginRealm(ProofRecordParameterRealm); - const equal = realm.root.X.add(); - const value = { - first: equal, - second: equal, - proof: equal, - trailing: equal, - }; - const accepted = realm.root.Accepted(value).add(); - realm.root.select(value).set(equal); - const view = realm.commit(); - - assert.equal(view.Accepted(value).has(accepted), true); - assert.equal(valueEqual(view.select(value).get(), equal), true); -}); - -test( - "proof-record-parameter ignores its nested proof handle", - expectedFailure, - () => { - const realm = beginRealm(ProofRecordParameterRealm); - const equal = realm.root.X.add(); - const trailing = realm.root.X.add(); - const firstValue = { - first: equal, - second: equal, - proof: equal, - trailing, - }; - const secondValue = { ...firstValue, proof: trailing }; - const firstProof = realm.root.Accepted(firstValue).add(); - const secondProof = realm.root.Accepted(secondValue).add(); - for (const equalField of [equal, trailing]) { - for (const trailingField of [equal, trailing]) { - realm.root - .select({ - first: equalField, - second: equalField, - proof: equal, - trailing: trailingField, - }) - .set(trailingField); - } - } - realm.commit(); - - assert.equal(valueEqual(firstProof, secondProof), true); - }, -); - -test("proof-record-parameter retains its erased equality", expectedFailure, () => { - const realm = beginRealm(ProofRecordParameterRealm); - const first = realm.root.X.add(); - const second = realm.root.X.add(); - const trailing = realm.root.X.add(); - const value = { first, second, proof: first, trailing }; - realm.root.Accepted(value).add(); - - assert.throws(() => realm.commit(), /\.Accepted\.foreignKey/); -}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-prop-field.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-prop-field.test.ts new file mode 100644 index 00000000..f39e6243 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-prop-field.test.ts @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as ProofRecordPropFieldRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-prop-field.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("proof-record-prop-field", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordPropFieldRealm); + const proof = realm.root.P.add(); + const view = realm.commit(); + + assert.equal(valueEqual(view.evidence.proof.get(), proof), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record-structural-equality.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record-structural-equality.test.ts new file mode 100644 index 00000000..da63daeb --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record-structural-equality.test.ts @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import * as ProofRecordStructuralEqualityRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record-structural-equality.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("proof-record-structural-equality exposes its equality field", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordStructuralEqualityRealm); + const left = realm.root.X.add(); + const right = realm.root.X.add(); + realm.root.comparison.first.left.set(left); + realm.root.comparison.first.right.set(right); + realm.root.comparison.second.left.set(left); + realm.root.comparison.second.right.set(right); + const view = realm.commit(); + + view.comparison.same.get(); +}); + +test("proof-record-structural-equality retains every leaf equality", { expectFailure: true }, () => { + const realm = beginRealm(ProofRecordStructuralEqualityRealm); + const first = realm.root.X.add(); + const second = realm.root.X.add(); + realm.root.comparison.first.left.set(first); + realm.root.comparison.first.right.set(first); + realm.root.comparison.second.left.set(first); + realm.root.comparison.second.right.set(second); + + assert.throws(() => realm.commit(), /\.comparison\.foreignKey/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/proof-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/proof-record.test.ts index 86e5aeda..bf78d6f1 100644 --- a/packages/coln-js-runtime/tests/basic-ir/proof-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/proof-record.test.ts @@ -2,25 +2,15 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -import assert from "node:assert/strict"; import test from "node:test"; import * as ProofRecordRealm from "../../../coln-compiler/test/golden/basic-ir/proof-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "proof records are emitted as table cells rather than sets", - match: /realm\.root\.witness\(\.\.\.\)\.add is not a function/, - }, -}; - -test("proof-record", expectedFailure, () => { +test("proof-record", { expectFailure: true }, () => { const realm = beginRealm(ProofRecordRealm); const value = realm.root.X.add(); - const proof = realm.root.witness(value).add(); const view = realm.commit(); - assert.equal(view.X.has(value), true); - assert.equal(view.witness(value).has(proof), true); + view.witness(value).proof.get(); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop-alias.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop-alias.test.ts new file mode 100644 index 00000000..8ba1d65a --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/prop-alias.test.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as PropAliasRealm from "../../../coln-compiler/test/golden/basic-ir/prop-alias.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("prop-alias canonicalizes proofs", { expectFailure: true }, () => { + const realm = beginRealm(PropAliasRealm); + const first = realm.root.V.add(); + const second = realm.root.V.add(); + realm.commit(); + + assert.equal(valueEqual(first, second), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop-multi-argument.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop-multi-argument.test.ts index f4027a77..f71d577d 100644 --- a/packages/coln-js-runtime/tests/basic-ir/prop-multi-argument.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/prop-multi-argument.test.ts @@ -9,20 +9,6 @@ import { valueEqual } from "@coln-project/runtime"; import * as PropMultiArgumentRealm from "../../../coln-compiler/test/golden/basic-ir/prop-multi-argument.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedParameterFailure = { - expectFailure: { - label: "a relation treats equal proof parameters as distinct", - match: /false !== true/, - }, -}; - -const expectedCanonicalizationFailure = { - expectFailure: { - label: "a mixed-parameter proposition can contain distinct proofs", - match: /false !== true/, - }, -}; - test("prop-multi-argument", () => { const realm = beginRealm(PropMultiArgumentRealm); const value = realm.root.X.add(); @@ -34,41 +20,6 @@ test("prop-multi-argument", () => { assert.equal(view.R(value)(firstProof)(secondProof).has(relationProof), true); }); -test("prop-multi-argument rejects parameters in the wrong order", () => { - const realm = beginRealm(PropMultiArgumentRealm); - const value = realm.root.X.add(); - const firstProof = realm.root.P.add(); - const secondProof = realm.root.Q.add(); - realm.root.R(firstProof)(value)(secondProof).add(); - - assert.throws(() => realm.commit(), /\.R\.foreignKey/); -}); - -test("prop-multi-argument ignores proof identity in its parameters", expectedParameterFailure, () => { - const realm = beginRealm(PropMultiArgumentRealm); - const value = realm.root.X.add(); - const firstPProof = realm.root.P.add(); - const secondPProof = realm.root.P.add(); - const firstQProof = realm.root.Q.add(); - const secondQProof = realm.root.Q.add(); - const relationProof = realm.root.R(value)(firstPProof)(firstQProof).add(); - const view = realm.commit(); - - assert.equal(view.R(value)(secondPProof)(secondQProof).has(relationProof), true); -}); - -test("prop-multi-argument canonicalizes proofs", expectedCanonicalizationFailure, () => { - const realm = beginRealm(PropMultiArgumentRealm); - const value = realm.root.X.add(); - const firstProof = realm.root.P.add(); - const secondProof = realm.root.Q.add(); - const firstRelationProof = realm.root.R(value)(firstProof)(secondProof).add(); - const secondRelationProof = realm.root.R(value)(firstProof)(secondProof).add(); - realm.commit(); - - assert.equal(valueEqual(firstRelationProof, secondRelationProof), true); -}); - test("prop-multi-argument keeps different Set parameters distinct", () => { const realm = beginRealm(PropMultiArgumentRealm); const firstValue = realm.root.X.add(); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop-record-dependent-equality.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop-record-dependent-equality.test.ts new file mode 100644 index 00000000..1efdcd5c --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/prop-record-dependent-equality.test.ts @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import test from "node:test"; + +import * as PropRecordDependentEqualityRealm from "../../../coln-compiler/test/golden/basic-ir/prop-record-dependent-equality.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("prop-record-dependent-equality retains evidence used by a later equality field", { expectFailure: true }, () => { + const realm = beginRealm(PropRecordDependentEqualityRealm); + realm.root.P.add(); + const view = realm.commit(); + + view.witness.same.get(); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop-record-nested-dependent.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop-record-nested-dependent.test.ts new file mode 100644 index 00000000..da867e76 --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/prop-record-nested-dependent.test.ts @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as PropRecordNestedDependentRealm from "../../../coln-compiler/test/golden/basic-ir/prop-record-nested-dependent.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("prop-record-nested-dependent", { expectFailure: true }, () => { + const realm = beginRealm(PropRecordNestedDependentRealm); + const value = realm.root.X.add(); + const nested = realm.root.P(value).add(); + const direct = realm.root.Q(value).add(); + const proof = realm.root.make(value); + proof.nested.proof.set(nested); + proof.direct.set(direct); + const view = realm.commit(); + const result = view.make(value); + + assert.equal(valueEqual(result.nested.proof.get(), nested), true); + assert.equal(valueEqual(result.direct.get(), direct), true); +}); + +test("prop-record-nested-dependent retains its nested result obligation", () => { + const realm = beginRealm(PropRecordNestedDependentRealm); + const value = realm.root.X.add(); + realm.root.Q(value).add(); + + assert.throws(() => realm.commit(), /rule TRealm\.make/); +}); + +test("prop-record-nested-dependent retains its direct result obligation", () => { + const realm = beginRealm(PropRecordNestedDependentRealm); + const value = realm.root.X.add(); + realm.root.P(value).add(); + + assert.throws(() => realm.commit(), /rule TRealm\.make/); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop-record.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop-record.test.ts index 40b5284e..e3621141 100644 --- a/packages/coln-js-runtime/tests/basic-ir/prop-record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/prop-record.test.ts @@ -9,21 +9,7 @@ import { valueEqual } from "@coln-project/runtime"; import * as PropRecordRealm from "../../../coln-compiler/test/golden/basic-ir/prop-record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFieldFailure = { - expectFailure: { - label: "proposition record fields are not exposed structurally", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -const expectedShapeFailure = { - expectFailure: { - label: "proposition records are exposed as table cells", - match: /Expected values to be strictly deep-equal/, - }, -}; - -test("prop-record", expectedFieldFailure, () => { +test("prop-record", { expectFailure: true }, () => { const realm = beginRealm(PropRecordRealm); const left = realm.root.P.add(); const right = realm.root.Q.add(); @@ -31,26 +17,12 @@ test("prop-record", expectedFieldFailure, () => { pair.left.set(left); pair.right.set(right); const view = realm.commit(); + const made = view.make(left)(right); - assert.equal(view.P.has(left), true); - assert.equal(view.Q.has(right), true); + assert.equal(valueEqual(made.left.get(), left), true); + assert.equal(valueEqual(made.right.get(), right), true); assert.equal( valueEqual(view.projectLeft({ left, right }).get(), left), true, ); }); - -test( - "prop-record exposes its erased fields structurally", - expectedShapeFailure, - () => { - const realm = beginRealm(PropRecordRealm); - const left = realm.root.P.add(); - const right = realm.root.Q.add(); - - assert.deepEqual(Object.keys(realm.root.make(left)(right)), [ - "left", - "right", - ]); - }, -); diff --git a/packages/coln-js-runtime/tests/basic-ir/prop.test.ts b/packages/coln-js-runtime/tests/basic-ir/prop.test.ts index f6bdb9c5..66318f50 100644 --- a/packages/coln-js-runtime/tests/basic-ir/prop.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/prop.test.ts @@ -9,27 +9,6 @@ import { valueEqual } from "@coln-project/runtime"; import * as PropRealm from "../../../coln-compiler/test/golden/basic-ir/prop.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedCanonicalizationFailure = { - expectFailure: { - label: "multiple proofs of a proposition are not canonicalized", - match: /false !== true/, - }, -}; - -const expectedPendingCanonicalizationFailure = { - expectFailure: { - label: "pending proofs of a proposition are not canonicalized", - match: /false !== true/, - }, -}; - -const expectedCardinalityFailure = { - expectFailure: { - label: "a proposition can contain multiple proof rows", - match: /false !== true/, - }, -}; - test("prop may be empty", () => { const realm = beginRealm(PropRealm); const view = realm.commit(); @@ -45,7 +24,7 @@ test("prop", () => { assert.equal(view.V.has(value), true); }); -test("prop canonicalizes proofs", expectedCanonicalizationFailure, () => { +test("prop canonicalizes proofs", { expectFailure: true }, () => { const realm = beginRealm(PropRealm); const first = realm.root.V.add(); const second = realm.root.V.add(); @@ -54,25 +33,16 @@ test("prop canonicalizes proofs", expectedCanonicalizationFailure, () => { assert.equal(valueEqual(first, second), true); }); -test("prop canonicalizes pending proofs", expectedPendingCanonicalizationFailure, () => { - const realm = beginRealm(PropRealm); - const first = realm.root.V.add(); - const second = realm.root.V.add(); - - assert.equal(valueEqual(first, second), true); -}); - test("prop keeps canonical proof handles valid", () => { const realm = beginRealm(PropRealm); - const first = realm.root.V.add(); - const second = realm.root.V.add(); + realm.root.V.add(); + const canonical = realm.root.V.add(); const view = realm.commit(); - assert.equal(view.V.has(first), true); - assert.equal(view.V.has(second), true); + assert.equal(view.V.has(canonical), true); }); -test("prop has at most one proof", expectedCardinalityFailure, () => { +test("prop has at most one proof", { expectFailure: true }, () => { const realm = beginRealm(PropRealm); realm.root.V.add(); realm.root.V.add(); diff --git a/packages/coln-js-runtime/tests/basic-ir/record-field-order.test.ts b/packages/coln-js-runtime/tests/basic-ir/record-field-order.test.ts index 763a4abc..bb9e5979 100644 --- a/packages/coln-js-runtime/tests/basic-ir/record-field-order.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/record-field-order.test.ts @@ -8,14 +8,7 @@ import test from "node:test"; import * as RecordFieldOrderRealm from "../../../coln-compiler/test/golden/basic-ir/record-field-order.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record values are not implemented by the runtime", - match: /missing field `tag`/, - }, -}; - -test("record-field-order", expectedFailure, () => { +test("record-field-order", { expectFailure: true }, () => { const realm = beginRealm(RecordFieldOrderRealm); const pair = { first: { tag: "int", value: 1 }, @@ -25,11 +18,10 @@ test("record-field-order", expectedFailure, () => { const related = realm.root.R(pair)(edge).add(); const view = realm.commit(); - assert.equal(view.E(pair.second)(pair.first).has(edge), true); assert.equal(view.R(pair)(edge).has(related), true); }); -test("record-field-order rejects declaration order as dependency order", expectedFailure, () => { +test("record-field-order rejects declaration order as dependency order", { expectFailure: true }, () => { const realm = beginRealm(RecordFieldOrderRealm); const pair = { first: { tag: "int", value: 1 }, diff --git a/packages/coln-js-runtime/tests/basic-ir/record-nested.test.ts b/packages/coln-js-runtime/tests/basic-ir/record-nested.test.ts new file mode 100644 index 00000000..705daeea --- /dev/null +++ b/packages/coln-js-runtime/tests/basic-ir/record-nested.test.ts @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Coln contributors +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +import assert from "node:assert/strict"; +import test from "node:test"; + +import { valueEqual } from "@coln-project/runtime"; +import * as RecordNestedRealm from "../../../coln-compiler/test/golden/basic-ir/record-nested.ts.output/TRealm.ts"; +import { beginRealm } from "./helpers.ts"; + +test("record-nested", { expectFailure: true }, () => { + const realm = beginRealm(RecordNestedRealm); + const name = { tag: "string", value: "example" } as const; + const rank = { tag: "int", value: 1 } as const; + realm.root.payload.inner.rank.set(rank); + realm.root.payload.name.set(name); + const view = realm.commit(); + + assert.equal(valueEqual(view.payload.name.get(), name), true); + assert.equal(valueEqual(view.payload.inner.rank.get(), rank), true); +}); diff --git a/packages/coln-js-runtime/tests/basic-ir/record.test.ts b/packages/coln-js-runtime/tests/basic-ir/record.test.ts index d3118033..beb42206 100644 --- a/packages/coln-js-runtime/tests/basic-ir/record.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/record.test.ts @@ -9,24 +9,16 @@ import { valueEqual } from "@coln-project/runtime"; import * as RecordRealm from "../../../coln-compiler/test/golden/basic-ir/record.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; -const expectedFailure = { - expectFailure: { - label: "record fields are not exposed through the generated table cell", - match: /Cannot read properties of undefined \(reading 'set'\)/, - }, -}; - -test("record", expectedFailure, () => { +test("record", { expectFailure: true }, () => { const realm = beginRealm(RecordRealm); const point = realm.root.point.add(); const name = { tag: "string", value: "example" } as const; const rank = { tag: "int", value: 1 } as const; const payload = realm.root.payload(point); - payload.name.set(name); payload.rank.set(rank); + payload.name.set(name); const view = realm.commit(); - assert.equal(view.point.has(point), true); assert.equal(valueEqual(view.payload(point).name.get(), name), true); assert.equal(valueEqual(view.payload(point).rank.get(), rank), true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/rule-literals.pending.ts b/packages/coln-js-runtime/tests/basic-ir/rule-literals.pending.ts index 453596ab..1ad7b8f2 100644 --- a/packages/coln-js-runtime/tests/basic-ir/rule-literals.pending.ts +++ b/packages/coln-js-runtime/tests/basic-ir/rule-literals.pending.ts @@ -5,7 +5,6 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { valueEqual } from "@coln-project/runtime"; import * as RuleLiteralsRealm from "../../../coln-compiler/test/golden/basic-ir/rule-literals.ts.output/TRealm.ts"; import { beginRealm } from "./helpers.ts"; @@ -17,12 +16,10 @@ test("rule-literals", () => { const value = realm.root.X.add(); realm.root.count(value).set(count); realm.root.label(value).set(label); - realm.root.countIs19(value).add(); - realm.root.labelIsZombocom(value).add(); const view = realm.commit(); - assert.equal(valueEqual(view.count(value).get(), count), true); - assert.equal(valueEqual(view.label(value).get(), label), true); + view.countIs19(value).get(); + view.labelIsZombocom(value).get(); }); test("rule-literals rejects a different integer", () => { @@ -30,10 +27,8 @@ test("rule-literals rejects a different integer", () => { const value = realm.root.X.add(); realm.root.count(value).set({ tag: "int", value: 20 }); realm.root.label(value).set(label); - realm.root.countIs19(value).add(); - realm.root.labelIsZombocom(value).add(); - assert.throws(() => realm.commit(), /\.countIs19\.foreignKey/); + assert.throws(() => realm.commit(), /rule TRealm\.countIs19/); }); test("rule-literals rejects a different string", () => { @@ -41,8 +36,6 @@ test("rule-literals rejects a different string", () => { const value = realm.root.X.add(); realm.root.count(value).set(count); realm.root.label(value).set({ tag: "string", value: "not-zombocom" }); - realm.root.countIs19(value).add(); - realm.root.labelIsZombocom(value).add(); - assert.throws(() => realm.commit(), /\.labelIsZombocom\.foreignKey/); + assert.throws(() => realm.commit(), /rule TRealm\.labelIsZombocom/); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/set.test.ts b/packages/coln-js-runtime/tests/basic-ir/set.test.ts index cdbd3b57..8801221f 100644 --- a/packages/coln-js-runtime/tests/basic-ir/set.test.ts +++ b/packages/coln-js-runtime/tests/basic-ir/set.test.ts @@ -14,16 +14,4 @@ test("set", () => { const view = realm.commit(); assert.equal(view.V.has(value), true); - assert.equal(value.tag, "row_id"); - if (value.tag !== "row_id") { - assert.fail("set insertion did not return a row ID"); - } - const values = view.V.values(); - const first = values.next(); - assert.equal(first.done, false); - if (first.done) { - assert.fail("committed set was empty"); - } - assert.deepEqual(first.value, { rowId: value.value, values: [] }); - assert.equal(values.next().done, true); }); diff --git a/packages/coln-js-runtime/tests/basic-ir/typecheck.ts b/packages/coln-js-runtime/tests/basic-ir/typecheck.ts index ad1124ef..ca6f6af6 100644 --- a/packages/coln-js-runtime/tests/basic-ir/typecheck.ts +++ b/packages/coln-js-runtime/tests/basic-ir/typecheck.ts @@ -26,147 +26,47 @@ if (config.errors.length !== 0) { throw new Error(formatDiagnostics(config.errors)); } -const knownFailures = new Map([ - [ - "equality", - { - label: "equality generation crashes before producing a realm", - match: /Cannot find module .*equality\.ts\.output\/TRealm\.ts/, - }, - ], - [ - "equality-prop", - { - label: "proof equality generation crashes before producing a realm", - match: /Cannot find module .*equality-prop\.ts\.output\/TRealm\.ts/, - }, - ], - [ - "empty-prop-record", - { - label: "proposition record declarations refer to a missing Truth namespace", - match: /Cannot find namespace 'Truth'/, - }, - ], - [ - "empty-record", - { - label: "empty record declarations refer to a missing Unit namespace", - match: /Cannot find namespace 'Unit'/, - }, - ], - [ - "lookup-record", - { - label: "record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "lookup-record-composition", - { - label: "record declarations refer to missing record namespaces", - match: /Cannot find namespace 'Key'/, - }, - ], - [ - "lookup-record-expansion", - { - label: "record declarations refer to a missing Payload namespace", - match: /Cannot find namespace 'Payload'/, - }, - ], - [ - "lookup-record-field", - { - label: "record declarations refer to a missing Payload namespace", - match: /Cannot find namespace 'Payload'/, - }, - ], - [ - "param-record", - { - label: "record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "param-record-concrete", - { - label: "concrete nested record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "param-record-model", - { - label: "model-parameterized record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "param-record-nested", - { - label: "nested record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "projection", - { - label: "record values are not represented as runtime Values", - match: /does not exist in type 'Value'/, - }, - ], - [ - "proof-record", - { - label: "proof record declarations refer to a missing Witness namespace", - match: /Cannot find namespace 'Witness'/, - }, - ], - [ - "proof-record-mixed", - { - label: "mixed proof record declarations refer to a missing EqualTriple namespace", - match: /Cannot find namespace 'EqualTriple'/, - }, - ], - [ - "proof-record-parameter", - { - label: "proof-bearing record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "prop-record", - { - label: "proposition record declarations refer to a missing And namespace", - match: /Cannot find namespace 'And'/, - }, - ], - [ - "record", - { - label: "record declarations refer to a missing Payload namespace", - match: /Cannot find namespace 'Payload'/, - }, - ], - [ - "record-field-order", - { - label: "record values are not represented as runtime Values", - match: /not assignable to parameter of type 'Value'/, - }, - ], - [ - "rule-literals", - { - label: "equality-valued fields are not supported by TypeScript generation", - match: /Cannot find module .*rule-literals\.ts\.output\/TRealm\.ts/, - }, - ], +const knownFailures = new Set([ + "empty-prop-record", + "empty-prop-record-function", + "empty-record", + "equality", + "equality-prop", + "equality-record", + "equality-record-nested", + "lookup-record", + "lookup-record-composition", + "lookup-record-expansion", + "lookup-record-field", + "param-alias", + "param-alias-set", + "param-record", + "param-record-concrete", + "param-record-dependent-function", + "param-record-dependent-model", + "param-record-function", + "param-record-model", + "param-record-nested", + "param-record-type-family-lambda", + "param-record-type-family-multi-argument", + "param-record-type-family-partial", + "param-record-type-family-prop", + "param-record-type-family-unused", + "projection", + "proof-record", + "proof-record-function-argument", + "proof-record-mixed-fields", + "proof-record-nested-dependent-equality", + "proof-record-nested-dependent-prop", + "proof-record-prop-field", + "proof-record-structural-equality", + "prop-record", + "prop-record-dependent-equality", + "prop-record-nested-dependent", + "record", + "record-field-order", + "record-nested", + "rule-literals", ]); const integrationTestSuffix = /\.(?:pending|test)\.ts$/; @@ -174,24 +74,42 @@ const testFiles = readdirSync(here) .filter((path) => integrationTestSuffix.test(path)) .sort(); +const fixtureNames = new Set( + testFiles.map((path) => path.replace(integrationTestSuffix, "")), +); +for (const name of knownFailures.keys()) { + if (!fixtureNames.has(name)) { + throw new Error(`Known typecheck failure has no fixture: ${name}`); + } +} + +const successfulFiles = testFiles.filter( + (path) => !knownFailures.has(path.replace(integrationTestSuffix, "")), +); + +test("typecheck basic-ir fixtures", () => { + typecheck(successfulFiles); +}); + for (const path of testFiles) { const name = path.replace(integrationTestSuffix, ""); - const expectedFailure = knownFailures.get(name); - - test( - `typecheck ${name}`, - expectedFailure === undefined - ? {} - : { expectFailure: expectedFailure }, - () => { - const program = ts.createProgram([resolve(here, path)], config.options); - const diagnostics = ts.getPreEmitDiagnostics(program); + if (knownFailures.has(name)) { + test(`typecheck ${name}`, { expectFailure: true }, () => { + typecheck([path]); + }); + } +} - if (diagnostics.length !== 0) { - throw new Error(formatDiagnostics(diagnostics)); - } - }, +function typecheck(paths: readonly string[]): void { + const program = ts.createProgram( + paths.map((path) => resolve(here, path)), + config.options, ); + const diagnostics = ts.getPreEmitDiagnostics(program); + + if (diagnostics.length !== 0) { + throw new Error(formatDiagnostics(diagnostics)); + } } function formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string {