Search in sources :

Example 91 with Pair

use of catdata.Pair in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, TransEval e) {
    InstExp k = env.insts.get(e.inst);
    if (k == null) {
        throw new RuntimeException("Missing instance: " + e.inst);
    }
    if (!(k instanceof Times)) {
        throw new RuntimeException("Not a product: " + k + " in " + e);
    }
    Times t = (Times) k;
    InstExp v = env.insts.get(t.a);
    if (!(v instanceof Exp)) {
        throw new RuntimeException("Not an exponential: " + v + " in " + e);
    }
    Exp i = (Exp) v;
    if (!(t.b.equals(i.b))) {
        throw new RuntimeException("Exponent and product do not match in " + e);
    }
    return new Pair<>(e.inst, i.a);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) Exp(catdata.fql.decl.InstExp.Exp) TransExp(catdata.fql.decl.TransExp) SigExp(catdata.fql.decl.SigExp) InstExp(catdata.fql.decl.InstExp) Pair(catdata.Pair)

Example 92 with Pair

use of catdata.Pair in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, Prod 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);
    }
    // InstExp.Times y = (InstExp.Times) x;
    Pair<String, String> a = e.l.accept(env, this);
    Pair<String, String> b = e.r.accept(env, this);
    if (!a.first.equals(b.first)) {
        throw new RuntimeException("Domain mismatch: " + e + " with " + a.first + " and " + b.first);
    }
    return new Pair<>(a.first, e.obj);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) Pair(catdata.Pair)

Example 93 with Pair

use of catdata.Pair in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, TransCurry e) {
    InstExp inst = env.insts.get(e.inst);
    if (inst == null) {
        throw new RuntimeException("Missing instance: " + e.inst);
    }
    if (!(inst instanceof Exp)) {
        throw new RuntimeException("Instance is not an exponential");
    }
    Exp i = (Exp) inst;
    if (seen.contains(e.trans)) {
        throw new RuntimeException("Circular transform " + e);
    }
    seen.add(e.trans);
    Pair<String, String> k = env.transforms.get(e.trans).accept(env, this);
    InstExp ab = env.insts.get(k.first);
    if (!(ab instanceof Times)) {
        throw new RuntimeException("Source is not a product");
    }
    Times t = (Times) ab;
    if (!i.a.equals(k.second)) {
        throw new RuntimeException("Bases do not match");
    }
    if (!i.b.equals(t.b)) {
        throw new RuntimeException("Exponents do not match");
    }
    return new Pair<>(t.a, e.inst);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) Exp(catdata.fql.decl.InstExp.Exp) TransExp(catdata.fql.decl.TransExp) SigExp(catdata.fql.decl.SigExp) InstExp(catdata.fql.decl.InstExp) Pair(catdata.Pair)

Example 94 with Pair

use of catdata.Pair in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, Squash e) {
    InstExp s = env.insts.get(e.src);
    if (!(s instanceof InstExp.Relationalize)) {
        throw new RuntimeException("Not a relationalize: " + e);
    }
    InstExp.Relationalize xxx = (InstExp.Relationalize) s;
    return new Pair<>(xxx.I, e.src);
}
Also used : Relationalize(catdata.fql.decl.TransExp.Relationalize) InstExp(catdata.fql.decl.InstExp) Pair(catdata.Pair)

Example 95 with Pair

use of catdata.Pair in project fql by CategoricalData.

the class TransChecker method visit.

@Override
public Pair<String, String> visit(FQLProgram env, Snd 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.b);
}
Also used : InstExp(catdata.fql.decl.InstExp) Times(catdata.fql.decl.InstExp.Times) Pair(catdata.Pair)

Aggregations

Pair (catdata.Pair)305 LinkedList (java.util.LinkedList)169 HashMap (java.util.HashMap)144 List (java.util.List)127 HashSet (java.util.HashSet)101 Triple (catdata.Triple)98 Map (java.util.Map)94 LinkedHashMap (java.util.LinkedHashMap)82 Set (java.util.Set)70 Tuple3 (org.jparsec.functors.Tuple3)46 Node (catdata.fql.decl.Node)38 JPanel (javax.swing.JPanel)37 GridLayout (java.awt.GridLayout)32 FQLException (catdata.fql.FQLException)31 Paint (java.awt.Paint)29 Chc (catdata.Chc)28 Util (catdata.Util)27 En (catdata.aql.exp.SchExpRaw.En)26 Tuple5 (org.jparsec.functors.Tuple5)26 Ty (catdata.aql.exp.TyExpRaw.Ty)25