Program: 166732
Project: 166732
Buggy source:
public static boolean temporalInductionChain(final Sentence s1,final Sentence s2,final nars.core.control.NAL nal){
  if ((s1.truth == null) || (s2.truth == null))   return false;
  Implication S1=(Implication)s1.content;
  Implication S2=(Implication)s2.content;
  Term A=S1.getSubject();
  Term B1=S1.getPredicate();
  Term B2=S2.getSubject();
  Term C=S2.getPredicate();
  ArrayList<Term> args=null;
  int beginoffset=0;
  if (B2 instanceof Conjunction) {
    Conjunction CB2=((Conjunction)B2);
    if (CB2.getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
      if (A instanceof Conjunction && ((Conjunction)A).getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
        Conjunction ConjA=(Conjunction)A;
        args=new ArrayList(CB2.term.length + ConjA.term.length);
        beginoffset=ConjA.size();
        for (        final Term t : ConjA.term)         args.add(t);
      }
 else {
        args=new ArrayList(CB2.term.length + 1);
        args.add(A);
        beginoffset=1;
      }
      for (      final Term t : CB2.term)       args.add(t);
    }
  }
 else {
    args=Lists.newArrayList(A,B1);
  }
  if (args == null)   return false;
  Term[] term=args.toArray(new Term[args.size()]);
  Term realB2=term[beginoffset];
  HashMap<Term,Term> res1=new HashMap<>();
  HashMap<Term,Term> res2=new HashMap<>();
  if (Variables.findSubstitute(Symbols.VAR_INDEPENDENT,B1,realB2,res1,res2)) {
    for (int i=0; i < term.length; i++) {
      if (term[i] instanceof CompoundTerm) {
        term[i]=((CompoundTerm)term[i]).applySubstitute(res1);
        if (term[i] == null) {
          return false;
        }
      }
    }
    int order1=s1.getTemporalOrder();
    int order2=s2.getTemporalOrder();
    Conjunction S=(Conjunction)Conjunction.make(term,order1);
    for (    Term t : term) {
      if (Terms.equalSubTermsInRespectToImageAndProduct(t,C)) {
        return false;
      }
      for (      Term u : term) {
        if (u != t) {
          if (Terms.equalSubTermsInRespectToImageAndProduct(t,u)) {
            return false;
          }
        }
      }
    }
    Implication whole=Implication.make(S,C,order2);
    if (whole != null) {
      TruthValue truth=TruthFunctions.deduction(s1.truth,s2.truth);
      BudgetValue budget=BudgetFunctions.forward(truth,nal);
      budget.setPriority((float)Math.min(0.99,budget.getPriority()));
      if (whole.getTemporalOrder() == TemporalRules.ORDER_FORWARD && whole.getSubject() instanceof Conjunction) {
        Conjunction conj=(Conjunction)whole.getSubject();
        if (conj.getTemporalOrder() == TemporalRules.ORDER_FORWARD && conj.term.length > 0 && !(conj.term[0] instanceof Interval)) {
          Term[] t2=new Term[conj.term.length - 2];
          for (int i=0; i < t2.length; i++) {
            t2[i]=conj.term[i + 2];
          }
          Term reduced=Conjunction.make(t2,TemporalRules.ORDER_FORWARD);
          Implication impnew=Implication.make(reduced,whole.getPredicate(),TemporalRules.ORDER_FORWARD);
          for (          Concept c : nal.memory.concepts) {
            if (!(reduced instanceof Interval) && !c.beliefs.isEmpty() && c.term.equals(impnew)) {
              ArrayList<Long> newBases=new ArrayList<Long>();
              for (int i=0; i < s1.stamp.evidentialBase.length; i++) {
                newBases.add(s1.stamp.evidentialBase[i]);
              }
              for (int i=0; i < s2.stamp.evidentialBase.length; i++) {
                newBases.add(s2.stamp.evidentialBase[i]);
              }
              boolean isCompletelyIn=false;
              for (              ArrayList<Long> ev : c.evidentalDiscountBases) {
                if (ev.size() == newBases.size()) {
                  boolean isAllIn=true;
                  for (                  Long bas : ev) {
                    boolean isIn=false;
                    for (                    Long bas2 : newBases) {
                      if (Objects.equals(bas,bas2)) {
                        isIn=true;
                        break;
                      }
                    }
                    if (isIn == false) {
                      isAllIn=false;
                    }
                  }
                  if (isAllIn) {
                    isCompletelyIn=true;
                    break;
                  }
                }
              }
              if (!isCompletelyIn) {
                c.evidentalDiscountBases.add(newBases);
                c.discountConfidence(true);
              }
            }
          }
        }
      }
      return nal.doublePremiseTask(whole,truth,budget,true) != null;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean temporalInductionChain(final Sentence s1,final Sentence s2,final nars.core.control.NAL nal){
  if ((s1.truth == null) || (s2.truth == null))   return false;
  Implication S1=(Implication)s1.content;
  Implication S2=(Implication)s2.content;
  Term A=S1.getSubject();
  Term B1=S1.getPredicate();
  Term B2=S2.getSubject();
  Term C=S2.getPredicate();
  ArrayList<Term> args=null;
  int beginoffset=0;
  if (B2 instanceof Conjunction) {
    Conjunction CB2=((Conjunction)B2);
    if (CB2.getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
      if (A instanceof Conjunction && ((Conjunction)A).getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
        Conjunction ConjA=(Conjunction)A;
        args=new ArrayList(CB2.term.length + ConjA.term.length);
        beginoffset=ConjA.size();
        for (        final Term t : ConjA.term)         args.add(t);
      }
 else {
        args=new ArrayList(CB2.term.length + 1);
        args.add(A);
        beginoffset=1;
      }
      for (      final Term t : CB2.term)       args.add(t);
    }
  }
 else {
    args=Lists.newArrayList(A,B1);
  }
  if (args == null)   return false;
  Term[] term=args.toArray(new Term[args.size()]);
  Term realB2=term[beginoffset];
  HashMap<Term,Term> res1=new HashMap<>();
  HashMap<Term,Term> res2=new HashMap<>();
  if (Variables.findSubstitute(Symbols.VAR_INDEPENDENT,B1,realB2,res1,res2)) {
    for (int i=0; i < term.length; i++) {
      if (term[i] instanceof CompoundTerm) {
        term[i]=((CompoundTerm)term[i]).applySubstitute(res1);
        if (term[i] == null) {
          return false;
        }
      }
    }
    int order1=s1.getTemporalOrder();
    int order2=s2.getTemporalOrder();
    Term S=Conjunction.make(term,order1);
    for (    Term t : term) {
      if (Terms.equalSubTermsInRespectToImageAndProduct(t,C)) {
        return false;
      }
      for (      Term u : term) {
        if (u != t) {
          if (Terms.equalSubTermsInRespectToImageAndProduct(t,u)) {
            return false;
          }
        }
      }
    }
    Implication whole=Implication.make(S,C,order2);
    if (whole != null) {
      TruthValue truth=TruthFunctions.deduction(s1.truth,s2.truth);
      BudgetValue budget=BudgetFunctions.forward(truth,nal);
      budget.setPriority((float)Math.min(0.99,budget.getPriority()));
      if (whole.getTemporalOrder() == TemporalRules.ORDER_FORWARD && whole.getSubject() instanceof Conjunction) {
        Conjunction conj=(Conjunction)whole.getSubject();
        if (conj.getTemporalOrder() == TemporalRules.ORDER_FORWARD && conj.term.length > 0 && !(conj.term[0] instanceof Interval)) {
          Term[] t2=new Term[conj.term.length - 2];
          for (int i=0; i < t2.length; i++) {
            t2[i]=conj.term[i + 2];
          }
          Term reduced=Conjunction.make(t2,TemporalRules.ORDER_FORWARD);
          Implication impnew=Implication.make(reduced,whole.getPredicate(),TemporalRules.ORDER_FORWARD);
          for (          Concept c : nal.memory.concepts) {
            if (!(reduced instanceof Interval) && !c.beliefs.isEmpty() && c.term.equals(impnew)) {
              ArrayList<Long> newBases=new ArrayList<Long>();
              for (int i=0; i < s1.stamp.evidentialBase.length; i++) {
                newBases.add(s1.stamp.evidentialBase[i]);
              }
              for (int i=0; i < s2.stamp.evidentialBase.length; i++) {
                newBases.add(s2.stamp.evidentialBase[i]);
              }
              boolean isCompletelyIn=false;
              for (              ArrayList<Long> ev : c.evidentalDiscountBases) {
                if (ev.size() == newBases.size()) {
                  boolean isAllIn=true;
                  for (                  Long bas : ev) {
                    boolean isIn=false;
                    for (                    Long bas2 : newBases) {
                      if (Objects.equals(bas,bas2)) {
                        isIn=true;
                        break;
                      }
                    }
                    if (isIn == false) {
                      isAllIn=false;
                    }
                  }
                  if (isAllIn) {
                    isCompletelyIn=true;
                    break;
                  }
                }
              }
              if (!isCompletelyIn) {
                c.evidentalDiscountBases.add(newBases);
                c.discountConfidence(true);
              }
            }
          }
        }
      }
      return nal.doublePremiseTask(whole,truth,budget,true) != null;
    }
  }
  return false;
}