public FVT(LVar variable) : base() { this.variable = variable; count++; varMS = new FVMS(variable); }
public static int compare(FVMS ms1, FVMS ms2) { if (ms1.count <= ms2.count) { return(compare1(ms1, ms2)); } else { return(-compare1(ms2, ms1)); } }
internal FC(IEnumerable <IL> ils) : base(ils) { #if DEBUG index = currentIndex; currentIndex++; m[index] = this; #endif stringNCache = makeStringN(ils); hashCache = stringNCache.GetHashCode(); varMS = new FVMS(from il in ils select il.fvMS); }
internal FTT(IEnumerable <IT> its) : base(its) { Debug.Assert(its.Any()); Debug.Assert(its.Any(t => t.freeVariables.Any())); // Debug.Assert(terms.All(t => !(t is GroundTermEC) || universe.groundTermMergeMap[t as GroundTermEC]==t)); pHeight = its.Max(t => t.height) + 1; // pWeight = terms.Sum(t => t.weight) + 1; stringCacheN = makeStringN(ts); hashCache = stringCacheN.GetHashCode(); index = currentIndex; currentIndex++; #if DEBUG m[index] = this; #endif varMS = new FVMS(from it in its select it.fvMS); }
//{-2,2} : incomparable, {-1} il1<il1, {0} equal, {1} il1>il2 private static int compare1(FVMS ms1, FVMS ms2) { Debug.Assert(ms1.count <= ms2.count); var il1g = false; var il2g = ms1.count < ms2.count; foreach (var kv in ms1.fvms) { int il2v; if (!ms2.fvms.TryGetValue(kv.Key, out il2v)) { return(2); } var c = kv.Value - il2v; if (c > 0) { if (il2g) { return(2); //incomparable } il1g = true; } else if (c < 0) { if (il1g) { return(2); //incomparable } il2g = true; } } Debug.Assert(!il1g || !il2g); Debug.Assert(ms1.count == ms2.count || il1g || il2g); if (il1g) { return(1); } if (il2g) { return(-1); } return(0); }