/**
  * Applies the <b>(TRANS)</b> rule to the <code>node</code> using the <code>context</code>.
  *
  * @param context the minimal typing proof context.
  * @param pNode the minimal typing proof node.
  */
 public void applyTrans(MinimalTypingProofContext context, MinimalTypingProofNode pNode) {
   MinimalTypingTypesProofNode node = (MinimalTypingTypesProofNode) pNode;
   try {
     ObjectType type = (ObjectType) node.getType2();
     ObjectType type2 = (ObjectType) node.getType();
     ArrayList<Identifier> newIds = new ArrayList<Identifier>();
     ArrayList<MonoType> newTypes = new ArrayList<MonoType>();
     RowType r1 = (RowType) (type).getPhi();
     RowType r2 = (RowType) (type2).getPhi();
     Identifier[] ids1 = r1.getIdentifiers();
     Identifier[] ids2 = r2.getIdentifiers();
     MonoType[] types2 = r2.getTypes();
     boolean goOn;
     for (int i = 0; i < ids1.length; i++) {
       goOn = false;
       for (int j = 0; j < ids2.length; j++) {
         if (ids1[i].equals(ids2[j])) {
           newIds.add(ids2[j]);
           newTypes.add(types2[j]);
           goOn = true;
           break;
         }
       }
       if (goOn) continue;
       throw new RuntimeException(Messages.getString("SubTypingException.5")); // $NON-NLS-1$
     }
     Identifier[] tmpIds = new Identifier[newIds.size()];
     for (int i = 0; i < newIds.size(); i++) {
       tmpIds[i] = newIds.get(i);
     }
     MonoType[] tmpTypes = new MonoType[newTypes.size()];
     for (int i = 0; i < newTypes.size(); i++) {
       tmpTypes[i] = newTypes.get(i);
     }
     // ObjectType newType = new ObjectType ( new RowType ( (Identifier[])
     // newIds.toArray ( ),(MonoType[]) newTypes.toArray ( ) ) );
     ObjectType newType = new ObjectType(new RowType(tmpIds, tmpTypes));
     // generate new child node
     context.addProofNode(node, type2, newType);
     // generate new child node
     context.addProofNode(node, newType, type);
   } catch (ClassCastException e) {
     MonoType type = node.getType();
     MonoType type2 = node.getType2();
     // if both types instance of Primitive Type throw Exception
     if (type instanceof PrimitiveType && type2 instanceof PrimitiveType) {
       throw new IllegalArgumentException(
           Messages.getString("SubTypingException.1")); // $NON-NLS-1$
     }
     // generate new child node
     context.addProofNode(node, type, type);
     // generate new child node
     context.addProofNode(node, type, type2);
     SubTypingProofNode parent = (SubTypingProofNode) node.getParent();
     int count = 0;
     // check how often the trans rule was applied
     while (parent != null) {
       if (parent.getRule().toString().equals("TRANS")) { // $NON-NLS-1$
         count++;
       } else break;
       parent = (SubTypingProofNode) parent.getParent();
     }
     // if applied 15 times the trans rule throw Exception
     if (count >= 15)
       throw new RuntimeException(Messages.getString("SubTypingException.2")); // $NON-NLS-1$
   }
 }