

#include "BUILTIN.h"
extern OBJ _ARel_7(OBJ,OBJ);extern OBJ __ARel_7;
extern OBJ _ARel_8(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);extern OBJ __ARel_8;
extern OBJ _ARel_35(OBJ,OBJ,OBJ,OBJ,OBJ);extern OBJ __ARel_35;
extern OBJ _ARel_39(OBJ,OBJ,OBJ);extern OBJ __ARel_39;
extern OBJ _ARel_47(OBJ,OBJ,OBJ,OBJ);extern OBJ __ARel_47;

#include "Nat.h"
extern OBJ _ASeq_42(OBJ,OBJ);extern OBJ __ASeq_42;
extern TUP2 _APair_8(OBJ);extern OBJ __APair_8;
extern OBJ _ARelCompose_12(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);extern OBJ __ARelCompose_12;
extern OBJ _ARelReduce_7(OBJ,OBJ,OBJ,OBJ,OBJ);extern OBJ __ARelReduce_7;
extern OBJ _AMap_33(OBJ,OBJ,OBJ);extern OBJ __AMap_33;
extern OBJ _AMapReduce_6(OBJ,OBJ,OBJ,OBJ);extern OBJ __AMapReduce_6;
extern OBJ _ASeqReduce_3(OBJ,OBJ,OBJ);extern OBJ __ASeqReduce_3;
extern OBJ _ACAST_3(OBJ);extern OBJ __ACAST_3;
extern OBJ _ARelHomog_7(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_7; /* id */
extern OBJ _ARelHomog_8(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_8; /* iter */
extern OBJ _ARelHomog_9(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_9; /* ^ */
extern OBJ _ARelHomog_10(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_10; /* symmetric? */
extern OBJ _ARelHomog_11(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_11; /* symClosure */
extern OBJ _ARelHomog_12(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_12; /* reflexive? */
extern OBJ _ARelHomog_13(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_13; /* refClosure */
extern OBJ _ARelHomog_14(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_14; /* transitive? */
extern OBJ _ARelHomog_15(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_15; /* + */
extern OBJ _ARelHomog_16(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_16; /* transClosure */
extern OBJ _ARelHomog_17(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_17; /* * */
extern OBJ _ARelHomog_18(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_18; /* refTransClosure */
extern OBJ _ARelHomog_19(OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_19; /* RSTClosure */
extern TUP2 _ARelHomog_20(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_20; /* ; */
extern OBJ _ARelHomog_21(OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_21; /* id'21 */
extern OBJ _ARelHomog_22(OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_22; /* symmetric?'22 */
extern OBJ _ARelHomog_23(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_23; /* symClosure'23 */
extern OBJ _ARelHomog_24(OBJ,OBJ,OBJ);OBJ __ARelHomog_24; /* reflexive?'24 */
extern OBJ _ARelHomog_25(OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_25; /* refClosure'25 */
extern OBJ _ARelHomog_26(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_26; /* ;'26 */
extern OBJ _ARelHomog_27(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ);OBJ __ARelHomog_27; /* ;'27 */

extern OBJ _ARelHomog_7(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* id */
{OBJ r;
 CPCLS(__ARelHomog_21,1);
 CPCLS(x1,2);
 FRCLS(x3,1);
 FRCLS(x4,1);
 {OBJ x6;OBJ x7;
  x6=_ARel_7(x1,x1);
  x7=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_21,2))(__ARelHomog_21,x1,x2);
  r=_ASeqReduce_3(x7,x6,x5);}
 return r;}

extern OBJ _ARelHomog_8(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6) /* iter */
{OBJ r;
 r=_ARelHomog_9(x1,x2,x3,x4,x5,x6);
 return r;}

extern OBJ _ARelHomog_9(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6) /* ^ */
{OBJ r;
 {OBJ x7;
  ANat_6(x6,x7);
  if(ISTGPRM(x7,1)){
   CPCLS(x1,2);
   {OBJ x8;
    x8=_ARel_39(x1,x1,x5);
    r=_ARelHomog_7(x1,x2,x3,x4,x8);}
  }else{
   {OBJ x9;
    ANat_3(x6,x9);
    if(ISTGPRM(x9,1)){
     {OBJ x10;OBJ x11;
      ANat_4(x6,x10);
      ANat_6(x10,x11);
      if(ISTGPRM(x11,1)){
       FRCLS(x1,1);
       FRCLS(x2,1);
       FRCLS(x3,1);
       FRCLS(x4,1);
       r=x5;
      }else{
       CPCLS(x1,3);
       CPCLS(x4,1);
       COPY(x5,1);
       {OBJ x12;
	x12=_ARelHomog_9(x1,x2,x3,x4,x5,x10);
	r=_ARelCompose_12(x1,x1,x1,x4,x12,x5);}}}
    }else{
     HLT("RelHomog at <unknown> : missing else in ^\'RelHomog:rel**nat->rel");}}}}
 return r;}

extern OBJ _ARelHomog_10(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* symmetric? */
{OBJ r;
 CPCLS(__ARelHomog_22,1);
 CPCLS(x1,2);
 FRCLS(x2,1);
 FRCLS(x3,1);
 FRCLS(x4,1);
 COPY(x5,1);
 {OBJ x6;
  x6=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_22,2))(__ARelHomog_22,x1,x5);
  r=_ARel_47(x1,x1,x6,x5);}
 return r;}

extern OBJ _ARelHomog_11(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* symClosure */
{OBJ r;
 CPCLS(__ARelHomog_23,1);
 CPCLS(x1,2);
 FRCLS(x2,1);
 FRCLS(x4,1);
 COPY(x5,1);
 {OBJ x6;
  x6=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_23,2))(__ARelHomog_23,x1,x3);
  r=_ARelReduce_7(x1,x1,x6,x5,x5);}
 return r;}

extern OBJ _ARelHomog_12(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* reflexive? */
{OBJ r;
 CPCLS(__ARelHomog_24,1);
 CPCLS(x1,2);
 FRCLS(x2,1);
 FRCLS(x3,1);
 FRCLS(x4,1);
 COPY(x5,1);
 {OBJ x6;OBJ x7;
  x6=_ARel_39(x1,x1,x5);
  x7=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_24,2))(__ARelHomog_24,x1,x5);
  r=_ASeq_42(x7,x6);}
 return r;}

extern OBJ _ARelHomog_13(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* refClosure */
{OBJ r;
 CPCLS(__ARelHomog_25,1);
 CPCLS(x1,2);
 FRCLS(x3,1);
 FRCLS(x4,1);
 COPY(x5,1);
 {OBJ x6;OBJ x7;
  x6=_ARel_39(x1,x1,x5);
  x7=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_25,2))(__ARelHomog_25,x1,x2);
  r=_ASeqReduce_3(x7,x5,x6);}
 return r;}

extern OBJ _ARelHomog_14(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* transitive? */
{OBJ r;
 COPY(x5,1);
 {TUP2 x7;
  x7=_ARelHomog_20(x1,x2,x3,x4,x5,x5);r=x7.c2;
  FREE(x7.c1,1);}
 return r;}

extern OBJ _ARelHomog_15(register OBJ x1,register OBJ x2,register OBJ x3,register OBJ x4,register OBJ x5) /* + */
{OBJ r;
 for(;;){
  CPCLS(x1,1);
  CPCLS(x2,1);
  CPCLS(x3,1);
  CPCLS(x4,1);
  COPY(x5,2);
  {TUP2 x7;
   x7=_ARelHomog_20(x1,x2,x3,x4,x5,x5);
   if(ISTGPRM(x7.c2,1)){
    FREE(x5,1);
    x5=x7.c1;continue;
   }else{
    FRCLS(x1,1);
    FRCLS(x2,1);
    FRCLS(x3,1);
    FRCLS(x4,1);
    FREE(x7.c1,1);
    r=x5;}}
  break;}
 return r;}

extern OBJ _ARelHomog_16(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* transClosure */
{OBJ r;
 r=_ARelHomog_15(x1,x2,x3,x4,x5);
 return r;}

extern OBJ _ARelHomog_17(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* * */
{OBJ r;
 CPCLS(x1,1);
 CPCLS(x2,1);
 CPCLS(x3,1);
 CPCLS(x4,1);
 {OBJ x6;
  x6=_ARelHomog_13(x1,x2,x3,x4,x5);
  r=_ARelHomog_15(x1,x2,x3,x4,x6);}
 return r;}

extern OBJ _ARelHomog_18(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* refTransClosure */
{OBJ r;
 CPCLS(x1,1);
 CPCLS(x2,1);
 CPCLS(x3,1);
 CPCLS(x4,1);
 {OBJ x6;
  x6=_ARelHomog_13(x1,x2,x3,x4,x5);
  r=_ARelHomog_15(x1,x2,x3,x4,x6);}
 return r;}

extern OBJ _ARelHomog_19(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5) /* RSTClosure */
{OBJ r;
 CPCLS(__ARelHomog_23,1);
 CPCLS(x1,4);
 CPCLS(x2,1);
 CPCLS(x3,2);
 CPCLS(x4,1);
 {OBJ x6;OBJ x7;OBJ x8;
  x6=_ARelHomog_13(x1,x2,x3,x4,x5);
  COPY(x6,1);
  x7=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(__ARelHomog_23,2))(__ARelHomog_23,x1,x3);
  x8=_ARelReduce_7(x1,x1,x7,x6,x6);
  r=_ARelHomog_15(x1,x2,x3,x4,x8);}
 return r;}

extern TUP2 _ARelHomog_20(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6) /* ; */
{TUP2 r;
 CPCLS(__ARelHomog_27,1);
 CPCLS(x1,4);
 FRCLS(x2,1);
 FRCLS(x3,1);
 {OBJ x7;OBJ x8;OBJ x9;OBJ x10;OBJ x11;
  x7=_ACAST_3(x6);
  x8=_ARel_7(x1,x1);
  PRD1(2,x9);FLD1(x9,1)=x8;FLD1(x9,2)=__ABUILTIN_3;
  x10=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ))METHOD(__ARelHomog_27,3))(__ARelHomog_27,x1,x4,x7);
  x11=_ARelReduce_7(x1,x1,x10,x9,x5);
  r=_APair_8(x11);}
 return r;}
extern OBJ _ARelHomog_20_c(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6) /* ; */
{OBJ r;
 {TUP2 t=_ARelHomog_20(x1,x2,x3,x4,x5,x6);
  PRD1(2,r);
  FLD1(r,1)=t.c1;
  FLD1(r,2)=t.c2;}
 return r;}

extern OBJ _ARelHomog_21(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* id'21 */
{OBJ r;
 CPCLS(x1,1);
 COPY(x3,3);
 {OBJ x5;
  x5=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x2,2))(x2,x3,x3);
  r=_ARel_8(x1,x1,x3,x3,x5,x4);}
 return r;}

extern OBJ _ARelHomog_22(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* symmetric?'22 */
{OBJ r;
 CPCLS(x1,1);
 r=_ARel_35(x1,x1,x4,x3,x2);
 return r;}

extern OBJ _ARelHomog_23(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6) /* symClosure'23 */
{OBJ r;
 CPCLS(x1,2);
 COPY(x3,1);
 COPY(x4,1);
 COPY(x6,1);
 {OBJ x7;
  x7=_ARel_35(x1,x1,x4,x3,x6);
  if(ISTGPRM(x7,1)){
   FRCLS(x1,1);
   FRCLS(x2,1);
   FREE(x3,1);
   FREE(x4,1);
   FREE(x5,1);
   r=x6;
  }else{
   CPCLS(x1,1);
   {OBJ x8;
    x8=(*(OBJ(*)(OBJ,OBJ))METHOD(x2,1))(x2,x5);
    r=_ARel_8(x1,x1,x4,x3,x8,x6);}}}
 return r;}

extern OBJ _ARelHomog_24(OBJ x1,OBJ x2,OBJ x3) /* reflexive?'24 */
{OBJ r;
 CPCLS(x1,1);
 COPY(x3,1);
 r=_ARel_35(x1,x1,x3,x3,x2);
 return r;}

extern OBJ _ARelHomog_25(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* refClosure'25 */
{OBJ r;
 CPCLS(x1,2);
 COPY(x3,2);
 COPY(x4,1);
 {OBJ x5;
  x5=_ARel_35(x1,x1,x3,x3,x4);
  if(ISTGPRM(x5,1)){
   FRCLS(x1,1);
   FRCLS(x2,1);
   FREE(x3,1);
   r=x4;
  }else{
   CPCLS(x1,1);
   COPY(x3,3);
   {OBJ x6;
    x6=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x2,2))(x2,x3,x3);
    r=_ARel_8(x1,x1,x3,x3,x6,x4);}}}
 return r;}

extern OBJ _ARelHomog_26(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6,OBJ x7) /* ;'26 */
{OBJ r;
 {OBJ x8=FLD1(x7,1);
  COPY(x8,1);
  CPCLS(x1,2);
  COPY(x3,1);
  COPY(x5,1);
  {OBJ x10;OBJ x11;
   x10=x8;
   COPY(x10,1);
   x11=_ARel_35(x1,x1,x3,x5,x10);
   if(ISTGPRM(x11,1)){
    FRCLS(x1,1);
    FRCLS(x2,1);
    FREE(x3,1);
    FREE(x4,1);
    FREE(x5,1);
    FREE(x6,1);
    FREE(x10,1);
    r=x7;
   }else{
    if(EXPRD(x7,1)){
     FREE(FLD1(x7,1),1);DSPRDF(x7);
    }else{
     DCPRD(x7,1);}
    CPCLS(x1,1);
    {OBJ x12;
     x12=(*(OBJ(*)(OBJ,OBJ,OBJ))METHOD(x2,2))(x2,x4,x6);
     PRD1(2,r);FLD1(r,2)=__ABUILTIN_5;
     FLD1(r,1)=_ARel_8(x1,x1,x3,x5,x12,x10);}}}}
 return r;}

extern OBJ _ARelHomog_27(OBJ x1,OBJ x2,OBJ x3,OBJ x4,OBJ x5,OBJ x6,OBJ x7) /* ;'27 */
{OBJ r;
 CPCLS(x1,1);
 {OBJ x8;
  x8=_AMap_33(x1,x3,x5);
  if(ISPRM(x8)){
   FRCLS(x1,1);
   FRCLS(x2,1);
   FREE(x4,1);
   FREE(x6,1);
   r=x7;
  }else{
   {OBJ x14=FLD1(x8,1);
    if(EXPRD(x8,1)){
     DSPRDF(x8);
    }else{
     COPY(x14,1);
     FRPRD(x8,1);}
    CPCLS(x1,1);
    CPCLS(__ARelHomog_26,1);
    {OBJ x15;
     x15=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ,OBJ))METHOD(__ARelHomog_26,4))(__ARelHomog_26,x1,x2,x4,x6);
     r=_AMapReduce_6(x1,x15,x7,x14);}}}}
 return r;}

static OBJ _mt_7_0_3(OBJ t,OBJ t1,OBJ t2,OBJ t3) 
{OBJ r;
 DPCLS(t,r);
 INCCLS(r,0,3);
 FLDCLS(r,1)=t1;
 FLDCLS(r,2)=t2;
 FLDCLS(r,3)=t3;
 return r;}

static OBJ _mt_7_0_4(OBJ t,OBJ t1,OBJ t2,OBJ t3,OBJ t4) 
{OBJ r;
 DPCLS(t,r);
 INCCLS(r,0,4);
 FLDCLS(r,1)=t1;
 FLDCLS(r,2)=t2;
 FLDCLS(r,3)=t3;
 FLDCLS(r,4)=t4;
 return r;}

static OBJ _mt_7_3_4(OBJ t,OBJ t1,OBJ t2,OBJ t3,OBJ t4) 
{OBJ r;
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  COPY(FLDCLS(t,1),1);
  COPY(FLDCLS(t,2),1);
  COPY(FLDCLS(t,3),1);
  DCCLS(t,1);}
 r=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),FLDCLS(t,2),FLDCLS(t,3),t1,t2,t3,t4);
 return r;}

static OBJ _mt_7_4_3(OBJ t,OBJ t1,OBJ t2,OBJ t3) 
{OBJ r;
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  COPY(FLDCLS(t,1),1);
  COPY(FLDCLS(t,2),1);
  COPY(FLDCLS(t,3),1);
  COPY(FLDCLS(t,4),1);
  DCCLS(t,1);}
 r=(*(OBJ(*)(OBJ,OBJ,OBJ,OBJ,OBJ,OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),FLDCLS(t,2),FLDCLS(t,3),FLDCLS(t,4),t1,t2,t3);
 return r;}

init_ARelHomog()
{
 static int visited=0; if(visited) return; visited=1;
 init_ARel();
 init_ASet();
 init_ANat();
 init_ASeq();
 init_AOption();
 init_APair();
 init_ATriple();
 init_AAnonPair();
 init_ASetReduce();
 init_ARelCompose();
 init_ARelReduce();
 init_ARelNotForUserPurpose();
 init_AMap();
 init_AMapReduce();
 init_AMapFilter();
 init_ASetByBST();
 init_ABSTree();
 init_ATree();
 init_ASeqReduce();
 init_ACAST();
 CLS(7,_ARelHomog_27,__ARelHomog_27);
 CLS(7,_ARelHomog_26,__ARelHomog_26);
 CLS(4,_ARelHomog_25,__ARelHomog_25);
 CLS(3,_ARelHomog_24,__ARelHomog_24);
 CLS(6,_ARelHomog_23,__ARelHomog_23);
 CLS(4,_ARelHomog_22,__ARelHomog_22);
 CLS(4,_ARelHomog_21,__ARelHomog_21);
 CLS(6,_ARelHomog_20_c,__ARelHomog_20);
 CLS(5,_ARelHomog_19,__ARelHomog_19);
 CLS(5,_ARelHomog_18,__ARelHomog_18);
 CLS(5,_ARelHomog_17,__ARelHomog_17);
 CLS(5,_ARelHomog_16,__ARelHomog_16);
 CLS(5,_ARelHomog_15,__ARelHomog_15);
 CLS(5,_ARelHomog_14,__ARelHomog_14);
 CLS(5,_ARelHomog_13,__ARelHomog_13);
 CLS(5,_ARelHomog_12,__ARelHomog_12);
 CLS(5,_ARelHomog_11,__ARelHomog_11);
 CLS(5,_ARelHomog_10,__ARelHomog_10);
 CLS(6,_ARelHomog_9,__ARelHomog_9);
 CLS(6,_ARelHomog_8,__ARelHomog_8);
 CLS(5,_ARelHomog_7,__ARelHomog_7);
 MTH(7,0,3,_mt_7_0_3);LZYMTH(7,0,3,_mt_7_0_3);
 MTH(7,0,4,_mt_7_0_4);LZYMTH(7,0,4,_mt_7_0_4);
 MTH(7,3,4,_mt_7_3_4);LZYMTH(7,3,4,_mt_7_3_4);
 MTH(7,4,3,_mt_7_4_3);LZYMTH(7,4,3,_mt_7_4_3);}

