public NormalSubstituter(Substitution subst, Substitution forold) : base() { Contract.Requires(subst != null); this.always = subst; this.forold = forold; }
private void Ask(LinkedList<Expression> goals, KnowledgeBase context, Substitution theta, ProverCache cache, VariableRenamer renamer, bool askOne, HashSet<Substitution> results, HashSet<Fact> alreadyAsking) { if (goals.Count == 0) results.Add(theta); else { Expression literal = goals.First.Value; goals.RemoveFirst(); Expression qPrime = Substituter.Substitute(literal, theta); var fact = qPrime as Fact; if (fact != null && fact.RelationName == GameContainer.Parser.TokDistinct) AskDistinct(fact, goals, context, theta, cache, renamer, askOne, results, alreadyAsking); else { var negation = qPrime as Negation; if (negation != null) AskNot(negation, goals, context, theta, cache, renamer, askOne, results, alreadyAsking); else { var disjunction = qPrime as Disjunction; if (disjunction != null) AskOr(disjunction, goals, context, theta, cache, renamer, askOne, results, alreadyAsking); else { var sentence = (Fact) qPrime; AskSentence(sentence, goals, context, theta, cache, renamer, askOne, results, alreadyAsking); } } } goals.AddFirst(literal); } }
/// <summary> /// Hide data in buffer /// </summary> /// <param name="buffer">Buffer in which data is to be hidden</param> /// <param name="bufferLen">Length of buffer</param> protected virtual unsafe int HideData(byte *buffer, int bufferLen) { int offset = 0; while ((offset + 8) < bufferLen) { iter++; int next = this._message.NextByte(); if (next == -1) { this._processing = ProcessingType.Done; ///No more data to hide break; } byte data = (byte)next; ///Get 8 bytes of cover message and ///hide a byte of data in it for (int i = 0; i < 8; i++) { byte cover = buffer[offset]; ///Right shift the data to get next byte and AND with 1 = 00000001 Substitution.LsbSubstitute(ref cover, (byte)(((data >> i) & 0x1))); buffer[offset] = cover; offset++; } } return(offset); }
public NormalSubstituter(Substitution subst) : base() { Contract.Requires(subst != null); this.always = subst; this.forold = Substituter.SubstitutionFromHashtable(new Dictionary <Variable, Expr>()); }
public CodeCopier(Dictionary<Variable, Expr> substMap, Dictionary<Variable, Expr> oldSubstMap) { Contract.Requires(oldSubstMap != null); Contract.Requires(substMap != null); Subst = Substituter.SubstitutionFromHashtable(substMap); OldSubst = Substituter.SubstitutionFromHashtable(oldSubstMap); }
// ----------------------------- Substitutions for Cmd ------------------------------- /// <summary> /// Apply a substitution to a command. Any variables not in domain(subst) /// is not changed. The substitutions apply within the "old", but the "old" /// expression remains. /// </summary> public static Cmd Apply(Substitution subst, Cmd cmd) { Contract.Requires(subst != null); Contract.Requires(cmd != null); Contract.Ensures(Contract.Result <Cmd>() != null); return((Cmd) new NormalSubstituter(subst).Visit(cmd)); }
// ----------------------------- Substitutions for CmdSeq ------------------------------- /// <summary> /// Apply a substitution to a command sequence. Any variables not in domain(subst) /// is not changed. The substitutions apply within the "old", but the "old" /// expression remains. /// </summary> public static List <Cmd> Apply(Substitution subst, List <Cmd> cmdSeq) { Contract.Requires(subst != null); Contract.Requires(cmdSeq != null); Contract.Ensures(Contract.Result <Cmd>() != null); return(new NormalSubstituter(subst).VisitCmdSeq(cmdSeq)); }
/** * Creates an identical substitution. * * @return A new, identical substitution. */ public Substitution Copy() { var copy = new Substitution(); foreach (var kv in _contents) copy._contents[kv.Key] = kv.Value; return copy; }
// ----------------------------- Substitutions for Expr ------------------------------- /// <summary> /// Apply a substitution to an expression. Any variables not in domain(subst) /// is not changed. The substitutions apply within the "old", but the "old" /// expression remains. /// </summary> public static Expr Apply(Substitution subst, Expr expr) { Contract.Requires(subst != null); Contract.Requires(expr != null); Contract.Ensures(Contract.Result <Expr>() != null); return((Expr) new NormalSubstituter(subst).Visit(expr)); }
public static void SubstituteIncarnationInInstantiationSources(Cmd cmd, Substitution incarnationSubst) { QKeyValue iter = null; if (cmd is AssignCmd assignCmd) { iter = assignCmd.Attributes; } else if (cmd is PredicateCmd predicateCmd) { iter = predicateCmd.Attributes; } while (iter != null) { if (iter.Key == "inst_add") { var label = iter.Params[0] as string; var instance = iter.Params[1] as Expr; if (label != null && instance != null) { instance = Substituter.Apply(incarnationSubst, instance); iter.ClearParams(); iter.AddParams(new List <object> { label, instance }); } } iter = iter.Next; } }
private void TryElimination(IEnumerable <Variable> extraDefinedVariables) { bool Defined(Variable v) => varToExpr.ContainsKey(v) || extraDefinedVariables.Contains(v); bool changed; do { changed = false; var remainingAssignments = new List <Assignment>(); foreach (var assignment in assignments) { if (!Defined(assignment.Var) && VariableCollector.Collect(assignment.Expr).Intersect(AllIntroducedVariables).All(Defined)) { varToExpr[assignment.Var] = SubstitutionHelper.Apply(varToExpr, assignment.Expr); changed = true; } else { remainingAssignments.Add(assignment); } } Substitution sub = Substituter.SubstitutionFromDictionary(varToExpr); foreach (var assignment in remainingAssignments) { assignment.Expr = Substituter.Apply(sub, assignment.Expr); } assignments = remainingAssignments; assumes = SubstitutionHelper.Apply(sub, assumes).ToList(); } while (changed); }
public IResMemberTerm Substitute(Substitution subst) { var obj = _obj.Substitute(subst); var memberSpec = _memberSpec.Substitute(subst); var objType = obj.Type; var dataType = objType; if (objType is ResFreqQualType) { dataType = ((ResFreqQualType)objType).Type; } if (dataType is Spark.Resolve.ResDummyTypeArg) { var typeArg = (Spark.Resolve.ResDummyTypeArg)dataType; if(typeArg.ConcreteType != null ) dataType = typeArg.ConcreteType; } if (dataType is ResErrorTerm) { } else if (dataType is IResContainerRef) { var containerRef = (IResContainerRef)dataType; memberSpec = containerRef.FindMember(memberSpec).EffectiveSpec; } return new ResMemberBind( _range, obj, memberSpec); }
private List <Cmd> InlineYieldLoopInvariants(List <CallCmd> yieldInvariants) { var inlinedYieldInvariants = new List <Cmd>(); foreach (var callCmd in yieldInvariants) { var yieldInvariant = civlTypeChecker.procToYieldInvariant[callCmd.Proc]; if (layerNum == yieldInvariant.LayerNum) { Dictionary <Variable, Expr> map = callCmd.Proc.InParams.Zip(callCmd.Ins) .ToDictionary(x => x.Item1, x => x.Item2); Substitution subst = Substituter.SubstitutionFromDictionary(map); foreach (Requires req in callCmd.Proc.Requires) { var newExpr = Substituter.Apply(subst, req.Condition); if (req.Free) { inlinedYieldInvariants.Add(new AssumeCmd(req.tok, newExpr, req.Attributes)); } else { inlinedYieldInvariants.Add(new AssertCmd(req.tok, newExpr, req.Attributes)); } } } } return(inlinedYieldInvariants); }
public static Substitution Unify(Fact x, Fact y) { Substitution theta = new Substitution(); bool isGood = UnifyTerm(x.ToTerm(), y.ToTerm(), theta); return isGood ? theta : null; }
public IFormula visit(ExistentialFormula f) { if (f.f is Or) { var c = f.f as Or; var i1 = c.f1.ffreeVariables.Contains(f.var); var i2 = c.f2.ffreeVariables.Contains(f.var); if (i1 && i2) { var newVar = srs.getFreshVariable(f.var); var ns = new Substitution(f.var, new Variable(newVar)); return(new Or( new ExistentialFormula(f.var, c.f1, f.attributes, f.triggers).visit(this), new ExistentialFormula(newVar, c.f2.substitute(ns), f.attributes, from ts in f.triggers select from t in ts select t.substitute(ns)).visit( this) )); } else if (i1) { return(new Or(new ExistentialFormula(f.var, c.f1, f.attributes, f.triggers).visit(this), c.f2.visit(this))); } else if (i2) { return(new Or(c.f1.visit(this), new ExistentialFormula(f.var, c.f2, f.attributes, f.triggers).visit(this))); } else { return(c.visit(this)); } } else if (f.f is And) { var c = f.f as And; var i1 = c.f1.ffreeVariables.Contains(f.var); var i2 = c.f2.ffreeVariables.Contains(f.var); if (i1 && i2) { return(new ExistentialFormula(f.var, f.f.visit(this), f.attributes, f.triggers)); } else if (i1) { return(new And(new ExistentialFormula(f.var, c.f1, f.attributes, f.triggers).visit(this), c.f2.visit(this))); } else if (i2) { return(new And(c.f1.visit(this), new ExistentialFormula(f.var, c.f2, f.attributes, f.triggers).visit(this))); } else { return(c.visit(this)); } } else { return(new ExistentialFormula(f.var, f.f.visit(this), f.attributes, f.triggers)); } }
public void GetDisplayName_WithoutSubstitutedUser() { Substitution substitution = Substitution.NewObject(); substitution.SubstitutedUser = null; Assert.That(substitution.DisplayName, Is.EqualTo("?")); }
public void Initialize() { Substitution substitution = Substitution.NewObject(); Assert.That(substitution.IsEnabled, Is.True); Assert.That(substitution.BeginDate, Is.Null); Assert.That(substitution.EndDate, Is.Null); }
public void Clone_AnySubstitution_ClonedSubstitution(string s) { var sub = new Substitution(s); var clone = sub.Clone(); Assert.That(!ReferenceEquals(sub, clone)); Assert.That(sub.Equals(clone)); }
public static int ReplaceFirst(Matcher m,Substitution substitution,TextWriter _out) { try { return ReplaceFirst(m,substitution,Wrap(_out)); } catch(WriteException e) { throw e.reason; } }
public ReplacingOldSubstituter(Substitution always, Substitution forold) : base() { Contract.Requires(forold != null); Contract.Requires(always != null); this.always = always; this.forold = forold; }
/// <summary> /// Apply a substitution to a command replacing "old" expressions. /// Outside "old" expressions, the substitution "always" is applied; any variable not in /// domain(always) is not changed. Inside "old" expressions, apply map "oldExpr" to /// variables in domain(oldExpr), apply map "always" to variables in /// domain(always)-domain(oldExpr), and leave variable unchanged otherwise. /// </summary> public static Cmd ApplyReplacingOldExprs(Substitution always, Substitution forold, Cmd cmd) { Contract.Requires(cmd != null); Contract.Requires(forold != null); Contract.Requires(always != null); Contract.Ensures(Contract.Result <Cmd>() != null); return((Cmd) new ReplacingOldSubstituter(always, forold).Visit(cmd)); }
public override IResExp Substitute(Substitution subst) { return new ResAttributeFetch( this.Range, this.Type.Substitute(subst), _obj.Substitute(subst), _attribute.Substitute(subst)); }
/// <summary> /// Apply a substitution to a command sequence replacing "old" expressions. /// Outside "old" expressions, the substitution "always" is applied; any variable not in /// domain(always) is not changed. Inside "old" expressions, apply map "forOld" to /// variables in domain(forOld), apply map "always" to variables in /// domain(always)-domain(forOld), and leave variable unchanged otherwise. /// </summary> public static List <Cmd> ApplyReplacingOldExprs(Substitution always, Substitution forOld, List <Cmd> cmdSeq) { Contract.Requires(always != null); Contract.Requires(forOld != null); Contract.Requires(cmdSeq != null); Contract.Ensures(Contract.Result <Cmd>() != null); return(new ReplacingOldSubstituter(always, forOld).VisitCmdSeq(cmdSeq)); }
/// <summary> /// Apply a substitution to a command. /// Outside "old" expressions, the substitution "always" is applied; any variable not in /// domain(always) is not changed. Inside "old" expressions, apply map "forOld" to /// variables in domain(forOld), apply map "always" to variables in /// domain(always)-domain(forOld), and leave variable unchanged otherwise. /// </summary> public static Cmd Apply(Substitution always, Substitution forOld, Cmd cmd) { Contract.Requires(always != null); Contract.Requires(forOld != null); Contract.Requires(cmd != null); Contract.Ensures(Contract.Result <Cmd>() != null); return((Cmd) new NormalSubstituter(always, forOld).Visit(cmd)); }
public ActionResult DeleteConfirmed(string id) { Substitution substitution = db.Substitutions.Find(id); db.Substitutions.Remove(substitution); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task AddSubstitution(Substitution sub) { sub.Player = await _context.Players.FirstAsync(p => p.Id == sub.PlayerId); await _context.Substitutions.AddAsync(sub); await _context.SaveChangesAsync(); }
public static Expr FunctionCallReresolvingApply(Substitution always, Substitution forOld, Expr expr, Program program) { Contract.Requires(always != null); Contract.Requires(forOld != null); Contract.Requires(expr != null); Contract.Ensures(Contract.Result <Expr>() != null); return((Expr) new FunctionCallReresolvingNormalSubstituter(program, always, forOld).Visit(expr)); }
public override IResExp Substitute(Substitution subst) { return new ResMethodApp( this.Range, this.Type.Substitute(subst), _method.Substitute<IResMethodRef>(subst), from a in _args select a.Substitute(subst)); }
public void Test_SelfCompare_Diferent() { var c = Condition.Parse("[x] != Self"); var s = new Substitution("[x]/Agatha"); var res = c.Evaluate(_kb, Name.SELF_SYMBOL, new[] { new SubstitutionSet(s) }); Assert.IsFalse(res); }
/// <summary> /// Apply a substitution to an expression replacing "old" expressions. /// Outside "old" expressions, the substitution "always" is applied; any variable not in /// domain(always) is not changed. Inside "old" expressions, apply map "forOld" to /// variables in domain(forOld), apply map "always" to variables in /// domain(always)-domain(forOld), and leave variable unchanged otherwise. /// </summary> public static Expr ApplyReplacingOldExprs(Substitution always, Substitution forold, Expr expr) { Contract.Requires(expr != null); Contract.Requires(forold != null); Contract.Requires(always != null); Contract.Ensures(Contract.Result <Expr>() != null); return((Expr) new ReplacingOldSubstituter(always, forold).Visit(expr)); }
public override Expr VisitNAryExpr(NAryExpr node) { if (!(node.Fun is FunctionCall)) { return(base.VisitNAryExpr(node)); } var FC = node.Fun as FunctionCall; // Can't inline SMTLIBv2 functions if (QKeyValue.FindStringAttribute(FC.Func.Attributes, "bvbuiltin") != null) { return(base.VisitNAryExpr(node)); } if (Condition(FC.Func)) { if (FC.Func.Body == null) { throw new InvalidOperationException("Can't inline a function without a body"); } // Compute mapping var varToExprMap = new Dictionary <Variable, Expr>(); foreach (var parameterArgumentPair in FC.Func.InParams.Zip(node.Args)) { varToExprMap.Add(parameterArgumentPair.Item1, parameterArgumentPair.Item2); } // Using Closure :) Substitution sub = delegate(Variable v) { try { return(varToExprMap[v]); } catch (KeyNotFoundException) { // The substituter seems to expect null being // returned if we don't want to change the variable return(null); } }; // Return the Function expression with variables substituted for function arguments. // This is basically inling ++InlineCounter; var result = Substituter.Apply(sub, FC.Func.Body); // Make sure we visit the result because it may itself contain function calls return((Expr)base.Visit(result)); } else { return(base.VisitNAryExpr(node)); } }
public void GetDisplayName_WithSubstitutedUser() { User user = TestHelper.CreateUser("user", "Firstname", "Lastname", "Title", null, null); Substitution substitution = Substitution.NewObject(); substitution.SubstitutedUser = user; Assert.That(substitution.DisplayName, Is.EqualTo("Lastname Firstname, Title")); }
public IResTypeExp Substitute(Substitution subst) { var memberTerm = this.MemberTerm.Substitute(subst); return(new ResTypeSlotRef( this.Range, (ResTypeSlotDecl)memberTerm.Decl, memberTerm)); }
public IResConceptClassRef Substitute(Substitution subst) { var memberTerm = this.MemberTerm.Substitute(subst); return(new ResConceptClassRef( this.Range, (ResConceptClassDecl)memberTerm.Decl, memberTerm)); }
public IResMethodRef Substitute(Substitution subst) { var memberTerm = MemberTerm.Substitute(subst); return(new ResMethodRef( Range, (ResMethodDecl)memberTerm.Decl, memberTerm)); }
public void Substitution_ValidVariableAndValidValue_NewSubstitution(string var, string val) { var sub = new Substitution(var, val); Assert.That(sub.Variable.ToString() == var); Assert.That(sub.Value.ToString() == val); var sub2 = new Substitution(Name.BuildName(var), Name.BuildName(val)); Assert.That(sub2.Equals(sub)); }
public Type Infer(Environment env) { var subst = new Substitution(); var ret = Infer(env, subst); ret.Perform(subst); env.Perform(subst); return(ret); }
private Term ApplySubstitution(Substitution newSubstitution, Term substituteTerm) { var substitutionFrame = new Frame(_termDatabase); substitutionFrame.RootTerms.Add(substituteTerm); substitutionFrame.Substitutions.Add(newSubstitution); substitutionFrame.Rewrite(int.MaxValue); return(substitutionFrame.RootTerms.Single()); }
public IResGenericRef Substitute(Substitution subst) { var memberTerm = this.MemberTerm.Substitute(subst); return(new ResGenericRef( this.Range, (ResGenericDecl)memberTerm.Decl, memberTerm)); }
protected override IEnumerable<SubstitutionSet> CheckActivation(IQueryable db, Name perspective, IEnumerable<SubstitutionSet> constraints) { foreach (var result in m_other.Retrive(db, perspective, constraints)) { var sub = new Substitution(m_variable, result.Item1); if (result.Item2.AddSubstitution(sub)) yield return result.Item2; } }
public ResGlobalMemberTerm( SourceRange range, ILazy<IResModuleDecl> module, IResMemberDecl decl) { _range = range; _module = module; _decl = decl; _subst = new Substitution(); }
private static TermFunction SubstituteFunction(TermFunction function, Substitution theta) { if (!function.HasVariables) return function; var body = new List<Term>(); for (int i = 0; i < function.Arity; i++) body.Add(SubstituteTerm(function.GetTerm(i), theta)); return new TermFunction(function.FunctionName, body.ToArray()); }
public override string GetState(Newtonsoft.Json.Linq.JObject jobject) { var result = Response; Substitution s = new Substitution(); Dictionary<string, string> pairs = new Dictionary<string, string>(); pairs["PropertyName"] = PropertyName; pairs["PropertyValue"] = GetValue(jobject, PropertyName); pairs["PropertyHasValue"] = (jobject[PropertyName] != null).ToString().ToLower(); result = s.Substitute(result, pairs); return result; }
public static int ReplaceFirst(Matcher m,Substitution substitution,TextBuffer dest) { int c=0; if(m.Find()) { if(m.Start>0) m.Group(Matcher.PREFIX,dest); substitution.AppendSubstitution(m,dest); c++; m.SetTarget(m,Matcher.SUFFIX); } m.Group(Matcher.TARGET,dest); return c; }
public Substitution Compose(Substitution thetaPrime) { var result = new Substitution(); foreach (var kv in _contents) result._contents[kv.Key] = kv.Value; foreach (var kv in thetaPrime._contents) result._contents[kv.Key] = kv.Value; return result; }
private static Fact SubstituteDistinct(Fact distinct, Substitution theta) { if (distinct is GroundFact) return distinct; Term arg1 = SubstituteTerm(distinct.GetTerm(0), theta); Term arg2 = SubstituteTerm(distinct.GetTerm(1), theta); return arg1.HasVariables || arg2.HasVariables ? new VariableFact(false, distinct.RelationName, arg1, arg2) : (Fact) new GroundFact(distinct.RelationName, arg1, arg2); }
private static bool UnifyVariable(TermVariable var, Term x, Substitution theta) { if (theta.Contains(var)) return UnifyTerm(theta[var], x, theta); TermVariable termVariable = x as TermVariable; if ((termVariable != null) && theta.Contains(termVariable)) return UnifyTerm(var, theta[termVariable], theta); theta[var] = x; return true; }
public void AddSubstitution(Substitution s) { Constraint c; bool needsBuild = !m_constraints.TryGetValue(s.Variable, out c); if (s.Value.IsVariable) { Constraint c2; if (m_constraints.TryGetValue(s.Value, out c2)) { if (needsBuild) { m_constraints[s.Variable] = c2; c2.EquivalentVariables.Add(s.Variable); } else if (!Object.ReferenceEquals(c, c2)) { c2.UnionWith(c); foreach (var v in c2.EquivalentVariables) m_constraints[v] = c2; } } else { if (needsBuild) { c = new Constraint(); m_constraints[s.Variable] = c; c.EquivalentVariables.Add(s.Variable); } m_constraints[s.Value] = c; c.EquivalentVariables.Add(s.Value); } } else { if (needsBuild) { c = new Constraint(); m_constraints[s.Variable] = c; c.EquivalentVariables.Add(s.Variable); } c.Value = s.Value; } m_substitutions.Add(s); m_hashIsDirty = true; }
public static int Replace(Matcher m,Substitution substitution,TextBuffer dest) { bool firstPass=true; int c=0; while(m.Find()) { if(m.End==0 && !firstPass) continue; //allow to Replace at "^" if(m.Start>0) m.Group(Matcher.PREFIX,dest); substitution.AppendSubstitution(m,dest); c++; m.SetTarget(m,Matcher.SUFFIX); firstPass=false; } m.Group(Matcher.TARGET,dest); return c; }
void Start() { levelNameSubstitution = DynamicTextManager.instance.Substitute("#{hoveredLevelName}", () => hovered == null ? "" : hovered.levelName); levelStatusSubstitution = DynamicTextManager.instance.Substitute("#{hoveredLevelStatus}", () => { if (hovered == null) { return ""; } if (hovered.level.Completed()) { return "completed"; } if (hovered.level.Unlocked()) { return "unlocked"; } return "locked"; }); }
public GenericFactory(Type genericTypeDescription, Subsistence subsistence, object serviceKey, ConstructorInfo constructor, Substitution substitution) : base(genericTypeDescription, serviceKey, substitution) { Subsistence = subsistence; Constructor = constructor; _dependencyFactories = new Dictionary<Type, IDependencyFactory>(); ConstructorInfo[] allConstructors = Type.GetConstructors(); for (int i = 0; i < allConstructors.Length; i++) if (allConstructors[i] == constructor) { _constructorIndex = i; break; } }
private static Expression SubstituteLiteral(Expression literal, Substitution theta) { var negation = literal as Negation; if (negation != null) return SubstituteNot(negation, theta); var disjunction = literal as Disjunction; if (disjunction != null) return SubstituteOr(disjunction, theta); var fact = (Fact) literal; return fact.RelationName == GameContainer.Parser.TokDistinct ? SubstituteDistinct(fact, theta) : SubstituteSentence(fact, theta); }
public ResMemberBind( SourceRange range, IResExp obj, IResMemberSpec memberSpec) { _range = range; _obj = obj; _memberSpec = memberSpec; _subst = new Substitution( memberSpec.Container.MemberTerm.Subst ); // \todo: Need to ensure "obj" is clone-able... // \todo: Need to iteratively re-subst... _subst.Insert( memberSpec.Container.ThisParameter, (r) => obj); }
public TransientFactory(Type type, object serviceKey, ConstructorInfo constructorInfo, Substitution substitution) : base(type, serviceKey, substitution) { _constructorData = new ConstructorData(constructorInfo); PropertyInfo[] propertyInfos = type.GetProperties() .Where(x => x.SetMethod != null && x.SetMethod.IsPublic && x.GetCustomAttribute<InjectableAttribute>() != null) .ToArray(); _propertiesData = new PropertyData[propertyInfos.Length]; for (int i = 0; i < _propertiesData.Length; i++) _propertiesData[i] = new PropertyData(propertyInfos[i]); FieldInfo[] fieldInfos = type.GetFields() .Where(x => x.IsPublic && x.GetCustomAttribute<InjectableAttribute>() != null) .ToArray(); _fieldsData = new FieldData[fieldInfos.Length]; for (int i = 0; i < _fieldsData.Length; i++) _fieldsData[i] = new FieldData(fieldInfos[i]); }
private static bool UnifyTerm(Term x, Term y, Substitution theta) { if (x.Equals(y)) return true; if (x is TermVariable) { if (!UnifyVariable((TermVariable)x, y, theta)) return false; } else if (y is TermVariable) { if (!UnifyVariable((TermVariable)y, x, theta)) return false; } else if ((x is TermFunction) && (y is TermFunction)) { var xFunction = (TermFunction)x; var yFunction = (TermFunction)y; if (xFunction.FunctionName != yFunction.FunctionName) return false; for (int i = 0; i < xFunction.Arity; i++) { if (!UnifyTerm(xFunction.GetTerm(i), yFunction.GetTerm(i), theta)) return false; } } else { return false; } return true; }
public IResMemberSpec Substitute(Substitution subst) { return new ResMemberSpec( _range, _container.Substitute<IResContainerRef>(subst), _decl); }
public FunctionCallReresolvingNormalSubstituter(Program program, Substitution always, Substitution forold) : base(always, forold) { Program = program; }
public NormalSubstituter(Substitution subst) : base() { Contract.Requires(subst != null); this.always = subst; this.forold = Substituter.SubstitutionFromHashtable(new Dictionary<Variable, Expr>()); }