nus-yam/ex-repair huggingface dataset:
Program: 166719
Project: 166719
Buggy source:
public static Implication make(final Term subject,final Term predicate,int temporalOrder){
  if ((subject == null) || (predicate == null)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Equivalence)) {
    return null;
  }
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if (predicate instanceof Implication) {
    final Term oldCondition=((Statement)predicate).getSubject();
    if ((oldCondition instanceof Conjunction) && oldCondition.containsTerm(subject)) {
      return null;
    }
    final Term newCondition=Conjunction.make(subject,oldCondition,temporalOrder);
    return make(newCondition,((Statement)predicate).getPredicate(),temporalOrder);
  }
 else {
    return new Implication(new Term[]{subject,predicate},temporalOrder);
  }
}

Fixed version (ground truth):
public static Implication make(final Term subject,final Term predicate,int temporalOrder){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Equivalence)) {
    return null;
  }
  if (predicate instanceof Implication) {
    final Term oldCondition=((Statement)predicate).getSubject();
    if ((oldCondition instanceof Conjunction) && oldCondition.containsTerm(subject)) {
      return null;
    }
    final Term newCondition=Conjunction.make(subject,oldCondition,temporalOrder);
    return make(newCondition,((Statement)predicate).getPredicate(),temporalOrder);
  }
 else {
    return new Implication(new Term[]{subject,predicate},temporalOrder);
  }
}
Program: 166720
Project: 166720
Buggy source:
/** 
 * alternate version of Inheritance.make that allows equivalent subject and predicate to be reduced to the common term.      
 */
public static Term makeTerm(final Term subject,final Term predicate){
  if (subject.equals(predicate))   return subject;
  return make(subject,predicate);
}

Fixed version (ground truth):
/** 
 * alternate version of Inheritance.make that allows equivalent subject and predicate to be reduced to the common term.      
 */
public static Term makeTerm(final Term subject,final Term predicate){
  return make(subject,predicate);
}
Program: 166721
Project: 166721
Buggy source:
/** 
 * Try to make a new compound from two term. Called by the inference rules.
 * @param subject The first component
 * @param predicate The second component
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Similarity make(final Term subject,final Term predicate){
  if (subject == null || predicate == null || invalidStatement(subject,predicate)) {
    return null;
  }
  if (subject.compareTo(predicate) > 0) {
    return make(predicate,subject);
  }
  return new Similarity(subject,predicate);
}

Fixed version (ground truth):
/** 
 * Try to make a new compound from two term. Called by the inference rules.
 * @param subject The first component
 * @param predicate The second component
 * @param memory Reference to the memory
 * @return A compound generated or null
 */
public static Similarity make(final Term subject,final Term predicate){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if (subject.compareTo(predicate) > 0) {
    return make(predicate,subject);
  }
  return new Similarity(subject,predicate);
}
Program: 166722
Project: 166722
Buggy source:
/** 
 * Check if one term is identical to or included in another one, except in a reflexive relation <p>
 * @param t1 The first term
 * @param t2 The second term
 * @return Whether they cannot be related in a statement
 */
private static boolean invalidReflexive(final Term t1,final Term t2){
  if (!(t1 instanceof CompoundTerm)) {
    return false;
  }
  final CompoundTerm com=(CompoundTerm)t1;
  if ((com instanceof ImageExt) || (com instanceof ImageInt)) {
    return false;
  }
  return com.containsTerm(t2);
}

Fixed version (ground truth):
/** 
 * Check if one term is identical to or included in another one, except in a reflexive relation <p>
 * @param t1 The first term
 * @param t2 The second term
 * @return Whether they cannot be related in a statement
 */
private static boolean invalidReflexive(final Term t1,final Term t2){
  if (!(t1 instanceof CompoundTerm)) {
    return false;
  }
  final CompoundTerm ct1=(CompoundTerm)t1;
  if ((ct1 instanceof ImageExt) || (ct1 instanceof ImageInt)) {
    return false;
  }
  return ct1.containsTerm(t2);
}
Program: 166723
Project: 166723
Buggy source:
/** 
 * Check the validity of a potential Statement. [To be refined] <p>
 * @param subject The first component
 * @param predicate The second component
 * @return Whether The Statement is invalid
 */
final public static boolean invalidStatement(final Term subject,final Term predicate){
  if (subject.equals(predicate)) {
    return true;
  }
  if (invalidReflexive(subject,predicate)) {
    return true;
  }
  if (invalidReflexive(predicate,subject)) {
    return true;
  }
  if ((subject instanceof Statement) && (predicate instanceof Statement)) {
    final Statement s1=(Statement)subject;
    final Statement s2=(Statement)predicate;
    final Term t11=s1.getSubject();
    final Term t22=s2.getPredicate();
    final Term t12=s1.getPredicate();
    final Term t21=s2.getSubject();
    if (t11.equals(t22) && t12.equals(t21)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check the validity of a potential Statement. [To be refined] <p>
 * @param subject The first component
 * @param predicate The second component
 * @return Whether The Statement is invalid
 */
final public static boolean invalidStatement(final Term subject,final Term predicate){
  if (subject == null || predicate == null)   return true;
  if (subject.equals(predicate)) {
    return true;
  }
  if (invalidReflexive(subject,predicate)) {
    return true;
  }
  if (invalidReflexive(predicate,subject)) {
    return true;
  }
  if ((subject instanceof Statement) && (predicate instanceof Statement)) {
    final Statement s1=(Statement)subject;
    final Statement s2=(Statement)predicate;
    final Term t11=s1.getSubject();
    final Term t22=s2.getPredicate();
    final Term t12=s1.getPredicate();
    final Term t21=s2.getSubject();
    if (t11.equals(t22) && t12.equals(t21)) {
      return true;
    }
  }
  return false;
}
Program: 166724
Project: 166724
Buggy source:
/** 
 * Make a Statement from given term, called by the rules
 * @param order The temporal order of the statement
 * @return The Statement built
 * @param subj The first component
 * @param pred The second component
 * @param statement A sample statement providing the class type
 * @param memory Reference to the memory
 */
final public static Statement make(final Statement statement,final Term subj,final Term pred,int order){
  if (subj == null || pred == null || invalidStatement(subj,pred)) {
    return null;
  }
  if (statement instanceof Inheritance) {
    return Inheritance.make(subj,pred);
  }
  if (statement instanceof Similarity) {
    return Similarity.make(subj,pred);
  }
  if (statement instanceof Implication) {
    return Implication.make(subj,pred,order);
  }
  if (statement instanceof Equivalence) {
    return Equivalence.make(subj,pred,order);
  }
  throw new RuntimeException("String_Node_Str" + statement.getClass().getSimpleName() + "String_Node_Str"+ subj+ "String_Node_Str"+ pred+ "String_Node_Str"+ order);
}

Fixed version (ground truth):
/** 
 * Make a Statement from given term, called by the rules
 * @param order The temporal order of the statement
 * @return The Statement built
 * @param subj The first component
 * @param pred The second component
 * @param statement A sample statement providing the class type
 * @param memory Reference to the memory
 */
final public static Statement make(final Statement statement,final Term subj,final Term pred,int order){
  return make(statement.operator(),subj,pred);
}
Program: 166725
Project: 166725
Buggy source:
/** 
 * performs a thorough check of the validity of a term (by cloneDeep it) to see if it's valid 
 */
public static boolean valid(Term content){
  try {
    Term cloned=content.cloneDeep();
    return true;
  }
 catch (  Throwable e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * performs a thorough check of the validity of a term (by cloneDeep it) to see if it's valid 
 */
public static boolean valid(Term content){
  try {
    Term cloned=content.cloneDeep();
    return cloned != null;
  }
 catch (  Throwable e) {
    return false;
  }
}
Program: 166726
Project: 166726
Buggy source:
public void recurseTerms(final TermVisitor v){
  v.visit(this);
  if (this instanceof CompoundTerm) {
    for (    Term t : ((CompoundTerm)this).term) {
      t.recurseTerms(v);
    }
  }
}

Fixed version (ground truth):
public void recurseTerms(final TermVisitor v,Term parent){
  v.visit(this,parent);
  if (this instanceof CompoundTerm) {
    for (    Term t : ((CompoundTerm)this).term) {
      t.recurseTerms(v,this);
    }
  }
}
Program: 166727
Project: 166727
Buggy source:
public void visit(Term t);

Fixed version (ground truth):
public void visit(Term t,Term superterm);
Program: 166728
Project: 166728
Buggy source:
@Override public void vertex(AbstractGraphVis<Item,Object> g,VertexVis<Item,Object> v){
  float priority=v.getVertex().getPriority();
  double radius=(1.0 - priority) * spacing + 8;
  float angle=((arcStop - arcStart) * Video.hashFloat(v.vertex.hashCode()) + arcStart) * ((float)Math.PI * 2f);
  v.tx=(float)(Math.cos(angle) * radius) * spacing;
  v.ty=(float)(Math.sin(angle) * radius) * spacing;
}

Fixed version (ground truth):
@Override public void vertex(AbstractGraphVis<Item,Object> g,VertexVis<Item,Object> v){
  if (v.getVertex() instanceof Item) {
    float priority=v.getVertex().getPriority();
    double radius=(1.0 - priority) * spacing + 8;
    float angle=((arcStop - arcStart) * Video.hashFloat(v.vertex.hashCode()) + arcStart) * ((float)Math.PI * 2f);
    v.tx=(float)(Math.cos(angle) * radius) * spacing;
    v.ty=(float)(Math.sin(angle) * radius) * spacing;
  }
}
Program: 166729
Project: 166729
Buggy source:
/** 
 * Shared final operations by all double-premise rules, called from the rules except StructuralRules
 * @param newContent The content of the sentence in task
 * @param newTruth The truth value of the sentence in task
 * @param newBudget The budget value in task
 */
public Task doublePremiseTask(final Term newContent,final TruthValue newTruth,final BudgetValue newBudget,boolean temporalAdd){
  if (!newBudget.aboveThreshold()) {
    return null;
  }
  Task derived=null;
  if (newContent != null) {
{
      final Sentence newSentence=new Sentence(newContent,getCurrentTask().sentence.punctuation,newTruth,getTheNewStamp());
      final Task newTask=Task.make(newSentence,newBudget,getCurrentTask(),getCurrentBelief());
      if (newTask != null) {
        boolean added=derivedTask(newTask,false,false,null,null);
        if (added && temporalAdd) {
          memory.temporalRuleOutputToGraph(newSentence,newTask);
        }
        if (added) {
          derived=newTask;
        }
      }
    }
  }
  return derived;
}

Fixed version (ground truth):
/** 
 * Shared final operations by all double-premise rules, called from the rules except StructuralRules
 * @param newContent The content of the sentence in task
 * @param newTruth The truth value of the sentence in task
 * @param newBudget The budget value in task
 */
public Task doublePremiseTask(final Term newContent,final TruthValue newTruth,final BudgetValue newBudget,boolean temporalAdd){
  if (!newBudget.aboveThreshold()) {
    return null;
  }
  if (newContent != null) {
    final Sentence newSentence=new Sentence(newContent,getCurrentTask().sentence.punctuation,newTruth,getTheNewStamp());
    final Task newTask=Task.make(newSentence,newBudget,getCurrentTask(),getCurrentBelief());
    Task derived=null;
    if (newTask != null) {
      boolean added=derivedTask(newTask,false,false,null,null);
      if (added && temporalAdd) {
        memory.temporalRuleOutputToGraph(newSentence,newTask);
      }
      if (added) {
        derived=newTask;
      }
    }
    return derived;
  }
  return null;
}
Program: 166731
Project: 166731
Buggy source:
@Override public void visit(final Term t){
  if (t instanceof Variable) {
    Variable v=((Variable)t);
    if (v.getScope() != v) {
      v.setScope(c,v.name());
    }
    vars.add(v);
  }
}

Fixed version (ground truth):
@Override public void visit(final Term t){
  if (t instanceof Variable) {
    Variable v=((Variable)t);
    vars.add(v);
  }
}
Program: 166733
Project: 166733
Buggy source:
@Override public CompoundTerm cloneDeep(){
  Term c=clone(cloneTermsDeep());
  if (c.getClass() != getClass())   throw new RuntimeException("String_Node_Str" + c + "String_Node_Str"+ this);
  if (isNormalized())   ((CompoundTerm)c).setNormalized(true);
  return (CompoundTerm)c;
}

Fixed version (ground truth):
@Override public CompoundTerm cloneDeep(){
  Term c=clone(cloneTermsDeep());
  if (c == null)   throw new UnableToCloneException("String_Node_Str" + this);
  if (c.getClass() != getClass())   throw new UnableToCloneException("String_Node_Str" + c + "String_Node_Str"+ this);
  if (isNormalized())   ((CompoundTerm)c).setNormalized(true);
  return (CompoundTerm)c;
}
Program: 166734
Project: 166734
Buggy source:
public void invalidateName(){
  this.name=null;
  for (  Term t : term) {
    if (t.hasVar())     if (t instanceof CompoundTerm)     ((CompoundTerm)t).invalidateName();
  }
}

Fixed version (ground truth):
public void invalidateName(){
  this.name=null;
  for (  Term t : term) {
    if (t.hasVar())     if (t instanceof CompoundTerm)     ((CompoundTerm)t).invalidateName();
  }
  setNormalized(false);
}
Program: 166735
Project: 166735
Buggy source:
public CompoundTerm cloneDeepVariables(){
  Term c=clone(cloneVariableTermsDeep());
  if (c == null)   throw new RuntimeException("String_Node_Str" + this);
  if (c.getClass() != getClass())   throw new RuntimeException("String_Node_Str" + c + "String_Node_Str"+ this);
  return (CompoundTerm)c;
}

Fixed version (ground truth):
public CompoundTerm cloneDeepVariables(){
  Term c=clone(cloneVariableTermsDeep());
  if (c == null)   throw new UnableToCloneException("String_Node_Str" + this);
  if (c.getClass() != getClass())   throw new UnableToCloneException("String_Node_Str" + c + "String_Node_Str"+ this);
  return (CompoundTerm)c;
}
Program: 166736
Project: 166736
Buggy source:
/** 
 * Constructor with partial values, called by make
 * @param arg The component list of the term
 */
protected Conjunction(final Term[] arg,final int order,boolean normalized){
  super(arg);
  temporalOrder=order;
  init(arg);
  if (normalized)   setNormalized(true);
}

Fixed version (ground truth):
/** 
 * Constructor with partial values, called by make
 * @param arg The component list of the term
 */
protected Conjunction(final Term[] arg,final int order,boolean normalized){
  super(arg);
  temporalOrder=order;
  init(arg);
}
Program: 166737
Project: 166737
Buggy source:
/** 
 * Make a Statement from given term, called by the rules
 * @param order The temporal order of the statement
 * @return The Statement built
 * @param subj The first component
 * @param pred The second component
 * @param statement A sample statement providing the class type
 * @param memory Reference to the memory
 */
final public static Statement make(final Statement statement,final Term subj,final Term pred,int order){
  if (subj == null || pred == null) {
    return null;
  }
  if (statement instanceof Inheritance) {
    return Inheritance.make(subj,pred);
  }
  if (statement instanceof Similarity) {
    return Similarity.make(subj,pred);
  }
  if (statement instanceof Implication) {
    return Implication.make(subj,pred,order);
  }
  if (statement instanceof Equivalence) {
    return Equivalence.make(subj,pred,order);
  }
  throw new RuntimeException("String_Node_Str" + statement.getClass().getSimpleName() + "String_Node_Str"+ subj+ "String_Node_Str"+ pred+ "String_Node_Str"+ order);
}

Fixed version (ground truth):
/** 
 * Make a Statement from given term, called by the rules
 * @param order The temporal order of the statement
 * @return The Statement built
 * @param subj The first component
 * @param pred The second component
 * @param statement A sample statement providing the class type
 * @param memory Reference to the memory
 */
final public static Statement make(final Statement statement,final Term subj,final Term pred,int order){
  if (subj == null || pred == null || invalidStatement(subj,pred)) {
    return null;
  }
  if (statement instanceof Inheritance) {
    return Inheritance.make(subj,pred);
  }
  if (statement instanceof Similarity) {
    return Similarity.make(subj,pred);
  }
  if (statement instanceof Implication) {
    return Implication.make(subj,pred,order);
  }
  if (statement instanceof Equivalence) {
    return Equivalence.make(subj,pred,order);
  }
  throw new RuntimeException("String_Node_Str" + statement.getClass().getSimpleName() + "String_Node_Str"+ subj+ "String_Node_Str"+ pred+ "String_Node_Str"+ order);
}
Program: 166740
Project: 166740
Buggy source:
protected void rect(Object event,Object subject,float r,float x,float y){
  float px=x * timeScale;
  float py=y;
  if (r < 2) {
    r=2;
  }
  l.rect(px + -r / 2f,py + -r / 2f,r,r);
  label(event,subject,r,x,y);
}

Fixed version (ground truth):
protected void rect(Object event,Object subject,float r,float x,float y){
  float px=x * timeScale;
  float py=y;
  if (r < 2) {
    r=2;
  }
  l.g.rect(px + -r / 2f,py + -r / 2f,r,r);
  label(event,subject,r,x,y);
}
Program: 166741
Project: 166741
Buggy source:
protected void triangleHorizontal(Object event,Object subject,float r,float x,float y,float direction){
  float px=x * timeScale;
  float py=y;
  if (r < 2) {
    r=2;
  }
  l.triangle(px + direction * -r / 2,py + direction * -r / 2,px + direction * r / 2,py + 0,px + direction * -r / 2,py + direction * r / 2);
  label(event,subject,r,x,y);
}

Fixed version (ground truth):
protected void triangleHorizontal(Object event,Object subject,float r,float x,float y,float direction){
  float px=x * timeScale;
  float py=y;
  if (r < 2) {
    r=2;
  }
  l.g.triangle(px + direction * -r / 2,py + direction * -r / 2,px + direction * r / 2,py + 0,px + direction * -r / 2,py + direction * r / 2);
  label(event,subject,r,x,y);
}
Program: 166743
Project: 166743
Buggy source:
@Override public void update(Timeline2DCanvas l,float timeScale,float yScale){
  TreeMap<Long,List<Events.InferenceEvent>> time=trace.time;
  timepoints.putAll(time.subMap(l.getStart(),l.getEnd()));
}

Fixed version (ground truth):
@Override public void update(TimelineVis l,float timeScale,float yScale){
  TreeMap<Long,List<Events.InferenceEvent>> time=trace.time;
  timepoints.putAll(time.subMap(l.getStart(),l.getEnd()));
}
Program: 166744
Project: 166744
Buggy source:
@Override public void draw(Timeline2DCanvas l,float y,float timeScale,float yScale){
  this.timeScale=timeScale;
  this.yScale=yScale * getHeight();
  this.l=l;
  if ((timepoints == null) || (timepoints.isEmpty())) {
    return;
  }
  lastSubjectEvent.clear();
  events.clear();
  l.noStroke();
  l.textSize(l.getDrawnTextScale());
synchronized (timepoints) {
    long maxItemsPerCycle=timepoints.values().stream().map((x) -> x.stream().filter((e) -> include(e)).count()).max(Long::compare).get();
    for (    Map.Entry<Long,List<Events.InferenceEvent>> e : timepoints.entrySet()) {
      long t=e.getKey();
      List<Events.InferenceEvent> v=e.getValue();
      drawEvent(t,v,y,(int)maxItemsPerCycle);
    }
  }
  l.strokeCap(PConstants.SQUARE);
  l.strokeWeight(4f);
  for (  final EventPoint<Object> to : events.values()) {
    for (    final EventPoint<Object> from : to.incoming) {
      l.stroke(256f * NARSwing.hashFloat(to.subject.hashCode()),100f,200f,68f);
      l.line(timeScale * from.x,from.y,timeScale * to.x,to.y);
    }
  }
}

Fixed version (ground truth):
@Override public void draw(TimelineVis l,float y,float timeScale,float yScale){
  this.timeScale=timeScale;
  this.yScale=yScale * getHeight();
  this.l=l;
  if ((timepoints == null) || (timepoints.isEmpty())) {
    return;
  }
  lastSubjectEvent.clear();
  events.clear();
  l.g.noStroke();
  l.g.textSize(l.getDrawnTextScale());
synchronized (timepoints) {
    long maxItemsPerCycle=timepoints.values().stream().map((x) -> x.stream().filter((e) -> include(e)).count()).max(Long::compare).get();
    for (    Map.Entry<Long,List<Events.InferenceEvent>> e : timepoints.entrySet()) {
      long t=e.getKey();
      List<Events.InferenceEvent> v=e.getValue();
      drawEvent(t,v,y,(int)maxItemsPerCycle);
    }
  }
  l.g.strokeCap(PConstants.SQUARE);
  l.g.strokeWeight(4f);
  for (  final EventPoint<Object> to : events.values()) {
    for (    final EventPoint<Object> from : to.incoming) {
      l.g.stroke(256f * Video.hashFloat(to.subject.hashCode()),100f,200f,68f);
      l.g.line(timeScale * from.x,from.y,timeScale * to.x,to.y);
    }
  }
}
Program: 166745
Project: 166745
Buggy source:
protected void label(Object event,Object subject,float r,float x,float y){
  if ((l.isShowingItemLabels()) && (r * l.getDrawnTextScale() > l.getMinLabelScale())) {
    l.fill(255f);
    String s;
    if (event instanceof HasLabel)     s=((HasLabel)event).toLabel();
 else     s=event.toString();
    l.text(s,timeScale * x - r / 2f,y - r / 2f,x + r / 2 * 6f,y + r / 2f);
  }
  setEventPoint(event,subject,x,y,0);
}

Fixed version (ground truth):
protected void label(Object event,Object subject,float r,float x,float y){
  if ((l.isShowingItemLabels()) && (r * l.getDrawnTextScale() > l.getMinLabelScale())) {
    l.g.fill(255f);
    String s;
    if (event instanceof HasLabel)     s=((HasLabel)event).toLabel();
 else     s=event.toString();
    l.g.text(s,timeScale * x - r / 2f,y - r / 2f,x + r / 2 * 6f,y + r / 2f);
  }
  setEventPoint(event,subject,x,y,0);
}
Program: 166746
Project: 166746
Buggy source:
protected void updateGUI(){
  long now=System.currentTimeMillis();
  speedSlider.repaint();
  if (now - lastChartUpdateTime > minChartUpdateTime) {
    chart.redraw();
    lastChartUpdateTime=now;
  }
  updateScheduled.set(false);
}

Fixed version (ground truth):
protected void updateGUI(){
  speedSlider.repaint();
  updateScheduled.set(false);
}
Program: 166749
Project: 166749
Buggy source:
@Override public void event(final Class event,final Object... arguments){
  if (event == FrameEnd.class) {
    long now=System.currentTimeMillis();
    long deltaTime=now - lastUpdateTime;
    if ((deltaTime >= GUIUpdatePeriodMS)) {
      updateScheduled.set(true);
      senses.update(memory);
      chart.updateData(memory.time());
      speedSlider.repaint();
      SwingUtilities.invokeLater(updateGUIRunnable);
      lastUpdateTime=now;
    }
  }
}

Fixed version (ground truth):
@Override public void event(final Class event,final Object... arguments){
  if (event == FrameEnd.class) {
    long now=System.currentTimeMillis();
    long deltaTime=now - lastUpdateTime;
    if ((deltaTime >= GUIUpdatePeriodMS)) {
      updateScheduled.set(true);
      speedSlider.repaint();
      SwingUtilities.invokeLater(updateGUIRunnable);
      lastUpdateTime=now;
    }
  }
}
Program: 166752
Project: 166752
Buggy source:
@Override public Concept addConcept(final Term term,final Memory memory){
  Concept concept=conceptBuilder.newConcept(term,memory);
  Concept removed=concepts.putIn(concept);
  if (removed == null) {
  }
 else   if (removed == concept) {
    memory.emit(ConceptRemove.class,concept);
    return null;
  }
 else   if (removed != null) {
    memory.emit(ConceptRemove.class,removed);
  }
  memory.logic.CONCEPT_ADD.commit(term.getComplexity());
  memory.emit(Events.ConceptAdd.class,concept);
  return concept;
}

Fixed version (ground truth):
@Override public Concept addConcept(final Term term,final Memory memory){
  Concept concept=conceptBuilder.newConcept(term,memory);
  boolean merged=false;
  Concept removed=concepts.putIn(concept);
  if (removed == null) {
  }
 else   if (removed == concept) {
    System.out.println("String_Node_Str" + concept);
    memory.emit(ConceptRemove.class,removed);
    return null;
  }
 else   if (removed != null) {
    if (removed.name().equals(concept.name())) {
      System.out.println("String_Node_Str" + removed);
      merged=true;
    }
 else {
      System.out.println("String_Node_Str" + removed + "String_Node_Str"+ concept);
      memory.emit(ConceptRemove.class,removed);
    }
  }
  if (!merged) {
    memory.logic.CONCEPT_ADD.commit(term.getComplexity());
    memory.emit(Events.ConceptAdd.class,concept);
  }
  return concept;
}
Program: 166753
Project: 166753
Buggy source:
/** 
 * Merge with another Item with identical key
 * @param that The Item to be merged
 */
public void merge(final Item that){
  budget.merge(budget);
}

Fixed version (ground truth):
/** 
 * Merge with another Item with identical key
 * @param that The Item to be merged
 * @return the resulting Item: this or that
 */
public Item merge(final Item that){
  budget.merge(that.budget);
  return this;
}
Program: 166754
Project: 166754
Buggy source:
/** 
 * Merge one Task into another
 * @param that The other Task
 */
@Override public void merge(final Item that){
  if (getCreationTime() >= ((Task)that).getCreationTime()) {
    super.merge(that);
  }
 else {
    that.merge(this);
  }
}

Fixed version (ground truth):
/** 
 * Merge one Task into another
 * @param that The other Task
 */
@Override public Item merge(final Item that){
  if (getCreationTime() >= ((Task)that).getCreationTime()) {
    return super.merge(that);
  }
 else {
    return that.merge(this);
  }
}
Program: 166755
Project: 166755
Buggy source:
/** 
 * Add a new Item into the Bag
 * @param newItem The new Item
 * @return the item which was removed, which may be the input item if it could not be inserted; or null if nothing needed removed
 */
public E putIn(final E newItem){
  final K newKey=newItem.name();
  final E existingItemWithSameKey=nameRemove(newKey);
  if (existingItemWithSameKey != null) {
    outOfBase(existingItemWithSameKey);
    newItem.merge(existingItemWithSameKey);
  }
  final E overflowItem=intoBase(newItem);
  if (overflowItem == newItem) {
    return newItem;
  }
  namePut(newKey,newItem);
  if (overflowItem != null) {
    final K overflowKey=overflowItem.name();
    if (!overflowKey.equals(newKey)) {
      nameRemove(overflowKey);
    }
    return overflowItem;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Add a new Item into the Bag
 * @param newItem The new Item
 * @return the item which was removed, which may be the input item if it could not be inserted; or null if nothing needed removed
 */
public E putIn(E newItem){
  final K newKey=newItem.name();
  final E existingItemWithSameKey=nameRemove(newKey);
  if (existingItemWithSameKey != null) {
    outOfBase(existingItemWithSameKey);
    newItem=(E)existingItemWithSameKey.merge(newItem);
  }
  final E overflowItem=intoBase(newItem);
  if (overflowItem == newItem) {
    return newItem;
  }
  namePut(newKey,newItem);
  if (overflowItem != null) {
    final K overflowKey=overflowItem.name();
    if (!overflowKey.equals(newKey)) {
      nameRemove(overflowKey);
    }
    return overflowItem;
  }
  return null;
}
Program: 166756
Project: 166756
Buggy source:
/** 
 * Remove an item from itemTable, then adjust mass
 * @param oldItem The Item to be removed
 */
protected void outOfBase(final E oldItem){
  if (items.remove(oldItem)) {
    addToMass(-(oldItem.getPriority()));
  }
}

Fixed version (ground truth):
/** 
 * Remove an item from itemTable, then adjust mass
 * @param oldItem The Item to be removed
 */
@Override protected void outOfBase(final E oldItem){
  if (items.remove(oldItem)) {
    mass-=oldItem.getPriority();
  }
}
Program: 166757
Project: 166757
Buggy source:
/** 
 * Defines the focus curve.  x is a proportion between 0 and 1 (inclusive).  x=0 represents low priority (bottom of bag), x=1.0 represents high priority
 * @param x
 * @return 
 */
public float getFocus(float x){
  return (x * x * x);
}

Fixed version (ground truth):
/** 
 * Defines the focus curve.  x is a proportion between 0 and 1 (inclusive).  x=0 represents low priority (bottom of bag), x=1.0 represents high priority
 * @param x
 * @return 
 */
public float getFocus(final float x){
  return (float)curve.y(x);
}
Program: 166758
Project: 166758
Buggy source:
/** 
 * Insert an item into the itemTable, and return the overflow
 * @param newItem The Item to put in
 * @return The overflow Item
 */
@Override protected E intoBase(E newItem){
  E oldItem=null;
  if (size() >= capacity) {
    oldItem=takeOutIndex(0);
  }
  items.add(newItem);
  mass+=(newItem.budget.getPriority());
  return oldItem;
}

Fixed version (ground truth):
/** 
 * Insert an item into the itemTable, and return the overflow
 * @param newItem The Item to put in
 * @return The overflow Item
 */
@Override protected E intoBase(E newItem){
  float newPriority=newItem.getPriority();
  E oldItem=null;
  if (size() >= capacity) {
    if (newPriority < getMinPriority())     return newItem;
    oldItem=takeOutIndex(0);
  }
  items.add(newItem);
  mass+=(newItem.budget.getPriority());
  return oldItem;
}
Program: 166759
Project: 166759
Buggy source:
/** 
 * distributor function 
 */
public int nextRemovalIndex(){
  final int s=size();
  if (randomRemoval) {
    x=Memory.randomNumber.nextFloat();
  }
 else {
    x+=scanningRate * 1.0f / (1 + s);
    if (x >= 1.0f)     x-=1.0f;
    if (x <= 0.0f)     x+=1.0f;
  }
  float y=getFocus(x);
  int result=(int)fastRound((1.0 - y) * (s - 1));
  if (result == s) {
    throw new RuntimeException("String_Node_Str" + x + "String_Node_Str"+ y);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * distributor function 
 */
public int nextRemovalIndex(){
  final float s=size();
  if (randomRemoval) {
    x=Memory.randomNumber.nextFloat();
  }
 else {
    x+=scanningRate * 1.0f / (1 + s);
    if (x >= 1.0f)     x-=1.0f;
    if (x <= 0.0f)     x+=1.0f;
  }
  float y=getFocus(x);
  if (y < 0)   y=0;
  if (y > 1.0f)   y=1f;
  int result=(int)Math.round(y * (s - 1));
  if (result == s) {
    throw new RuntimeException("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ result);
  }
  return result;
}
Program: 166760
Project: 166760
Buggy source:
/** 
 * Take out the first or last E in a level from the itemTable
 * @param level The current level
 * @return The first Item
 */
private E takeOutIndex(final int index){
  final E selected=items.remove(index);
  addToMass(-(selected.budget.getPriority()));
  nameTable.remove(selected.name());
  return selected;
}

Fixed version (ground truth):
/** 
 * Take out the first or last E in a level from the itemTable
 * @param level The current level
 * @return The first Item
 */
private E takeOutIndex(final int index){
  final E selected=items.remove(index);
  mass-=selected.budget.getPriority();
  nameTable.remove(selected.name());
  return selected;
}
Program: 166763
Project: 166763
Buggy source:
private NSlider newSpeedSlider(){
  final NSlider s=new NSlider(0,0,1.0f){
    @Override public String getText(){
      if (value == null) {
        return "String_Node_Str";
      }
      float v=value();
      String s="String_Node_Str" + memory.getTime();
      if (currentSpeed == 0) {
        s+="String_Node_Str";
      }
 else       if (currentSpeed == 1.0) {
        s+="String_Node_Str";
      }
 else {
        s+="String_Node_Str" + nar.getMinCyclePeriodMS() + "String_Node_Str";
      }
      return s;
    }
    @Override public void onChange(    float v){
      setSpeed(v);
    }
  }
;
  this.speedSlider=s;
  return s;
}

Fixed version (ground truth):
private NSlider newSpeedSlider(){
  final NSlider s=new NSlider(0f,0f,1.0f){
    @Override public String getText(){
      if (value == null) {
        return "String_Node_Str";
      }
      String s="String_Node_Str" + memory.getTime();
      if (currentSpeed == 0) {
        s+="String_Node_Str";
      }
 else       if (currentSpeed == 1.0) {
        s+="String_Node_Str";
      }
 else {
        s+="String_Node_Str" + nar.getMinCyclePeriodMS() + "String_Node_Str";
      }
      return s;
    }
    @Override public void onChange(    float v){
      setSpeed(v);
    }
  }
;
  this.speedSlider=s;
  return s;
}
Program: 166764
Project: 166764
Buggy source:
@Override public void actionPerformed(ActionEvent e){
  setSpeed(1.0);
  volumeSlider.setValue(20);
}

Fixed version (ground truth):
@Override public void actionPerformed(ActionEvent e){
  setSpeed(1.0f);
  volumeSlider.setValue(20f);
}
Program: 166765
Project: 166765
Buggy source:
public void setSpeed(float nextSpeed){
  final float maxPeriodMS=1024.0f;
  if (nextSpeed == 0) {
    if (currentSpeed == 0) {
      if (lastSpeed == 0) {
        lastSpeed=defaultSpeed;
      }
      nextSpeed=lastSpeed;
    }
 else {
    }
  }
  lastSpeed=currentSpeed;
  speedSlider.repaint();
  stopButton.setText(String.valueOf(FA_PlayCharacter));
  speedSlider.setValue(nextSpeed);
  currentSpeed=nextSpeed;
  double logScale=50;
  if (nextSpeed > 0) {
    int ms=(int)((1.0 - Math.log(1 + nextSpeed * logScale) / Math.log(1 + logScale)) * maxPeriodMS);
    if (ms < 1) {
      if (allowFullSpeed)       ms=0;
 else       ms=1;
    }
    stopButton.setText(String.valueOf(FA_StopCharacter));
    nar.start(ms);
  }
 else {
    stopButton.setText(String.valueOf(FA_PlayCharacter));
    nar.stop();
  }
}

Fixed version (ground truth):
public void setSpeed(float nextSpeed){
  final float maxPeriodMS=1024.0f;
  if (nextSpeed == 0) {
    if (currentSpeed == 0) {
      if (lastSpeed == 0) {
        lastSpeed=defaultSpeed;
      }
      nextSpeed=lastSpeed;
    }
 else {
    }
  }
  lastSpeed=currentSpeed;
  speedSlider.repaint();
  stopButton.setText(String.valueOf(FA_PlayCharacter));
  speedSlider.setValue(nextSpeed);
  currentSpeed=nextSpeed;
  float logScale=50f;
  if (nextSpeed > 0) {
    int ms=(int)((1.0 - Math.log(1 + nextSpeed * logScale) / Math.log(1 + logScale)) * maxPeriodMS);
    if (ms < 1) {
      if (allowFullSpeed)       ms=0;
 else       ms=1;
    }
    stopButton.setText(String.valueOf(FA_StopCharacter));
    nar.start(ms);
  }
 else {
    stopButton.setText(String.valueOf(FA_PlayCharacter));
    nar.stop();
  }
}
Program: 166766
Project: 166766
Buggy source:
private JComponent newParameterPanel(){
  JPanel p=new JPanel();
  JPanel pc=new JPanel();
  pc.setLayout(new GridLayout(1,0));
  stopButton=new FAButton(FA_StopCharacter);
  stopButton.addActionListener(this);
  pc.add(stopButton);
  walkButton=new FAButton('\uf051');
  walkButton.setToolTipText("String_Node_Str");
  walkButton.addActionListener(this);
  pc.add(walkButton);
  JButton focusButton=new FAButton(FA_FocusCharacter);
  focusButton.setToolTipText("String_Node_Str");
  focusButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      setSpeed(1.0);
      volumeSlider.setValue(20);
    }
  }
);
  pc.add(focusButton);
  p.setLayout(new GridBagLayout());
  GridBagConstraints c=new GridBagConstraints();
  c.anchor=GridBagConstraints.NORTH;
  c.fill=GridBagConstraints.HORIZONTAL;
  c.weightx=1;
  c.gridx=0;
  c.ipady=8;
  p.add(pc,c);
  NSlider vs=newVolumeSlider();
  vs.setFont(vs.getFont().deriveFont(Font.BOLD));
  p.add(vs,c);
  NSlider ss=newSpeedSlider();
  ss.setFont(vs.getFont());
  p.add(ss,c);
  c.ipady=4;
  p.add(newIntSlider(memory.param.taskForgettingRate,"String_Node_Str",1,99),c);
  p.add(newIntSlider(memory.param.beliefForgettingRate,"String_Node_Str",1,99),c);
  p.add(newIntSlider(memory.param.conceptForgettingRate,"String_Node_Str",1,99),c);
{
    this.chart=new ChartsPanel(nar.memory.logic,chartHistoryLength);
  }
  c.weighty=1.0;
  c.fill=GridBagConstraints.BOTH;
  p.add(chart,c);
  return p;
}

Fixed version (ground truth):
private JComponent newParameterPanel(){
  JPanel p=new JPanel();
  JPanel pc=new JPanel();
  pc.setLayout(new GridLayout(1,0));
  stopButton=new FAButton(FA_StopCharacter);
  stopButton.addActionListener(this);
  pc.add(stopButton);
  walkButton=new FAButton('\uf051');
  walkButton.setToolTipText("String_Node_Str");
  walkButton.addActionListener(this);
  pc.add(walkButton);
  JButton focusButton=new FAButton(FA_FocusCharacter);
  focusButton.setToolTipText("String_Node_Str");
  focusButton.addActionListener(new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      setSpeed(1.0f);
      volumeSlider.setValue(20f);
    }
  }
);
  pc.add(focusButton);
  p.setLayout(new GridBagLayout());
  GridBagConstraints c=new GridBagConstraints();
  c.anchor=GridBagConstraints.NORTH;
  c.fill=GridBagConstraints.HORIZONTAL;
  c.weightx=1;
  c.gridx=0;
  c.ipady=8;
  p.add(pc,c);
  NSlider vs=newVolumeSlider();
  vs.setFont(vs.getFont().deriveFont(Font.BOLD));
  p.add(vs,c);
  NSlider ss=newSpeedSlider();
  ss.setFont(vs.getFont());
  p.add(ss,c);
  c.ipady=4;
  p.add(newIntSlider(memory.param.taskForgettingRate,"String_Node_Str",1,99),c);
  p.add(newIntSlider(memory.param.beliefForgettingRate,"String_Node_Str",1,99),c);
  p.add(newIntSlider(memory.param.conceptForgettingRate,"String_Node_Str",1,99),c);
{
    this.chart=new ChartsPanel(nar.memory.logic,chartHistoryLength);
  }
  c.weighty=1.0;
  c.fill=GridBagConstraints.BOTH;
  p.add(chart,c);
  return p;
}
Program: 166767
Project: 166767
Buggy source:
private NSlider newVolumeSlider(){
  final NSlider s=this.volumeSlider=new NSlider(100,0,100){
    @Override public String getText(){
      if (value == null) {
        return "String_Node_Str";
      }
      float v=value();
      String s="String_Node_Str" + super.getText() + "String_Node_Str";
      if (v == 0) {
        s+="String_Node_Str";
      }
 else       if (v < 25) {
        s+="String_Node_Str";
      }
 else       if (v < 75) {
        s+="String_Node_Str";
      }
 else {
        s+="String_Node_Str";
      }
      s+="String_Node_Str";
      return s;
    }
    @Override public void setValue(    float v){
      super.setValue(Math.round(v));
      repaint();
    }
    @Override public void onChange(    float v){
      int level=(int)v;
      nar.param().noiseLevel.set(level);
    }
  }
;
  return s;
}

Fixed version (ground truth):
private NSlider newVolumeSlider(){
  final NSlider s=this.volumeSlider=new NSlider(100f,0,100f){
    @Override public String getText(){
      if (value == null) {
        return "String_Node_Str";
      }
      float v=value();
      String s="String_Node_Str" + super.getText() + "String_Node_Str";
      if (v == 0) {
        s+="String_Node_Str";
      }
 else       if (v < 25) {
        s+="String_Node_Str";
      }
 else       if (v < 75) {
        s+="String_Node_Str";
      }
 else {
        s+="String_Node_Str";
      }
      s+="String_Node_Str";
      return s;
    }
    @Override public void setValue(    float v){
      super.setValue(Math.round(v));
      repaint();
    }
    @Override public void onChange(    float v){
      int level=(int)v;
      nar.param().noiseLevel.set(level);
    }
  }
;
  return s;
}
Program: 166768
Project: 166768
Buggy source:
public NSlider(AtomicReference<Double> value,float min,float max){
  super();
  nf.setMaximumFractionDigits(3);
  this.value=value;
  this.min=min;
  this.max=max;
  setBorder(BasicBorders.getButtonBorder());
  addMouseListener(this);
  addMouseMotionListener(this);
  setFont(NARSwing.monofont.deriveFont(12f));
}

Fixed version (ground truth):
public NSlider(AtomicReference<Float> value,float min,float max){
  super();
  nf.setMaximumFractionDigits(3);
  this.value=value;
  this.min=min;
  this.max=max;
  setBorder(BasicBorders.getButtonBorder());
  addMouseListener(this);
  addMouseMotionListener(this);
  setFont(NARSwing.monofont.deriveFont(12f));
}
Program: 166769
Project: 166769
Buggy source:
public void setValue(float v){
  if (v != value.get().floatValue()) {
    value.set((double)v);
    onChange(v);
  }
}

Fixed version (ground truth):
public void setValue(float v){
  if (v != value.get().floatValue()) {
    value.set(v);
    onChange(v);
  }
}
Program: 166770
Project: 166770
Buggy source:
public MultiModePanel(NAR nar,Object object){
  super(new BorderLayout());
  this.nar=nar;
  this.object=object;
  if (object instanceof Task) {
    label=((Task)object).sentence.toString();
  }
 else {
    label=object.toString();
  }
  setMode(new LogView());
}

Fixed version (ground truth):
public MultiModePanel(NAR nar,Object object){
  super(new BorderLayout());
  this.nar=nar;
  this.object=object;
  if (object instanceof Task) {
    label=((Task)object).sentence.toString();
  }
 else {
    label=object.toString();
  }
  setMode(new GraphView());
}
Program: 166771
Project: 166771
Buggy source:
/** 
 * returns the same instance 
 */
public LogicSense update(){
  long time=memory.getTime();
  if (time == lastUpdate) {
    return this;
  }
  lastUpdate=time;
  put("String_Node_Str",conceptNum);
  put("String_Node_Str",conceptPriorityMean);
  put("String_Node_Str",conceptBeliefsSum);
  put("String_Node_Str",conceptQuestionsSum);
  put("String_Node_Str",memory.novelTasks.size());
  put("String_Node_Str",memory.emotion.happy());
  put("String_Node_Str",memory.emotion.busy());
  double cycleTimeMS=CYCLE.getValue();
  double cycleTimeMeanMS=CYCLE.get().mean();
{
    put("String_Node_Str",(1000.0 / CYCLE_REAL.getValue()));
    put("String_Node_Str",(cycleTimeMeanMS == 0) ? 0 : (1000.0 / cycleTimeMeanMS));
  }
{
    put("String_Node_Str",IO_CYCLE.getValue() / MEMORY_CYCLE.getValue());
  }
{
    put("String_Node_Str",MEMORY_CYCLE_RAM_USED.getValue());
  }
{
    put("String_Node_Str",CYCLE_CPU_TIME.get().mean());
  }
{
    DataSet fire=TASKLINK_FIRE.get();
    put("String_Node_Str",fire.mean());
    put("String_Node_Str",(double)TASKLINK_FIRE.getDeltaHits());
    put("String_Node_Str",TASKTERMLINK_REASON.get().mean());
    put("String_Node_Str",(double)TASKTERMLINK_REASON.getHits());
  }
{
    put("String_Node_Str",OUTPUT_TASK.getHits());
    put("String_Node_Str",OUTPUT_TASK.get().mean());
  }
{
    put("String_Node_Str",CONCEPT_NEW.getHits());
    put("String_Node_Str",CONCEPT_NEW.get().mean());
  }
  if (time % allSensorResetPeriodCycles == 0)   updateSensors(true);
  return this;
}

Fixed version (ground truth):
/** 
 * returns the same instance 
 */
public LogicSense update(){
  long time=memory.getTime();
  if (time == lastUpdate) {
    return this;
  }
  lastUpdate=time;
  put("String_Node_Str",conceptNum);
  put("String_Node_Str",conceptPriorityMean);
  put("String_Node_Str",conceptBeliefsSum);
  put("String_Node_Str",conceptQuestionsSum);
  put("String_Node_Str",memory.novelTasks.size());
  put("String_Node_Str",memory.emotion.happy());
  put("String_Node_Str",memory.emotion.busy());
  double cycleTimeMS=CYCLE.getValue();
  double cycleTimeMeanMS=CYCLE.get().mean();
{
    put("String_Node_Str",(1000.0 / CYCLE_REAL.getValue()));
    put("String_Node_Str",(cycleTimeMeanMS == 0) ? 0 : (1000.0 / cycleTimeMeanMS));
  }
{
    put("String_Node_Str",IO_CYCLE.getValue() / MEMORY_CYCLE.getValue());
  }
{
    put("String_Node_Str",MEMORY_CYCLE_RAM_USED.getValue());
  }
{
    put("String_Node_Str",CYCLE_CPU_TIME.get().mean());
  }
{
    DataSet fire=TASKLINK_FIRE.get();
    put("String_Node_Str",fire.mean());
    put("String_Node_Str",TASKLINK_FIRE.getDeltaHits());
    put("String_Node_Str",TASKTERMLINK_REASON.get().mean());
    put("String_Node_Str",TASKTERMLINK_REASON.getHits());
  }
{
    put("String_Node_Str",OUTPUT_TASK.getHits());
    put("String_Node_Str",OUTPUT_TASK.get().mean());
  }
{
    put("String_Node_Str",CONCEPT_NEW.getHits());
    put("String_Node_Str",CONCEPT_NEW.get().mean());
  }
  if (time % allSensorResetPeriodCycles == 0)   updateSensors(true);
  return this;
}
Program: 166772
Project: 166772
Buggy source:
default public double mean(){
  return (sum() / hits());
}

Fixed version (ground truth):
default public double mean(){
  long h=hits();
  if (h == 0)   return 0;
  return (sum() / h);
}
Program: 166773
Project: 166773
Buggy source:
@Override protected ArrayList<Task> execute(Operation operation,Term[] args,Memory memory){
  js.put("String_Node_Str",memory);
  if (args.length != 2)   return null;
  if (!(args[1] instanceof Variable)) {
    return null;
  }
  Object result=null;
  String input=Texts.unescape(args[0].name()).toString();
  if (input.charAt(0) == '"')   input=input.substring(1,input.length() - 1);
  try {
    result=js.eval(input);
  }
 catch (  Throwable ex) {
    result=ex.toString();
  }
  memory.output(Javascript.class,input + "String_Node_Str" + result);
  Term r=new Term(Texts.escape('"' + result.toString() + '"').toString());
  Inheritance t=Inheritance.make(Product.make(new Term[]{operation,r},memory),new Term("String_Node_Str"),memory);
  memory.output(Task.class,t);
  ArrayList<Task> results=new ArrayList<>(1);
  results.add(memory.newTask(t,Symbols.JUDGMENT_MARK,1f,0.99f,Parameters.DEFAULT_JUDGMENT_PRIORITY,Parameters.DEFAULT_JUDGMENT_DURABILITY));
  return results;
}

Fixed version (ground truth):
@Override protected ArrayList<Task> execute(Operation operation,Term[] args,Memory memory){
  js.put("String_Node_Str",memory);
  if (args.length != 2)   return null;
  if (!(args[1] instanceof Variable)) {
    return null;
  }
  Object result=null;
  String input=Texts.unescape(args[0].name()).toString();
  if (input.charAt(0) == '"')   input=input.substring(1,input.length() - 1);
  try {
    result=js.eval(input);
  }
 catch (  Throwable ex) {
    result=ex.toString();
  }
  memory.output(Javascript.class,input + "String_Node_Str" + result);
  Term resultTerm=new Term(Texts.escape('"' + result.toString() + '"').toString());
  Inheritance operatorInheritance=Operation.make(Product.make(new Term[]{args[0],resultTerm},memory),this,memory);
  Inheritance resultInheritance=Inheritance.make(operatorInheritance,new Term("String_Node_Str"),memory);
  memory.output(Task.class,resultInheritance);
  ArrayList<Task> results=new ArrayList<>(1);
  results.add(memory.newTask(resultInheritance,Symbols.JUDGMENT_MARK,1f,0.99f,Parameters.DEFAULT_JUDGMENT_PRIORITY,Parameters.DEFAULT_JUDGMENT_DURABILITY));
  return results;
}
Program: 166774
Project: 166774
Buggy source:
/** 
 * To accept a new goal, and check for revisions and realization, then decide whether to actively pursue it
 * @param judg The judgment to be accepted
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
private void processGoal(final Task task){
  final Sentence goal=task.sentence;
  final Sentence oldGoal=selectCandidate(goal,desires);
  boolean noRevision=true;
  if (oldGoal != null) {
    final Stamp newStamp=goal.stamp;
    final Stamp oldStamp=oldGoal.stamp;
    if (newStamp.equals(oldStamp)) {
      return;
    }
    if (revisible(goal,oldGoal)) {
      memory.setTheNewStamp(make(newStamp,oldStamp,memory.getTime()));
      if (memory.getTheNewStamp() != null) {
        revision(goal,oldGoal,false,memory);
        noRevision=false;
      }
    }
  }
  if (task.aboveThreshold()) {
    final Sentence belief=selectCandidate(goal,beliefs);
    if (belief != null)     trySolution(belief,task,memory);
    if (task.aboveThreshold()) {
      addToTable(goal,desires,Parameters.MAXIMUM_BELIEF_LENGTH);
      if (noRevision) {
        decisionMaking(task,this);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * To accept a new goal, and check for revisions and realization, then decide whether to actively pursue it
 * @param judg The judgment to be accepted
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
private void processGoal(final Task task){
  final Sentence goal=task.sentence;
  final Sentence oldGoal=selectCandidate(goal,desires);
  boolean noRevision=true;
  if (oldGoal != null) {
    final Stamp newStamp=goal.stamp;
    final Stamp oldStamp=oldGoal.stamp;
    if (newStamp.equals(oldStamp)) {
      return;
    }
    if (revisible(goal,oldGoal)) {
      memory.setTheNewStamp(make(newStamp,oldStamp,memory.getTime()));
      if (memory.getTheNewStamp() != null) {
        revision(goal,oldGoal,false,memory);
        noRevision=false;
      }
    }
  }
  if (task.aboveThreshold()) {
    final Sentence belief=selectCandidate(goal,beliefs);
    if (belief != null)     trySolution(belief,task,memory);
    if (task.aboveThreshold()) {
      addToTable(goal,desires,Parameters.MAXIMUM_BELIEF_LENGTH);
      if (noRevision || (task.sentence.content instanceof Operation)) {
        decisionMaking(task,this);
      }
    }
  }
}