package tcra.exercises.resolve_random_access_capability_private;

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

public class ResolveRandomAccessCapability_PreRemoveAssertion 
   implements Assertion
{
   public ResolveRandomAccessCapability_PreRemoveAssertion() {}
   
   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> state)
   {
      MathString<MathType> lb_self   =
                                  (MathString<MathType>)state.get(0);
      MathInteger          lb_index  = (MathInteger)state.get(2);

      return(lb_index.getValue() >= 1 &&
             lb_index.getValue() <= lb_self.length());
   } // end check(List)
   
   public String toString() { return("1 &lt;= k &lt;= |S|"); }
   
   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> state)
   {
      MathString<MathType> lb_self   =
                                   (MathString<MathType>)state.get(0);
      MathInteger          lb_index  = (MathInteger)state.get(2);
      
      return ("1 &lt;= " +lb_index.getValue()+ " &lt;= |"+
              lb_self.toHTMLString()+"|");
   } // end toInstanceString(List)
} // end class
