package tcra.exercises.queue_reasoning_private;

import tcra.math.*;
import java.util.*;

public class QueuePostEnqueueAssertion implements Assertion
{
   public QueuePostEnqueueAssertion() {}

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> states)
   {
      MathString<MathType> lb_self =
                                  (MathString<MathType>)states.get(0);
      MathInteger          lb_x = (MathInteger)states.get(1);
      MathString<MathType> self = (MathString<MathType>)states.get(2);
      MathInteger          x    = (MathInteger)states.get(3);

      if(!x.equals(lb_x)) return false;
      if(!self.equals(lb_self.concat(lb_x))) return false;

      return true;
   } // end check(List)

   public String toString()
   {
      return "(x = #x) and<br> (self = #self * &lt #x &gt )";
   } // end toString()

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> states)
   {
      MathString<MathType> lb_self =
                                  (MathString<MathType>)states.get(0);
      MathInteger          lb_x = (MathInteger)states.get(1);
      MathString<MathType> self = (MathString<MathType>)states.get(2);
      MathInteger          x    = (MathInteger)states.get(3);

      return ("(" +x+ " = " +lb_x+ ") and<br> (" +self.toHTMLString()+
              " = " +lb_self.toHTMLString()+
              " * &lt " +lb_x+ " &gt )");
   } // end toString(List)
} // end class
