use of catdata.fqlpp.cat.FinSet.Fn in project fql by CategoricalData.
the class Inst method not.
private Functor<O, A, Set, Fn> not(Functor<O, A, Set<A>, Fn<A, A>> Hc, Functor<O, A, Set, Fn> I) {
Map<O, Set<A>> nm = new HashMap<>();
for (O d : cat.objects()) {
Set<A> s = new HashSet<>();
xxx: for (A ff : Hc.applyO(d)) {
for (O d0 : cat.objects()) {
for (A g : cat.hom(d, d0)) {
A fg = cat.compose(ff, g);
if (I.applyO(d0).contains(fg)) {
continue xxx;
}
}
}
s.add(ff);
}
nm.put(d, s);
}
Map<A, Fn> em = new HashMap<>();
for (A h : cat.arrows()) {
Map<Object, Object> dd = new HashMap<>();
for (A ff : nm.get(cat.source(h))) {
A fg = cat.compose(ff, h);
dd.put(ff, fg);
}
em.put(h, new Fn(nm.get(cat.source(h)), nm.get(cat.target(h)), dd::get));
}
return new Functor<>(cat, FinSet.FinSet, nm::get, em::get);
}
use of catdata.fqlpp.cat.FinSet.Fn in project fql by CategoricalData.
the class Inst method curry.
public Transform<O, A, Set, Fn> curry(Transform<O, A, Set, Fn> t) {
Functor<O, A, Set, Fn> IJ = t.source;
Functor<O, A, Set, Fn> K = t.target;
Pair<Functor<O, A, Set, Fn>, Functor<O, A, Set, Fn>> IJx = split(IJ);
Functor<O, A, Set, Fn> I = IJx.first;
Functor<O, A, Set, Fn> J = IJx.second;
Functor<O, A, Set<Transform<O, A, Set, Fn>>, Fn<Transform<O, A, Set, Fn>, Transform<O, A, Set, Fn>>> JK = exp(K, J);
Map<O, Fn> l = new HashMap<>();
for (O c : I.source.objects()) {
Map<Object, Transform<O, A, Set, Fn>> s = new HashMap<>();
for (Object x : I.applyO(c)) {
// construct transform depending on x
Map<O, Map<Object, Object>> tx = new HashMap<>();
for (O d : I.source.objects()) {
Map<Object, Object> tx0 = new HashMap<>();
for (A f : I.source.hom(c, d)) {
for (Object y : J.applyO(d)) {
Object Ifx = I.applyA(f).apply(x);
Object v = t.apply(d).apply(new Pair<>(Ifx, y));
tx0.put(new Pair<>(y, f), v);
}
}
tx.put(d, tx0);
}
Functor<O, A, Set, Fn> ppp = (Functor<O, A, Set, Fn>) ((Object) I.source.repX().first.get(c));
Functor<O, A, Set, Fn> qqq = product(J, ppp);
// Hc * J -> K
Transform<O, A, Set, Fn> xxx = new Transform<>(qqq, K, o -> new Fn<>(qqq.applyO(o), K.applyO(o), tx.get(o)::get));
s.put(x, xxx);
}
l.put(c, new Fn(I.applyO(c), JK.applyO(c), s::get));
}
Transform zzz = new Transform(I, JK, l::get);
return zzz;
}
use of catdata.fqlpp.cat.FinSet.Fn in project fql by CategoricalData.
the class Pi method pi.
public static <O1, A1, O2, A2> Triple<Functor<O2, A2, Set, Fn>, Map<O2, Set<Map>>, Map<O2, Triple<O2, O1, A2>[]>> pi(Functor<O1, A1, O2, A2> F, Functor<O1, A1, Set, Fn> inst) {
Category<O2, A2> D = F.target;
Category<O1, A1> C = F.source;
Map<O2, Set> ret1 = new HashMap<>();
Map<A2, Map> ret2 = new HashMap<>();
Map<O2, Triple<O2, O1, A2>[]> nodecats = new HashMap<>();
Map<O2, Set<Map>> nodetables = new HashMap<>();
for (O2 d0 : D.objects()) {
Triple<Category<Triple<O2, O1, A2>, Quad<A2, A1, A2, A2>>, Functor<Triple<O2, O1, A2>, Quad<A2, A1, A2, A2>, O2, A2>, Functor<Triple<O2, O1, A2>, Quad<A2, A1, A2, A2>, O1, A1>> B = doComma2(D, C, F, d0);
Set<Map> r = lim2(Functor.compose(B.third, inst));
if (r != null) {
ret1.put(d0, squish(r));
nodetables.put(d0, r);
}
nodecats.put(d0, cnames(B.first));
}
for (A2 s : D.arrows()) {
O2 dA = D.source(s);
Set<Map> q1 = nodetables.get(dA);
Triple<O2, O1, A2>[] cnames1 = nodecats.get(dA);
O2 dB = D.target(s);
Set<Map> q2 = nodetables.get(dB);
Triple<O2, O1, A2>[] cnames2 = nodecats.get(dB);
Set<Map> raw = product(q2, q1);
Set<Map> rax = subset2(D, s, cnames2, cnames1, raw);
Map<Object, Object> ray = project(rax, cnames2.length + 1, 0);
ret2.put(s, ray);
}
Functor<O2, A2, Set, Fn> ret = new Functor<>(F.target, FinSet.FinSet, ret1::get, a -> new Fn<>(ret1.get(F.target.source(a)), ret1.get(F.target.target(a)), ret2.get(a)::get));
Triple xxx = new Triple<>(ret, nodetables, nodecats);
return xxx;
}
Aggregations