use of catdata.Triple in project fql by CategoricalData.
the class PSMEval method exec.
@Override
public void exec(PSMInterp interp, Map<String, Set<Map<Object, Object>>> state) {
try {
Quad<Instance, Map<Pair<Node, LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>>, Triple<Instance, Map<Node, Map<Object, Pair<Arr<Node, Path>, Object>>>, Map<Node, Map<Pair<Arr<Node, Path>, Object>, Object>>>>, Map<Node, Map<Object, Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>>>, Map<Node, Map<Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>, Object>>> xxx = interp.exps2.get(AB);
Instance Jw = xxx.first;
Map<Pair<Node, LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>>, Triple<Instance, Map<Node, Map<Object, Pair<Arr<Node, Path>, Object>>>, Map<Node, Map<Pair<Arr<Node, Path>, Object>, Object>>>> map = xxx.second;
Map<Node, Map<Object, Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>>> map2 = xxx.third;
FinCat<Node, Path> cat = Jw.thesig.toCategory2().first;
Instance abb = new Instance(sig, PSMGen.gather(ABB, sig, state));
// Instance ab = new Instance(sig, PSMGen.gather(AB, sig, state));
// //already have in interp
Instance a = new Instance(sig, PSMGen.gather(A, sig, state));
Instance b = new Instance(sig, PSMGen.gather(B, sig, state));
Transform fst = new Transform(abb, Jw, PSMGen.gather(ABB + "_fst", sig, state));
Transform snd = new Transform(abb, b, PSMGen.gather(ABB + "_snd", sig, state));
List<Pair<String, List<Pair<Object, Object>>>> data = new LinkedList<>();
for (Node n : sig.nodes) {
List<Pair<Object, Object>> d = new LinkedList<>();
Map<Object, Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>> m2 = map2.get(n);
for (Pair<Object, Object> id : abb.data.get(n.string)) {
Object id_ab = lookup(fst.data.get(n.string), id.first);
Object x = lookup(snd.data.get(n.string), id.first);
Transform t = m2.get(id_ab).second;
LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object> w = m2.get(id_ab).first;
Triple<Instance, Map<Node, Map<Object, Pair<Arr<Node, Path>, Object>>>, Map<Node, Map<Pair<Arr<Node, Path>, Object>, Object>>> m = map.get(new Pair<>(n, w));
Object y = m.third.get(n).get(new Pair<>(cat.id(n), x));
Object f = lookup(t.data.get(n.string), y);
d.add(new Pair<>(id.first, f));
}
data.add(new Pair<>(n.string, d));
}
Transform curry = new Transform(abb, a, data);
PSMGen.shred(pre, curry, state);
} catch (FQLException fe) {
fe.printStackTrace();
throw new RuntimeException(fe.getMessage());
}
}
use of catdata.Triple in project fql by CategoricalData.
the class OplOps method visit.
@Override
public OplObject visit(Program<OplExp> env, OplColim e) {
OplObject o = ENV.get(e.name);
if (!(o instanceof OplGraph)) {
throw new RuntimeException("Not a graph: " + e.name);
}
OplGraph<String, String> shape = (OplGraph<String, String>) o;
OplObject base0 = ENV.get(e.base);
String typeSide;
if (base0 instanceof OplSig) {
typeSide = e.base;
OplUnion u0 = new OplUnion(new LinkedList<>(shape.nodes), typeSide);
OplObject u1 = u0.accept(env, this);
OplSchema<String, String, String> u = (OplSchema<String, String, String>) u1;
Map<String, Set<String>> equivs = new HashMap<>();
Map<String, String> equivs0 = new HashMap<>();
for (String schname : shape.nodes) {
OplSchema<String, String, String> sch = (OplSchema<String, String, String>) ENV.get(schname);
for (String ename : sch.entities) {
Set<String> set = new HashSet<>();
set.add(schname + "_" + ename);
equivs.put(schname + "_" + ename, set);
}
}
// : type check colimit
for (String mname : shape.edges.keySet()) {
Pair<String, String> mt = shape.edges.get(mname);
String s = mt.first;
String t = mt.second;
OplSchema<String, String, String> s0 = (OplSchema<String, String, String>) ENV.get(s);
OplTyMapping<String, String, String, String, String> m0 = (OplTyMapping<String, String, String, String, String>) ENV.get(mname);
if (!m0.src0.equals(s)) {
throw new RuntimeException("Source of " + m0 + " is " + m0.src + " and not " + s + "as expected");
}
if (!m0.dst0.equals(t)) {
throw new RuntimeException("Target of " + m0 + " is " + m0.dst + " and not " + t + "as expected");
}
for (String ob : s0.entities) {
String ob0 = m0.m.sorts.get(ob);
Set<String> set1 = equivs.get(s + "_" + ob);
Set<String> set2 = equivs.get(t + "_" + ob0);
set1.addAll(set2);
equivs.put(s + "_" + ob, set1);
equivs.put(t + "_" + ob0, set1);
}
}
for (String k : equivs.keySet()) {
List<String> v = new LinkedList<>(equivs.get(k));
v.sort(String.CASE_INSENSITIVE_ORDER);
equivs0.put(k, Util.sep(v, "__"));
}
Set<String> entities = new HashSet<>(equivs0.values());
Map<String, Pair<List<String>, String>> edges = new HashMap<>();
Map<String, Pair<List<String>, String>> attrs = new HashMap<>();
List<Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>>> pathEqs = new LinkedList<>();
List<Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>>> obsEqs = new LinkedList<>();
Function<String, String> fun = x -> {
if (equivs0.containsKey(x)) {
return equivs0.get(x);
}
return x;
};
for (String edge : u.toSchema0().edges.keySet()) {
Pair<List<String>, String> ty = u.toSchema0().edges.get(edge);
edges.put(edge, new Pair<>(ty.first.stream().map(fun).collect(Collectors.toList()), fun.apply(ty.second)));
}
for (String attr : u.toSchema0().attrs.keySet()) {
Pair<List<String>, String> ty = u.toSchema0().attrs.get(attr);
attrs.put(attr, new Pair<>(ty.first.stream().map(fun).collect(Collectors.toList()), fun.apply(ty.second)));
}
for (Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>> eq : u.toSchema0().pathEqs) {
OplCtx<String, String> ctx = new OplCtx<>(eq.first.values2().stream().map(x -> new Pair<>(x.first, fun.apply(x.second))).collect(Collectors.toList()));
pathEqs.add(new Triple<>(ctx, fun2(equivs0, eq.second), fun2(equivs0, eq.third)));
}
for (Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>> eq : u.toSchema0().obsEqs) {
OplCtx<String, String> ctx = new OplCtx<>(eq.first.values2().stream().map(x -> new Pair<>(x.first, fun.apply(x.second))).collect(Collectors.toList()));
obsEqs.add(new Triple<>(ctx, fun2(equivs0, eq.second), fun2(equivs0, eq.third)));
}
for (String mname : shape.edges.keySet()) {
Pair<String, String> mt = shape.edges.get(mname);
String s = mt.first;
String t = mt.second;
OplSchema<String, String, String> s0 = (OplSchema<String, String, String>) ENV.get(s);
// OplSchema<String, String, String> t0 = (OplSchema<String,
// String, String>) ENV.get(t);
OplTyMapping<String, String, String, String, String> m0 = (OplTyMapping<String, String, String, String, String>) ENV.get(mname);
for (String edge : s0.projE().symbols.keySet()) {
Pair<OplCtx<String, String>, OplTerm<String, String>> edge2 = m0.m.symbols.get(edge);
List<OplTerm<String, String>> args = edge2.first.vars0.keySet().stream().map((Function<String, OplTerm<String, String>>) OplTerm::new).collect(Collectors.toList());
OplTerm<String, String> lhs = fun2(equivs0, new OplTerm<>(s + "_" + edge, args));
OplCtx<String, String> ctx = new OplCtx<>(edge2.first.values2().stream().map(x -> new Pair<>(x.first, fun.apply(s + "_" + x.second))).collect(Collectors.toList()));
OplTerm<String, String> rhs = fun2(equivs0, prepend(t, edge2.second));
pathEqs.add(new Triple<>(ctx, lhs, rhs));
}
for (String edge : s0.projA().symbols.keySet()) {
Pair<OplCtx<String, String>, OplTerm<String, String>> edge2 = m0.m.symbols.get(edge);
List<OplTerm<String, String>> args = edge2.first.vars0.keySet().stream().map((Function<String, OplTerm<String, String>>) OplTerm::new).collect(Collectors.toList());
OplTerm<String, String> lhs = fun2(equivs0, new OplTerm<>(s + "_" + edge, args));
OplCtx<String, String> ctx = new OplCtx<>(edge2.first.values2().stream().map(x -> new Pair<>(x.first, fun.apply(s + "_" + x.second))).collect(Collectors.toList()));
OplTerm<String, String> rhs = fun2(equivs0, prepend(t, edge2.second));
obsEqs.add(new Triple<>(ctx, lhs, rhs));
}
}
OplSCHEMA0<String, String, String> ret = new OplSCHEMA0<>(new HashMap<>(), entities, edges, attrs, pathEqs, obsEqs, typeSide);
OplSchema retsch = (OplSchema) ret.accept(env, this);
e.compiled.put("Colimit", ret);
for (String schname : shape.nodes) {
OplSchema<String, String, String> sch = (OplSchema<String, String, String>) ENV.get(schname);
Map<String, String> inj_sorts = new HashMap<>();
Map<String, Pair<OplCtx<String, String>, OplTerm<String, String>>> inj_symbols = new HashMap<>();
for (String ename : sch.entities) {
inj_sorts.put(ename, fun.apply(schname + "_" + ename));
}
for (String c1 : sch.projEA().symbols.keySet()) {
Pair<List<String>, String> t = sch.projEA().symbols.get(c1);
List<Pair<String, String>> l = new LinkedList<>();
List<OplTerm<String, String>> vs = new LinkedList<>();
for (String s1 : t.first) {
String v = (String) retsch.sig.fr.next();
vs.add(new OplTerm<>(v));
l.add(new Pair<>(v, fun.apply(schname + "_" + s1)));
}
OplCtx<String, String> ctx = new OplCtx<>(l);
OplTerm<String, String> value = fun2(equivs0, new OplTerm<>(schname + "_" + c1, vs));
inj_symbols.put(c1, new Pair<>(ctx, value));
}
OplMapping<String, String, String, String, String> mapping = new OplMapping<>(inj_sorts, inj_symbols, schname, "Colimit");
// : name of colimit
OplTyMapping<String, String, String, String, String> tm = new OplTyMapping<>(schname, "Colimit", sch, retsch, mapping);
tm.extend().validate(sch.sig, retsch.sig);
e.compiled.put(schname + "To" + "Colimit", mapping);
}
return e;
} else if (base0 instanceof OplSchema) {
OplSchema sch2 = (OplSchema) base0;
// OplSCHEMA0 sch = sch2.toSchema0();
List<Pair<OplTerm<Chc<String, String>, String>, OplTerm<Chc<String, String>, String>>> equations = new LinkedList<>();
// List<Pair<OplTerm<Object, String>, OplTerm<Object, String>>> equations1 = new LinkedList<>();
Map<String, String> gens = new HashMap<>();
Map<String, Integer> prec = new HashMap<>();
for (String s : shape.nodes) {
OplInst<String, String, String, String> toAdd = (OplInst<String, String, String, String>) ENV.get(s);
for (Object gen : toAdd.P.gens.keySet()) {
Object ty = toAdd.P.gens.get(gen);
gens.put(s + "_" + gen, ty.toString());
}
for (Object gen : toAdd.P.prec.keySet()) {
if (toAdd.P.gens.keySet().contains(gen)) {
if (toAdd.P.prec.containsKey(gen)) {
prec.put(s + "_" + gen, toAdd.P.prec.get(gen));
}
} else {
if (toAdd.P.prec.containsKey(gen)) {
prec.put(toAdd.P.S + "_" + gen, toAdd.P.prec.get(gen));
}
}
}
for (Pair<OplTerm<Chc<String, String>, String>, OplTerm<Chc<String, String>, String>> tr : toAdd.P.equations) {
OplTerm lhs1 = prepend3(s, tr.first);
OplTerm rhs1 = prepend3(s, tr.second);
equations.add(new Pair<>(lhs1, rhs1));
}
}
for (String mname : shape.edges.keySet()) {
Pair<String, String> mt = shape.edges.get(mname);
String s = mt.first;
String t = mt.second;
OplInst<String, String, String, String> s0 = (OplInst<String, String, String, String>) ENV.get(s);
// OplSchema<String, String, String> t0 = (OplSchema<String,
// String, String>) ENV.get(t);
OplPresTrans<String, String, String, String, String> m0 = (OplPresTrans<String, String, String, String, String>) ENV.get(mname);
for (String edge : s0.projE().gens.keySet()) {
Pair<OplCtx<String, String>, OplTerm<Chc<String, String>, String>> edge2 = m0.mapping.symbols.get(Chc.inRight(edge));
OplTerm<Chc<String, String>, String> lhs = new OplTerm<>(Chc.inRight(s + "_" + edge), new LinkedList<>());
equations.add(new Pair<>(lhs, prepend3(t, edge2.second)));
}
}
OplPres<String, String, String, String> pres = new OplPres<>(prec, e.base, sch2.sig, gens, equations);
OplInst<String, String, String, String> colimInst = new OplInst<>(e.base, "?", null);
colimInst.validate(sch2, pres, null);
e.compiled.put("ColimitInstance", colimInst);
for (String s : shape.nodes) {
OplInst<String, String, String, String> toAdd = (OplInst<String, String, String, String>) ENV.get(s);
Map<String, Map<String, OplTerm<Chc<String, String>, String>>> inj_map = new HashMap<>();
for (String entity : toAdd.S.entities) {
inj_map.put(entity, new HashMap<>());
}
for (Object gen : toAdd.P.gens.keySet()) {
Object ty = toAdd.P.gens.get(gen);
gens.put(s + "_" + gen, ty.toString());
Map<String, OplTerm<Chc<String, String>, String>> m = inj_map.get(ty);
OplTerm<Chc<String, String>, String> term = new OplTerm<>(Chc.inRight(s + "_" + gen), new LinkedList<>());
m.put((String) gen, term);
}
// OplPresTrans
OplPresTrans<String, String, String, String, String> inj = new OplPresTrans<>(inj_map, s, "ColimitInstance", toAdd.P, pres);
e.compiled.put(s + "ToColimitInstance", inj);
}
return colimInst;
}
throw new RuntimeException("Report your program to Ryan");
}
use of catdata.Triple in project fql by CategoricalData.
the class OplOps method visit.
// private static int temp = 0;
@Override
public OplObject visit(Program<OplExp> env, OplUnion e) {
String typeSide;
OplSchema schema = null;
Map<String, Integer> prec = new HashMap<>();
OplObject o = ENV.get(e.base);
if (o instanceof OplSchema) {
schema = (OplSchema) o;
typeSide = schema.forSchema0;
if (typeSide == null) {
throw new RuntimeException(e.base + " is not a SCHEMA literal");
}
} else if (o instanceof OplSig) {
typeSide = e.base;
} else {
throw new RuntimeException("Report this program to Ryan");
}
if (schema == null) {
Set<String> entities = new HashSet<>();
Map<String, Pair<List<String>, String>> edges = new HashMap<>();
Map<String, Pair<List<String>, String>> attrs = new HashMap<>();
List<Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>>> pathEqs = new LinkedList<>();
List<Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>>> obsEqs = new LinkedList<>();
for (String s : e.names) {
OplExp exp = env.exps.get(s);
if (exp == null) {
throw new RuntimeException("Missing expression: " + s);
}
if (!(exp instanceof OplSCHEMA0)) {
throw new RuntimeException("Not a schema: " + s);
}
OplSCHEMA0<String, String, String> toAdd = (OplSCHEMA0<String, String, String>) exp;
if (!toAdd.typeSide.equals(typeSide)) {
throw new RuntimeException("not all equal typesides in " + e);
}
for (Object entity : toAdd.entities) {
String proposed = s + "_" + entity;
if (entities.contains(proposed)) {
throw new RuntimeException("name clash: " + entity);
}
entities.add(proposed);
}
for (Object edge : toAdd.edges.keySet()) {
String proposed = s + "_" + edge;
if (edges.containsKey(proposed)) {
throw new RuntimeException("name clash: " + edge);
}
edges.put(proposed, new Pair<>(Util.singList(s + "_" + toAdd.edges.get(edge).first.get(0)), s + "_" + toAdd.edges.get(edge).second));
if (toAdd.prec.containsKey(edge)) {
prec.put(proposed, toAdd.prec.get(edge));
}
}
for (Object att : toAdd.attrs.keySet()) {
String proposed = s + "_" + att;
if (attrs.containsKey(proposed)) {
throw new RuntimeException("name clash: " + att);
}
attrs.put(proposed, new Pair<>(Util.singList(s + "_" + toAdd.attrs.get(att).first.get(0)), toAdd.attrs.get(att).second));
if (toAdd.prec.containsKey(att)) {
prec.put(proposed, toAdd.prec.get(att));
}
}
for (Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>> tr : toAdd.pathEqs) {
String v = tr.first.names().get(0);
String t = s + "_" + tr.first.values().get(0);
OplCtx<String, String> ctx = new OplCtx<>(Util.singList(new Pair<>(v, t)));
OplTerm<String, String> lhs1 = prepend(s, tr.second);
OplTerm<String, String> rhs1 = prepend(s, tr.third);
pathEqs.add(new Triple<>(ctx, lhs1, rhs1));
}
for (Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>> tr : toAdd.obsEqs) {
String v = tr.first.names().get(0);
String t = s + "_" + tr.first.values().get(0);
OplCtx<String, String> ctx = new OplCtx<>(Util.singList(new Pair<>(v, t)));
OplTerm<String, String> lhs1 = prepend(s, tr.second);
OplTerm<String, String> rhs1 = prepend(s, tr.third);
obsEqs.add(new Triple<>(ctx, lhs1, rhs1));
}
}
return new OplSCHEMA0<>(prec, entities, edges, attrs, pathEqs, obsEqs, typeSide).accept(env, this);
} else {
for (String s : e.names) {
OplObject exp = ENV.get(s);
if (!(exp instanceof OplInst)) {
throw new RuntimeException("Not an instance: " + s);
}
OplInst<String, String, String, String> toAdd = (OplInst<String, String, String, String>) exp;
if (!toAdd.S.equals(schema)) {
throw new RuntimeException(s + " is not on schema " + schema);
}
}
OplSig<String, String, String> sig = schema.sig;
Map<String, String> gens = new HashMap<>();
List<Pair<OplTerm<Object, String>, OplTerm<Object, String>>> equations1 = new LinkedList<>();
// List<Pair<OplTerm<Chc<String,String>, String>, OplTerm<Chc<String,String>, String>>> equations2 = new LinkedList<>();
for (String s : e.names) {
OplExp exp = env.exps.get(s);
OplInst0<String, String, String, String> toAdd = (OplInst0<String, String, String, String>) exp;
for (Object gen : toAdd.P.gens.keySet()) {
Object ty = toAdd.P.gens.get(gen);
gens.put(s + "_" + gen, /* toAdd.P.S + "_" + */
ty.toString());
}
for (Object gen : toAdd.P.prec.keySet()) {
if (toAdd.P.gens.keySet().contains(gen)) {
if (toAdd.P.prec.containsKey(gen)) {
prec.put(s + "_" + gen, toAdd.P.prec.get(gen));
}
} else {
if (toAdd.P.prec.containsKey(gen)) {
prec.put(toAdd.P.S + "_" + gen, toAdd.P.prec.get(gen));
}
}
}
for (Pair<OplTerm<Chc<String, String>, String>, OplTerm<Chc<String, String>, String>> tr : toAdd.P.equations) {
OplTerm<Object, String> lhs1 = prepend2((OplTerm) tr.first, s, toAdd.P.gens.keySet());
OplTerm<Object, String> rhs1 = prepend2((OplTerm) tr.second, s, toAdd.P.gens.keySet());
equations1.add(new Pair<>(lhs1, rhs1));
}
}
// OplPres<String, String, String, String> pres = new OplPres(prec, "_temp" + temp, sig, gens, equations2);
OplPres<String, String, String, String> pres = new OplPres(prec, e.base, sig, gens, equations1);
if (DefunctGlobalOptions.debug.opl.opl_prover_simplify_instances) {
pres = pres.simplify();
}
// temp++;
OplInst0 ret = new OplInst0<>(pres);
OplObject x = (OplObject) ret.accept(env, this);
return x;
}
}
use of catdata.Triple in project fql by CategoricalData.
the class OplParser method toTheory.
private static OplExp toTheory(Object o) {
Tuple5 t = (Tuple5) o;
List<String> imports = t.a == null ? new LinkedList<>() : (List<String>) ((org.jparsec.functors.Pair) t.a).b;
Tuple3 a = (Tuple3) t.b;
Tuple3 b = (Tuple3) t.c;
Tuple3 c = (Tuple3) t.d;
Tuple3 d = (Tuple3) t.e;
Set<String> sorts = a == null ? new HashSet<>() : new HashSet<>((Collection<String>) a.b);
List<Tuple3> symbols0 = b == null ? new LinkedList<>() : (List<Tuple3>) b.b;
List<org.jparsec.functors.Pair> equations0 = c == null ? new LinkedList<>() : (List<org.jparsec.functors.Pair>) c.b;
List<org.jparsec.functors.Pair> implications0 = new LinkedList<>();
if (d != null) {
implications0 = (List<org.jparsec.functors.Pair>) d.b;
}
Map<String, Pair<List<String>, String>> symbols = new HashMap<>();
Map<String, Integer> prec = new HashMap<>();
for (Tuple3 x : symbols0) {
String dom;
List<String> args;
if (x.c instanceof Tuple3) {
Tuple3 zzz = (Tuple3) x.c;
args = (List<String>) zzz.a;
dom = (String) zzz.c;
} else {
dom = (String) x.c;
args = new LinkedList<>();
}
List<org.jparsec.functors.Pair> name0s = (List<org.jparsec.functors.Pair>) x.a;
for (org.jparsec.functors.Pair name0 : name0s) {
// org.jparsec.functors.Pair name0 =
// (org.jparsec.functors.Pair) x.a;
String name = (String) name0.a;
if (name0.b != null) {
org.jparsec.functors.Pair zzz = (org.jparsec.functors.Pair) name0.b;
Integer i = (Integer) zzz.b;
prec.put(name, i);
}
if (symbols.containsKey(name)) {
throw new DoNotIgnore("Duplicate symbol " + name);
}
symbols.put(name, new Pair<>(args, dom));
}
}
if (sorts.contains("Nat") && symbols.keySet().contains("zero") && symbols.keySet().contains("succ") && DefunctGlobalOptions.debug.opl.opl_desugar_nat) {
sugarForNat = true;
}
List<Triple<OplCtx<String, String>, OplTerm<String, String>, OplTerm<String, String>>> equations = new LinkedList<>();
for (org.jparsec.functors.Pair<Tuple3, Tuple3> x : equations0) {
List<Tuple3> fa = x.a == null ? new LinkedList<>() : (List<Tuple3>) x.a.b;
OplCtx<String, String> ctx = toCtx(fa);
Tuple3 eq = x.b;
OplTerm lhs = toTerm(ctx.names(), consts(symbols), eq.a, false);
OplTerm rhs = toTerm(ctx.names(), consts(symbols), eq.c, false);
equations.add(new Triple<>(ctx, lhs, rhs));
}
List<Triple<OplCtx<String, String>, List<Pair<OplTerm<String, String>, OplTerm<String, String>>>, List<Pair<OplTerm<String, String>, OplTerm<String, String>>>>> implications = new LinkedList<>();
for (org.jparsec.functors.Pair<Tuple3, Tuple3> x : implications0) {
List<Tuple3> fa = x.a == null ? new LinkedList<>() : (List<Tuple3>) x.a.b;
OplCtx<String, String> ctx = toCtx(fa);
Tuple3 eq = x.b;
List<Tuple3> lhs0 = (List<Tuple3>) eq.a;
List<Tuple3> rhs0 = (List<Tuple3>) eq.c;
List<Pair<OplTerm<String, String>, OplTerm<String, String>>> lhs = new LinkedList<>();
List<Pair<OplTerm<String, String>, OplTerm<String, String>>> rhs = new LinkedList<>();
for (Tuple3 obj : lhs0) {
OplTerm lhsX = toTerm(ctx.names(), consts(symbols), obj.a, false);
OplTerm rhsX = toTerm(ctx.names(), consts(symbols), obj.c, false);
lhs.add(new Pair<>(lhsX, rhsX));
}
for (Tuple3 obj : rhs0) {
OplTerm lhsX = toTerm(ctx.names(), consts(symbols), obj.a, false);
OplTerm rhsX = toTerm(ctx.names(), consts(symbols), obj.c, false);
rhs.add(new Pair<>(lhsX, rhsX));
}
implications.add(new Triple<>(ctx, lhs, rhs));
}
OplSig ret = new OplSig<>(new VIt(), prec, sorts, symbols, equations, implications);
ret.imports = new HashSet<>(imports);
return ret;
}
use of catdata.Triple in project fql by CategoricalData.
the class OplParser method toCatConst.
public static XSchema toCatConst(Object y) {
List<String> nodes = new LinkedList<>();
List<Triple<String, String, String>> arrows = new LinkedList<>();
List<Pair<List<String>, List<String>>> eqs = new LinkedList<>();
Tuple3 s = (Tuple3) y;
Tuple3 nodes0 = (Tuple3) s.a;
Tuple3 arrows0 = (Tuple3) s.b;
Tuple3 eqs0 = (Tuple3) s.c;
List nodes1 = (List) nodes0.b;
List arrows1 = (List) arrows0.b;
List eqs1 = (List) eqs0.b;
for (Object o : nodes1) {
nodes.add((String) o);
}
for (Object o : arrows1) {
Tuple5 x = (Tuple5) o;
arrows.add(new Triple<>((String) x.a, (String) x.c, (String) x.e));
}
for (Object o : eqs1) {
Tuple3 x = (Tuple3) o;
List<String> l1 = (List<String>) x.a;
List<String> l2 = (List<String>) x.c;
eqs.add(new Pair<>(l1, l2));
}
XSchema c = new XSchema(nodes, arrows, eqs);
return c;
}
Aggregations