Search in sources :

Example 1 with MapConst

use of catdata.fqlpp.FunctorExp.MapConst in project fql by CategoricalData.

the class Ben method colim.

public static Const colim(FQLPPProgram env, CatConst f) {
    if (!(f.sig instanceof CatExp.Var)) {
        throw new RuntimeException(f.sig + " is not variable, is " + f.sig.getClass());
    }
    CatExp c = env.cats.get(((CatExp.Var) f.sig).v);
    if (!(c instanceof Const)) {
        throw new RuntimeException(c + " is not finitely presented, is " + c.getClass());
    }
    Const src = (Const) c;
    Map<String, Const> obMapping = new HashMap<>();
    Map<String, MapConst> arrMapping = new HashMap<>();
    for (String src_ob : f.nm.keySet()) {
        CatExp C = f.nm.get(src_ob);
        if (!(C instanceof CatExp.Var)) {
            throw new RuntimeException(C + " is not a variable");
        }
        CatExp D = env.cats.get(((CatExp.Var) C).v);
        if (!(D instanceof Const)) {
            throw new RuntimeException(D + " is not finitely presented");
        }
        obMapping.put(src_ob, (Const) D);
    }
    for (String src_arr : f.em.keySet()) {
        FunctorExp C = f.em.get(src_arr);
        if (!(C instanceof Var)) {
            throw new RuntimeException(C + " is not a variable");
        }
        FunctorExp D = env.ftrs.get(((Var) C).v);
        if (!(D instanceof MapConst)) {
            throw new RuntimeException(D + " is not finitely presented");
        }
        arrMapping.put(src_arr, (MapConst) D);
    }
    return sandbox(src, obMapping, arrMapping);
}
Also used : HashMap(java.util.HashMap) Var(catdata.fqlpp.FunctorExp.Var) Const(catdata.fqlpp.CatExp.Const) MapConst(catdata.fqlpp.FunctorExp.MapConst) CatConst(catdata.fqlpp.FunctorExp.CatConst) MapConst(catdata.fqlpp.FunctorExp.MapConst)

Example 2 with MapConst

use of catdata.fqlpp.FunctorExp.MapConst in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Functor visit(FQLPPProgram env, MapConst ic) {
    Triple<Category, Category, Mapping<String, String, String, String>> xxx = toMapping(env, ic);
    Mapping<String, String, String, String> I = xxx.third;
    FUNCTION f = p0 -> {
        Path p = (Path) p0;
        return I.apply(p);
    };
    Functor et = new Functor(xxx.first, xxx.second, x -> I.nm.get(x), f);
    et.mapping0 = xxx.third;
    return et;
}
Also used : PeterApply(catdata.fqlpp.TransExp.PeterApply) FiniteCategory(catdata.fqlpp.cat.FiniteCategory) Named(catdata.fqlpp.CatExp.Named) Edge(catdata.fqlpp.cat.Signature.Edge) Snd(catdata.fqlpp.FunctorExp.Snd) Comp(catdata.fqlpp.FunctorExp.Comp) ToInst(catdata.fqlpp.TransExp.ToInst) Id(catdata.fqlpp.FunctorExp.Id) Inr(catdata.fqlpp.FunctorExp.Inr) FF(catdata.fqlpp.FunctorExp.FF) Migrate(catdata.fqlpp.FunctorExp.Migrate) Colim(catdata.fqlpp.CatExp.Colim) Exp(catdata.fqlpp.CatExp.Exp) Pushout(catdata.fqlpp.FunctorExp.Pushout) FinCat(catdata.fqlpp.cat.FinCat) FunCat(catdata.fqlpp.cat.FunCat) Pair(catdata.Pair) CoMonad(catdata.fqlpp.cat.CoMonad) Iso(catdata.fqlpp.FunctorExp.Iso) ApplyPath(catdata.fqlpp.TransExp.ApplyPath) Inj(catdata.fqlpp.TransExp.Inj) Fn(catdata.fqlpp.cat.FinSet.Fn) Bool(catdata.fqlpp.TransExp.Bool) Case(catdata.fqlpp.FunctorExp.Case) ToMap(catdata.fqlpp.TransExp.ToMap) Zero(catdata.fqlpp.CatExp.Zero) Monad(catdata.fqlpp.cat.Monad) Plus(catdata.fqlpp.CatExp.Plus) Category(catdata.fqlpp.cat.Category) CatConst(catdata.fqlpp.FunctorExp.CatConst) Inst(catdata.fqlpp.cat.Inst) ToSet(catdata.fqlpp.TransExp.ToSet) Groth(catdata.fqlpp.cat.Groth) Mapping(catdata.fqlpp.cat.Mapping) Serializable(java.io.Serializable) Kleisli(catdata.fqlpp.CatExp.Kleisli) ApplyTrans(catdata.fqlpp.TransExp.ApplyTrans) SetSetConst(catdata.fqlpp.FunctorExp.SetSetConst) Dom(catdata.fqlpp.CatExp.Dom) Triple(catdata.Triple) Eval(catdata.fqlpp.FunctorExp.Eval) Var(catdata.fqlpp.FunctorExp.Var) Times(catdata.fqlpp.CatExp.Times) Const(catdata.fqlpp.CatExp.Const) java.util(java.util) Prod(catdata.fqlpp.FunctorExp.Prod) InstConst(catdata.fqlpp.FunctorExp.InstConst) Node(catdata.fqlpp.cat.Signature.Node) Chc(catdata.Chc) TT(catdata.fqlpp.FunctorExp.TT) Functor(catdata.fqlpp.cat.Functor) Proj(catdata.fqlpp.TransExp.Proj) Prop(catdata.fqlpp.FunctorExp.Prop) CatExpVisitor(catdata.fqlpp.CatExp.CatExpVisitor) Signature(catdata.fqlpp.cat.Signature) TransExpVisitor(catdata.fqlpp.TransExp.TransExpVisitor) Union(catdata.fqlpp.CatExp.Union) ToCat(catdata.fqlpp.TransExp.ToCat) One(catdata.fqlpp.CatExp.One) FDM(catdata.fqlpp.cat.FDM) Ker(catdata.fqlpp.TransExp.Ker) Fst(catdata.fqlpp.FunctorExp.Fst) Whisker(catdata.fqlpp.TransExp.Whisker) Curry(catdata.fqlpp.FunctorExp.Curry) Transform(catdata.fqlpp.cat.Transform) Apply(catdata.fqlpp.FunctorExp.Apply) Instance(catdata.fqlpp.cat.Instance) MapConst(catdata.fqlpp.FunctorExp.MapConst) Path(catdata.fqlpp.cat.Signature.Path) Pivot(catdata.fqlpp.FunctorExp.Pivot) Chr(catdata.fqlpp.TransExp.Chr) Cod(catdata.fqlpp.CatExp.Cod) FinSet(catdata.fqlpp.cat.FinSet) Uncurry(catdata.fqlpp.FunctorExp.Uncurry) FunctorExpVisitor(catdata.fqlpp.FunctorExp.FunctorExpVisitor) Adj(catdata.fqlpp.TransExp.Adj) SetSet(catdata.fqlpp.TransExp.SetSet) AndOrNotImplies(catdata.fqlpp.TransExp.AndOrNotImplies) FinalConst(catdata.fqlpp.FunctorExp.FinalConst) Inl(catdata.fqlpp.FunctorExp.Inl) CoProd(catdata.fqlpp.TransExp.CoProd) ApplyPath(catdata.fqlpp.TransExp.ApplyPath) Path(catdata.fqlpp.cat.Signature.Path) FiniteCategory(catdata.fqlpp.cat.FiniteCategory) Category(catdata.fqlpp.cat.Category) Mapping(catdata.fqlpp.cat.Mapping) Functor(catdata.fqlpp.cat.Functor)

Example 3 with MapConst

use of catdata.fqlpp.FunctorExp.MapConst in project fql by CategoricalData.

the class PPParser method toMapConst.

private static FunctorExp toMapConst(Object decl) {
    Tuple5 y = (Tuple5) decl;
    org.jparsec.functors.Pair x = (org.jparsec.functors.Pair) y.a;
    Tuple3 nodes = (Tuple3) x.a;
    Tuple3 arrows = (Tuple3) x.b;
    List nodes0 = (List) nodes.b;
    List arrows0 = (List) arrows.b;
    Map<String, String> nodesX = new HashMap<>();
    for (Object o : nodes0) {
        if (nodesX.containsKey(o)) {
            throw new RuntimeException("Duplicate object: " + o + " in " + decl);
        }
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        String l = u.c.toString();
        nodesX.put(n, l);
    }
    Map<String, Pair<String, List<String>>> arrowsX = new HashMap<>();
    for (Object o : arrows0) {
        if (arrowsX.containsKey(o)) {
            throw new RuntimeException("Duplicate arrow: " + o + " in " + decl);
        }
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        List<String> l = (List<String>) u.c;
        String ll = l.remove(0);
        arrowsX.put(n, new Pair<>(ll, l));
    }
    MapConst ret = new MapConst(toCat(y.c), toCat(y.e), nodesX, arrowsX);
    return ret;
}
Also used : HashMap(java.util.HashMap) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) MapConst(catdata.fqlpp.FunctorExp.MapConst) Pair(catdata.Pair)

Example 4 with MapConst

use of catdata.fqlpp.FunctorExp.MapConst in project fql by CategoricalData.

the class CatOps method toMapping.

private Triple<Category, Category, Mapping<String, String, String, String>> toMapping(FQLPPProgram env, MapConst ic) {
    CatExp src0 = resolve(env, ic.src);
    if (src0 == null) {
        throw new RuntimeException("Missing category: " + ic.src);
    }
    if (!(src0 instanceof Const)) {
        throw new RuntimeException("Can only create mappings for finitely-presented categories.");
    }
    Const src = (Const) src0;
    CatExp dst0 = resolve(env, ic.dst);
    if (!(dst0 instanceof Const)) {
        throw new RuntimeException("Can only create mappings for finitely-presented categories.");
    }
    Const dst = (Const) dst0;
    Category srcX = src.accept(env, this);
    Category dstX = dst.accept(env, this);
    Signature<String, String> srcY = new Signature<>(src.nodes, src.arrows, src.eqs);
    Signature<String, String> dstY = new Signature<>(dst.nodes, dst.arrows, dst.eqs);
    Map<Node, Node> nm = new HashMap<>();
    for (String n0 : ic.nm.keySet()) {
        Signature<String, String>.Node n = srcY.getNode(n0);
        String v = ic.nm.get(n.name);
        if (v == null) {
            throw new RuntimeException("Missing object mapping for " + n.name);
        }
        nm.put(n, dstY.getNode(v));
    }
    Map<Edge, Path> em = new HashMap<>();
    for (String n0 : ic.em.keySet()) {
        Signature<String, String>.Edge n = srcY.getEdge(n0);
        Pair<String, List<String>> k = ic.em.get(n.name);
        if (k == null) {
            throw new RuntimeException("Missing arrow mapping for " + n.name);
        }
        em.put(n, dstY.path(k.first, k.second));
    }
    Mapping<String, String, String, String> I = new Mapping(nm, em, srcY, dstY);
    return new Triple<>(srcX, dstX, I);
}
Also used : ApplyPath(catdata.fqlpp.TransExp.ApplyPath) Path(catdata.fqlpp.cat.Signature.Path) FiniteCategory(catdata.fqlpp.cat.FiniteCategory) Category(catdata.fqlpp.cat.Category) CatConst(catdata.fqlpp.FunctorExp.CatConst) SetSetConst(catdata.fqlpp.FunctorExp.SetSetConst) Const(catdata.fqlpp.CatExp.Const) InstConst(catdata.fqlpp.FunctorExp.InstConst) MapConst(catdata.fqlpp.FunctorExp.MapConst) FinalConst(catdata.fqlpp.FunctorExp.FinalConst) Node(catdata.fqlpp.cat.Signature.Node) Mapping(catdata.fqlpp.cat.Mapping) Triple(catdata.Triple) Signature(catdata.fqlpp.cat.Signature) Edge(catdata.fqlpp.cat.Signature.Edge)

Aggregations

MapConst (catdata.fqlpp.FunctorExp.MapConst)4 Const (catdata.fqlpp.CatExp.Const)3 CatConst (catdata.fqlpp.FunctorExp.CatConst)3 Pair (catdata.Pair)2 Triple (catdata.Triple)2 FinalConst (catdata.fqlpp.FunctorExp.FinalConst)2 InstConst (catdata.fqlpp.FunctorExp.InstConst)2 SetSetConst (catdata.fqlpp.FunctorExp.SetSetConst)2 Var (catdata.fqlpp.FunctorExp.Var)2 Chc (catdata.Chc)1 CatExpVisitor (catdata.fqlpp.CatExp.CatExpVisitor)1 Cod (catdata.fqlpp.CatExp.Cod)1 Colim (catdata.fqlpp.CatExp.Colim)1 Dom (catdata.fqlpp.CatExp.Dom)1 Exp (catdata.fqlpp.CatExp.Exp)1 Kleisli (catdata.fqlpp.CatExp.Kleisli)1 Named (catdata.fqlpp.CatExp.Named)1 One (catdata.fqlpp.CatExp.One)1 Plus (catdata.fqlpp.CatExp.Plus)1 Times (catdata.fqlpp.CatExp.Times)1