

#include "BUILTIN.h"
extern OBJ _AMap_23(OBJ,OBJ);extern OBJ __AMap_23;
extern OBJ _AMap_31(OBJ,OBJ,OBJ,OBJ);extern OBJ __AMap_31;

#include "Nat.h"
extern OBJ _AMapReduce_6(OBJ,OBJ,OBJ,OBJ);extern OBJ __AMapReduce_6;
extern OBJ __ATree_7;
extern OBJ _AMapInvert_5(OBJ,OBJ,OBJ);OBJ __AMapInvert_5; /* invert */
extern OBJ _AMapInvert_6(OBJ,OBJ,OBJ,OBJ);OBJ __AMapInvert_6; /* invert'6 */

extern OBJ _AMapInvert_5(OBJ x1,OBJ x2,OBJ x3) /* invert */
{OBJ r;
 CPCLS(__AMapInvert_6,1);
 CPCLS(x1,1);
 CPCLS(x2,1);
 COPY(x3,1);
 {OBJ x4;OBJ x5;OBJ x6;OBJ x7;OBJ x8;
  x4=_AMap_23(x1,x3);
  x5=(*(OBJ(*)(OBJ,OBJ))METHOD(__AMapInvert_6,1))(__AMapInvert_6,x2);
  x6=_AMapReduce_6(x1,x5,__ATree_7,x3);
  COPY(x6,1);
  x7=_AMap_23(x2,x6);
  ANat_76(x4,x7,x8);
  if(ISTGPRM(x8,1)){
   r=x6;
  }else{
   HLT("invert\'MapInvert: mapping not injective");}}
 return r;}

extern OBJ _AMapInvert_6(OBJ x1,OBJ x2,OBJ x3,OBJ x4) /* invert'6 */
{OBJ r;
 r=_AMap_31(x1,x3,x2,x4);
 return r;}

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

static OBJ _mt_3_2_1(OBJ t,OBJ t1) 
{OBJ r;
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  COPY(FLDCLS(t,1),1);
  COPY(FLDCLS(t,2),1);
  DCCLS(t,1);}
 r=(*(OBJ(*)(OBJ,OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),FLDCLS(t,2),t1);
 return r;}
static OBJ _mt_3_2_1_l(OBJ t,OBJ t1) 
{OBJ r;
 r=(*(OBJ(*)(OBJ,OBJ,OBJ))ENTRY(t))(FLDCLS(t,1),FLDCLS(t,2),t1);
 if(EXCLS(t)){
  DSCLSF(t);
 }else{
  DCCLS(t,1);
  FLDCLS(t,1)=NIL;FLDCLS(t,2)=NIL;
  COPY(r,1);LZYCLS(t,r);}
 return r;}

init_AMapInvert()
{
 static int visited=0; if(visited) return; visited=1;
 init_AMap();
 init_ANat();
 init_AOption();
 init_ASet();
 init_ASeq();
 init_APair();
 init_AMapReduce();
 init_ASetByBST();
 init_ABSTree();
 init_ATree();
 CLS(4,_AMapInvert_6,__AMapInvert_6);
 CLS(3,_AMapInvert_5,__AMapInvert_5);
 MTH(3,0,2,_mt_3_0_2);LZYMTH(3,0,2,_mt_3_0_2);
 MTH(3,2,1,_mt_3_2_1);LZYMTH(3,2,1,_mt_3_2_1_l);}

