Search in sources :

Example 11 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, TT e) {
    InstExp x = env.insts.get(e.obj);
    if (x == null) {
        throw new RuntimeException("Missing " + e.obj + " in " + e);
    }
    if (!(x instanceof One)) {
        throw new RuntimeException(e.obj + " is not a unit: " + x);
    }
    // InstExp.One y = (InstExp.One) x;
    InstExp z = env.insts.get(e.tgt);
    if (z == null) {
        throw new RuntimeException("Missing " + e.tgt + " in " + e);
    }
    SigExp xt = x.type(env);
    SigExp yt = z.type(env);
    if (!xt.equals(yt)) {
        throw new RuntimeException("Instances have different types in " + e + ": " + xt + " and " + yt);
    }
    return new Pair<>(e.tgt, e.obj);
}
Also used : InstExp(catdata.fql.decl.InstExp) SigExp(catdata.fql.decl.SigExp) One(catdata.fql.decl.InstExp.One) Pair(catdata.Pair)

Example 12 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, External e) {
    InstExp src = env.insts.get(e.src);
    if (src == null) {
        throw new RuntimeException("Missing instance " + e.src);
    }
    InstExp dst = env.insts.get(e.dst);
    if (dst == null) {
        throw new RuntimeException("Missing instance " + e.src);
    }
    if (!(src instanceof InstExp.External)) {
        throw new RuntimeException(e.src + " is not external.");
    }
    if (!(dst instanceof InstExp.External)) {
        throw new RuntimeException(e.dst + " is not external.");
    }
    InstExp.External src0 = (InstExp.External) src;
    InstExp.External dst0 = (InstExp.External) dst;
    SigExp srct = src0.type(env);
    SigExp dstt = dst0.type(env);
    if (!srct.equals(dstt)) {
        throw new RuntimeException("Instances not of same type on " + e + " are " + srct + " and " + dstt);
    }
    return new Pair<>(e.src, e.dst);
}
Also used : InstExp(catdata.fql.decl.InstExp) SigExp(catdata.fql.decl.SigExp) External(catdata.fql.decl.TransExp.External) Pair(catdata.Pair)

Example 13 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, FF e) {
    InstExp x = env.insts.get(e.obj);
    if (x == null) {
        throw new RuntimeException("Missing " + e.obj + " in " + e);
    }
    if (!(x instanceof Zero)) {
        throw new RuntimeException(e.obj + " is not void: " + x);
    }
    // InstExp.One y = (InstExp.One) x;
    InstExp z = env.insts.get(e.tgt);
    if (z == null) {
        throw new RuntimeException("Missing " + e.tgt + " in " + e);
    }
    SigExp xt = x.type(env);
    SigExp yt = z.type(env);
    if (!xt.equals(yt)) {
        throw new RuntimeException("Instances have different types in " + e + ": " + xt + " and " + yt);
    }
    return new Pair<>(e.obj, e.tgt);
}
Also used : InstExp(catdata.fql.decl.InstExp) Zero(catdata.fql.decl.InstExp.Zero) SigExp(catdata.fql.decl.SigExp) Pair(catdata.Pair)

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

Example 15 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, Fst e) {
    InstExp x = env.insts.get(e.obj);
    if (x == null) {
        throw new RuntimeException("Missing " + e.obj + " in " + e);
    }
    if (!(x instanceof Times)) {
        throw new RuntimeException(e.obj + " is not a times: " + x);
    }
    Times y = (Times) x;
    return new Pair<>(e.obj, y.a);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) 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