package tcra.exercises.resolve_stack_mystery_private;

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

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

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          mystery = (MathInteger)t.get(3);
      
      MathString<MathType> rst =
                         (MathString<MathType>)lb_self.split(0).get(1);
      
      if(!self.equals(rst.prepend(mystery))) return false;
      if(!self.equals(lb_self)) return false;
      
      return true;
   } // end check(List)
   
   public String toString()
   {
      return("∃ Rst: String(Integer) ∋ &lt;I&gt; * Rst = S;");
   } // end toString

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      MathInteger          mystery = (MathInteger)t.get(3);
      
      MathString<MathType> rst =
                         (MathString<MathType>)lb_self.split(0).get(1);
      
      return("∃ Rst: String(Integer ) ∋ &lt;"+
             mystery.toHTMLString()+"&gt; * "+rst.toHTMLString()+
             " = "+self.toHTMLString()+";");
   } // end toInstanceString(List)
} // end class
