Commit ab6c7231 authored by Ryan Wisnesky's avatar Ryan Wisnesky
Browse files

initial implementation of sigma by parallel chase

parent 1f1b5db0
Loading
Loading
Loading
Loading
+8 −0
Changes for src/catdata/BinRelMap.java: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -188,4 +188,12 @@ public class BinRelMap<X, Y> implements Iterable<Pair<X, Y>> {
		return R.containsKey(x);
	}

	public int size() {
		int i = 0;
		for (Pair<X, Y> x : this) {
			i++;
		}
		return i;
	}

}
+5 −5
Changes for src/catdata/LineException.java: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -9,10 +9,10 @@ public class LineException extends RuntimeException {
		private final String str ;
		
		public LineException(String string, String decl, String kind) {
			super(string);
			this.decl = decl;
			this.kind = kind;
            str = string;
			super(string == null ? "" : string);
			this.decl = decl == null ? "" : decl;
			this.kind = kind == null ? "" : kind;
            str = string == null ? "" : string;
		}
		
		@Override public boolean equals(Object o) {
@@ -21,7 +21,7 @@ public class LineException extends RuntimeException {
			}
		//	if (o == null) {
			//	return false;
			//}
			//} //dead code, apparently
			LineException oe = (LineException) o;
			return (oe.decl.equals(decl) && oe.kind.equals(kind) && oe.str.equals(str));
		}
+130 −55
Changes for src/catdata/aql/Chase.java: 130 added lines, 55 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ package catdata.aql;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

@@ -18,7 +18,8 @@ import catdata.graph.UnionFind;
public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {

	private final Mapping<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2> F;
	//private final Schema<Ty,Chc<En1,En2>,Sym,Chc<Chc<Fk1,Fk2>,En1>,Chc<Att1,Att2>> S;
	// private final
	// Schema<Ty,Chc<En1,En2>,Sym,Chc<Chc<Fk1,Fk2>,En1>,Chc<Att1,Att2>> S;

	public class Content {
		public final Ctx<En2, BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>> ens;
@@ -50,10 +51,14 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {

		public void addAll(Content c) {
			for (En2 en : ens.keySet()) {
				ens.get(en).addAll(c.ens.get(en));
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> x = c.ens
						.get(en);
				ens.get(en).addAll(x);
			}
			for (Fk2 fk : fks.keySet()) {
				fks.get(fk).addAll(c.fks.get(fk));
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> x = c.fks
						.get(fk);
				fks.get(fk).addAll(x);
			}
			for (En1 en1 : us.keySet()) {
				us.get(en1).putAll(c.us.get(en1).map);
@@ -76,7 +81,8 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
			for (En1 en1 : I.schema().ens) {
				Ctx<X, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> ctx = new Ctx<>();
				for (X x : I.algebra().en(en1)) {
					Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk> t = F.trans(I.algebra().repr(x).map(Util.voidFn(), Util.voidFn(), q->q, Util.voidFn(), q->q, Util.voidFn()));
					Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk> t = F.trans(I.algebra().repr(x).map(Util.voidFn(),
							Util.voidFn(), q -> q, Util.voidFn(), q -> q, Util.voidFn()));
					ctx.put(x, new Lineage<>(fresh.next(), t));
				}
				us.put(en1, ctx);
@@ -90,7 +96,8 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
		public Content merge(Ctx<En2, UnionFind<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>> ufs) {
			Content ret = new Content();
			for (En2 en : F.dst.ens) {
				for (Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> x : ens.get(en)) {
				for (Pair<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> x : ens
						.get(en)) {
					if (!x.first.equals(x.second)) {
						Util.anomaly();
					}
@@ -98,50 +105,69 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
					ret.ens.get(en).add(n, n);
				}
			}
			// System.out.println("yyy " + ret);
			for (Fk2 fk : F.dst.fks.keySet()) {
				En2 a = F.dst.fks.get(fk).first;
				En2 b = F.dst.fks.get(fk).second;
				for (Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> x : fks.get(fk)) {
				for (Pair<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> x : fks
						.get(fk)) {
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n1 = ufs.get(a).find(x.first);
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n2 = ufs.get(b).find(x.second);
					ret.fks.get(fk).add(n1, n2);
					// System.out.println("on " + fk + " doing " + x + " is " + n1 + "," + n2);
				}
			}
			// System.out.println("xxx " + ret);
			for (En1 en : us.keySet()) {
				for (X x : us.get(en).keySet()) {
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n = us.get(en).get(x);
					ret.us.get(en).put(x, ufs.get(F.ens.get(en)).find(n));
				}
			}
			// System.out.println("merged " + ret);
			// ret.iso = iso.map((k,x)->new Pair<>(k,x.map(y->ufs.get(k).find(y))));
			return ret;
		}

		public String sizes() {
			String s = "";
			for (En2 en2 : ens.keySet()) {
				s += (en2 + ": " + ens.get(en2).size() + ", ");
			}
			return s;
		}
	}

	public Content T;

	private Iterator<Integer> fresh = new Iterator<Integer>() {
		private int i = 0;

		@Override
		public boolean hasNext() {
			return true;
		}

		@Override
		public Integer next() {
			return i++;
		}
	};

	public Chase(Mapping<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2> F, Instance<Ty,En1,Sym,Fk1,Att1,Gen,Sk,X,Y> I, int max) {
	private Instance<Ty, En1, Sym, Fk1, Att1, Gen, Sk, X, Y> I;

	public Chase(Mapping<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2> F, Instance<Ty, En1, Sym, Fk1, Att1, Gen, Sk, X, Y> I,
			int max) {
		this.F = F;
		this.I = I;
		T = new Content(I);
		
		// System.out.println(T.sizes());
		for (int i = 0; i < max; i++) {
			System.out.println(T);
			boolean changed = step();
			if (!changed) {
				return;
			}
			// System.out.println(T.sizes());
		}

		throw new RuntimeException("No convergence after " + max + " rounds.");
@@ -157,11 +183,13 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {

		// a : v -> w
		for (En2 v : F.dst.ens) {
			BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_v = T.ens.get(v);
			BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_v = T.ens
					.get(v);
			for (Fk2 a : F.dst.fksFrom(v)) {

				// T_v(x) -> Ey. T_a(x,y)
				BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_a = T.fks.get(a);
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_a = T.fks
						.get(a);
				for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> x : T_v.keySet()) {
					if (T_a.get(x) == null || T_a.get(x).isEmpty()) { // latter should be impossible
						toAdd.fks.get(a).add(x, new Lineage<>(fresh.next(), Term.Fk(a, x.t)));
@@ -170,27 +198,31 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
				}
			}
		}
		System.out.println("A " + changed);
		// System.out.println("A " + changed);
		// a : v -> w
		for (En2 v : F.dst.ens) {
			BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_v = T.ens.get(v);
			BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_v = T.ens
					.get(v);
			for (Fk2 a : F.dst.fksFrom(v)) {

				// T_v(x) -> Ey. T_a(x,y)
				BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_a = T.fks.get(a);
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_a = T.fks
						.get(a);

				// T_a(x,y) -> T_v(x) /\ T_w(y)
				En2 w = F.dst.fks.get(a).second;
				BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_w = T.ens.get(w);
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_w = T.ens
						.get(w);
				for (Pair<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> xy : T_a) {
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> x = xy.first;
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> y = xy.second;
					if (!T_v.containsKey(x)) {
						System.out.println("B " + changed);
						// System.out.println("B " + changed);
						changed = changed | toAdd.ens.get(v).add(x, x);
					}
					if (!T_w.containsKey(y)) {
						System.out.println("B2 " + y + " and " + T_w);
						// System.out.println("B2 " + y + " and a=" + a + " and v=" + v + " and w=" + w
						// + " and x=" + x + " tw = " + T_w);
						changed = changed | toAdd.ens.get(w).add(y, y);
					}
				}
@@ -206,7 +238,8 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
			// T_a(x,y) -> T_v(x) /\ T_w(y)
			En2 w = F.ens.get(a);
			Ctx<X, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_a = T.us.get(a);
				BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_w = T.ens.get(w);
			BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_w = T.ens
					.get(w);
			for (X xy : T_a.keySet()) {
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> x = T_a.get(xy);
				if (!T_w.containsKey(x)) {
@@ -215,7 +248,7 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
			}
		}

		System.out.println("C " + changed);
		// System.out.println("C " + changed);
		for (Triple<Pair<Var, En2>, Term<Ty, En2, Sym, Fk2, Att2, Void, Void>, Term<Ty, En2, Sym, Fk2, Att2, Void, Void>> eq : F.dst.eqs) {
			Chc<Ty, En2> t = F.dst.type(eq.first, eq.second);
			if (t.left) {
@@ -227,16 +260,16 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
			List<Fk2> rhs = eq.third.toFkList();

			Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> active = new HashSet<>();
			outer: for (Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> x : T.ens.get(src)) {
			for (Pair<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> x : T.ens
					.get(src)) {
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> initial = x.first;
				Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> N = Util.singSet(x.first);
				for (Fk2 fk : lhs) {
					Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> M = new HashSet<>();
					for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n : N) {
						Collection<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> s = T.fks.get(fk).get(n);
						if (s == null || s.isEmpty()) { //latter should be impossible
							active.add(initial);
							continue outer;
						if (s == null) {
							s = new LinkedList<>();
						}
						M.addAll(s);
					}
@@ -248,9 +281,8 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
					Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> M = new HashSet<>();
					for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n : N2) {
						Collection<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> s = T.fks.get(fk).get(n);
						if (s == null || s.isEmpty()) { //latter should be impossible
							active.add(initial);
							continue outer;
						if (s == null) { // latter should be impossible
							s = new LinkedList<>();
						}
						M.addAll(s);
					}
@@ -258,73 +290,116 @@ public class Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y> {
				}

				if (!N.equals(N2)) {
					// System.out.println(N + " and " + N2 + " for initial " + initial);
					active.add(initial);
					changed = true;
				}
			}
			System.out.println("D " + changed);
			for (Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> x : T.ens.get(src)) {
				Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>> n = x.first;
				Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>> m = x.first;
			// System.out.println("D active " + active.size() + " and actual " +
			// T.ens.get(src).size());
			for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> x : active) {
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n = x;
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> m = x;
				for (Fk2 fk : lhs) {
					toAdd.fks.get(fk).add(n, new Lineage<>(fresh.next(), Term.Fk(fk, n.t)));
					m = new Lineage<>(fresh.next(), Term.Fk(fk, n.t));
					toAdd.fks.get(fk).add(n, m);
					n = m;
				}

				Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>> n2 = x.first;
				Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>> m2 = x.first;
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n2 = x;
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> m2 = x;
				for (Fk2 fk2 : rhs) {
					toAdd.fks.get(fk2).add(n2, new Lineage<>(fresh.next(), Term.Fk(fk2, n2.t)));
					m2 = new Lineage<>(fresh.next(), Term.Fk(fk2, n2.t));
					toAdd.fks.get(fk2).add(n2, m2);
					n2 = m2;
				}
				
				// System.out.println("equating " + m + " = " + m2 + " at " + dst);
				ufs.get(dst).union(m, m2);
			}

		}

		//TODO must also do eq / naturality condition for En1
	
		for (Fk1 a : F.src.fks.keySet()) {
			En1 v = F.src.fks.get(a).first;
			En1 w = F.src.fks.get(a).second;
			// a.m_w = m_v.F(a)

		
			for (X x : I.algebra().en(v)) {
				X a0 = I.algebra().fk(a, x);
				Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> lhs = T.us.get(w).get(a0);

//				for (X y : T.us.get(v).keySet()) {
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> initial = T.us.get(v).get(x);
					Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> N = Util.singSet(initial);
					for (Fk2 fk : F.fks.get(a).second) {
						Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> M = new HashSet<>();
						for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n : N) {
							Collection<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> s = T.fks.get(fk).get(n);
							if (s == null) {
								s = new LinkedList<>();
							}
							M.addAll(s);
						}
						N = M;
					}
					Set<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> active = new HashSet<>();

					if (!N.equals(Util.singSet(lhs))) {
				//		 System.out.println(N + " for initial " + initial + " was not " + lhs);
						active.add(initial);
					//	changed = true;
					}
			//	}
				// System.out.println("D active " + active.size() + " and actual " +
				//		 T.us.get(v).keySet().size());
				 
				for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> y : active) {
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> n = y;
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> m = y;
					for (Fk2 fk : F.fks.get(a).second) {
						m = new Lineage<>(fresh.next(), Term.Fk(fk, n.t));
						toAdd.fks.get(fk).add(n, m);
						n = m;
					}

				//	System.out.println("equating " + m + " = " + lhs + " at " + F.ens.get(w));
					ufs.get(F.ens.get(w)).union(m, lhs);
				}
			}
		}
		T.addAll(toAdd);

		for (En2 v : F.dst.ens) {
			for (Fk2 a : F.dst.fksFrom(v)) {

				//T_a(x,y1) /\ T_b(x<Y>> T_a = T.fks.get(a);
				// T_a(x,y1) /\ T_b(x,y2) -> y2=y1;
				En2 w = F.dst.fks.get(a).second;
				BinRelMap<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> T_a= T.fks.get(a);
				BinRelMap<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>, Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> T_a = T.fks
						.get(a);

				for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> x : T_a.keySet()) {
					Collection<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> ys = T_a.get(x);
					// System.out.println("collection is " + ys);
					Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> y1 = Util.get0X(ys);
					for (Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>> y2 : ys) {
						if (!y1.equals(y2)) {
							ufs.get(w).union(y1, y2);
							//System.out.println("equating " + y1 + " = " + y2 + " at " + w);

							changed = true;
						}
					}
				}
			}
		}
		System.out.println("E " + changed);
		/*
		for (Fk1 a : src.fks.keySet()) {
			En1 v = src.fks.get(a).first;
			En1 w = src.fks.get(a).second;
			//a.m_w = m_v.F(a)
			Var x = new Var("x");
			Term<Ty, Chc<En1, En2>, Sym, Chc<Chc<Fk1,Fk2>,En1>, Chc<Att1, Att2>, Void, Void> lhs
			= Term.Fk(Chc.inRight(w), Term.Fk(Chc.inLeft(Chc.inLeft(a)), Term.Var(x)));
			
			Term<Ty, Chc<En1, En2>, Sym, Chc<Chc<Fk1,Fk2>,En1>, Chc<Att1, Att2>, Void, Void> rhs
			= Term.Fks(Chc.inLeft(Chc.inRight(fks.get(a).second)), Term.Fk(Chc.inRight(v), Term.Var(x)));
			
			eqs2.add(new Triple<>(new Pair<>(x, Chc.inLeft(v)), lhs, rhs));
		}*/
		// System.out.println("E " + changed);

		if (!changed) {
			return false;
		}

		T.addAll(toAdd);
		T = T.merge(ufs);

		return true;
+10 −6
Changes for src/catdata/aql/fdm/SigmaChaseAlgebra.java: 10 added lines, 6 removed lines.
Original line number Diff line number Diff line
package catdata.aql.fdm;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -56,13 +56,16 @@ public class SigmaChaseAlgebra<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk,
	
		chase = new Chase<Ty,En1,Sym,Fk1,Att1,En2,Fk2,Att2,Gen,Sk,X,Y>(F, X, max);
		
	
		for (En2 en2 : B.ens) {
			Collection<Lineage<Term<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> s = chase.T.ens.get(en2).keySet();
			ens0.put(en2, s);
		}
	
	
	}

	
	private final Ctx<En2, Set<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>>> ens0 = new Ctx<>();
	private final Ctx<En2, Collection<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>>> ens0 = new Ctx<>();


	@Override
@@ -82,7 +85,7 @@ public class SigmaChaseAlgebra<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk,
	}

	@Override
	public Set<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> en(En2 en) {
	public Collection<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>> en(En2 en) {
		return ens0.get(en);
	}

@@ -95,8 +98,8 @@ public class SigmaChaseAlgebra<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk,

	
	private Term<Ty, Void, Sym, Void, Void, Void, Chc<Sk, Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Att2>>> reprT0(Chc<Sk, Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Att2>> y) {
     return null;
		//   return schema().typeSide.js.java_tys.isEmpty() ? simpl(Term.Sk(y)) : schema().typeSide.js.reduce(simpl(Term.Sk(y)));
		return schema().typeSide.js.java_tys.isEmpty() ? simpl(Term.Sk(y))
				: schema().typeSide.js.reduce(simpl(Term.Sk(y)));
	} 
	
	@Override
@@ -170,6 +173,7 @@ public class SigmaChaseAlgebra<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk,
	@Override
	public Term<Ty, Void, Sym, Void, Void, Void, Chc<Sk, Pair<Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>>, Att2>>> att(
			Att2 att, Lineage<Term<Ty,En2,Sym,Fk2,Att2,Gen,Sk>> x) {
		
		return reprT0(Chc.inRight(new Pair<>(x, att)));
	}