Search in sources :

Example 16 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, Bool e) {
    InstExp u = env.insts.get(e.unit);
    if (u == null) {
        throw new RuntimeException("Missing instance: " + e.unit);
    }
    if (!(u instanceof One)) {
        throw new RuntimeException("Not a unit in " + e);
    }
    InstExp v = env.insts.get(e.prop);
    if (v == null) {
        throw new RuntimeException("Missing instance: " + e.prop);
    }
    if (!(v instanceof Two)) {
        throw new RuntimeException("Not a prop in " + e);
    }
    return new Pair<>(e.unit, e.prop);
}
Also used : InstExp(catdata.fql.decl.InstExp) One(catdata.fql.decl.InstExp.One) Two(catdata.fql.decl.InstExp.Two) Pair(catdata.Pair)

Example 17 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, Inl 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.a, e.obj);
}
Also used : InstExp(catdata.fql.decl.InstExp) Plus(catdata.fql.decl.InstExp.Plus) Pair(catdata.Pair)

Example 18 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, Case 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);
    }
    // InstExp.Plus y = (InstExp.Plus) x;
    Pair<String, String> a = e.l.accept(env, this);
    Pair<String, String> b = e.r.accept(env, this);
    if (!a.second.equals(b.second)) {
        throw new RuntimeException("Codomain mismatch: " + e + " with " + a.second + " and " + b.second);
    }
    return new Pair<>(e.obj, a.second);
}
Also used : InstExp(catdata.fql.decl.InstExp) Plus(catdata.fql.decl.InstExp.Plus) Pair(catdata.Pair)

Example 19 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, Delta e) {
    Pair<String, String> ht = e.h.type(env);
    InstExp i1 = env.insts.get(e.src);
    if (!(i1 instanceof InstExp.Delta)) {
        throw new RuntimeException(i1 + " is not a delta in " + e);
    }
    String i1x = ((InstExp.Delta) 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.Delta)) {
        throw new RuntimeException(i2 + " is not a delta in " + e);
    }
    String i2x = ((InstExp.Delta) 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) Delta(catdata.fql.decl.TransExp.Delta) Pair(catdata.Pair)

Example 20 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, UnChi e) {
    InstExp p = env.insts.get(e.a);
    if (p == null) {
        throw new RuntimeException("Missing instance " + e.a);
    }
    if (!(p instanceof Kernel)) {
        throw new RuntimeException("Not a kernel " + e);
    }
    Kernel k = (Kernel) p;
    Pair<String, String> trans = env.transforms.get(k.trans).type(env);
    return new Pair<>(e.a, trans.first);
}
Also used : InstExp(catdata.fql.decl.InstExp) Kernel(catdata.fql.decl.InstExp.Kernel) 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