/// <summary> /// Builds the full next-state relation. /// </summary> /// <param name="constants">The system constants.</param> /// <returns>The full next-state relation.</returns> private static INextStateRelation <Constants, Variables> BuildNextStateRelation(Constants constants) { var fillJug = new ExistentialQuantification <int, Constants, Variables>( constants.Jugs, jug => new FillJug(jug)); var emptyJug = new ExistentialQuantification <int, Constants, Variables>( constants.Jugs, jug => new EmptyJug(jug)); var transfer = new ExistentialQuantification <int, Constants, Variables>( constants.Jugs, jug1 => new ExistentialQuantification <int, Constants, Variables>( constants.Jugs, jug2 => new TransferBetweenJugs(jug1, jug2))); return(new Disjunction <Constants, Variables>(fillJug, emptyJug, transfer)); }
public void ExistentiallyQuantifiesCriteria() { var spec = new IntegerPredicate(i => i == 0); var criteria = spec.Criteria; var anySpec = new ExistentialQuantification<int>(spec); var anyCriteria = anySpec.Criteria; Assert.That(anyCriteria.Body, Is.AssignableTo<MethodCallExpression>()); var call = (MethodCallExpression)anyCriteria.Body; Assert.That(call.NodeType, Is.EqualTo(ExpressionType.Call)); Assert.That(call.Method, Is.EqualTo(typeof(Enumerable).GetMethods().Where(m => m.Name == "Any").ToArray()[1].MakeGenericMethod(new[] { typeof(int) }))); Assert.That(call.Object, Is.Null); Assert.That(call.Arguments, Has.Count.EqualTo(2)); Assert.That(call.Arguments[0], Is.AssignableTo<ParameterExpression>()); Assert.That(call.Arguments[1], Is.EqualTo(criteria)); ExpressionWriter.Write(anyCriteria); }