use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, And e) {
InstExp v = env.insts.get(e.prop);
if (v == null) {
throw new RuntimeException("Missing instance: " + e.prop);
}
if (!(v instanceof Times)) {
throw new RuntimeException("Not a product in " + e);
}
Times v0 = (Times) v;
if (!v0.a.equals(v0.b)) {
throw new RuntimeException("Not the same prop in " + e);
}
if (!(env.insts.get(v0.a) instanceof Two)) {
throw new RuntimeException("Not a prop in " + e);
}
return new Pair<>(e.prop, v0.a);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, FullSigma e) {
if (seen.contains(e.h)) {
throw new RuntimeException("Circular transform " + e);
}
seen.add(e.h);
if (env.transforms.get(e.h) == null) {
throw new RuntimeException("Transform not found " + e);
}
Pair<String, String> ht = env.transforms.get(e.h).type(env);
InstExp i1 = env.insts.get(e.src);
if (!(i1 instanceof InstExp.FullSigma)) {
throw new RuntimeException(i1 + " is not a full sigma in " + e);
}
String i1x = ((InstExp.FullSigma) i1).I;
if (!i1x.equals(ht.first)) {
throw new RuntimeException("Source mismatch on " + e + ": " + i1x + " and " + ht.first);
}
InstExp i2 = env.insts.get(e.dst);
if (!(i2 instanceof InstExp.FullSigma)) {
throw new RuntimeException(i2 + " is not a fullsigma in " + e);
}
String i2x = ((InstExp.FullSigma) i2).I;
if (!i2x.equals(ht.second)) {
throw new RuntimeException("Target mismatch on " + e + ": " + i2x + " and " + ht.second);
}
return new Pair<>(e.src, e.dst);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Inr e) {
InstExp x = env.insts.get(e.obj);
if (x == null) {
throw new RuntimeException("Missing " + e.obj + " in " + e);
}
if (!(x instanceof Plus)) {
throw new RuntimeException(e.obj + " is not a plus: " + x);
}
Plus y = (Plus) x;
return new Pair<>(y.b, e.obj);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Chi e) {
InstExp prop = env.insts.get(e.prop);
if (prop == null) {
throw new RuntimeException("Missing instance " + e.prop);
}
if (!(prop instanceof Two)) {
throw new RuntimeException("Not a prop " + e);
}
if (seen.contains(e.trans)) {
throw new RuntimeException("Circular transform " + e);
}
seen.add(e.trans);
TransExp t = env.transforms.get(e.trans);
if (t == null) {
throw new RuntimeException("Missing transform " + e.trans);
}
Pair<String, String> k = t.accept(env, this);
return new Pair<>(k.second, e.prop);
}
use of catdata.fql.decl.InstExp in project fql by CategoricalData.
the class TransChecker method visit.
@Override
public Pair<String, String> visit(FQLProgram env, Relationalize e) {
Pair<String, String> ht = e.h.type(env);
InstExp i1 = env.insts.get(e.src);
if (!(i1 instanceof InstExp.Relationalize)) {
throw new RuntimeException(i1 + " is not a relationalize in " + e);
}
String i1x = ((InstExp.Relationalize) i1).I;
if (!i1x.equals(ht.first)) {
throw new RuntimeException("Source mismatch on " + e + ": " + i1x + " and " + ht.first);
}
InstExp i2 = env.insts.get(e.dst);
if (!(i2 instanceof InstExp.Relationalize)) {
throw new RuntimeException(i2 + " is not a relationalize in " + e);
}
String i2x = ((InstExp.Relationalize) i2).I;
if (!i2x.equals(ht.second)) {
throw new RuntimeException("Target mismatch on " + e + ": " + i2x + " and " + ht.second);
}
return new Pair<>(e.src, e.dst);
}
Aggregations