nus-yam/ex-repair huggingface dataset:
Program: 166778
Project: 166778
Buggy source:
@Override public void run(){
  s.cells.click("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override public void run(){
  s.nar.addInput("String_Node_Str");
}
Program: 166779
Project: 166779
Buggy source:
public static void buildInnerMaze(Hauto m,int x1,int y1,int x2,int y2){
  m.forEach(x1,y1,x2,y2,new SetMaterial(Material.StoneWall));
  int w=x2 - x1 + 1;
  int rw=(w + 1) / 2;
  int h=y2 - y1 + 1;
  int rh=(h + 1) / 2;
  int sx=x1 + 2 * irand(rw);
  int sy=y1 + 2 * irand(rh);
  m.at(sx,sy,new SetMaterial(Material.DirtFloor));
  int finishedCount=0;
  for (int i=1; (i < (rw * rh * 1000)) && (finishedCount < (rw * rh)); i++) {
    int x=x1 + 2 * irand(rw);
    int y=y1 + 2 * irand(rh);
    if (m.at(x,y).material != Material.StoneWall)     continue;
    int dx=(irand(2) == 1) ? (irand(2) * 2 - 1) : 0;
    int dy=(dx == 0) ? (irand(2) * 2 - 1) : 0;
    int lx=x + dx * 2;
    int ly=y + dy * 2;
    if ((lx >= x1) && (lx <= x2) && (ly >= y1)&& (ly <= y2)) {
      if (m.at(lx,ly).material != Material.StoneWall) {
        m.at(x,y,new SetMaterial(Material.DirtFloor));
        m.at(x + dx,y + dy,new SetMaterial(Material.DirtFloor));
        finishedCount++;
      }
    }
  }
}

Fixed version (ground truth):
public static void buildInnerMaze(Hauto m,int x1,int y1,int x2,int y2){
  m.forEach(x1,y1,x2,y2,new SetMaterial(Material.StoneWall));
  int w=x2 - x1 + 1;
  int rw=(w + 1) / 2;
  int h=y2 - y1 + 1;
  int rh=(h + 1) / 2;
  int sx=x1 + 2 * irand(rw);
  int sy=y1 + 2 * irand(rh);
  m.at(sx,sy,new SetMaterial(Material.DirtFloor));
  int finishedCount=0;
  for (int i=1; (i < (rw * rh * 1000)) && (finishedCount < (rw * rh)); i++) {
    int x=x1 + 2 * irand(rw);
    int y=y1 + 2 * irand(rh);
    if (m.at(x,y).material != Material.StoneWall)     continue;
    int dx=(irand(2) == 1) ? (irand(2) * 2 - 1) : 0;
    int dy=(dx == 0) ? (irand(2) * 2 - 1) : 0;
    int lx=x + dx * 2;
    int ly=y + dy * 2;
    if ((lx >= x1) && (lx <= x2) && (ly >= y1)&& (ly <= y2)) {
      if (m.at(lx,ly).material != Material.StoneWall) {
        m.at(x,y,new SetMaterial(Material.DirtFloor));
        m.at(x + dx,y + dy,new SetMaterial(Material.DirtFloor));
        m.readCells[x][y].setHeight((int)(Math.random() * 24 + 1));
        m.writeCells[x][y].setHeight((int)(Math.random() * 24 + 1));
        finishedCount++;
      }
    }
  }
}
Program: 166780
Project: 166780
Buggy source:
@Override public void draw(){
  background(0,0,0);
  pushMatrix();
  hnav.Transform();
  hrend_DrawBegin();
  drawGround();
  drawObjects();
  drawParticles();
  hrend_DrawEnd();
  popMatrix();
  hrend_DrawGUI();
  realtime=System.nanoTime() / 1.0e9;
  if (time % automataPeriod == 0) {
    updateAutomata();
  }
  if (time % agentPeriod == 0) {
    for (    GridObject g : objects) {
      Effect e=(g instanceof GridAgent) ? ((GridAgent)g).perceiveNext() : null;
      g.update(e);
      if (g instanceof GridAgent) {
        GridAgent b=(GridAgent)g;
        if (b.actions.size() > 0) {
          Action a=b.actions.pop();
          if (a != null) {
            process(b,a);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void draw(){
  background(0,0,0);
  pushMatrix();
  hnav.Transform();
  hrend_DrawBegin();
  drawGround();
  drawObjects();
  drawParticles();
  hrend_DrawEnd();
  popMatrix();
  hrend_DrawGUI();
  realtime=System.nanoTime() / 1.0e9;
  if (time % automataPeriod == 0) {
    updateAutomata();
  }
  if (time % agentPeriod == 0) {
    try {
      for (      GridObject g : objects) {
        Effect e=(g instanceof GridAgent) ? ((GridAgent)g).perceiveNext() : null;
        g.update(e);
        if (g instanceof GridAgent) {
          GridAgent b=(GridAgent)g;
          if (b.actions.size() > 0) {
            Action a=b.actions.pop();
            if (a != null) {
              process(b,a);
            }
          }
        }
      }
    }
 catch (    Exception ex) {
    }
  }
}
Program: 166781
Project: 166781
Buggy source:
/** 
 * Try to make a new compound from two term. Called by the inference rules.
 * @param subject The first compoment
 * @param predicate The second compoment
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Inheritance make(final Term subject,final Term predicate,final Memory memory){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  String name;
  if ((subject instanceof Product) && (predicate instanceof Operator)) {
    name=Operation.makeName(predicate.name(),((CompoundTerm)subject).term,memory);
  }
 else {
    name=makeStatementName(subject,NativeOperator.INHERITANCE,predicate);
  }
  Term t=memory.conceptTerm(name);
  if (t != null) {
    return (Inheritance)t;
  }
  Term[] arguments=termArray(subject,predicate);
  if ((subject instanceof Product) && (predicate instanceof Operator)) {
    return new Operation(name,arguments);
  }
 else {
    return new Inheritance(name,arguments);
  }
}

Fixed version (ground truth):
/** 
 * Try to make a new compound from two term. Called by the inference rules.
 * @param subject The first compoment
 * @param predicate The second compoment
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Inheritance make(final Term subject,final Term predicate,final Memory memory){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  String name;
  if ((subject instanceof Product) && (predicate instanceof Operator)) {
    name=Operation.makeName(predicate.name(),((CompoundTerm)subject).term);
  }
 else {
    name=makeStatementName(subject,NativeOperator.INHERITANCE,predicate);
  }
  Term t=memory.conceptTerm(name);
  if (t != null) {
    return (Inheritance)t;
  }
  Term[] arguments=termArray(subject,predicate);
  if ((subject instanceof Product) && (predicate instanceof Operator)) {
    return new Operation(name,arguments);
  }
 else {
    return new Inheritance(name,arguments);
  }
}
Program: 166782
Project: 166782
Buggy source:
/** 
 * @param that The Term to be compared with the current Term
 * @return The same as compareTo as defined on Strings
 */
@Override public int compareTo(final Term that){
  if (that.getClass() == getClass())   return name.compareTo(that.name());
  return that.getClass().getSimpleName().compareTo(getClass().getSimpleName());
}

Fixed version (ground truth):
/** 
 * @param that The Term to be compared with the current Term
 * @return The same as compareTo as defined on Strings
 */
@Override public int compareTo(final Term that){
  if (that instanceof CompoundTerm) {
    return -1;
  }
 else   if (that instanceof Variable) {
    return 1;
  }
 else {
    return name.compareTo(that.name());
  }
}
Program: 166783
Project: 166783
Buggy source:
/** 
 * Try to make a new compound from two components. Called by the inference rules.
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Operation make(Operator oper,final Term[] arg,final Memory memory){
  if (oper == null) {
    return null;
  }
  String name=makeName(oper.name(),arg,memory);
  Term t=memory.conceptTerm(name);
  if (t != null) {
    return (Operation)t;
  }
  ArrayList<Term> opArg=new ArrayList<>();
  Term list=Product.make(arg,memory);
  opArg.add(list);
  opArg.add(oper);
  return new Operation(name,opArg.toArray(new Term[opArg.size()]));
}

Fixed version (ground truth):
/** 
 * Try to make a new compound from two components. Called by the inference rules.
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Operation make(Operator oper,final Term[] arg,final Memory memory){
  if (oper == null) {
    return null;
  }
  String name=makeName(oper.name(),arg);
  Term t=memory.conceptTerm(name);
  if (t != null) {
    return (Operation)t;
  }
  ArrayList<Term> opArg=new ArrayList<>();
  Term list=Product.make(arg,memory);
  opArg.add(list);
  opArg.add(oper);
  return new Operation(name,opArg.toArray(new Term[opArg.size()]));
}
Program: 166784
Project: 166784
Buggy source:
public static String makeName(final String op,Term[] arg,final Memory memory){
  final StringBuilder nameBuilder=new StringBuilder(16).append(COMPOUND_TERM_OPENER.ch).append(op);
  for (  final Term t : arg) {
    nameBuilder.append(Symbols.ARGUMENT_SEPARATOR);
    nameBuilder.append(t.name());
  }
  nameBuilder.append(COMPOUND_TERM_CLOSER.ch);
  return nameBuilder.toString();
}

Fixed version (ground truth):
public static String makeName(final String op,Term[] arg){
  final StringBuilder nameBuilder=new StringBuilder(16).append(COMPOUND_TERM_OPENER.ch).append(op);
  for (  final Term t : arg) {
    nameBuilder.append(Symbols.ARGUMENT_SEPARATOR);
    nameBuilder.append(t.name());
  }
  nameBuilder.append(COMPOUND_TERM_CLOSER.ch);
  return nameBuilder.toString();
}
Program: 166785
Project: 166785
Buggy source:
@Override public Operator clone(){
  return null;
}

Fixed version (ground truth):
@Override public Operator clone(){
  return this;
}
Program: 166786
Project: 166786
Buggy source:
protected void testNAL(final String path){
  Memory.resetStatic();
  final NAR n=newNAR();
  final List<Expect> expects=new ArrayList();
  String example=getExample(path);
  List<Expect> extractedExpects=getExpectations(n,example,saveSimilar);
  for (  Expect e1 : extractedExpects)   expects.add((Expect)n.addOutput(e1));
  if (showOutput)   new TextOutput(n,System.out);
  n.addInput(new TextInput(example));
  boolean error=false;
  try {
    n.finish(minCycles);
  }
 catch (  Exception e) {
    e.printStackTrace();
    error=true;
  }
catch (  Throwable e) {
    e.printStackTrace();
    error=true;
  }
  boolean success=expects.size() > 0 && (!error);
  for (  Expect e : expects) {
    if (!e.realized)     success=false;
  }
  if ((!success) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.getTime());
    for (    Expect e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  assertTrue(path,success);
}

Fixed version (ground truth):
protected void testNAL(final String path){
  Memory.resetStatic();
  final NAR n=newNAR();
  final List<Expect> expects=new ArrayList();
  String example=getExample(path);
  List<Expect> extractedExpects=getExpectations(n,example,saveSimilar);
  for (  Expect e1 : extractedExpects)   expects.add((Expect)n.addOutput(e1));
  if (showOutput)   new TextOutput(n,System.out);
  n.addInput(new TextInput(example));
  boolean error=false;
  try {
    n.finish(minCycles);
  }
 catch (  Throwable e) {
    e.printStackTrace();
    error=true;
  }
  boolean success=expects.size() > 0 && (!error);
  for (  Expect e : expects) {
    if (!e.realized)     success=false;
  }
  if ((!success) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.getTime());
    for (    Expect e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  assertTrue(path,success);
}
Program: 166787
Project: 166787
Buggy source:
/** 
 * Return a string representation of the concept, called in ConceptBag only
 * @return The concept name, with taskBudget in the full version
 */
@Override public String toString(){
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Return a string representation of the concept, called in ConceptBag only
 * @return The concept name, with taskBudget in the full version
 */
@Override public String toString(){
  return super.toStringBrief();
}
Program: 166788
Project: 166788
Buggy source:
/** 
 * Get a String representation of the sentence for display purpose
 * @return The String
 */
public CharSequence toString(NAR nar,boolean showStamp){
  CharSequence contentName=content.name();
  final long t=nar.memory.getTime();
  final String tenseString=((punctuation == Symbols.JUDGMENT_MARK) || (punctuation == Symbols.QUESTION_MARK)) ? stamp.getTense(t) : "String_Node_Str";
  final String truthString=(truth != null) ? truth.toStringBrief() : null;
  CharSequence stampString=showStamp ? stamp.name() : null;
  int stringLength=contentName.length() + tenseString.length() + 1+ 1;
  if (truth != null) {
    stringLength+=truthString.length();
  }
  if (showStamp) {
    stringLength+=stampString.length();
  }
  final TextBuilder buffer=new TextBuilder(stringLength).append(contentName).append(contentName).append(punctuation);
  if (tenseString.length() > 0)   buffer.append(' ').append(tenseString);
  if (truth != null)   buffer.append(' ').append(truthString);
  if (showStamp)   buffer.append(' ').append(stampString);
  return buffer;
}

Fixed version (ground truth):
/** 
 * Get a String representation of the sentence for display purpose
 * @return The String
 */
public CharSequence toString(NAR nar,boolean showStamp){
  CharSequence contentName=content.name();
  final long t=nar.memory.getTime();
  final String tenseString=((punctuation == Symbols.JUDGMENT_MARK) || (punctuation == Symbols.QUESTION_MARK)) ? stamp.getTense(t) : "String_Node_Str";
  final String truthString=(truth != null) ? truth.toStringBrief() : null;
  CharSequence stampString=showStamp ? stamp.name() : null;
  int stringLength=contentName.length() + tenseString.length() + 1+ 1;
  if (truth != null) {
    stringLength+=truthString.length();
  }
  if (showStamp) {
    stringLength+=stampString.length();
  }
  final TextBuilder buffer=new TextBuilder(stringLength).append(contentName).append(punctuation);
  if (tenseString.length() > 0)   buffer.append(' ').append(tenseString);
  if (truth != null)   buffer.append(' ').append(truthString);
  if (showStamp)   buffer.append(' ').append(stampString);
  return buffer;
}
Program: 166789
Project: 166789
Buggy source:
public static void main(String[] args){
  int repeats=4;
  int warmups=1;
  int extraCycles=512;
  NAR n=new DefaultNARBuilder().build();
  Collection c=NALTest.params();
  while (true) {
    for (    Object o : c) {
      String examplePath=(String)((Object[])o)[0];
      perfNAL(n,examplePath,extraCycles,repeats,warmups,true);
    }
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  int repeats=1;
  int warmups=0;
  int extraCycles=2048;
  NAR n=new DefaultNARBuilder().build();
  Collection c=NALTest.params();
  while (true) {
    for (    Object o : c) {
      String examplePath=(String)((Object[])o)[0];
      perfNAL(n,examplePath,extraCycles,repeats,warmups,true);
    }
  }
}
Program: 166790
Project: 166790
Buggy source:
protected void testNAL(final String path){
  Memory.resetStatic();
  final NAR n=newNAR();
  final List<Expect> expects=new ArrayList();
  String example=getExample(path);
  List<Expect> extractedExpects=getExpectations(n,example,saveSimilar);
  for (  Expect e1 : extractedExpects)   expects.add((Expect)n.addOutput(e1));
  if (showOutput)   new TextOutput(n,System.out);
  n.addInput(new TextInput(example));
  n.step(1);
  boolean error=false;
  try {
    n.finish(minCycles,showDebug);
  }
 catch (  Throwable e) {
    e.printStackTrace();
    error=true;
  }
  boolean success=expects.size() > 0 && (!error);
  for (  Expect e : expects) {
    if (!e.realized)     success=false;
  }
  if ((!success) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.getTime());
    for (    Expect e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  assertTrue(path,success);
}

Fixed version (ground truth):
protected void testNAL(final String path){
  Memory.resetStatic();
  final NAR n=newNAR();
  final List<Expect> expects=new ArrayList();
  String example=getExample(path);
  List<Expect> extractedExpects=getExpectations(n,example,saveSimilar);
  for (  Expect e1 : extractedExpects)   expects.add((Expect)n.addOutput(e1));
  if (showOutput)   new TextOutput(n,System.out);
  if (showTrace) {
    InferenceLogger logger=new InferenceLogger();
    logger.addOutput(new LogOutput(){
      @Override public void logAppend(      String s){
        System.out.println("String_Node_Str" + s);
      }
    }
);
    n.memory.setRecorder(logger);
  }
  n.addInput(new TextInput(example));
  n.step(1);
  boolean error=false;
  try {
    n.finish(minCycles,showDebug);
  }
 catch (  Throwable e) {
    e.printStackTrace();
    error=true;
  }
  boolean success=expects.size() > 0 && (!error);
  for (  Expect e : expects) {
    if (!e.realized)     success=false;
  }
  if ((!success) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.getTime());
    for (    Expect e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  assertTrue(path,success);
}
Program: 166791
Project: 166791
Buggy source:
public NALTestSome(String scriptPath){
  super(scriptPath);
  showSuccess=true;
  showOutput=true;
  showDebug=true;
  System.out.println("String_Node_Str" + scriptPath);
}

Fixed version (ground truth):
public NALTestSome(String scriptPath){
  super(scriptPath);
  showSuccess=true;
  showOutput=true;
  showTrace=true;
  System.out.println("String_Node_Str" + scriptPath);
}
Program: 166792
Project: 166792
Buggy source:
/** 
 * An atomic step in a concept, only called in   {@link Memory#processConcept}
 */
public void fire(){
  final TaskLink currentTaskLink=taskLinks.takeOut();
  if (currentTaskLink == null) {
    return;
  }
  memory.setCurrentTaskLink(currentTaskLink);
  memory.setCurrentBeliefLink(null);
  if (memory.getRecorder().isActive()) {
    memory.getRecorder().append("String_Node_Str" + currentTaskLink + "String_Node_Str");
  }
  final Task task=currentTaskLink.getTargetTask();
  memory.setCurrentTask(task);
  if (currentTaskLink.getType() == TermLink.TRANSFORM) {
    memory.setCurrentBelief(null);
    RuleTables.transformTask(currentTaskLink,memory);
  }
 else {
    int termLinkCount=Parameters.MAX_REASONED_TERM_LINK;
    while (termLinkCount > 0) {
      final TermLink termLink=termLinks.takeOut(currentTaskLink,memory.getTime());
      if (termLink != null) {
        if (memory.getRecorder().isActive()) {
          memory.getRecorder().append("String_Node_Str" + termLink + "String_Node_Str");
        }
        memory.setCurrentBeliefLink(termLink);
        RuleTables.reason(currentTaskLink,termLink,memory);
        termLinks.putBack(termLink);
        termLinkCount--;
      }
 else {
        termLinkCount=0;
      }
    }
  }
  taskLinks.putBack(currentTaskLink);
}

Fixed version (ground truth):
/** 
 * An atomic step in a concept, only called in   {@link Memory#processConcept}
 */
public void fire(){
  final TaskLink currentTaskLink=taskLinks.takeOut();
  if (currentTaskLink == null) {
    return;
  }
  memory.setCurrentTaskLink(currentTaskLink);
  memory.setCurrentBeliefLink(null);
  if (memory.getRecorder().isActive()) {
    memory.getRecorder().append("String_Node_Str" + currentTaskLink + "String_Node_Str");
  }
  final Task task=currentTaskLink.getTargetTask();
  memory.setCurrentTask(task);
  if (currentTaskLink.type == TermLink.TRANSFORM) {
    memory.setCurrentBelief(null);
    RuleTables.transformTask(currentTaskLink,memory);
  }
 else {
    int termLinkCount=Parameters.MAX_REASONED_TERM_LINK;
    while (termLinkCount > 0) {
      final TermLink termLink=termLinks.takeOut(currentTaskLink,memory.getTime());
      if (termLink != null) {
        if (memory.getRecorder().isActive()) {
          memory.getRecorder().append("String_Node_Str" + termLink + "String_Node_Str");
        }
        memory.setCurrentBeliefLink(termLink);
        RuleTables.reason(currentTaskLink,termLink,memory);
        termLinks.putBack(termLink);
        termLinkCount--;
      }
 else {
        termLinkCount=0;
      }
    }
  }
  taskLinks.putBack(currentTaskLink);
}
Program: 166793
Project: 166793
Buggy source:
/** 
 * Recursively build TermLinks between a compound and its components <p> called only from Memory.continuedProcess
 * @param taskBudget The BudgetValue of the task
 */
public void buildTermLinks(final BudgetValue taskBudget){
  if (termLinkTemplates.size() > 0) {
    BudgetValue subBudget=BudgetFunctions.distributeAmongLinks(taskBudget,termLinkTemplates.size());
    if (subBudget.aboveThreshold()) {
      for (      final TermLink template : termLinkTemplates) {
        if (template.getType() != TermLink.TRANSFORM) {
          Term t=template.getTarget();
          final Concept concept=memory.getConcept(t);
          if (concept != null) {
            TermLink termLink1=new TermLink(t,template,subBudget);
            insertTermLink(termLink1);
            TermLink termLink2=new TermLink(term,template,subBudget);
            concept.insertTermLink(termLink2);
            if (t instanceof CompoundTerm) {
              concept.buildTermLinks(subBudget);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Recursively build TermLinks between a compound and its components <p> called only from Memory.continuedProcess
 * @param taskBudget The BudgetValue of the task
 */
public void buildTermLinks(final BudgetValue taskBudget){
  if (termLinkTemplates.size() > 0) {
    BudgetValue subBudget=BudgetFunctions.distributeAmongLinks(taskBudget,termLinkTemplates.size());
    if (subBudget.aboveThreshold()) {
      for (      final TermLink template : termLinkTemplates) {
        if (template.type != TermLink.TRANSFORM) {
          Term t=template.target;
          final Concept concept=memory.getConcept(t);
          if (concept != null) {
            TermLink termLink1=new TermLink(t,template,subBudget);
            insertTermLink(termLink1);
            TermLink termLink2=new TermLink(term,template,subBudget);
            concept.insertTermLink(termLink2);
            if (t instanceof CompoundTerm) {
              concept.buildTermLinks(subBudget);
            }
          }
        }
      }
    }
  }
}
Program: 166794
Project: 166794
Buggy source:
/** 
 * Link to a new task from all relevant concepts for continued processing in the near future for unspecified time. <p> The only method that calls the TaskLink constructor.
 * @param task The task to be linked
 * @param content The content of the task
 */
private void linkToTask(final Task task){
  final BudgetValue taskBudget=task.budget;
  insertTaskLink(new TaskLink(task,null,taskBudget));
  if (term instanceof CompoundTerm) {
    if (!termLinkTemplates.isEmpty()) {
      final BudgetValue subBudget=BudgetFunctions.distributeAmongLinks(taskBudget,termLinkTemplates.size());
      if (subBudget.aboveThreshold()) {
        for (        final TermLink termLink : termLinkTemplates) {
          Term componentTerm=termLink.getTarget();
          Concept componentConcept=memory.getConcept(componentTerm);
          if (componentConcept != null) {
            componentConcept.insertTaskLink(new TaskLink(task,termLink,subBudget));
          }
        }
        buildTermLinks(taskBudget);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Link to a new task from all relevant concepts for continued processing in the near future for unspecified time. <p> The only method that calls the TaskLink constructor.
 * @param task The task to be linked
 * @param content The content of the task
 */
private void linkToTask(final Task task){
  final BudgetValue taskBudget=task.budget;
  insertTaskLink(new TaskLink(task,null,taskBudget));
  if (term instanceof CompoundTerm) {
    if (!termLinkTemplates.isEmpty()) {
      final BudgetValue subBudget=BudgetFunctions.distributeAmongLinks(taskBudget,termLinkTemplates.size());
      if (subBudget.aboveThreshold()) {
        for (        final TermLink termLink : termLinkTemplates) {
          Term componentTerm=termLink.target;
          Concept componentConcept=memory.getConcept(componentTerm);
          if (componentConcept != null) {
            componentConcept.insertTaskLink(new TaskLink(task,termLink,subBudget));
          }
        }
        buildTermLinks(taskBudget);
      }
    }
  }
}
Program: 166795
Project: 166795
Buggy source:
/** 
 * Constructor <p> only called in Memory.continuedProcess
 * @param t The target Task
 * @param template The TermLink template
 * @param v The budget
 */
public TaskLink(final Task t,final TermLink template,final BudgetValue v){
  super("String_Node_Str",v);
  targetTask=t;
  if (template == null) {
    type=TermLink.SELF;
    index=null;
  }
 else {
    type=template.getType();
    index=template.getIndices();
  }
  recordedLinks=new String[Parameters.TERM_LINK_RECORD_LENGTH];
  recordingTime=new long[Parameters.TERM_LINK_RECORD_LENGTH];
  counter=0;
  setKey();
  key+=t.getKey();
}

Fixed version (ground truth):
/** 
 * Constructor <p> only called in Memory.continuedProcess
 * @param t The target Task
 * @param template The TermLink template
 * @param v The budget
 */
public TaskLink(final Task t,final TermLink template,final BudgetValue v){
  super("String_Node_Str",v,template == null ? TermLink.SELF : template.type,template == null ? null : template.index);
  targetTask=t;
  recordedLinks=new String[Parameters.TERM_LINK_RECORD_LENGTH];
  recordingTime=new long[Parameters.TERM_LINK_RECORD_LENGTH];
  counter=0;
  setKey();
  key+=t.getKey();
}
Program: 166796
Project: 166796
Buggy source:
/** 
 * To check whether a TaskLink should use a TermLink, return false if they interacted recently <p> called in TermLinkBag only
 * @param termLink The TermLink to be checked
 * @param currentTime The current time
 * @return Whether they are novel to each other
 */
public boolean novel(final TermLink termLink,final long currentTime){
  final Term bTerm=termLink.getTarget();
  if (bTerm.equals(targetTask.getSentence().getContent())) {
    return false;
  }
  String linkKey=termLink.getKey();
  int next, i;
  for (i=0; i < counter; i++) {
    next=i % Parameters.TERM_LINK_RECORD_LENGTH;
    if (linkKey.equals(recordedLinks[next])) {
      if (currentTime < recordingTime[next] + Parameters.TERM_LINK_RECORD_LENGTH) {
        return false;
      }
 else {
        recordingTime[next]=currentTime;
        return true;
      }
    }
  }
  next=i % Parameters.TERM_LINK_RECORD_LENGTH;
  recordedLinks[next]=linkKey;
  recordingTime[next]=currentTime;
  if (counter < Parameters.TERM_LINK_RECORD_LENGTH) {
    counter++;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * To check whether a TaskLink should use a TermLink, return false if they interacted recently <p> called in TermLinkBag only
 * @param termLink The TermLink to be checked
 * @param currentTime The current time
 * @return Whether they are novel to each other
 */
public boolean novel(final TermLink termLink,final long currentTime){
  final Term bTerm=termLink.target;
  if (bTerm.equals(targetTask.getSentence().getContent())) {
    return false;
  }
  String linkKey=termLink.getKey();
  int next, i;
  for (i=0; i < counter; i++) {
    next=i % Parameters.TERM_LINK_RECORD_LENGTH;
    if (linkKey.equals(recordedLinks[next])) {
      if (currentTime < recordingTime[next] + Parameters.TERM_LINK_RECORD_LENGTH) {
        return false;
      }
 else {
        recordingTime[next]=currentTime;
        return true;
      }
    }
  }
  next=i % Parameters.TERM_LINK_RECORD_LENGTH;
  recordedLinks[next]=linkKey;
  recordingTime[next]=currentTime;
  if (counter < Parameters.TERM_LINK_RECORD_LENGTH) {
    counter++;
  }
  return true;
}
Program: 166797
Project: 166797
Buggy source:
/** 
 * Set the key of the link
 */
protected final void setKey(){
  final String at1, at2;
  if ((type % 2) == 1) {
    at1=Symbols.TO_COMPONENT_1;
    at2=Symbols.TO_COMPONENT_2;
  }
 else {
    at1=Symbols.TO_COMPOUND_1;
    at2=Symbols.TO_COMPOUND_2;
  }
  final StringBuffer sb=new StringBuffer(16).append(at1).append('T').append(type);
  if (index != null) {
    for (int i=0; i < index.length; i++) {
      sb.append('-').append((index[i] + 1));
    }
  }
  sb.append(at2);
  if (target != null) {
    sb.append(target);
  }
  key=sb.toString();
}

Fixed version (ground truth):
/** 
 * Set the key of the link
 */
protected final void setKey(){
  final String at1, at2;
  if ((type % 2) == 1) {
    at1=Symbols.TO_COMPONENT_1;
    at2=Symbols.TO_COMPONENT_2;
  }
 else {
    at1=Symbols.TO_COMPOUND_1;
    at2=Symbols.TO_COMPOUND_2;
  }
  final String targetString=target != null ? target.toString() : null;
  int targetLength=target != null ? targetString.length() : 0;
  int estimatedLength=2 + 2 + targetLength+ 1+ 4 * ((index != null ? index.length : 0) + 1);
  final StringBuffer sb=new StringBuffer(estimatedLength).append(at1).append('T').append(type);
  if (index != null) {
    for (int i=0; i < index.length; i++) {
      sb.append('-').append((index[i] + 1));
    }
  }
  sb.append(at2);
  if (target != null) {
    sb.append(targetString);
  }
  key=sb.toString();
}
Program: 166798
Project: 166798
Buggy source:
/** 
 * Common processing for all inference step
 * @param qual Quality of the inference
 * @param complexity Syntactic complexity of the conclusion
 * @param memory Reference to the memory
 * @return Budget of the conclusion task
 */
private static BudgetValue budgetInference(final float qual,final int complexity,final Memory memory){
  Item t=memory.getCurrentTaskLink();
  if (t == null) {
    t=memory.getCurrentTask();
  }
  float priority=t.getPriority();
  float durability=t.getDurability() / complexity;
  final float quality=qual / complexity;
  final TermLink bLink=memory.getCurrentBeliefLink();
  if (bLink != null) {
    priority=or(priority,bLink.getPriority());
    durability=and(durability,bLink.getDurability());
    final float targetActivation=memory.getConceptActivation(bLink.getTarget());
    bLink.incPriority(or(quality,targetActivation));
    bLink.incDurability(quality);
  }
  return new BudgetValue(priority,durability,quality);
}

Fixed version (ground truth):
/** 
 * Common processing for all inference step
 * @param qual Quality of the inference
 * @param complexity Syntactic complexity of the conclusion
 * @param memory Reference to the memory
 * @return Budget of the conclusion task
 */
private static BudgetValue budgetInference(final float qual,final int complexity,final Memory memory){
  Item t=memory.getCurrentTaskLink();
  if (t == null) {
    t=memory.getCurrentTask();
  }
  float priority=t.getPriority();
  float durability=t.getDurability() / complexity;
  final float quality=qual / complexity;
  final TermLink bLink=memory.getCurrentBeliefLink();
  if (bLink != null) {
    priority=or(priority,bLink.getPriority());
    durability=and(durability,bLink.getDurability());
    final float targetActivation=memory.getConceptActivation(bLink.target);
    bLink.incPriority(or(quality,targetActivation));
    bLink.incDurability(quality);
  }
  return new BudgetValue(priority,durability,quality);
}
Program: 166800
Project: 166800
Buggy source:
/** 
 * The TaskLink is of type TRANSFORM, and the conclusion is an equivalent transformation
 * @param tLink The task link
 * @param memory Reference to the memory
 */
public static void transformTask(TaskLink tLink,Memory memory){
  CompoundTerm content=(CompoundTerm)memory.getCurrentTask().getContent().clone();
  short[] indices=tLink.getIndices();
  Term inh=null;
  if ((indices.length == 2) || (content instanceof Inheritance)) {
    inh=content;
  }
 else   if (indices.length == 3) {
    inh=content.componentAt(indices[0]);
  }
 else   if (indices.length == 4) {
    Term component=content.componentAt(indices[0]);
    if ((component instanceof Conjunction) && (((content instanceof Implication) && (indices[0] == 0)) || (content instanceof Equivalence))) {
      inh=((CompoundTerm)component).componentAt(indices[1]);
    }
 else {
      return;
    }
  }
  if (inh instanceof Inheritance) {
    StructuralRules.transformProductImage((Inheritance)inh,content,indices,memory);
  }
}

Fixed version (ground truth):
/** 
 * The TaskLink is of type TRANSFORM, and the conclusion is an equivalent transformation
 * @param tLink The task link
 * @param memory Reference to the memory
 */
public static void transformTask(TaskLink tLink,Memory memory){
  CompoundTerm content=(CompoundTerm)memory.getCurrentTask().getContent().clone();
  short[] indices=tLink.index;
  Term inh=null;
  if ((indices.length == 2) || (content instanceof Inheritance)) {
    inh=content;
  }
 else   if (indices.length == 3) {
    inh=content.componentAt(indices[0]);
  }
 else   if (indices.length == 4) {
    Term component=content.componentAt(indices[0]);
    if ((component instanceof Conjunction) && (((content instanceof Implication) && (indices[0] == 0)) || (content instanceof Equivalence))) {
      inh=((CompoundTerm)component).componentAt(indices[1]);
    }
 else {
      return;
    }
  }
  if (inh instanceof Inheritance) {
    StructuralRules.transformProductImage((Inheritance)inh,content,indices,memory);
  }
}
Program: 166801
Project: 166801
Buggy source:
/** 
 * Add a new Item into the Bag
 * @param newItem The new Item
 * @return Whether the new Item is added into the Bag
 */
public boolean putIn(final E newItem){
  final String newKey=newItem.getKey();
  final E oldItem=nameTable.put(newKey,newItem);
  if (oldItem != null) {
    outOfBase(oldItem);
    newItem.merge(oldItem);
  }
  final E overflowItem=intoBase(newItem);
  if (overflowItem != null) {
    final String overflowKey=overflowItem.getKey();
    nameTable.remove(overflowKey);
    return (overflowItem != newItem);
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Add a new Item into the Bag
 * @param newItem The new Item
 * @return Whether the new Item is added into the Bag
 */
public boolean putIn(final E newItem){
  final String newKey=newItem.getKey();
  final E oldItem=nameTable.put(newKey,newItem);
  if (oldItem != null) {
    try {
      outOfBase(oldItem);
    }
 catch (    NullPointerException e) {
      System.out.println("String_Node_Str");
    }
    newItem.merge(oldItem);
  }
  final E overflowItem=intoBase(newItem);
  if (overflowItem != null) {
    final String overflowKey=overflowItem.getKey();
    nameTable.remove(overflowKey);
    return (overflowItem != newItem);
  }
 else {
    return true;
  }
}
Program: 166802
Project: 166802
Buggy source:
public void addConceptTermLinks(Concept c){
  final Term source=c.term;
  if (!containsVertex(c)) {
    addVertex(c);
{
      for (      TermLink t : c.termLinks.nameTable.values()) {
        Term target=t.getTarget();
        if (!containsVertex(target)) {
          addVertex(target);
        }
        addEdge(source,target,t);
      }
    }
{
      for (      TaskLink t : c.taskLinks.nameTable.values()) {
        Term target=t.getTarget();
        if (!containsVertex(target)) {
          addVertex(target);
        }
        addEdge(source,target,t);
      }
    }
{
      for (      Sentence s : c.beliefs) {
        Term target=s.getContent();
        if (!containsVertex(target))         addVertex(target);
        addEdge(source,target,s);
      }
    }
{
      for (      Task t : c.questions) {
        Term target=t.getContent();
        if (!containsVertex(target))         addVertex(target);
        addEdge(source,target,t);
      }
    }
  }
}

Fixed version (ground truth):
public void addConceptTermLinks(Concept c){
  final Term source=c.term;
  if (!containsVertex(c)) {
    addVertex(c);
{
      for (      TermLink t : c.termLinks.nameTable.values()) {
        Term target=t.target;
        if (!containsVertex(target)) {
          addVertex(target);
        }
        addEdge(source,target,t);
      }
    }
{
      for (      TaskLink t : c.taskLinks.nameTable.values()) {
        Term target=t.target;
        if (!containsVertex(target)) {
          addVertex(target);
        }
        addEdge(source,target,t);
      }
    }
{
      for (      Sentence s : c.beliefs) {
        Term target=s.getContent();
        if (!containsVertex(target))         addVertex(target);
        addEdge(source,target,s);
      }
    }
{
      for (      Task t : c.questions) {
        Term target=t.getContent();
        if (!containsVertex(target))         addVertex(target);
        addEdge(source,target,t);
      }
    }
  }
}
Program: 166803
Project: 166803
Buggy source:
public void add(Iterable<Concept> concepts,boolean includeTermLinks,boolean includeTaskLinks){
  for (  final Concept c : concepts) {
    final Term source=c.term;
    if (!containsVertex(source)) {
      addVertex(source);
      if (includeTermLinks) {
        for (        TermLink t : c.termLinks.nameTable.values()) {
          Term target=t.getTarget();
          if (!containsVertex(target)) {
            addVertex(target);
          }
          addEdge(source,target,t);
        }
      }
      if (includeTaskLinks) {
        for (        TaskLink t : c.taskLinks.nameTable.values()) {
          Term target=t.getTarget();
          if (!containsVertex(target)) {
            addVertex(target);
          }
          addEdge(source,target,t);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void add(Iterable<Concept> concepts,boolean includeTermLinks,boolean includeTaskLinks){
  for (  final Concept c : concepts) {
    final Term source=c.term;
    if (!containsVertex(source)) {
      addVertex(source);
      if (includeTermLinks) {
        for (        TermLink t : c.termLinks.nameTable.values()) {
          Term target=t.target;
          if (!containsVertex(target)) {
            addVertex(target);
          }
          addEdge(source,target,t);
        }
      }
      if (includeTaskLinks) {
        for (        TaskLink t : c.taskLinks.nameTable.values()) {
          Term target=t.target;
          if (!containsVertex(target)) {
            addVertex(target);
          }
          addEdge(source,target,t);
        }
      }
    }
  }
}
Program: 166804
Project: 166804
Buggy source:
@Test public void testNARState() throws IOException {
  int N=2;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  new Number1DInput(n,"String_Node_Str",x,2);
  n.finish(16);
  HashMap<String,Object> d=new NARState(n).measure();
  assert(d.keySet().size() > 0);
}

Fixed version (ground truth):
@Test public void testNARState() throws IOException {
  int N=2;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  n.finish(16);
  HashMap<String,Object> d=new NARState(n).measure();
  assert(d.keySet().size() > 0);
}
Program: 166805
Project: 166805
Buggy source:
@Test public void test2() throws Exception {
  int N=4;
  int resolution=4;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  new TextOutput(n,System.out);
  Number1DInput v=new Number1DInput(n,"String_Node_Str",x,resolution);
  for (int i=0; i < 10; i++) {
    v.next(randomArray(N,1.0,0));
  }
  v.close();
  n.finish(12);
  Assert.assertTrue(true);
}

Fixed version (ground truth):
public void test2() throws Exception {
  int N=4;
  int resolution=4;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  Number1DInput v=new Number1DInput(n,"String_Node_Str",x,resolution);
  for (int i=0; i < 10; i++) {
    v.next(randomArray(N,1.0,0));
  }
  v.close();
  n.finish(12);
  Assert.assertTrue(true);
}
Program: 166806
Project: 166806
Buggy source:
@Test public void test1() throws Exception {
  int N=4;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  Number1DInput v=new Number1DInput(n,"String_Node_Str",x,2);
  for (int i=0; i < 10; i++) {
    v.next(pulse(N,i % N));
  }
  v.close();
  n.finish(256);
  Assert.assertTrue(true);
}

Fixed version (ground truth):
@Test public void test1() throws Exception {
  int N=4;
  double[] x=randomArray(N,1.0,0);
  NAR n=new NAR();
  Number1DInput v=new Number1DInput(n,"String_Node_Str",x,2);
  Assert.assertTrue(true);
}
Program: 166808
Project: 166808
Buggy source:
/** 
 * Add element to the chain.
 * @return The evidentialBase of numbers
 */
public void addToChain(final Term T,Sentence owner){
  derivationChain.add(T);
  if (derivationChain.size() > Parameters.MAXIMUM_DERIVATION_CHAIN_LENGTH) {
    derivationChain.remove(0);
  }
  owner.setStamp(this);
}

Fixed version (ground truth):
/** 
 * Add element to the chain.
 * @return The evidentialBase of numbers
 */
public void addToChain(final Term T){
  derivationChain.add(T);
  if (derivationChain.size() > Parameters.MAXIMUM_DERIVATION_CHAIN_LENGTH) {
    derivationChain.remove(0);
  }
}
Program: 166809
Project: 166809
Buggy source:
/** 
 * Check if a Sentence provide a better answer to a Question or Goal
 * @param belief The proposed answer
 * @param task The task to be processed
 * @param memory Reference to the memory
 */
public static void trySolution(Sentence belief,final Task task,final Memory memory){
  Sentence problem=task.getSentence();
  if (TemporalRules.matchingOrder(problem.getTemporalOrder(),belief.getTemporalOrder())) {
    Sentence oldBest=task.getBestSolution();
    float newQ=solutionQuality(problem,belief);
    if (oldBest != null) {
      float oldQ=solutionQuality(problem,oldBest);
      if (oldQ >= newQ) {
        return;
      }
    }
    Term content=belief.cloneContent();
    if (Variable.containVarIndep(content.getName())) {
      Variable.unify(Symbols.VAR_INDEPENDENT,content,problem.cloneContent());
      belief=(Sentence)belief.clone();
      belief.setContent(content);
      Stamp st=new Stamp(belief.getStamp(),memory.getTime());
      st.addToChain(belief.getContent(),belief);
    }
    task.setBestSolution(belief);
    if (task.isInput()) {
      memory.nar.output(OUT.class,belief);
    }
    BudgetValue budget=BudgetFunctions.solutionEval(problem,belief,task,memory);
    if ((budget != null) && budget.aboveThreshold()) {
      memory.activatedTask(budget,belief,task.getParentBelief());
    }
  }
}

Fixed version (ground truth):
/** 
 * Check if a Sentence provide a better answer to a Question or Goal
 * @param belief The proposed answer
 * @param task The task to be processed
 * @param memory Reference to the memory
 */
public static void trySolution(Sentence belief,final Task task,final Memory memory){
  Sentence problem=task.getSentence();
  if (TemporalRules.matchingOrder(problem.getTemporalOrder(),belief.getTemporalOrder())) {
    Sentence oldBest=task.getBestSolution();
    float newQ=solutionQuality(problem,belief);
    if (oldBest != null) {
      float oldQ=solutionQuality(problem,oldBest);
      if (oldQ >= newQ) {
        return;
      }
    }
    Term content=belief.cloneContent();
    if (Variable.containVarIndep(content.getName())) {
      Variable.unify(Symbols.VAR_INDEPENDENT,content,problem.cloneContent());
      belief=(Sentence)belief.clone();
      belief.setContent(content);
      Stamp st=new Stamp(belief.getStamp(),memory.getTime());
      st.addToChain(belief.getContent());
    }
    task.setBestSolution(belief);
    if (task.isInput()) {
      memory.nar.output(OUT.class,belief);
    }
    BudgetValue budget=BudgetFunctions.solutionEval(problem,belief,task,memory);
    if ((budget != null) && budget.aboveThreshold()) {
      memory.activatedTask(budget,belief,task.getParentBelief());
    }
  }
}
Program: 166810
Project: 166810
Buggy source:
/** 
 * Constructor called from subclasses constructors to initialize the fields
 * @param name Name of the compound
 * @param components Component list
 */
protected CompoundTerm(final String name,final ArrayList<Term> components){
  this.components=components;
  calcComplexity();
  setName(name);
  isConstant=!Variable.containVar(name);
}

Fixed version (ground truth):
/** 
 * Constructor called from subclasses constructors to initialize the fields
 * @param name Name of the compound
 * @param components Component list
 */
protected CompoundTerm(final String name,final ArrayList<Term> components){
  this.components=ensureValidComponents(components);
  calcComplexity();
  setName(name);
  isConstant=!Variable.containVar(name);
}
Program: 166811
Project: 166811
Buggy source:
/** 
 * Recursively apply a substitute to the current CompoundTerm
 * @param subs
 */
public void applySubstitute(final HashMap<Term,Term> subs){
  int i=0;
  for (  final Term t1 : components) {
    if (subs.containsKey(t1)) {
      Term t2=subs.get(t1);
      while (subs.containsKey(t2)) {
        t2=subs.get(t2);
      }
      components.set(i,(Term)t2.clone());
    }
 else     if (t1 instanceof CompoundTerm) {
      ((CompoundTerm)t1).applySubstitute(subs);
    }
    i++;
  }
  if (this.isCommutative()) {
    components.clear();
    components.addAll(new TreeSet<>(components));
  }
  name=makeName();
}

Fixed version (ground truth):
/** 
 * Recursively apply a substitute to the current CompoundTerm
 * @param subs
 */
public void applySubstitute(final HashMap<Term,Term> subs){
  int i=0;
  for (  final Term t1 : components) {
    if (subs.containsKey(t1)) {
      Term t2=subs.get(t1);
      while (subs.containsKey(t2)) {
        t2=subs.get(t2);
      }
      components.set(i,(Term)t2.clone());
    }
 else     if (t1 instanceof CompoundTerm) {
      ((CompoundTerm)t1).applySubstitute(subs);
    }
    i++;
  }
  if (this.isCommutative()) {
    final TreeSet<Term> ordered=new TreeSet<>(components);
    components.clear();
    components.addAll(ordered);
  }
  name=makeName();
}
Program: 166812
Project: 166812
Buggy source:
/** 
 * default method to make the oldName of a compound term from given fields
 * @param op the term operator
 * @param arg the list of components
 * @return the oldName of the term
 */
protected static String makeCompoundName(final Operator op,final ArrayList<Term> arg){
  final StringBuilder nameBuilder=new StringBuilder(16).append(Symbols.COMPOUND_TERM_OPENER).append(op.toString());
  for (  final Term t : arg) {
    nameBuilder.append(Symbols.ARGUMENT_SEPARATOR);
    if (t instanceof CompoundTerm) {
      ((CompoundTerm)t).setName(((CompoundTerm)t).makeName());
    }
    nameBuilder.append(t.getName());
  }
  nameBuilder.append(Symbols.COMPOUND_TERM_CLOSER);
  return nameBuilder.toString();
}

Fixed version (ground truth):
/** 
 * default method to make the oldName of a compound term from given fields
 * @param op the term operator
 * @param arg the list of components
 * @return the oldName of the term
 */
protected static String makeCompoundName(final Operator op,final List<Term> arg){
  final StringBuilder nameBuilder=new StringBuilder(16).append(Symbols.COMPOUND_TERM_OPENER).append(op.toString());
  for (  final Term t : arg) {
    nameBuilder.append(Symbols.ARGUMENT_SEPARATOR);
    if (t instanceof CompoundTerm) {
      ((CompoundTerm)t).setName(((CompoundTerm)t).makeName());
    }
    nameBuilder.append(t.getName());
  }
  nameBuilder.append(Symbols.COMPOUND_TERM_CLOSER);
  return nameBuilder.toString();
}
Program: 166813
Project: 166813
Buggy source:
/** 
 * make the oldName of an ExtensionSet or IntensionSet
 * @param opener the set opener
 * @param closer the set closer
 * @param arg the list of components
 * @return the oldName of the term
 */
protected static String makeSetName(final char opener,final ArrayList<Term> arg,final char closer){
  StringBuilder name=new StringBuilder(16).append(opener);
  if (arg.size() == 0) {
    throw new RuntimeException("String_Node_Str");
  }
  name.append(arg.get(0).getName());
  for (int i=1; i < arg.size(); i++) {
    name.append(Symbols.ARGUMENT_SEPARATOR);
    name.append(arg.get(i).getName());
  }
  name.append(closer);
  return name.toString();
}

Fixed version (ground truth):
/** 
 * make the oldName of an ExtensionSet or IntensionSet
 * @param opener the set opener
 * @param closer the set closer
 * @param arg the list of components
 * @return the oldName of the term
 */
protected static String makeSetName(final char opener,final List<Term> arg,final char closer){
  StringBuilder name=new StringBuilder(16).append(opener);
  if (arg.size() == 0) {
  }
 else {
    name.append(arg.get(0).getName());
    for (int i=1; i < arg.size(); i++) {
      name.append(Symbols.ARGUMENT_SEPARATOR);
      name.append(arg.get(i).getName());
    }
  }
  name.append(closer);
  return name.toString();
}
Program: 166814
Project: 166814
Buggy source:
/** 
 * Get the component list
 * @return The component list
 */
public ArrayList<Term> getComponents(){
  return components;
}

Fixed version (ground truth):
/** 
 * Get the component list
 * @return The component list
 */
public List<Term> getComponents(){
  return components;
}