Search in sources :

Example 26 with InstExp

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);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) Two(catdata.fql.decl.InstExp.Two) Pair(catdata.Pair)

Example 27 with InstExp

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);
}
Also used : InstExp(catdata.fql.decl.InstExp) FullSigma(catdata.fql.decl.TransExp.FullSigma) Pair(catdata.Pair)

Example 28 with InstExp

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);
}
Also used : InstExp(catdata.fql.decl.InstExp) Plus(catdata.fql.decl.InstExp.Plus) Pair(catdata.Pair)

Example 29 with InstExp

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);
}
Also used : InstExp(catdata.fql.decl.InstExp) TransExp(catdata.fql.decl.TransExp) Two(catdata.fql.decl.InstExp.Two) Pair(catdata.Pair)

Example 30 with InstExp

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);
}
Also used : Relationalize(catdata.fql.decl.TransExp.Relationalize) InstExp(catdata.fql.decl.InstExp) Pair(catdata.Pair)

Aggregations

InstExp (catdata.fql.decl.InstExp)30 Pair (catdata.Pair)24 Times (catdata.fql.decl.InstExp.Times)9 SigExp (catdata.fql.decl.SigExp)8 TransExp (catdata.fql.decl.TransExp)8 Two (catdata.fql.decl.InstExp.Two)6 Exp (catdata.fql.decl.InstExp.Exp)5 One (catdata.fql.decl.InstExp.One)5 Plus (catdata.fql.decl.InstExp.Plus)5 Kernel (catdata.fql.decl.InstExp.Kernel)4 External (catdata.fql.decl.InstExp.External)3 Zero (catdata.fql.decl.InstExp.Zero)3 Signature (catdata.fql.decl.Signature)3 ExpPSM (catdata.fql.sql.ExpPSM)3 PSM (catdata.fql.sql.PSM)3 PropPSM (catdata.fql.sql.PropPSM)3 LinkedList (java.util.LinkedList)3 FQLException (catdata.fql.FQLException)2 FullQueryExp (catdata.fql.decl.FullQueryExp)2 Delta (catdata.fql.decl.InstExp.Delta)2