public void Equation_Var_Substitution_1() { //a = 1, a*b = -1; var a = new Var("a"); var b = new Var("b"); var eqGoal = new EqGoal(a, 1); var lhsTerm = new Term(Expression.Multiply, new List <object>() { a, b }); var equation = new Equation(lhsTerm, -1); bool result = equation.Reify(eqGoal); Assert.True(result); Assert.True(equation.CachedEntities.Count == 1); var cachedEq = equation.CachedEntities.ToList()[0] as Equation; object obj; result = cachedEq.IsEqGoal(out obj); Assert.True(result); var gGoal = obj as EqGoal; Assert.NotNull(gGoal); Assert.True(gGoal.Rhs.Equals(-1)); }
public void Equation_Var_Substitution_4() { //x = 3, x = y var x = new Var('a'); var eq1 = new EqGoal(x, 3); // x=3 var y = new Var('y'); var eq2 = new Equation(x, y); // x=y bool result = eq2.Reify(eq1); Assert.True(result); Assert.True(eq2.CachedEntities.Count == 1); }
public void Equation_Var_Substitution_1() { //a = 1, a*b = -1; var a = new Var("a"); var b = new Var("b"); var eqGoal = new EqGoal(a, 1); var lhsTerm = new Term(Expression.Multiply, new List<object>() { a, b }); var equation = new Equation(lhsTerm, -1); bool result = equation.Reify(eqGoal); Assert.True(result); Assert.True(equation.CachedEntities.Count == 1); var cachedEq = equation.CachedEntities.ToList()[0] as Equation; object obj; result = cachedEq.IsEqGoal(out obj); Assert.True(result); var gGoal = obj as EqGoal; Assert.NotNull(gGoal); Assert.True(gGoal.Rhs.Equals(-1)); }
public void Equation_Var_Substitution_2() { //14: a = 2, b=a var a = new Var("a"); var b = new Var("b"); var eqGoal = new EqGoal(a, 2); var equation = new Equation(b, a); bool result = equation.Reify(eqGoal); Assert.True(result); Assert.True(equation.CachedEntities.Count == 1); var cachedEq = equation.CachedEntities.ToList()[0] as Equation; object obj; result = cachedEq.IsEqGoal(out obj); Assert.True(result); var gGoal = obj as EqGoal; Assert.NotNull(gGoal); Assert.True(gGoal.Lhs.Equals(b)); Assert.True(gGoal.Rhs.Equals(2)); }
private bool DispatchReify(Equation eq, EqGoal goal) { if (eq == null) return false; return eq.Reify(goal); }