Search in sources :

Example 16 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class Inst method terminal.

public Transform<O, A, Set, Fn> terminal(Functor<O, A, Set, Fn> o) {
    Set<Unit> ret = new HashSet<>();
    ret.add(new Unit());
    FUNCTION<O, Fn> fn = x -> new Fn(o.applyO(x), ret, y -> new Unit());
    return new Transform<>(o, terminal(), fn);
}
Also used : Fn(catdata.fqlpp.cat.FinSet.Fn) FUNCTION(catdata.fqlpp.FUNCTION) Chc(catdata.Chc) Util(catdata.Util) Set(java.util.Set) HashMap(java.util.HashMap) Unit(catdata.Unit) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) Map(java.util.Map) Entry(java.util.Map.Entry) Optional(java.util.Optional) LinkedList(java.util.LinkedList) Pair(catdata.Pair) Fn(catdata.fqlpp.cat.FinSet.Fn) Unit(catdata.Unit) HashSet(java.util.HashSet)

Example 17 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class Instance method terminal.

public static <X, Y> Instance<X, Y> terminal(Signature<X, Y> sig) {
    Map<Signature<X, Y>.Node, Set<Object>> objs = new HashMap<>();
    Map<Signature<X, Y>.Edge, Map<Object, Object>> arrs = new HashMap<>();
    Set<Object> s = new HashSet<>();
    s.add(new Unit());
    for (Signature<X, Y>.Node k : sig.nodes) {
        objs.put(k, s);
    }
    Map<Object, Object> t = new HashMap<>();
    t.put(new Unit(), new Unit());
    for (Signature<X, Y>.Edge k : sig.edges) {
        arrs.put(k, t);
    }
    return new Instance<>(objs, arrs, sig);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Unit(catdata.Unit) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 18 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class FinSet method terminal.

public static Set<Unit> terminal() {
    Set<Unit> ret = new HashSet<>();
    ret.add(new Unit());
    return ret;
}
Also used : Unit(catdata.Unit) HashSet(java.util.HashSet)

Example 19 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class Constraints method step.

// TODO aql needs to be over all eds
public <Gen, Sk, X, Y> Instance<Ty, En, Sym, Fk, Att, ?, ?, ?, ?> step(Instance<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> I, AqlOptions options) {
    Collection<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>> T = triggers(I, options);
    if (T.isEmpty()) {
        return null;
    }
    DMG<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Void> shape = new DMG<>(T, new HashMap<>());
    Ctx<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Instance<Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>>> nodesA = new Ctx<>();
    Ctx<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Instance<Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>>> nodesE = new Ctx<>();
    Map<Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Term<Void, En, Void, Fk, Void, Gen, Void>> aaa = new HashMap<>();
    Map<Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Term<Void, En, Void, Fk, Void, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Void>> xxx = new HashMap<>();
    for (Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>> t : T) {
        Query<Ty, En, Sym, Fk, Att, WHICH, Unit, Void> Q = t.first.Q;
        Instance<Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>> A = Q.ens.get(WHICH.FRONT);
        Instance<Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>> E = Q.ens.get(WHICH.BACK);
        Transform<Ty, En, Sym, Fk, Att, Var, Var, Var, Var, ID, Chc<Var, Pair<ID, Att>>, ID, Chc<Var, Pair<ID, Att>>> AE = Q.fks.get(new Unit());
        nodesA.put(t, A);
        nodesE.put(t, E);
        for (Var v : AE.src().gens().keySet()) {
            // revisit after colimit fixed
            xxx.put(new Pair<>(t, v), Term.Gen(new Pair<>(t, v)));
            aaa.put(new Pair<>(t, v), I.algebra().repr(t.second.get(v)));
        }
    /*for (Void v : AE.src().sks().keySet()) {
				yyy.put(v, Util.abort(v)); // revisit after colimit fixed
				bbb.put(v, Util.abort(v));
			}*/
    }
    ColimitInstance<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Void, Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>> A0 = new ColimitInstance<>(schema, shape, nodesA, new Ctx<>(), options);
    ColimitInstance<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Void, Ty, En, Sym, Fk, Att, Var, Var, ID, Chc<Var, Pair<ID, Att>>> E0 = new ColimitInstance<>(schema, shape, nodesE, new Ctx<>(), options);
    LiteralTransform<Ty, En, Sym, Fk, Att, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, ID, Chc<Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<ID, Att>>, ID, Chc<Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<ID, Att>>> A0E0 = new LiteralTransform<>(xxx, new HashMap<>(), A0, E0, false);
    LiteralTransform<Ty, En, Sym, Fk, Att, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Gen, Sk, ID, Chc<Pair<Pair<ED<Ty, En, Sym, Fk, Att>, Row<WHICH, X>>, Var>, Pair<ID, Att>>, X, Y> A0I = new LiteralTransform<>(aaa, new HashMap<>(), A0, I, false);
    return pushout(A0E0, A0I, options);
// TODO aql disable checking for speed
}
Also used : EvalInstance(catdata.aql.fdm.EvalInstance) ColimitInstance(catdata.aql.fdm.ColimitInstance) HashMap(java.util.HashMap) Ctx(catdata.Ctx) ColimitInstance(catdata.aql.fdm.ColimitInstance) Unit(catdata.Unit) WHICH(catdata.aql.ED.WHICH) ID(catdata.aql.It.ID) Pair(catdata.Pair) DMG(catdata.graph.DMG) LiteralTransform(catdata.aql.fdm.LiteralTransform) Row(catdata.aql.fdm.EvalAlgebra.Row) Chc(catdata.Chc)

Example 20 with Unit

use of catdata.Unit in project fql by CategoricalData.

the class ED method getEDSchema.

public static <Ty, Sym> Schema<Ty, WHICH, Sym, Unit, Void> getEDSchema(TypeSide<Ty, Sym> ty, AqlOptions ops) {
    Collage<Ty, WHICH, Sym, Unit, Void, Void, Void> col = new Collage<>(ty.collage());
    col.ens.add(WHICH.FRONT);
    col.ens.add(WHICH.BACK);
    col.fks.put(new Unit(), new Pair<>(WHICH.BACK, WHICH.FRONT));
    // TODO aq;
    Schema<Ty, WHICH, Sym, Unit, Void> ret = new Schema<>(ty, col.ens, col.atts.map, col.fks.map, new HashSet<>(), AqlProver.create(ops, col, ty.js), true);
    return ret;
}
Also used : Unit(catdata.Unit)

Aggregations

Unit (catdata.Unit)29 Pair (catdata.Pair)16 LinkedList (java.util.LinkedList)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)10 List (java.util.List)9 Map (java.util.Map)8 Set (java.util.Set)8 Chc (catdata.Chc)6 Util (catdata.Util)6 Fn (catdata.fqlpp.cat.FinSet.Fn)6 JPanel (javax.swing.JPanel)6 GridLayout (java.awt.GridLayout)5 LinkedHashMap (java.util.LinkedHashMap)5 Collectors (java.util.stream.Collectors)5 FUNCTION (catdata.fqlpp.FUNCTION)4 CodeTextPanel (catdata.ide.CodeTextPanel)4 Entry (java.util.Map.Entry)4 Triple (catdata.Triple)3 Optional (java.util.Optional)3