private BasicMapWrite( MapType mapType, ITypeTuple indexTypes, IType sourceType, IType resultType, ITypeTuple mapTypeArguments ) { Debug.Assert(mapType != null); Debug.Assert(mapTypeArguments != null); Debug.Assert(indexTypes != null); Debug.Assert(sourceType != null); Debug.Assert(resultType != null); Debug.Assert(indexTypes.Count() == mapType.domain.Count()); Debug.Assert(mapTypeArguments.Count() == mapType.typeParameters.Length); this.mapType = mapType; mapIndexTypes = indexTypes; this.sourceType = sourceType; this.resultType = resultType; this.mapTypeArguments = TypeTuple.make(mapTypeArguments); Debug.Assert(this.mapTypeArguments != null); this.typeArguments = TypeTuple.make(new IType[1] { mapType }.Concat(mapTypeArguments)); this.argumentTypes = TypeTuple.make(new [] { mapType }.Concat(mapIndexTypes).Concat(new[] { sourceType })); this.freeTypeVariables = new HashSet <TypeVariable>(resultType.freeTypeVariables. Union(mapType.freeTypeVariables). Union(sourceType.freeTypeVariables). Union(from it in mapIndexTypes from fv in it.freeTypeVariables select fv) ); }
public TypeConstructorInstance(TypeConstructor typeConstructor, IEnumerable <IType> arguments) { Debug.Assert(typeConstructor != null); Debug.Assert(arguments != null); Debug.Assert(arguments.Count() == typeConstructor.arity); Debug.Assert(arguments.All(x => x != null)); this.typeConstructor = typeConstructor; this.arguments = TypeTuple.make(arguments); }
private string argumentString(ITypeTuple dataType) { string result = "<"; for (int i = 0; i < dataType.Count(); i++) { result += ((i == 0) ? "" : ",") + dataType[i].ToStringN(); } result += ">"; return(result); }
private string getInstantiationString(ITypeTuple typeArguments) { string result = "("; foreach (var t in typeArguments) { result += "," + t.ToString(); } result += " )"; return(result); }
public static BasicMapRead mapRead(MapType mapType, ITypeTuple typeArguments) { Debug.Assert(mapType != null); Debug.Assert(typeArguments != null); Debug.Assert(mapType.typeParameters.Length == typeArguments.Count()); var s = new TypeParameterInstantiation(mapType.typeParameters, typeArguments); var argumentTypes = TypeTuple.make(new [] { mapType }.Concat(from a in mapType.domain select a.substitute(s))); var resultType = mapType.range.substitute(s); return(mapRead(typeArguments, argumentTypes, resultType)); }
public bool isEquivalent(ITypeTuple other) { Debug.Assert(other.Count() == ts.Length); for (var i = 0; i < ts.Length; i++) { if (!ts[i].isEquivalent(other[i])) { return(false); } } return(true); }
// public readonly int index; // private static int lastIndex = 0; protected Function(string name, ITypeTuple argumentTypes, IType resultType) : base(name, name, argumentTypes) { // if (name == @"2147483647") // Debugger.Break(); this.resultType = resultType; hashCache = nameN.GetHashCode(); // index = lastIndex; // lastIndex++; #if DEBUG m[name] = this; #endif }
public BasicFunctionTemplateInstance( FunctionTemplate template, IEnumerable <IType> typeArguments ) : base( template.name, template.signature.resultType.substitute(new TypeParameterInstantiation(template.typeParameters, typeArguments)), (from at in template.signature.argumentTypes select at.substitute(new TypeParameterInstantiation(template.typeParameters, typeArguments))).ToArray() ) { this.template = template; pTypeArguments = TypeTuple.make(typeArguments); }
//////////////////////////////////////////////////////////////////////////////////////////////// public static string makeString(ITypeTuple ta) { string result = ""; if (ta.Count() > 0) { result += "<"; for (int i = 0; i < ta.Count(); i++) { result += ((i == 0) ? "" : ",") + ta[i].ToStringN(); } result += ">"; } return(result); }
public Function getFunction(string name, ITypeTuple typeArguments) { if (parentScope != null) { return(parentScope.getFunction(name, typeArguments)); } Debug.Assert(typeArguments != null); Debug.Assert(name != null); FunctionTemplate template = null; if (!standardFunctionTemplates.TryGetValue(name, out template)) { template = myFunctionTemplates[name]; } Debug.Assert(template != null); return(template.getInstance(typeArguments)); }
private static string makeIndexString(ITypeTuple typeArguments, ITypeTuple argumentTypes) { string indexString = "<"; for (int i = 0; i < typeArguments.Count(); i++) { indexString += (String.IsNullOrEmpty(indexString) ? "" : ",") + typeArguments[i].ToString(); } indexString += ">("; for (int i = 0; i < argumentTypes.Count(); i++) { indexString += (indexString == "" ? "" : ",") + argumentTypes[i].ToString(); } indexString += ")"; return(indexString); }
private void addConditionalMapEqualityAxiom(Expression[] i, Expression mu, Expression m, ITypeTuple typeArguments) { Debug.Assert(mu.type.ToStringN() == m.type.ToStringN()); string mlIndex = TypeInstanceCollector.makeString(typeArguments); Debug.Assert(tic.functionInstanceMap["MapRead"].ContainsKey(mlIndex)); Debug.Assert(m.type is MapType); var mt = m.type as MapType; TypeInstanceCollector.GFunctionInstance[] tpis = (from tpi in tic.functionInstanceMap["MapRead"].Values where tpi.function.typeArguments.First().ToStringN() == mt.ToStringN() select tpi).ToArray(); Debug.Assert( (from tpi in tpis select TypeInstanceCollector.makeString(tpi.function.typeArguments)).Contains( TypeInstanceCollector.makeString(typeArguments))); foreach (var tpi in tpis) { var ta = tpi.function.typeArguments; Debug.Assert(ta.Count() == mt.typeParameters.Count() + 1); Debug.Assert(ta.First().ToStringN() == mt.ToStringN()); var mta = ta.Skip(1).ToArray(); var ts = new TypeParameterInstantiation(mt.typeParameters, mta); var at = (from a in mt.domain select a.substitute(ts)).ToArray(); var rt = mt.range.substitute(ts); var bvs = (from a in at select procedure.makeFreshBoundVariable(a)).ToArray(); var bves = (from bv in bvs select new BasicBoundVariableExpression(bv)).ToArray(); if (TypeInstanceCollector.makeString(ta) == TypeInstanceCollector.makeString(typeArguments)) { addAxiom( sentence(implication(inEquality(bves, i), equality(ml(m, bves, mta, rt), ml(mu, bves, mta, rt))))); } else { addAxiom(sentence(equality(ml(m, bves, mta, rt), ml(mu, bves, mta, rt)))); } } }
public MapType(TypeVariable[] typeParameters, IEnumerable <IType> domain, IType range, TypeConstructorInstance originalType) { Debug.Assert(typeParameters != null); Debug.Assert(domain != null); Debug.Assert(range != null); Debug.Assert(domain.All(xx => xx != null)); this.typeParameters = new TypeVariable[typeParameters.Length]; for (int i = 0; i < typeParameters.Length; i++) { this.typeParameters[i] = typeParameters[i]; } this.domain = TypeTuple.make(domain); this.range = range; this.originalType = originalType; }
public Function getInstance(ITypeTuple typeArguments) { Debug.Assert(typeArguments.Count() == typeParameters.Length); BasicFunctionTemplateInstance result = null; bool foundInstance = instances.TryGetValue(getInstantiationString(typeArguments), out result); if (result != null) { for (int i = 0; i < typeArguments.Count(); i++) { if (!ReferenceEquals(typeArguments[i], result.typeArguments[i])) { foundInstance = false; break; } } } if (!foundInstance) { result = new BasicFunctionTemplateInstance(this, typeArguments); } return(result); }
public InterpretedPredicate(string name, ITypeTuple argumentTypes) : base(name, argumentTypes) { Debug.Assert(name != StateSpace.Functions.Basic.BFunctionTemplate.lt.name); }
protected Predicate(string name, ITypeTuple argumentTypes) : base(name, name, argumentTypes) { pps[true] = new PP(this); pps[false] = pps[true].n; }
internal static string polish(ITypeTuple dts) { return(dts.Aggregate("", (s, dt) => s + "_" + polish(dt))); }
public InterpretedFunction(string name, ITypeTuple argumentTypes, IType resultType) : base(name, argumentTypes, resultType) { }
public Function findFunction(string name, ITypeTuple Signature) { throw new NotImplementedException(); }