Program: 166675
Project: 166675
Buggy source:
/** 
 * Create a Sentence with the given fields
 * @param content The Term that forms the content of the sentence
 * @param punctuation The punctuation indicating the type of the sentence
 * @param truth The truth value of the sentence, null for question
 * @param stamp The stamp of the sentence indicating its derivation time andbase
 */
private Sentence(T _content,final char punctuation,final TruthValue truth,final Stamp stamp,final boolean normalize){
  if (punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
    if (_content instanceof Conjunction) {
      final Conjunction c=(Conjunction)_content;
      if (c.getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
        if (c.term[c.term.length - 1] instanceof Interval) {
          long time=0;
          int u=0;
          while (c.term.length - 1 - u >= 0 && c.term[c.term.length - 1 - u] instanceof Interval) {
            time+=((Interval)c.term[c.term.length - 1 - u]).time;
            u++;
          }
          final Term[] term2=new Term[c.term.length - u];
          System.arraycopy(c.term,0,term2,0,term2.length);
          _content=(T)Conjunction.make(term2,c.getTemporalOrder(),c.isSpatial);
          if (!c.isSpatial && stamp != null && stamp.getOccurrenceTime() != Stamp.ETERNAL)           stamp.setOccurrenceTime(stamp.getOccurrenceTime() - time);
        }
        if (c.term[0] instanceof Interval) {
          long time=0;
          int u=0;
          while (u < c.term.length && (c.term[u] instanceof Interval)) {
            time+=((Interval)c.term[u]).time;
            u++;
          }
          final Term[] term2=new Term[c.term.length - u];
          System.arraycopy(c.term,u,term2,0,term2.length);
          _content=(T)Conjunction.make(term2,c.getTemporalOrder(),c.isSpatial);
          if (!c.isSpatial && stamp != null && stamp.getOccurrenceTime() != Stamp.ETERNAL)           stamp.setOccurrenceTime(stamp.getOccurrenceTime() + time);
        }
      }
    }
  }
  this.punctuation=punctuation;
  if (truth != null) {
    if (_content instanceof Implication || _content instanceof Equivalence) {
      if (((Statement)_content).getSubject().hasVarIndep() && !((Statement)_content).getPredicate().hasVarIndep())       truth.setConfidence(0.0f);
      if (((Statement)_content).getPredicate().hasVarIndep() && !((Statement)_content).getSubject().hasVarIndep())       truth.setConfidence(0.0f);
    }
 else     if (_content instanceof Interval && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      truth.setConfidence(0.0f);
      if (Parameters.DEBUG)       throw new IllegalStateException("String_Node_Str" + _content + punctuation+ "String_Node_Str"+ stamp);
    }
    if ((!isQuestion() && !isQuest()) && (truth == null) && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      throw new IllegalStateException("String_Node_Str");
    }
    if (_content.subjectOrPredicateIsIndependentVar() && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      truth.setConfidence(0.0f);
      if (Parameters.DEBUG)       throw new IllegalStateException("String_Node_Str");
    }
    if (Parameters.DEBUG && Parameters.DEBUG_INVALID_SENTENCES && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      if (!Term.valid(_content)) {
        truth.setConfidence(0.0f);
        if (Parameters.DEBUG) {
          System.err.println("String_Node_Str" + _content);
          Thread.dumpStack();
        }
      }
    }
  }
  if ((isQuestion() || isQuest()) && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK && !stamp.isEternal()) {
    stamp.setEternal();
  }
  this.truth=truth;
  this.stamp=stamp;
  this.revisible=_content instanceof Implication || _content instanceof Equivalence || !(_content.hasVarDep());
  T newTerm=null;
  if (_content instanceof CompoundTerm)   newTerm=(T)((CompoundTerm)_content).cloneDeepVariables();
  if (newTerm != null && normalize && _content.hasVar() && (!((CompoundTerm)_content).isNormalized())) {
    this.term=(T)((CompoundTerm)_content).cloneDeepVariables();
    final CompoundTerm c=(CompoundTerm)term;
    final List<Variable> vars=new ArrayList();
    c.recurseSubtermsContainingVariables((t,parent) -> {
      if (t instanceof Variable) {
        final Variable v=((Variable)t);
        vars.add(v);
      }
    }
);
    final Map<CharSequence,CharSequence> rename=new HashMap();
    boolean renamed=false;
    for (    final Variable v : vars) {
      CharSequence vname=v.name();
      if (!v.hasVarIndep())       vname=vname + "String_Node_Str" + v.getScope().name();
      CharSequence n=rename.get(vname);
      if (n == null) {
        rename.put(vname,n=Variable.getName(v.getType(),rename.size() + 1));
        if (!n.equals(vname))         renamed=true;
      }
      v.setScope(c,n);
    }
    if (renamed) {
      c.invalidateName();
      if (Parameters.DEBUG && Parameters.DEBUG_INVALID_SENTENCES) {
        if (!Term.valid(c)) {
          final CompoundTerm.UnableToCloneException ntc=new CompoundTerm.UnableToCloneException("String_Node_Str" + c + "String_Node_Str"+ _content);
          ntc.printStackTrace();
          throw ntc;
        }
      }
    }
    c.setNormalized(true);
  }
 else {
    this.term=_content;
  }
  if (isNotTermlinkNormalizer())   this.hash=Objects.hash(term,punctuation,truth,stamp.getOccurrenceTime());
 else   this.hash=Objects.hash(term,punctuation,truth);
}

Fixed version (ground truth):
/** 
 * Create a Sentence with the given fields
 * @param content The Term that forms the content of the sentence
 * @param punctuation The punctuation indicating the type of the sentence
 * @param truth The truth value of the sentence, null for question
 * @param stamp The stamp of the sentence indicating its derivation time andbase
 */
private Sentence(T _content,final char punctuation,final TruthValue truth,final Stamp stamp,final boolean normalize){
  if (punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
    if (_content instanceof Conjunction) {
      final Conjunction c=(Conjunction)_content;
      if (c.getTemporalOrder() == TemporalRules.ORDER_FORWARD) {
        if (c.term[c.term.length - 1] instanceof Interval) {
          long time=0;
          int u=0;
          while (c.term.length - 1 - u >= 0 && c.term[c.term.length - 1 - u] instanceof Interval) {
            time+=((Interval)c.term[c.term.length - 1 - u]).time;
            u++;
          }
          final Term[] term2=new Term[c.term.length - u];
          System.arraycopy(c.term,0,term2,0,term2.length);
          _content=(T)Conjunction.make(term2,c.getTemporalOrder(),c.isSpatial);
          if (!c.isSpatial && stamp != null && stamp.getOccurrenceTime() != Stamp.ETERNAL)           stamp.setOccurrenceTime(stamp.getOccurrenceTime() - time);
        }
        if (c.term[0] instanceof Interval) {
          long time=0;
          int u=0;
          while (u < c.term.length && (c.term[u] instanceof Interval)) {
            time+=((Interval)c.term[u]).time;
            u++;
          }
          final Term[] term2=new Term[c.term.length - u];
          System.arraycopy(c.term,u,term2,0,term2.length);
          _content=(T)Conjunction.make(term2,c.getTemporalOrder(),c.isSpatial);
          if (!c.isSpatial && stamp != null && stamp.getOccurrenceTime() != Stamp.ETERNAL)           stamp.setOccurrenceTime(stamp.getOccurrenceTime() + time);
        }
      }
    }
  }
  this.punctuation=punctuation;
  if (truth != null) {
    if (_content instanceof Implication || _content instanceof Equivalence) {
      if (((Statement)_content).getSubject().hasVarIndep() && !((Statement)_content).getPredicate().hasVarIndep())       truth.setConfidence(0.0f);
      if (((Statement)_content).getPredicate().hasVarIndep() && !((Statement)_content).getSubject().hasVarIndep())       truth.setConfidence(0.0f);
    }
 else     if (_content instanceof Interval && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      truth.setConfidence(0.0f);
      if (Parameters.DEBUG)       throw new IllegalStateException("String_Node_Str" + _content + punctuation+ "String_Node_Str"+ stamp);
    }
    if ((!isQuestion() && !isQuest()) && (truth == null) && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      throw new IllegalStateException("String_Node_Str");
    }
    if (_content.subjectOrPredicateIsIndependentVar() && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      truth.setConfidence(0.0f);
      if (Parameters.DEBUG)       throw new IllegalStateException("String_Node_Str");
    }
    if (Parameters.DEBUG && Parameters.DEBUG_INVALID_SENTENCES && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK) {
      if (!Term.valid(_content)) {
        truth.setConfidence(0.0f);
        if (Parameters.DEBUG) {
          System.err.println("String_Node_Str" + _content);
          Thread.dumpStack();
        }
      }
    }
  }
  if ((isQuestion() || isQuest()) && punctuation != Symbols.TERM_NORMALIZING_WORKAROUND_MARK && !stamp.isEternal()) {
    stamp.setEternal();
  }
  this.truth=truth;
  this.stamp=stamp;
  this.revisible=_content instanceof Implication || _content instanceof Equivalence || !(_content.hasVarDep());
  T newTerm=null;
  if (_content instanceof CompoundTerm)   newTerm=(T)((CompoundTerm)_content).cloneDeepVariables();
  if (newTerm != null && normalize && _content.hasVar() && (!((CompoundTerm)_content).isNormalized())) {
    this.term=newTerm;
    final CompoundTerm c=(CompoundTerm)term;
    final List<Variable> vars=new ArrayList();
    c.recurseSubtermsContainingVariables((t,parent) -> {
      if (t instanceof Variable) {
        final Variable v=((Variable)t);
        vars.add(v);
      }
    }
);
    final Map<CharSequence,CharSequence> rename=new HashMap();
    boolean renamed=false;
    for (    final Variable v : vars) {
      CharSequence vname=v.name();
      if (!v.hasVarIndep())       vname=vname + "String_Node_Str" + v.getScope().name();
      CharSequence n=rename.get(vname);
      if (n == null) {
        rename.put(vname,n=Variable.getName(v.getType(),rename.size() + 1));
        if (!n.equals(vname))         renamed=true;
      }
      v.setScope(c,n);
    }
    if (renamed) {
      c.invalidateName();
      if (Parameters.DEBUG && Parameters.DEBUG_INVALID_SENTENCES) {
        if (!Term.valid(c)) {
          final CompoundTerm.UnableToCloneException ntc=new CompoundTerm.UnableToCloneException("String_Node_Str" + c + "String_Node_Str"+ _content);
          ntc.printStackTrace();
          throw ntc;
        }
      }
    }
    c.setNormalized(true);
  }
 else {
    this.term=_content;
  }
  if (isNotTermlinkNormalizer())   this.hash=Objects.hash(term,punctuation,truth,stamp.getOccurrenceTime());
 else   this.hash=Objects.hash(term,punctuation,truth);
}