/// <summary> /// If this is a variable with ought be replaced with another expression in a b-reduction, do so /// </summary> /// <param name="what">The variable which must be replaced</param> /// <param name="with">That with which we must replace what</param> internal override void Replace(LambdaVariable what, LambdaTerm with) { if (Name == what.Name && !IsBound()) { if (Parent.GetType() == typeof(LambdaFunction)) { (Parent as LambdaFunction).Output = with; with.Parent = (Parent as LambdaFunction); } else if (Parent.GetType() == typeof(LambdaApplication)) { if ((Parent as LambdaApplication).First == this) { (Parent as LambdaApplication).First = with; with.Parent = (Parent as LambdaApplication); } else { (Parent as LambdaApplication).Second = with; with.Parent = (Parent as LambdaApplication); } } else if (Parent.GetType() == typeof(LambdaExpression)) { (Parent as LambdaExpression).Root = with; with.Parent = (Parent as LambdaExpression); } } }
public LambdaFunction(LambdaVariable input, LambdaTerm output) { input.Parent = this; output.Parent = this; Input = input; Output = output; Input.IsDefinition = true; }
internal virtual void Replace(LambdaVariable what, LambdaTerm with) { }
internal override void Replace(LambdaVariable what, LambdaTerm with) { Root.Replace(what, with); }
/// <summary> /// Passes it on /// </summary> /// <param name="what"></param> /// <param name="with"></param> internal override void Replace(LambdaVariable what, LambdaTerm with) { First.Replace(what, with); Second.Replace(what, with); }