Program: 136053
Project: 136053
Buggy source:
private final void processConfigSpec(ExprNode pred,Context c,List subs){
  if (pred instanceof SubstInNode) {
    SubstInNode pred1=(SubstInNode)pred;
    this.processConfigSpec(pred1.getBody(),c,subs.cons(pred1));
    return;
  }
  if (pred instanceof OpApplNode) {
    OpApplNode pred1=(OpApplNode)pred;
    ExprOrOpArgNode[] args=pred1.getArgs();
    if (args.length == 0) {
      SymbolNode opNode=pred1.getOperator();
      Object val=this.lookup(opNode,c,false);
      if (val instanceof OpDefNode) {
        if (((OpDefNode)val).getArity() != 0) {
          Assert.fail(EC.TLC_CONFIG_OP_NO_ARGS,new String[]{opNode.getName().toString()});
        }
        ExprNode body=((OpDefNode)val).getBody();
        if (this.getLevelBound(body,c) == 1) {
          this.initPredVec.addElement(new Action(Spec.addSubsts(body,subs),c));
        }
 else {
          this.processConfigSpec(body,c,subs);
        }
      }
 else       if (val == null) {
        Assert.fail(EC.TLC_CONFIG_OP_NOT_IN_SPEC,new String[]{opNode.getName().toString()});
      }
 else       if (val instanceof BoolValue) {
        if (!((BoolValue)val).val) {
          Assert.fail(EC.TLC_CONFIG_SPEC_IS_TRIVIAL,opNode.getName().toString());
        }
      }
 else {
        Assert.fail(EC.TLC_CONFIG_OP_IS_EQUAL,new String[]{opNode.getName().toString(),val.toString()});
      }
      return;
    }
    int opcode=BuiltInOPs.getOpCode(pred1.getOperator().getName());
    if (opcode == OPCODE_cl || opcode == OPCODE_land) {
      for (int i=0; i < args.length; i++) {
        this.processConfigSpec((ExprNode)args[i],c,subs);
      }
      return;
    }
    if (opcode == OPCODE_box) {
      SemanticNode boxArg=args[0];
      if ((boxArg instanceof OpApplNode) && BuiltInOPs.getOpCode(((OpApplNode)boxArg).getOperator().getName()) == OPCODE_sa) {
        ExprNode arg=(ExprNode)((OpApplNode)boxArg).getArgs()[0];
        ExprNode subscript=(ExprNode)((OpApplNode)boxArg).getArgs()[1];
        Vect varsInSubscript=null;
        try {
class SubscriptCollector {
            /** 
 * This class attempts to recover all variables that appear in (possibly nested) tuples in the subscript of the next-state relation. Variables that appear in other kinds of expressions are ignored. The idea is to make sure that the subscript is a tuple that contains at least the declared variables of this specification object -- otherwise TLC's analysis is incorrect.
 */
            Vect components;
            SubscriptCollector(){
              this.components=new Vect();
            }
            void enter(            ExprNode subscript,            Context c){
              SymbolNode var=getVar(subscript,c,false);
              if (var != null) {
                components.addElement(var);
                return;
              }
switch (subscript.getKind()) {
case OpApplKind:
{
                  OpApplNode subscript1=(OpApplNode)subscript;
                  SymbolNode opNode=subscript1.getOperator();
                  ExprOrOpArgNode[] args=subscript1.getArgs();
                  int opCode=BuiltInOPs.getOpCode(opNode.getName());
                  if (opCode == OPCODE_tup) {
                    for (int i=0; i < args.length; i++) {
                      this.enter((ExprNode)args[i],c);
                    }
                    return;
                  }
 else                   if (opCode != 0) {
                    return;
                  }
                  Object opDef=lookup(opNode,c,false);
                  if (opDef instanceof OpDefNode) {
                    OpDefNode opDef1=(OpDefNode)opDef;
                    this.enter(opDef1.getBody(),getOpContext(opDef1,args,c,false));
                    return;
                  }
                  if (opDef instanceof LazyValue) {
                    LazyValue lv=(LazyValue)opDef;
                    this.enter((ExprNode)lv.expr,lv.con);
                    return;
                  }
                  break;
                }
case SubstInKind:
{
                SubstInNode subscript1=(SubstInNode)subscript;
                Subst[] subs=subscript1.getSubsts();
                Context c1=c;
                for (int i=0; i < subs.length; i++) {
                  c1=c1.cons(subs[i].getOp(),getVal(subs[i].getExpr(),c,false));
                }
                this.enter(subscript1.getBody(),c1);
                return;
              }
case LetInKind:
{
              LetInNode subscript1=(LetInNode)subscript;
              this.enter(subscript1.getBody(),c);
              return;
            }
case LabelKind:
{
            LabelNode subscript1=(LabelNode)subscript;
            this.enter((ExprNode)subscript1.getBody(),c);
            return;
          }
default :
        Assert.fail(EC.TLC_CANT_HANDLE_SUBSCRIPT,subscript.toString());
      return;
  }
}
Vect getComponents(){
  return components;
}
}
SubscriptCollector collector=new SubscriptCollector();
Context c1=c;
List subs1=subs;
while (!subs1.isEmpty()) {
SubstInNode sn=(SubstInNode)subs1.car();
Subst[] snsubs=sn.getSubsts();
for (int i=0; i < snsubs.length; i++) {
  c1=c1.cons(snsubs[i].getOp(),getVal(snsubs[i].getExpr(),c,false));
}
subs1=subs1.cdr();
}
collector.enter(subscript,c1);
varsInSubscript=collector.getComponents();
}
 catch (Exception e) {
MP.printWarning(EC.TLC_COULD_NOT_DETERMINE_SUBSCRIPT,new String[0]);
varsInSubscript=null;
}
if (varsInSubscript != null) {
for (int i=0; i < this.variablesNodes.length; i++) {
if (!varsInSubscript.contains(this.variablesNodes[i])) {
  MP.printWarning(EC.TLC_SUBSCRIPT_CONTAIN_NO_STATE_VAR,new String[]{this.variablesNodes[i].getName().toString()});
}
}
}
if (this.nextPred == null) {
this.nextPred=new Action(Spec.addSubsts(arg,subs),c);
}
 else {
Assert.fail(EC.TLC_CANT_HANDLE_TOO_MANY_NEXT_STATE_RELS);
}
}
 else {
this.temporalVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
this.temporalNameVec.addElement(pred.toString());
}
return;
}
}
int level=this.getLevelBound(pred,c);
if (level <= 1) {
this.initPredVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
}
 else if (level == 3) {
this.temporalVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
this.temporalNameVec.addElement(pred.toString());
}
 else {
Assert.fail(EC.TLC_CANT_HANDLE_CONJUNCT,pred.toString());
}
}

Fixed version (ground truth):
private final void processConfigSpec(ExprNode pred,Context c,List subs){
  if (pred instanceof SubstInNode) {
    SubstInNode pred1=(SubstInNode)pred;
    this.processConfigSpec(pred1.getBody(),c,subs.cons(pred1));
    return;
  }
  if (pred instanceof OpApplNode) {
    OpApplNode pred1=(OpApplNode)pred;
    ExprOrOpArgNode[] args=pred1.getArgs();
    if (args.length == 0) {
      SymbolNode opNode=pred1.getOperator();
      Object val=this.lookup(opNode,c,false);
      if (val instanceof OpDefNode) {
        if (((OpDefNode)val).getArity() != 0) {
          Assert.fail(EC.TLC_CONFIG_OP_NO_ARGS,new String[]{opNode.getName().toString()});
        }
        ExprNode body=((OpDefNode)val).getBody();
        if (this.getLevelBound(body,c) == 1) {
          this.initPredVec.addElement(new Action(Spec.addSubsts(body,subs),c));
        }
 else {
          this.processConfigSpec(body,c,subs);
        }
      }
 else       if (val == null) {
        Assert.fail(EC.TLC_CONFIG_OP_NOT_IN_SPEC,new String[]{opNode.getName().toString()});
      }
 else       if (val instanceof BoolValue) {
        if (!((BoolValue)val).val) {
          Assert.fail(EC.TLC_CONFIG_SPEC_IS_TRIVIAL,opNode.getName().toString());
        }
      }
 else {
        Assert.fail(EC.TLC_CONFIG_OP_IS_EQUAL,new String[]{opNode.getName().toString(),val.toString(),"String_Node_Str"});
      }
      return;
    }
    int opcode=BuiltInOPs.getOpCode(pred1.getOperator().getName());
    if (opcode == OPCODE_cl || opcode == OPCODE_land) {
      for (int i=0; i < args.length; i++) {
        this.processConfigSpec((ExprNode)args[i],c,subs);
      }
      return;
    }
    if (opcode == OPCODE_box) {
      SemanticNode boxArg=args[0];
      if ((boxArg instanceof OpApplNode) && BuiltInOPs.getOpCode(((OpApplNode)boxArg).getOperator().getName()) == OPCODE_sa) {
        ExprNode arg=(ExprNode)((OpApplNode)boxArg).getArgs()[0];
        ExprNode subscript=(ExprNode)((OpApplNode)boxArg).getArgs()[1];
        Vect varsInSubscript=null;
        try {
class SubscriptCollector {
            /** 
 * This class attempts to recover all variables that appear in (possibly nested) tuples in the subscript of the next-state relation. Variables that appear in other kinds of expressions are ignored. The idea is to make sure that the subscript is a tuple that contains at least the declared variables of this specification object -- otherwise TLC's analysis is incorrect.
 */
            Vect components;
            SubscriptCollector(){
              this.components=new Vect();
            }
            void enter(            ExprNode subscript,            Context c){
              SymbolNode var=getVar(subscript,c,false);
              if (var != null) {
                components.addElement(var);
                return;
              }
switch (subscript.getKind()) {
case OpApplKind:
{
                  OpApplNode subscript1=(OpApplNode)subscript;
                  SymbolNode opNode=subscript1.getOperator();
                  ExprOrOpArgNode[] args=subscript1.getArgs();
                  int opCode=BuiltInOPs.getOpCode(opNode.getName());
                  if (opCode == OPCODE_tup) {
                    for (int i=0; i < args.length; i++) {
                      this.enter((ExprNode)args[i],c);
                    }
                    return;
                  }
 else                   if (opCode != 0) {
                    return;
                  }
                  Object opDef=lookup(opNode,c,false);
                  if (opDef instanceof OpDefNode) {
                    OpDefNode opDef1=(OpDefNode)opDef;
                    this.enter(opDef1.getBody(),getOpContext(opDef1,args,c,false));
                    return;
                  }
                  if (opDef instanceof LazyValue) {
                    LazyValue lv=(LazyValue)opDef;
                    this.enter((ExprNode)lv.expr,lv.con);
                    return;
                  }
                  break;
                }
case SubstInKind:
{
                SubstInNode subscript1=(SubstInNode)subscript;
                Subst[] subs=subscript1.getSubsts();
                Context c1=c;
                for (int i=0; i < subs.length; i++) {
                  c1=c1.cons(subs[i].getOp(),getVal(subs[i].getExpr(),c,false));
                }
                this.enter(subscript1.getBody(),c1);
                return;
              }
case LetInKind:
{
              LetInNode subscript1=(LetInNode)subscript;
              this.enter(subscript1.getBody(),c);
              return;
            }
case LabelKind:
{
            LabelNode subscript1=(LabelNode)subscript;
            this.enter((ExprNode)subscript1.getBody(),c);
            return;
          }
default :
        Assert.fail(EC.TLC_CANT_HANDLE_SUBSCRIPT,subscript.toString());
      return;
  }
}
Vect getComponents(){
  return components;
}
}
SubscriptCollector collector=new SubscriptCollector();
Context c1=c;
List subs1=subs;
while (!subs1.isEmpty()) {
SubstInNode sn=(SubstInNode)subs1.car();
Subst[] snsubs=sn.getSubsts();
for (int i=0; i < snsubs.length; i++) {
  c1=c1.cons(snsubs[i].getOp(),getVal(snsubs[i].getExpr(),c,false));
}
subs1=subs1.cdr();
}
collector.enter(subscript,c1);
varsInSubscript=collector.getComponents();
}
 catch (Exception e) {
MP.printWarning(EC.TLC_COULD_NOT_DETERMINE_SUBSCRIPT,new String[0]);
varsInSubscript=null;
}
if (varsInSubscript != null) {
for (int i=0; i < this.variablesNodes.length; i++) {
if (!varsInSubscript.contains(this.variablesNodes[i])) {
  MP.printWarning(EC.TLC_SUBSCRIPT_CONTAIN_NO_STATE_VAR,new String[]{this.variablesNodes[i].getName().toString()});
}
}
}
if (this.nextPred == null) {
this.nextPred=new Action(Spec.addSubsts(arg,subs),c);
}
 else {
Assert.fail(EC.TLC_CANT_HANDLE_TOO_MANY_NEXT_STATE_RELS);
}
}
 else {
this.temporalVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
this.temporalNameVec.addElement(pred.toString());
}
return;
}
if (opcode == OPCODE_nop) {
this.processConfigSpec((ExprNode)args[0],c,subs);
return;
}
}
int level=this.getLevelBound(pred,c);
if (level <= 1) {
this.initPredVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
}
 else if (level == 3) {
this.temporalVec.addElement(new Action(Spec.addSubsts(pred,subs),c));
this.temporalNameVec.addElement(pred.toString());
}
 else {
Assert.fail(EC.TLC_CANT_HANDLE_CONJUNCT,pred.toString());
}
}