public static double dynamicallyEstimatePredicateGoalFanout(Proposition goal) {
    { GeneralizedSymbol testValue000 = goal.operator;

      if (testValue000 == Logic.SGT_PL_KERNEL_KB_MEMBER_OF) {
        return (Proposition.estimateMemberOfGoalFanout(goal));
      }
      else if (testValue000 == Logic.SGT_PL_KERNEL_KB_INSTANCE_OF) {
        return (Proposition.dynamicallyEstimateInstanceOfGoalFanout(goal));
      }
      else {
        { Cons patternargs = Stella.NIL;
          GeneralizedSymbol relation = goal.operator;
          Vector arguments = goal.arguments;
          int firstargindex = 0;
          int nofunboundargs = 0;
          int unboundargindex = Stella.NULL_INTEGER;
          Stella_Object key = null;
          boolean relationextensionP = true;
          NamedDescription description = Logic.getDescription(relation);

          if (relation == Logic.SGT_PL_KERNEL_KB_HOLDS) {
            if (Stella_Object.isaP(Logic.argumentBoundTo((arguments.theArray)[0]), Logic.SGT_LOGIC_NAMED_DESCRIPTION)) {
              description = ((NamedDescription)(Logic.argumentBoundTo((arguments.theArray)[0])));
              firstargindex = 1;
            }
            else {
              description = null;
            }
          }
          if (description == null) {
            return (Stella.NULL_FLOAT);
          }
          { int i = Stella.NULL_INTEGER;
            int iter000 = firstargindex;
            int upperBound000 = arguments.length() - 1;
            Cons collect000 = null;

            for (;iter000 <= upperBound000; iter000 = iter000 + 1) {
              i = iter000;
              key = Logic.argumentBoundTo((arguments.theArray)[i]);
              if (key != null) {
                if (Logic.instanceHasBacklinksP(key)) {
                  relationextensionP = false;
                }
              }
              else {
                nofunboundargs = nofunboundargs + 1;
                unboundargindex = i;
              }
              if (collect000 == null) {
                {
                  collect000 = Cons.cons(key, Stella.NIL);
                  if (patternargs == Stella.NIL) {
                    patternargs = collect000;
                  }
                  else {
                    Cons.addConsToEndOfConsList(patternargs, collect000);
                  }
                }
              }
              else {
                {
                  collect000.rest = Cons.cons(key, Stella.NIL);
                  collect000 = collect000.rest;
                }
              }
            }
          }
          if (Description.computedTermP(description)) {
            switch (nofunboundargs) {
              case 0: 
                return (((double)(1)));
              case 1: 
                if (unboundargindex == (arguments.length() - 1)) {
                  return (((double)(1)));
                }
                else if (Description.computedConstraintP(description)) {
                  return (((double)(1)));
                }
              break;
              default:
              break;
            }
            return (Stella.NULL_FLOAT);
          }
          if (Logic.testPropertyP(description, Logic.SGT_PL_KERNEL_KB_TOTAL) &&
              ((nofunboundargs > 1) &&
               (unboundargindex == (arguments.length() - 1)))) {
            return (Stella.NULL_FLOAT);
          }
          if (relationextensionP) {
            return (NamedDescription.dynamicallyEstimateExtensionSize(description));
          }
          else {
            return (((double)(Logic.selectPropositions(Cons.cons(Logic.KWD_RELATION, Cons.cons(((Stella.NIL == null) ? Stella.NIL : Stella.NIL), Cons.cons(relation, patternargs)))).estimatedLength())));
          }
        }
      }
    }
  }