public static SequenceIndex selectRelationPropositions(Cons pattern) {
    { Cons arguments = pattern.rest.rest;
      Stella_Object relation = arguments.value;
      Stella_Object key1 = null;
      Stella_Object key2 = null;

      arguments = arguments.rest;
      if (arguments == Stella.NIL) {
        { MemoizationTable memoTable000 = null;
          Cons memoizedEntry000 = null;
          Stella_Object memoizedValue000 = null;

          if (Stella.$MEMOIZATION_ENABLEDp$) {
            memoTable000 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_000.surrogateValue));
            if (memoTable000 == null) {
              Surrogate.initializeMemoizationTable(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_000, "(:MAX-VALUES 50 :TIMESTAMPS (:KB-UPDATE))");
              memoTable000 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_000.surrogateValue));
            }
            memoizedEntry000 = MruMemoizationTable.lookupMruMemoizedValue(((MruMemoizationTable)(memoTable000)), relation, ((Context)(Stella.$CONTEXT$.get())), Stella.MEMOIZED_NULL_VALUE, null, 2);
            memoizedValue000 = memoizedEntry000.value;
          }
          if (memoizedValue000 != null) {
            if (memoizedValue000 == Stella.MEMOIZED_NULL_VALUE) {
              memoizedValue000 = null;
            }
          }
          else {
            memoizedValue000 = Logic.helpSelectRelationPropositions(pattern);
            if (Stella.$MEMOIZATION_ENABLEDp$) {
              memoizedEntry000.value = ((memoizedValue000 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue000);
            }
          }
          { SequenceIndex value000 = ((SequenceIndex)(memoizedValue000));

            return (value000);
          }
        }
      }
      key1 = arguments.value;
      arguments = arguments.rest;
      if (arguments == Stella.NIL) {
        { MemoizationTable memoTable001 = null;
          Cons memoizedEntry001 = null;
          Stella_Object memoizedValue001 = null;

          if (Stella.$MEMOIZATION_ENABLEDp$) {
            memoTable001 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_001.surrogateValue));
            if (memoTable001 == null) {
              Surrogate.initializeMemoizationTable(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_001, "(:MAX-VALUES 1000 :TIMESTAMPS (:KB-UPDATE))");
              memoTable001 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_001.surrogateValue));
            }
            memoizedEntry001 = MruMemoizationTable.lookupMruMemoizedValue(((MruMemoizationTable)(memoTable001)), relation, key1, ((Context)(Stella.$CONTEXT$.get())), Stella.MEMOIZED_NULL_VALUE, 4);
            memoizedValue001 = memoizedEntry001.value;
          }
          if (memoizedValue001 != null) {
            if (memoizedValue001 == Stella.MEMOIZED_NULL_VALUE) {
              memoizedValue001 = null;
            }
          }
          else {
            memoizedValue001 = Logic.helpSelectRelationPropositions(pattern);
            if (Stella.$MEMOIZATION_ENABLEDp$) {
              memoizedEntry001.value = ((memoizedValue001 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue001);
            }
          }
          { SequenceIndex value001 = ((SequenceIndex)(memoizedValue001));

            return (value001);
          }
        }
      }
      key2 = arguments.value;
      arguments = arguments.rest;
      if (arguments == Stella.NIL) {
        { MemoizationTable memoTable002 = null;
          Cons memoizedEntry002 = null;
          Stella_Object memoizedValue002 = null;

          if (Stella.$MEMOIZATION_ENABLEDp$) {
            memoTable002 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_002.surrogateValue));
            if (memoTable002 == null) {
              Surrogate.initializeMemoizationTable(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_002, "(:MAX-VALUES 1000 :TIMESTAMPS (:KB-UPDATE))");
              memoTable002 = ((MemoizationTable)(Logic.SGT_LOGIC_F_SELECT_RELATION_PROPOSITIONS_MEMO_TABLE_002.surrogateValue));
            }
            memoizedEntry002 = MruMemoizationTable.lookupMruMemoizedValue(((MruMemoizationTable)(memoTable002)), relation, key1, key2, ((Context)(Stella.$CONTEXT$.get())), 8);
            memoizedValue002 = memoizedEntry002.value;
          }
          if (memoizedValue002 != null) {
            if (memoizedValue002 == Stella.MEMOIZED_NULL_VALUE) {
              memoizedValue002 = null;
            }
          }
          else {
            memoizedValue002 = Logic.helpSelectRelationPropositions(pattern);
            if (Stella.$MEMOIZATION_ENABLEDp$) {
              memoizedEntry002.value = ((memoizedValue002 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue002);
            }
          }
          { SequenceIndex value002 = ((SequenceIndex)(memoizedValue002));

            return (value002);
          }
        }
      }
      return (Logic.helpSelectRelationPropositions(pattern));
    }
  }