Search in sources :

Example 6 with Two

use of catdata.fql.decl.InstExp.Two 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 7 with Two

use of catdata.fql.decl.InstExp.Two 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)

Aggregations

Two (catdata.fql.decl.InstExp.Two)7 InstExp (catdata.fql.decl.InstExp)6 Pair (catdata.Pair)5 One (catdata.fql.decl.InstExp.One)5 Times (catdata.fql.decl.InstExp.Times)5 Exp (catdata.fql.decl.InstExp.Exp)4 External (catdata.fql.decl.InstExp.External)4 Kernel (catdata.fql.decl.InstExp.Kernel)4 Delta (catdata.fql.decl.InstExp.Delta)3 Eval (catdata.fql.decl.InstExp.Eval)3 FullEval (catdata.fql.decl.InstExp.FullEval)3 FullSigma (catdata.fql.decl.InstExp.FullSigma)3 Plus (catdata.fql.decl.InstExp.Plus)3 Relationalize (catdata.fql.decl.InstExp.Relationalize)3 Step (catdata.fql.decl.InstExp.Step)3 Zero (catdata.fql.decl.InstExp.Zero)3 TransExp (catdata.fql.decl.TransExp)3 Unit (catdata.Unit)2 FullQueryExp (catdata.fql.decl.FullQueryExp)2 Const (catdata.fql.decl.InstExp.Const)2