Program: 166679
Project: 166679
Buggy source:
/** 
 * {<S --> P>, S@(S&T)} |- <(S&T) --> (P&T)> {<S --> P>, S@(M-S)} |- <(M-P) --> (M-S)>
 * @param compound The compound term
 * @param index The location of the indicated term in the compound
 * @param statement The premise
 * @param side The location of the indicated term in the premise
 * @param nal Reference to the memory
 */
static void structuralCompose2(final CompoundTerm compound,final short index,final Statement statement,final short side,final DerivationContext nal){
  if (compound.equals(statement.term[side])) {
    return;
  }
  Term sub=statement.getSubject();
  Term pred=statement.getPredicate();
  final List<Term> components=compound.asTermList();
  if (((side == 0) && components.contains(pred)) || ((side == 1) && components.contains(sub))) {
    return;
  }
  if (side == 0) {
    if (components.contains(sub)) {
      sub=compound;
      components.set(index,pred);
      pred=Terms.term(compound,components);
    }
  }
 else {
    if (components.contains(pred)) {
      components.set(index,sub);
      sub=Terms.term(compound,components);
      pred=compound;
    }
  }
  if ((sub == null) || (pred == null))   return;
  final Statement content;
  final int order=statement.getTemporalOrder();
  if (switchOrder(compound,index)) {
    content=Statement.make(statement,pred,sub,TemporalRules.reverseOrder(order));
  }
 else {
    content=Statement.make(statement,sub,pred,order);
  }
  if (content == null)   return;
  final Sentence sentence=nal.getCurrentTask().sentence;
  final TruthValue truth=TruthFunctions.deduction(sentence.truth,Parameters.reliance);
  final BudgetValue budget=BudgetFunctions.compoundForward(truth,content,nal);
  nal.singlePremiseTask(content,truth,budget);
}

Fixed version (ground truth):
/** 
 * {<S --> P>, S@(S&T)} |- <(S&T) --> (P&T)> {<S --> P>, S@(M-S)} |- <(M-P) --> (M-S)>
 * @param compound The compound term
 * @param index The location of the indicated term in the compound
 * @param statement The premise
 * @param side The location of the indicated term in the premise
 * @param nal Reference to the memory
 */
static void structuralCompose2(final CompoundTerm compound,final short index,final Statement statement,final short side,final DerivationContext nal){
  if (compound.equals(statement.term[side])) {
    return;
  }
  Term sub=statement.getSubject();
  Term pred=statement.getPredicate();
  final List<Term> components=compound.asTermList();
  if (((side == 0) && components.contains(pred)) || ((side == 1) && components.contains(sub))) {
    return;
  }
  if (side == 0) {
    if (components.contains(sub)) {
      sub=compound;
      components.set(index,pred.cloneDeep());
      pred=Terms.term(compound,components);
    }
  }
 else {
    if (components.contains(pred)) {
      components.set(index,sub.cloneDeep());
      sub=Terms.term(compound,components);
      pred=compound;
    }
  }
  if ((sub == null) || (pred == null)) {
    return;
  }
  if (sub.cloneDeep().equals(pred.cloneDeep())) {
    return;
  }
  final Statement content;
  final int order=statement.getTemporalOrder();
  if (switchOrder(compound,index)) {
    content=Statement.make(statement,pred,sub,TemporalRules.reverseOrder(order));
  }
 else {
    content=Statement.make(statement,sub,pred,order);
  }
  if (content == null) {
    return;
  }
  final Sentence sentence=nal.getCurrentTask().sentence;
  final TruthValue truth=TruthFunctions.deduction(sentence.truth,Parameters.reliance);
  final BudgetValue budget=BudgetFunctions.compoundForward(truth,content,nal);
  nal.singlePremiseTask(content,truth,budget);
}