Search in sources :

Example 1 with Functor

use of catdata.fqlpp.cat.Functor 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 2 with Functor

use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Transform visit(FQLPPProgram env, Proj e) {
    Functor l = e.l.accept(env, this);
    Functor r = e.r.accept(env, this);
    if (!l.source.equals(r.source)) {
        throw new RuntimeException("Source category does not match");
    }
    if (!l.target.equals(r.target)) {
        throw new RuntimeException("Target category does not match");
    }
    if (l.target.equals(FinSet.FinSet)) {
        return e.proj1 ? Inst.get(l.source).first(l, r) : Inst.get(l.source).second(l, r);
    } else if (l.target.equals(FinCat.FinCat)) {
        return e.proj1 ? FunCat.get(l.source).first(l, r) : FunCat.get(l.source).second(l, r);
    } else {
        throw new RuntimeException("report this error to ryan");
    }
}
Also used : Functor(catdata.fqlpp.cat.Functor)

Example 3 with Functor

use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Transform visit(FQLPPProgram env, TransExp.Iso e) {
    Functor l = e.l.accept(env, this);
    Functor r = e.r.accept(env, this);
    if (!l.source.equals(r.source)) {
        throw new RuntimeException("Source categories do not match: " + l.source + "\nand\n" + r.source);
    }
    if (l.source.isInfinite()) {
        throw new RuntimeException("Source category must be finite.");
    }
    if (!l.target.equals(FinSet.FinSet)) {
        throw new RuntimeException("Target category must be Set.");
    }
    Optional<Pair<Transform, Transform>> k = Inst.get(l.source).iso(l, r);
    if (!k.isPresent()) {
        throw new RuntimeException("Not isomorphic: " + e.l + " and " + e.r);
    }
    return e.lToR ? k.get().first : k.get().second;
}
Also used : Functor(catdata.fqlpp.cat.Functor) Pair(catdata.Pair)

Example 4 with Functor

use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Transform visit(FQLPPProgram env, Whisker e) {
    Functor F = e.func.accept(env, this);
    Transform T = e.trans.accept(env, this);
    return e.left ? Transform.leftWhisker(F, T) : Transform.rightWhisker(F, T);
}
Also used : Functor(catdata.fqlpp.cat.Functor) Transform(catdata.fqlpp.cat.Transform)

Example 5 with Functor

use of catdata.fqlpp.cat.Functor in project fql by CategoricalData.

the class CatOps method visit.

@Override
public Transform visit(FQLPPProgram env, TransExp.Eval e) {
    Functor a = e.a.accept(env, this);
    Functor b = e.b.accept(env, this);
    if (!a.source.equals(b.source) || a.source.isInfinite() || !a.target.equals(FinSet.FinSet)) {
        throw new RuntimeException("Cannot eval " + a + " and " + b);
    }
    return Inst.get(a.source).eval(a, b);
}
Also used : Functor(catdata.fqlpp.cat.Functor)

Aggregations

Functor (catdata.fqlpp.cat.Functor)30 Transform (catdata.fqlpp.cat.Transform)18 Category (catdata.fqlpp.cat.Category)14 Fn (catdata.fqlpp.cat.FinSet.Fn)14 Pair (catdata.Pair)13 Const (catdata.fqlpp.CatExp.Const)13 FinSet (catdata.fqlpp.cat.FinSet)13 Signature (catdata.fqlpp.cat.Signature)13 Node (catdata.fqlpp.cat.Signature.Node)13 Triple (catdata.Triple)12 FinCat (catdata.fqlpp.cat.FinCat)12 FunCat (catdata.fqlpp.cat.FunCat)12 Inst (catdata.fqlpp.cat.Inst)12 Edge (catdata.fqlpp.cat.Signature.Edge)12 CatConst (catdata.fqlpp.FunctorExp.CatConst)10 FinalConst (catdata.fqlpp.FunctorExp.FinalConst)10 Chc (catdata.Chc)9 CatExpVisitor (catdata.fqlpp.CatExp.CatExpVisitor)9 Cod (catdata.fqlpp.CatExp.Cod)9 Colim (catdata.fqlpp.CatExp.Colim)9