nus-yam/ex-repair huggingface dataset:
Program: 166661
Project: 166661
Buggy source:
/** 
 * {<M --> S>, <M <-> P>} |- <M --> (S|P)>
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue union(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=or(f1,f2);
  final float c=and(c1,c2);
  return new TruthValue(f,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {&lt;M --&gt; S&gt;, &lt;M &gt; P&gt;} |- &lt;M --&gt; (S|P)&gt;
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue union(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=or(f1,f2);
  final float c=and(c1,c2);
  return new TruthValue(f,c,narParameters);
}
Program: 166662
Project: 166662
Buggy source:
/** 
 * {<S ==> M>, <M <=> P>} |- <S ==> P>
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue analogy(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=and(f1,f2);
  final float c=and(c1,c2,f2);
  return new TruthValue(f,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {&lt;S ==&gt; M&gt;, &lt;M &lt;=&gt; P&gt;} |- &lt;S ==&gt; P&gt;
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue analogy(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=and(f1,f2);
  final float c=and(c1,c2,f2);
  return new TruthValue(f,c,narParameters);
}
Program: 166663
Project: 166663
Buggy source:
/** 
 * {M, <M ==> P>} |- P
 * @param v1 Truth value of the first premise
 * @param reliance Confidence of the second (analytical) premise
 * @return Truth value of the conclusion
 */
public static final TruthValue deduction(final TruthValue v1,final float reliance,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float c=and(f1,c1,reliance);
  return new TruthValue(f1,c,true,narParameters);
}

Fixed version (ground truth):
/** 
 * {M, &lt;M ==&gt; P&gt;} |- P
 * @param v1 Truth value of the first premise
 * @param reliance Confidence of the second (analytical) premise
 * @return Truth value of the conclusion
 */
public static final TruthValue deduction(final TruthValue v1,final float reliance,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float c=and(f1,c1,reliance);
  return new TruthValue(f1,c,true,narParameters);
}
Program: 166664
Project: 166664
Buggy source:
/** 
 * {<A ==> B>} |- <(--, B) ==> (--, A)>
 * @param v1 Truth value of the premise
 * @return Truth value of the conclusion
 */
public static final TruthValue contraposition(final TruthValue v1,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(1 - f1,c1);
  final float c=w2c(w,narParameters);
  return new TruthValue(0,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {&lt;A ==&gt; B&gt;} |- &lt;(--, B) ==&gt; (--, A)&gt;
 * @param v1 Truth value of the premise
 * @return Truth value of the conclusion
 */
public static final TruthValue contraposition(final TruthValue v1,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(1 - f1,c1);
  final float c=w2c(w,narParameters);
  return new TruthValue(0,c,narParameters);
}
Program: 166665
Project: 166665
Buggy source:
/** 
 * {<M ==> S>, <P ==> M>} |- <S ==> P>
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue exemplification(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  if (v1.getAnalytic() || v2.getAnalytic()) {
    return new TruthValue(0.5f,0f,narParameters);
  }
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float w=and(f1,f2,c1,c2);
  final float c=w2c(w,narParameters);
  return new TruthValue(1,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {&lt;M ==&gt; S&gt;, &lt;P ==&gt; M&gt;} |- &lt;S ==&gt; P&gt;
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue exemplification(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  if (v1.getAnalytic() || v2.getAnalytic()) {
    return new TruthValue(0.5f,0f,narParameters);
  }
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float w=and(f1,f2,c1,c2);
  final float c=w2c(w,narParameters);
  return new TruthValue(1,c,narParameters);
}
Program: 166666
Project: 166666
Buggy source:
/** 
 * {<A ==> B>} |- <B ==> A>
 * @param v1 Truth value of the premise
 * @return Truth value of the conclusion
 */
static final TruthValue conversion(final TruthValue v1,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(f1,c1);
  final float c=w2c(w,narParameters);
  return new TruthValue(1,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {<A ==> B>} |- <B ==> A>
 * @param v1 Truth value of the premise
 * @return Truth value of the conclusion
 */
public static final TruthValue conversion(final TruthValue v1,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(f1,c1);
  final float c=w2c(w,narParameters);
  return new TruthValue(1,c,narParameters);
}
Program: 166667
Project: 166667
Buggy source:
/** 
 * {M, <P ==> M>} |- P
 * @param v1 Truth value of the first premise
 * @param reliance Confidence of the second (analytical) premise
 * @return Truth value of the conclusion
 */
static final TruthValue abduction(final TruthValue v1,final float reliance,Parameters narParameters){
  if (v1.getAnalytic()) {
    return new TruthValue(0.5f,0f,narParameters);
  }
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(c1,reliance);
  final float c=w2c(w,narParameters);
  return new TruthValue(f1,c,true,narParameters);
}

Fixed version (ground truth):
/** 
 * {M, <P ==> M>} |- P
 * @param v1 Truth value of the first premise
 * @param reliance Confidence of the second (analytical) premise
 * @return Truth value of the conclusion
 */
public static final TruthValue abduction(final TruthValue v1,final float reliance,Parameters narParameters){
  if (v1.getAnalytic()) {
    return new TruthValue(0.5f,0f,narParameters);
  }
  final float f1=v1.getFrequency();
  final float c1=v1.getConfidence();
  final float w=and(c1,reliance);
  final float c=w2c(w,narParameters);
  return new TruthValue(f1,c,true,narParameters);
}
Program: 166668
Project: 166668
Buggy source:
/** 
 * {<S <=> M>, <M <=> P>} |- <S <=> P>
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
static final TruthValue resemblance(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=and(f1,f2);
  final float c=and(c1,c2,or(f1,f2));
  return new TruthValue(f,c,narParameters);
}

Fixed version (ground truth):
/** 
 * {<S <=> M>, <M <=> P>} |- <S <=> P>
 * @param v1 Truth value of the first premise
 * @param v2 Truth value of the second premise
 * @return Truth value of the conclusion
 */
public static final TruthValue resemblance(final TruthValue v1,final TruthValue v2,Parameters narParameters){
  final float f1=v1.getFrequency();
  final float f2=v2.getFrequency();
  final float c1=v1.getConfidence();
  final float c2=v2.getConfidence();
  final float f=and(f1,f2);
  final float c=and(c1,c2,or(f1,f2));
  return new TruthValue(f,c,narParameters);
}
Program: 166669
Project: 166669
Buggy source:
public static Nar LoadFromFile(final String name) throws IOException, ClassNotFoundException, IllegalAccessException, ParseException, ParserConfigurationException, SAXException, NoSuchMethodException, InstantiationException, InvocationTargetException {
  final FileInputStream inStream=new FileInputStream(name);
  final ObjectInputStream stream=new ObjectInputStream(inStream);
  final Nar ret=(Nar)stream.readObject();
  ret.memory.event=new EventEmitter();
  ret.plugins=new ArrayList<>();
  List<Plugin> pluginsToAdd=ConfigReader.loadParamsFromFileAndReturnPlugins(ret.usedConfigFilePath,ret,ret.narParameters);
  for (  Plugin p : pluginsToAdd) {
    ret.addPlugin(p);
  }
  return ret;
}

Fixed version (ground truth):
public static Nar LoadFromFile(final String name) throws IOException, ClassNotFoundException, IllegalAccessException, ParseException, ParserConfigurationException, SAXException, NoSuchMethodException, InstantiationException, InvocationTargetException {
  final FileInputStream inStream=new FileInputStream(name);
  final ObjectInputStream stream=new ObjectInputStream(inStream);
  final Nar ret=(Nar)stream.readObject();
  ret.memory.event=new EventEmitter();
  ret.plugins=new ArrayList<>();
  ret.sensoryChannels=new HashMap<>();
  List<Plugin> pluginsToAdd=ConfigReader.loadParamsFromFileAndReturnPlugins(ret.usedConfigFilePath,ret,ret.narParameters);
  for (  Plugin p : pluginsToAdd) {
    ret.addPlugin(p);
  }
  return ret;
}
Program: 166670
Project: 166670
Buggy source:
@Override protected List<Task> execute(Operation operation,final Term[] args,final Memory m){
  final int numArgs=args.length - 1;
  if (numArgs < 1) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (numArgs < 2) {
    throw new IllegalStateException("String_Node_Str");
  }
  final Term lastTerm=args[numArgs];
  final boolean variable=lastTerm instanceof Variable;
  if (!variable) {
    throw new IllegalStateException("String_Node_Str");
  }
  final int numParam=numArgs - 1;
  final Term[] x=new Term[numParam];
  System.arraycopy(args,1,x,0,numParam);
  final Term y;
  y=function(m,x);
  if (y == null) {
    return null;
  }
  final Variable var=new Variable("String_Node_Str");
  operation=(Operation)operation.setComponent(0,((CompoundTerm)operation.getSubject()).setComponent(numArgs,y,m),m);
  final float confidence=m.narParameters.DEFAULT_JUDGMENT_CONFIDENCE;
  if (variable) {
    final Sentence s=new Sentence(operation,Symbols.JUDGMENT_MARK,new TruthValue(1.0f,m.narParameters.DEFAULT_JUDGMENT_CONFIDENCE,m.narParameters),new Stamp(m));
    final BudgetValue budgetForNewTask=new BudgetValue(m.narParameters.DEFAULT_JUDGMENT_PRIORITY,m.narParameters.DEFAULT_FEEDBACK_DURABILITY,truthToQuality(s.getTruth()),m.narParameters);
    final Task newTask=new Task(s,budgetForNewTask,Task.EnumType.INPUT);
    return Lists.newArrayList(newTask);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override protected List<Task> execute(Operation operation,final Term[] args,final Memory m){
  final int numArgs=args.length - 1;
  if (numArgs < 1) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (numArgs < 2) {
    throw new IllegalStateException("String_Node_Str");
  }
  final Term lastTerm=args[numArgs];
  final boolean variable=lastTerm instanceof Variable;
  if (!variable) {
    throw new IllegalStateException("String_Node_Str");
  }
  final int numParam=numArgs - 1;
  final Term[] x=new Term[numParam];
  System.arraycopy(args,1,x,0,numParam);
  final Term y;
  y=function(m,x);
  if (y == null) {
    return null;
  }
  final Variable var=new Variable("String_Node_Str");
  operation=(Operation)operation.setComponent(0,((CompoundTerm)operation.getSubject()).setComponent(numArgs,y,m),m);
  final float confidence=m.narParameters.DEFAULT_JUDGMENT_CONFIDENCE;
  if (variable) {
    final Sentence s=new Sentence(operation,Symbols.JUDGMENT_MARK,new TruthValue(1.0f,confidence,m.narParameters),new Stamp(m));
    final BudgetValue budgetForNewTask=new BudgetValue(m.narParameters.DEFAULT_JUDGMENT_PRIORITY,m.narParameters.DEFAULT_FEEDBACK_DURABILITY,truthToQuality(s.getTruth()),m.narParameters);
    final Task newTask=new Task(s,budgetForNewTask,Task.EnumType.INPUT);
    return Lists.newArrayList(newTask);
  }
 else {
    return null;
  }
}
Program: 166671
Project: 166671
Buggy source:
@Override public boolean setEnabled(final Nar n,final boolean enabled){
  n.memory.event.set(this,enabled,Events.InduceSucceedingEvent.class,Events.CycleEnd.class);
  TruthValue expiredTruth=new TruthValue(0.0f,n.narParameters.ANTICIPATION_CONFIDENCE,n.narParameters);
  BudgetValue expiredBudget=new BudgetValue(n.narParameters.DEFAULT_JUDGMENT_PRIORITY,n.narParameters.DEFAULT_JUDGMENT_DURABILITY,BudgetFunctions.truthToQuality(expiredTruth),n.narParameters);
  return true;
}

Fixed version (ground truth):
@Override public boolean setEnabled(final Nar n,final boolean enabled){
  n.memory.event.set(this,enabled,Events.InduceSucceedingEvent.class,Events.CycleEnd.class);
  expiredTruth=new TruthValue(0.0f,n.narParameters.ANTICIPATION_CONFIDENCE,n.narParameters);
  expiredBudget=new BudgetValue(n.narParameters.DEFAULT_JUDGMENT_PRIORITY,n.narParameters.DEFAULT_JUDGMENT_DURABILITY,BudgetFunctions.truthToQuality(expiredTruth),n.narParameters);
  return true;
}
Program: 166672
Project: 166672
Buggy source:
/** 
 * A frame, consisting of one or more Nar memory cycles
 */
public void cycle(){
synchronized (cycle) {
    cycle++;
  }
  try {
    memory.cycle(this);
  }
 catch (  final Exception e) {
    if (MiscFlags.SHOW_REASONING_ERRORS) {
      emit(ERR.class,e);
    }
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * A frame, consisting of one or more Nar memory cycles
 */
public void cycle(){
  try {
    memory.cycle(this);
synchronized (cycle) {
      cycle++;
    }
  }
 catch (  final Exception e) {
    if (MiscFlags.SHOW_REASONING_ERRORS) {
      emit(ERR.class,e);
    }
    throw e;
  }
}
Program: 166680
Project: 166680
Buggy source:
/** 
 * Try to replace a component in a compound at a given index by another one
 * @param compound The compound
 * @param index The location of replacement
 * @param t The new component
 * @param memory Reference to the memory
 * @return The new compound
 */
public Term setComponent(final int index,final Term t,final Memory memory){
  final List<Term> list=asTermList();
  list.remove(index);
  if (t != null) {
    if (getClass() != t.getClass()) {
      list.add(index,t);
    }
 else {
      final Term[] tt=((CompoundTerm)t).term;
      for (int i=0; i < tt.length; i++) {
        list.add(index + i,tt[i]);
      }
    }
  }
  return Terms.term(this,list);
}

Fixed version (ground truth):
/** 
 * Try to replace a component in a compound at a given index by another one
 * @param compound The compound
 * @param index The location of replacement
 * @param t The new component
 * @param memory Reference to the memory
 * @return The new compound
 */
public Term setComponent(final int index,final Term t,final Memory memory){
  final List<Term> list=asTermList();
  list.remove(index);
  if (t != null) {
    if (getClass() != t.getClass()) {
      list.add(index,t);
    }
 else {
      final Term[] tt=((CompoundTerm)t).term;
      for (int i=0; i < tt.length; i++) {
        list.add(index + i,tt[i]);
      }
    }
  }
  if (this.isCommutative()) {
    Term[] ret=list.toArray(new Term[0]);
    return Terms.term(this,ret);
  }
  return Terms.term(this,list);
}
Program: 166682
Project: 166682
Buggy source:
/** 
 * Parse a String to create a CompoundTerm.
 * @return the Term generated from the String
 * @param s0 The String to be parsed
 * @throws org.opennars.io.StringParser.InvalidInputException the String cannot beparsed into a Term
 */
private Term parseCompoundTerm(final String s0) throws InvalidInputException {
  final String s=s0.trim();
  if (s.isEmpty()) {
    throw new InvalidInputException("String_Node_Str" + s);
  }
  final int firstSeparator=s.indexOf(ARGUMENT_SEPARATOR);
  if (firstSeparator == -1) {
    throw new InvalidInputException("String_Node_Str" + s);
  }
  final String op=(firstSeparator < 0) ? s : s.substring(0,firstSeparator).trim();
  final NativeOperator oNative=getOperator(op);
  final Operator oRegistered=memory.getOperator(op);
  if ((oRegistered == null) && (oNative == null)) {
    throw new InvalidInputException("String_Node_Str" + op);
  }
  final List<Term> arg=(firstSeparator < 0) ? new ArrayList<>(0) : parseArguments(s.substring(firstSeparator + 1) + ARGUMENT_SEPARATOR);
  final Term[] argA=arg.toArray(new Term[arg.size()]);
  final Term t;
  if (oNative != null) {
    t=Terms.term(oNative,argA);
  }
 else   if (oRegistered != null) {
    t=make(oRegistered,argA,true);
  }
 else {
    throw new InvalidInputException("String_Node_Str");
  }
  return t;
}

Fixed version (ground truth):
/** 
 * Parse a String to create a CompoundTerm.
 * @return the Term generated from the String
 * @param s0 The String to be parsed
 * @throws org.opennars.io.StringParser.InvalidInputException the String cannot beparsed into a Term
 */
private Term parseCompoundTerm(final String s0) throws InvalidInputException {
  final String s=s0.trim();
  if (s.isEmpty()) {
    throw new InvalidInputException("String_Node_Str" + s);
  }
  final int firstSeparator=s.indexOf(ARGUMENT_SEPARATOR);
  if (firstSeparator == -1) {
    throw new InvalidInputException("String_Node_Str" + s);
  }
  final String op=(firstSeparator < 0) ? s : s.substring(0,firstSeparator).trim();
  final NativeOperator oNative=getOperator(op);
  final Operator oRegistered=memory.getOperator(op);
  if ((oRegistered == null) && (oNative == null)) {
    throw new InvalidInputException("String_Node_Str" + op);
  }
  final List<Term> arg=(firstSeparator < 0) ? new ArrayList<>(0) : parseArguments(s.substring(firstSeparator + 1) + ARGUMENT_SEPARATOR);
  final Term[] argA=arg.toArray(new Term[0]);
  final Term t;
  if (oNative != null) {
    t=Terms.term(oNative,argA);
  }
 else   if (oRegistered != null) {
    t=make(oRegistered,argA,true);
  }
 else {
    throw new InvalidInputException("String_Node_Str");
  }
  return t;
}
Program: 166683
Project: 166683
Buggy source:
/** 
 * Cloned array of Terms, except for one or more Terms.
 * @param toRemove
 * @return the cloned array with the missing terms removed, OR null if no terms were actually removed when requireModification=true
 */
public Term[] cloneTermsExcept(final boolean requireModification,final Term[] toRemove){
  final List<Term> l=asTermList();
  boolean removed=false;
  for (  final Term t : toRemove) {
    if (l.remove(t))     removed=true;
  }
  if ((!removed) && (requireModification))   return null;
  return l.toArray(new Term[l.size()]);
}

Fixed version (ground truth):
/** 
 * Cloned array of Terms, except for one or more Terms.
 * @param toRemove
 * @return the cloned array with the missing terms removed, OR null if no terms were actually removed when requireModification=true
 */
public Term[] cloneTermsExcept(final boolean requireModification,final Term[] toRemove){
  final List<Term> l=asTermList();
  boolean removed=false;
  for (  final Term t : toRemove) {
    if (l.remove(t))     removed=true;
  }
  if ((!removed) && (requireModification))   return null;
  return l.toArray(new Term[0]);
}
Program: 166685
Project: 166685
Buggy source:
public Product(final List<Term> x){
  this(x.toArray(new Term[x.size()]));
}

Fixed version (ground truth):
public Product(final List<Term> x){
  this(x.toArray(new Term[0]));
}
Program: 166686
Project: 166686
Buggy source:
public static SetExt make(final Collection<Term> l){
  return make(l.toArray(new Term[l.size()]));
}

Fixed version (ground truth):
public static SetExt make(final Collection<Term> l){
  return make(l.toArray(new Term[0]));
}
Program: 166687
Project: 166687
Buggy source:
public static Term[] toSortedSetArray(final Term... arg){
switch (arg.length) {
case 0:
    return EmptyTermArray;
case 1:
  return new Term[]{arg[0]};
case 2:
final Term a=arg[0];
final Term b=arg[1];
final int c=a.compareTo(b);
if (Parameters.DEBUG) {
final boolean equal=a.equals(b);
if ((equal && (c != 0)) || (!equal && (c == 0))) {
throw new IllegalStateException("String_Node_Str" + a + "String_Node_Str"+ b);
}
}
if (c < 0) return new Term[]{a,b};
 else if (c > 0) return new Term[]{b,a};
 else if (c == 0) return new Term[]{a};
}
final NavigableSet<Term> s=new TreeSet();
Collections.addAll(s,arg);
return s.toArray(new Term[s.size()]);
}

Fixed version (ground truth):
public static Term[] toSortedSetArray(final Term... arg){
switch (arg.length) {
case 0:
    return EmptyTermArray;
case 1:
  return new Term[]{arg[0]};
case 2:
final Term a=arg[0];
final Term b=arg[1];
final int c=a.compareTo(b);
if (Parameters.DEBUG) {
final boolean equal=a.equals(b);
if ((equal && (c != 0)) || (!equal && (c == 0))) {
throw new IllegalStateException("String_Node_Str" + a + "String_Node_Str"+ b);
}
}
if (c < 0) return new Term[]{a,b};
 else if (c > 0) return new Term[]{b,a};
 else if (c == 0) return new Term[]{a};
}
final NavigableSet<Term> s=new TreeSet();
Collections.addAll(s,arg);
return s.toArray(new Term[0]);
}
Program: 166688
Project: 166688
Buggy source:
public SensoryChannel(final NAR nar,final SensoryChannel reportResultsTo,final int width,final int height,final int duration){
  this(nar,Arrays.asList(reportResultsTo),width,height,duration);
}

Fixed version (ground truth):
public SensoryChannel(final NAR nar,final SensoryChannel reportResultsTo,final int width,final int height,final int duration){
  this(nar,Collections.singletonList(reportResultsTo),width,height,duration);
}
Program: 166689
Project: 166689
Buggy source:
public VisualSpace(final NAR nar,final float[][] source,final int py,final int px,final int height,final int width){
  this.nar=nar;
  this.height=height;
  this.width=width;
  this.cropped=new float[height][width];
  this.source=new float[source.length][source[0].length];
  for (int i=0; i < source.length; i++) {
    for (int j=0; j < source[0].length; j++) {
      this.source[i][j]=source[i][j];
    }
  }
  for (int i=0; i < height; i++) {
    for (int j=0; j < width; j++) {
      cropped[i][j]=source[py + i][px + j];
    }
  }
  nar.addPlugin(right);
  nar.addPlugin(left);
  nar.addPlugin(up);
  nar.addPlugin(down);
  ops.add(right);
  ops.add(left);
  ops.add(up);
  ops.add(down);
}

Fixed version (ground truth):
public VisualSpace(final NAR nar,final float[][] source,final int py,final int px,final int height,final int width){
  this.nar=nar;
  this.height=height;
  this.width=width;
  this.cropped=new float[height][width];
  this.source=new float[source.length][source[0].length];
  for (int i=0; i < source.length; i++) {
    System.arraycopy(source[i],0,this.source[i],0,source[0].length);
  }
  for (int i=0; i < height; i++) {
    System.arraycopy(source[py + i],px + 0,cropped[i],0,width);
  }
  nar.addPlugin(right);
  nar.addPlugin(left);
  nar.addPlugin(up);
  nar.addPlugin(down);
  ops.add(right);
  ops.add(left);
  ops.add(up);
  ops.add(down);
}
Program: 166690
Project: 166690
Buggy source:
protected double testNAL(final String path){
  Memory.resetStatic();
  final List<OutputCondition> expects=new ArrayList();
  NAR n=null;
  final boolean error=false;
  n=newNAR();
  final String example=getExample(path);
  if (showOutput) {
    System.out.println(example);
    System.out.println();
  }
  final List<OutputCondition> extractedExpects=OutputCondition.getConditions(n,example,similarsToSave);
  for (  final OutputCondition e1 : extractedExpects)   expects.add(e1);
  if (showOutput)   new TextOutputHandler(n,System.out);
  n.addInputFile(path);
  n.cycles(minCycles);
  System.err.flush();
  System.out.flush();
  boolean success=expects.size() > 0 && (!error);
  for (  final OutputCondition e : expects) {
    if (!e.succeeded)     success=false;
  }
  double score=Double.POSITIVE_INFINITY;
  if (success) {
    long lastSuccess=-1;
    for (    final OutputCondition e : expects) {
      if (e.getTrueTime() != -1) {
        if (lastSuccess < e.getTrueTime())         lastSuccess=e.getTrueTime();
      }
    }
    if (lastSuccess != -1) {
      score=lastSuccess;
      scores.put(path,score);
    }
  }
 else {
    scores.put(path,Double.POSITIVE_INFINITY);
  }
  if ((!success & showFail) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.memory.time());
    for (    final OutputCondition e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  if (requireSuccess)   assertTrue(path,success);
  return score;
}

Fixed version (ground truth):
protected double testNAL(final String path){
  Memory.resetStatic();
  final List<OutputCondition> expects=new ArrayList();
  NAR n=null;
  final boolean error=false;
  n=newNAR();
  final String example=getExample(path);
  if (showOutput) {
    System.out.println(example);
    System.out.println();
  }
  final List<OutputCondition> extractedExpects=OutputCondition.getConditions(n,example,similarsToSave);
  expects.addAll(extractedExpects);
  if (showOutput)   new TextOutputHandler(n,System.out);
  n.addInputFile(path);
  n.cycles(minCycles);
  System.err.flush();
  System.out.flush();
  boolean success=expects.size() > 0 && (!error);
  for (  final OutputCondition e : expects) {
    if (!e.succeeded)     success=false;
  }
  double score=Double.POSITIVE_INFINITY;
  if (success) {
    long lastSuccess=-1;
    for (    final OutputCondition e : expects) {
      if (e.getTrueTime() != -1) {
        if (lastSuccess < e.getTrueTime())         lastSuccess=e.getTrueTime();
      }
    }
    if (lastSuccess != -1) {
      score=lastSuccess;
      scores.put(path,score);
    }
  }
 else {
    scores.put(path,Double.POSITIVE_INFINITY);
  }
  if ((!success & showFail) || (success && showSuccess)) {
    System.err.println('\n' + path + "String_Node_Str"+ n.memory.time());
    for (    final OutputCondition e : expects) {
      System.err.println("String_Node_Str" + e);
    }
  }
  if (requireSuccess)   assertTrue(path,success);
  return score;
}
Program: 166691
Project: 166691
Buggy source:
public static void fireConcept(DerivationContext nal,int numTaskLinks){
  for (int i=0; i < numTaskLinks; i++) {
    if (nal.currentConcept.taskLinks.size() == 0) {
      return;
    }
    nal.currentTaskLink=nal.currentConcept.taskLinks.takeNext();
    if (nal.currentTaskLink == null) {
      return;
    }
    if (nal.currentTaskLink.budget.aboveThreshold()) {
      fireTaskLink(nal,Parameters.TERMLINK_MAX_REASONED);
    }
    nal.currentConcept.taskLinks.putBack(nal.currentTaskLink,nal.memory.cycles(nal.memory.param.taskLinkForgetDurations),nal.memory);
  }
}

Fixed version (ground truth):
public static boolean fireConcept(DerivationContext nal,int numTaskLinks){
  for (int i=0; i < numTaskLinks; i++) {
    if (nal.currentConcept.taskLinks.size() == 0) {
      return false;
    }
    nal.currentTaskLink=nal.currentConcept.taskLinks.takeNext();
    if (nal.currentTaskLink == null) {
      return false;
    }
    if (nal.currentTaskLink.budget.aboveThreshold()) {
      fireTaskLink(nal,Parameters.TERMLINK_MAX_REASONED);
    }
    nal.currentConcept.taskLinks.putBack(nal.currentTaskLink,nal.memory.cycles(nal.memory.param.taskLinkForgetDurations),nal.memory);
  }
  return true;
}
Program: 166692
Project: 166692
Buggy source:
public static void selectConceptForInference(Memory mem){
  Concept currentConcept=mem.concepts.takeNext();
  if (currentConcept == null) {
    return;
  }
  if (currentConcept.taskLinks.size() == 0) {
    mem.concepts.take(currentConcept.getTerm());
    mem.conceptRemoved(currentConcept);
    return;
  }
  if (currentConcept.termLinks.size() == 0) {
    mem.concepts.take(currentConcept.getTerm());
    mem.conceptRemoved(currentConcept);
    return;
  }
  DerivationContext nal=new DerivationContext(mem);
  nal.setCurrentConcept(currentConcept);
  fireConcept(nal,1);
{
    float forgetCycles=nal.memory.cycles(nal.memory.param.conceptForgetDurations);
    nal.currentConcept.setQuality(BudgetFunctions.or(nal.currentConcept.getQuality(),nal.memory.emotion.happy()));
    nal.memory.concepts.putBack(nal.currentConcept,forgetCycles,nal.memory);
  }
}

Fixed version (ground truth):
public static void selectConceptForInference(Memory mem){
  Concept currentConcept=mem.concepts.takeNext();
  if (currentConcept == null) {
    return;
  }
  if (currentConcept.taskLinks.size() == 0) {
    mem.concepts.take(currentConcept.getTerm());
    mem.conceptRemoved(currentConcept);
    return;
  }
  if (currentConcept.termLinks.size() == 0) {
    mem.concepts.take(currentConcept.getTerm());
    mem.conceptRemoved(currentConcept);
    return;
  }
  DerivationContext nal=new DerivationContext(mem);
  nal.setCurrentConcept(currentConcept);
  boolean putBackConcept=fireConcept(nal,1);
  if (putBackConcept) {
    float forgetCycles=nal.memory.cycles(nal.memory.param.conceptForgetDurations);
    nal.currentConcept.setQuality(BudgetFunctions.or(nal.currentConcept.getQuality(),nal.memory.emotion.happy()));
    nal.memory.concepts.putBack(nal.currentConcept,forgetCycles,nal.memory);
  }
}
Program: 166697
Project: 166697
Buggy source:
/** 
 * Constructor, called in Memory.getConcept only
 * @param tm A term corresponding to the concept
 * @param memory A reference to the memory
 */
public Concept(final BudgetValue b,final Term tm,final Memory memory){
  super(b);
  this.term=tm;
  this.memory=memory;
  this.questions=new ArrayList<>();
  this.beliefs=new ArrayList<>();
  this.enactable_explainations=new ArrayList<>();
  this.quests=new ArrayList<>();
  this.desires=new ArrayList<>();
  this.taskLinks=new LevelBag<>(Parameters.TASK_LINK_BAG_LEVELS,Parameters.TASK_LINK_BAG_SIZE);
  this.termLinks=new LevelBag<>(Parameters.TERM_LINK_BAG_LEVELS,Parameters.TERM_LINK_BAG_SIZE);
  if (tm instanceof CompoundTerm) {
    this.termLinkTemplates=((CompoundTerm)tm).prepareComponentLinks();
  }
 else {
    this.termLinkTemplates=null;
  }
}

Fixed version (ground truth):
/** 
 * Constructor, called in Memory.getConcept only
 * @param tm A term corresponding to the concept
 * @param memory A reference to the memory
 */
public Concept(final BudgetValue b,final Term tm,final Memory memory){
  super(b);
  this.term=tm;
  this.memory=memory;
  this.questions=new ArrayList<>();
  this.beliefs=new ArrayList<>();
  this.executable_preconditions=new ArrayList<>();
  this.quests=new ArrayList<>();
  this.desires=new ArrayList<>();
  this.taskLinks=new LevelBag<>(Parameters.TASK_LINK_BAG_LEVELS,Parameters.TASK_LINK_BAG_SIZE);
  this.termLinks=new LevelBag<>(Parameters.TERM_LINK_BAG_LEVELS,Parameters.TERM_LINK_BAG_SIZE);
  if (tm instanceof CompoundTerm) {
    this.termLinkTemplates=((CompoundTerm)tm).prepareComponentLinks();
  }
 else {
    this.termLinkTemplates=null;
  }
}
Program: 166699
Project: 166699
Buggy source:
/** 
 * To answer a question by existing beliefs
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
protected void processQuestion(final DerivationContext nal,final Task task){
  Sentence ques=task.sentence;
  boolean newQuestion=true;
  for (  final Task t : questions) {
    final Sentence q=t.sentence;
    if (q.equalsContent(ques)) {
      ques=q;
      newQuestion=false;
      break;
    }
  }
  if (newQuestion) {
    if (questions.size() + 1 > Parameters.CONCEPT_QUESTIONS_MAX) {
      Task removed=questions.remove(0);
      memory.event.emit(ConceptQuestionRemove.class,this,removed);
    }
    questions.add(task);
    memory.event.emit(ConceptQuestionAdd.class,this,task);
  }
  final Task newAnswerT=(ques.isQuestion()) ? selectCandidate(ques,beliefs,false) : selectCandidate(ques,desires,false);
  if (newAnswerT != null) {
    trySolution(newAnswerT.sentence,task,nal);
  }
}

Fixed version (ground truth):
/** 
 * To answer a question by existing beliefs
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
protected void processQuestion(final DerivationContext nal,final Task task){
  Task quesTask=task;
  boolean newQuestion=true;
  for (  final Task t : questions) {
    if (t.sentence.equalsContent(quesTask.sentence)) {
      quesTask=t;
      newQuestion=false;
      break;
    }
  }
  if (newQuestion) {
    if (questions.size() + 1 > Parameters.CONCEPT_QUESTIONS_MAX) {
      Task removed=questions.remove(0);
      memory.event.emit(ConceptQuestionRemove.class,this,removed);
    }
    questions.add(task);
    memory.event.emit(ConceptQuestionAdd.class,this,task);
  }
  Sentence ques=task.sentence;
  final Task newAnswerT=(ques.isQuestion()) ? selectCandidate(ques,beliefs,false) : selectCandidate(ques,desires,false);
  if (newAnswerT != null) {
    trySolution(newAnswerT.sentence,task,nal);
  }
 else   if (task.isInput() && quesTask.getBestSolution() != null) {
    memory.emit(Events.Answer.class,quesTask,quesTask.getBestSolution());
  }
}
Program: 166702
Project: 166702
Buggy source:
/** 
 * Constructor with partial values, called by make
 * @param arg The component list of the term
 * @param order
 * @param normalized
 */
protected Conjunction(Term[] arg,final int order,boolean normalized){
  super(removeFirstInterval(flatten(arg,order)));
  temporalOrder=order;
  init(this.term);
}

Fixed version (ground truth):
/** 
 * Constructor with partial values, called by make
 * @param arg The component list of the term
 * @param order
 * @param normalized
 */
protected Conjunction(Term[] arg,final int order,boolean normalized){
  super(arg);
  temporalOrder=order;
  init(this.term);
}
Program: 166703
Project: 166703
Buggy source:
public static Equivalence make(Term subject,Term predicate,int temporalOrder){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Implication)|| (predicate instanceof Equivalence)|| (subject instanceof Interval)|| (predicate instanceof Interval)) {
    return null;
  }
  if ((temporalOrder == TemporalRules.ORDER_BACKWARD) || ((subject.compareTo(predicate) > 0) && (temporalOrder != TemporalRules.ORDER_FORWARD))) {
    Term interm=subject;
    subject=predicate;
    predicate=interm;
  }
  NativeOperator copula;
switch (temporalOrder) {
case TemporalRules.ORDER_BACKWARD:
    temporalOrder=TemporalRules.ORDER_FORWARD;
case TemporalRules.ORDER_FORWARD:
  copula=NativeOperator.EQUIVALENCE_AFTER;
break;
case TemporalRules.ORDER_CONCURRENT:
copula=NativeOperator.EQUIVALENCE_WHEN;
break;
default :
copula=NativeOperator.EQUIVALENCE;
}
Term[] t=Term.toSortedSetArray(subject,predicate);
if (t.length != 2) return null;
return new Equivalence(t,temporalOrder);
}

Fixed version (ground truth):
public static Equivalence make(Term subject,Term predicate,int temporalOrder){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Implication)|| (predicate instanceof Equivalence)|| (subject instanceof Interval)|| (predicate instanceof Interval)) {
    return null;
  }
  if ((temporalOrder == TemporalRules.ORDER_BACKWARD) || ((subject.compareTo(predicate) > 0) && (temporalOrder != TemporalRules.ORDER_FORWARD))) {
    Term interm=subject;
    subject=predicate;
    predicate=interm;
  }
  NativeOperator copula;
switch (temporalOrder) {
case TemporalRules.ORDER_BACKWARD:
    temporalOrder=TemporalRules.ORDER_FORWARD;
case TemporalRules.ORDER_FORWARD:
  copula=NativeOperator.EQUIVALENCE_AFTER;
break;
case TemporalRules.ORDER_CONCURRENT:
copula=NativeOperator.EQUIVALENCE_WHEN;
break;
default :
copula=NativeOperator.EQUIVALENCE;
}
Term[] t;
if (temporalOrder == TemporalRules.ORDER_FORWARD) t=new Term[]{subject,predicate};
 else t=Term.toSortedSetArray(subject,predicate);
if (t.length != 2) return null;
return new Equivalence(t,temporalOrder);
}
Program: 166707
Project: 166707
Buggy source:
public ConsolePanel(NARControls narControls){
  super(JSplitPane.VERTICAL_SPLIT);
  LogPanel outputLog=new SwingLogPanel(narControls);
  add(outputLog,0);
  TextInputPanel inputPanel=new TextInputPanel(narControls.nar);
  add(inputPanel,1);
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      try {
        Thread.sleep(50);
      }
 catch (      InterruptedException ex) {
        Logger.getLogger(ConsolePanel.class.getName()).log(Level.SEVERE,null,ex);
      }
      setDividerLocation(0.75);
    }
  }
);
  setDividerLocation(0.75);
}

Fixed version (ground truth):
public ConsolePanel(NARControls narControls){
  super(JSplitPane.VERTICAL_SPLIT);
  LogPanel outputLog=new SwingLogPanel(narControls);
  add(outputLog,0);
  TextInputPanel inputPanel=new TextInputPanel(narControls.nar);
  add(inputPanel,1);
}
Program: 166712
Project: 166712
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;
  }
  if ((newContent != null) && (!(newContent instanceof Interval)) && (!(newContent instanceof Variable))) {
    try {
      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;
    }
 catch (    CompoundTerm.UnableToCloneException e) {
      return null;
    }
  }
  return null;
}

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) && (!(newContent instanceof Interval)) && (!(newContent instanceof Variable))&& (!Sentence.invalidSentenceTerm(newContent))) {
    try {
      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;
    }
 catch (    CompoundTerm.UnableToCloneException e) {
      return null;
    }
  }
  return null;
}
Program: 166713
Project: 166713
Buggy source:
/** 
 * To accept a new judgment as belief, and check for revisions and solutions
 * @param judg The judgment to be accepted
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
protected void processJudgment(final NAL nal,final Task task){
  final Sentence judg=task.sentence;
  final Sentence oldBelief=selectCandidate(judg,beliefs);
  if (oldBelief != null) {
    final Stamp newStamp=judg.stamp;
    final Stamp oldStamp=oldBelief.stamp;
    if (newStamp.equals(oldStamp,false,false,true,true)) {
      if (task.getParentTask() != null && task.getParentTask().sentence.isJudgment()) {
      }
      memory.removeTask(task,"String_Node_Str");
      return;
    }
 else     if (revisible(judg,oldBelief)) {
      nal.setTheNewStamp(newStamp,oldStamp,memory.time());
      Sentence projectedBelief=oldBelief.projection(newStamp.getOccurrenceTime(),memory.time());
      if (projectedBelief.getOccurenceTime() != oldBelief.getOccurenceTime()) {
        nal.singlePremiseTask(projectedBelief,task.budget);
      }
      nal.setCurrentBelief(projectedBelief);
      revision(judg,projectedBelief,false,nal);
    }
  }
  if (task.aboveThreshold()) {
    int nnq=questions.size();
    for (int i=0; i < nnq; i++) {
      trySolution(judg,questions.get(i),nal);
    }
    addToTable(task,judg,beliefs,memory.param.conceptBeliefsMax.get(),ConceptBeliefAdd.class,ConceptBeliefRemove.class);
  }
}

Fixed version (ground truth):
/** 
 * To accept a new judgment as belief, and check for revisions and solutions
 * @param judg The judgment to be accepted
 * @param task The task to be processed
 * @return Whether to continue the processing of the task
 */
protected void processJudgment(final NAL nal,final Task task){
  final Sentence judg=task.sentence;
  final Sentence oldBelief=selectCandidate(judg,beliefs);
  if (oldBelief != null) {
    final Stamp newStamp=judg.stamp;
    final Stamp oldStamp=oldBelief.stamp;
    if (newStamp.equals(oldStamp,false,false,true,true)) {
      if (task.getParentTask() != null && task.getParentTask().sentence.isJudgment()) {
      }
      memory.removeTask(task,"String_Node_Str");
      return;
    }
 else     if (revisible(judg,oldBelief)) {
      nal.setTheNewStamp(newStamp,oldStamp,memory.time());
      Sentence projectedBelief=oldBelief.projection(newStamp.getOccurrenceTime(),memory.time());
      if (projectedBelief != null) {
        if (projectedBelief.getOccurenceTime() != oldBelief.getOccurenceTime()) {
          nal.singlePremiseTask(projectedBelief,task.budget);
        }
        nal.setCurrentBelief(projectedBelief);
        revision(judg,projectedBelief,false,nal);
      }
    }
  }
  if (task.aboveThreshold()) {
    int nnq=questions.size();
    for (int i=0; i < nnq; i++) {
      trySolution(judg,questions.get(i),nal);
    }
    addToTable(task,judg,beliefs,memory.param.conceptBeliefsMax.get(),ConceptBeliefAdd.class,ConceptBeliefRemove.class);
  }
}
Program: 166715
Project: 166715
Buggy source:
@Override public void visit(final Term t){
  if (t instanceof Variable) {
    vars.add(((Variable)t));
  }
}

Fixed version (ground truth):
@Override public void visit(final Term t,final Term parent){
  if (t instanceof Variable) {
    Variable v=((Variable)t);
    vars.add(v);
  }
}
Program: 166716
Project: 166716
Buggy source:
private static void dedSecondLayerVariableUnificationTerms(final NAL nal,Task task,Sentence second_belief,final Stamp s,ArrayList<Term> terms_dependent,TruthValue truth,TruthValue t1,TruthValue t2,boolean strong){
  Stamp sx=null;
  final Sentence taskSentence=task.sentence;
  for (int i=0; i < terms_dependent.size(); i++) {
    final Term result=terms_dependent.get(i);
    if (invalidSentenceContent(result)) {
      continue;
    }
    char mark=Symbols.JUDGMENT_MARK;
    if (task.sentence.isGoal() || second_belief.isGoal()) {
      if (strong) {
        truth=abduction(t1,t2);
      }
 else {
        truth=intersection(t1,t2);
      }
      mark=Symbols.GOAL_MARK;
    }
    if (sx == null)     sx=new Stamp(taskSentence.stamp,nal.getTime(),s);
    try {
      Sentence newSentence=new Sentence(result,mark,truth,sx);
      BudgetValue budget=BudgetFunctions.compoundForward(truth,newSentence.content,nal);
      if (budget.aboveThreshold()) {
        Task newTask=new Task(newSentence,budget,task,null);
        Task dummy=new Task(second_belief,budget,task,null);
        nal.setCurrentBelief(taskSentence);
        nal.setCurrentTask(dummy);
        if (nal.derivedTask(newTask,false,false,task,second_belief)) {
          nal.mem().logic.DED_SECOND_LAYER_VARIABLE_UNIFICATION_TERMS.commit();
        }
      }
    }
 catch (    UnableToCloneException u) {
      return;
    }
  }
}

Fixed version (ground truth):
private static void dedSecondLayerVariableUnificationTerms(final NAL nal,Task task,Sentence second_belief,final Stamp s,ArrayList<Term> terms_dependent,TruthValue truth,TruthValue t1,TruthValue t2,boolean strong){
  Stamp sx=null;
  final Sentence taskSentence=task.sentence;
  for (int i=0; i < terms_dependent.size(); i++) {
    final Term result=terms_dependent.get(i);
    if (Sentence.invalidSentenceTerm(result)) {
      continue;
    }
    char mark=Symbols.JUDGMENT_MARK;
    if (task.sentence.isGoal() || second_belief.isGoal()) {
      if (strong) {
        truth=abduction(t1,t2);
      }
 else {
        truth=intersection(t1,t2);
      }
      mark=Symbols.GOAL_MARK;
    }
    if (sx == null)     sx=new Stamp(taskSentence.stamp,nal.getTime(),s);
    try {
      Sentence newSentence=new Sentence(result,mark,truth,sx);
      BudgetValue budget=BudgetFunctions.compoundForward(truth,newSentence.content,nal);
      if (budget.aboveThreshold()) {
        Task newTask=new Task(newSentence,budget,task,null);
        Task dummy=new Task(second_belief,budget,task,null);
        nal.setCurrentBelief(taskSentence);
        nal.setCurrentTask(dummy);
        if (nal.derivedTask(newTask,false,false,task,second_belief)) {
          nal.mem().logic.DED_SECOND_LAYER_VARIABLE_UNIFICATION_TERMS.commit();
        }
      }
    }
 catch (    UnableToCloneException u) {
      return;
    }
  }
}
Program: 166718
Project: 166718
Buggy source:
public static Equivalence make(Term subject,Term predicate,int temporalOrder){
  if (subject == null || predicate == null || invalidStatement(subject,predicate)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Implication)|| (predicate instanceof Equivalence)) {
    return null;
  }
  if (subject.equals(predicate))   return null;
  if ((temporalOrder == TemporalRules.ORDER_BACKWARD) || ((subject.compareTo(predicate) > 0) && (temporalOrder != TemporalRules.ORDER_FORWARD))) {
    Term interm=subject;
    subject=predicate;
    predicate=interm;
  }
  NativeOperator copula;
switch (temporalOrder) {
case TemporalRules.ORDER_BACKWARD:
    temporalOrder=TemporalRules.ORDER_FORWARD;
case TemporalRules.ORDER_FORWARD:
  copula=NativeOperator.EQUIVALENCE_AFTER;
break;
case TemporalRules.ORDER_CONCURRENT:
copula=NativeOperator.EQUIVALENCE_WHEN;
break;
default :
copula=NativeOperator.EQUIVALENCE;
}
Term[] t=Term.toSortedSetArray(subject,predicate);
if (t.length != 2) return null;
return new Equivalence(t,temporalOrder);
}

Fixed version (ground truth):
public static Equivalence make(Term subject,Term predicate,int temporalOrder){
  if (invalidStatement(subject,predicate)) {
    return null;
  }
  if ((subject instanceof Implication) || (subject instanceof Equivalence) || (predicate instanceof Implication)|| (predicate instanceof Equivalence)) {
    return null;
  }
  if ((temporalOrder == TemporalRules.ORDER_BACKWARD) || ((subject.compareTo(predicate) > 0) && (temporalOrder != TemporalRules.ORDER_FORWARD))) {
    Term interm=subject;
    subject=predicate;
    predicate=interm;
  }
  NativeOperator copula;
switch (temporalOrder) {
case TemporalRules.ORDER_BACKWARD:
    temporalOrder=TemporalRules.ORDER_FORWARD;
case TemporalRules.ORDER_FORWARD:
  copula=NativeOperator.EQUIVALENCE_AFTER;
break;
case TemporalRules.ORDER_CONCURRENT:
copula=NativeOperator.EQUIVALENCE_WHEN;
break;
default :
copula=NativeOperator.EQUIVALENCE;
}
Term[] t=Term.toSortedSetArray(subject,predicate);
if (t.length != 2) return null;
return new Equivalence(t,temporalOrder);
}