dwolter_SparQ/Calculi/cycord_ternary.lisp
;;; 
;;; CYCORD(X,Y,Z)

;;;

(def-calculus "CYCORD Calculus (CC)"
  :arity :ternary
  :basis-entity :1d-point ;; orientation
  :parametric? nil
  ;;:qualifier (external-lib "libdcc.dylib" "cc_qualify")
  :identity-relation eee
  :inverse-operation ((eee eee)
		      (ell ell)
		      (eoo eoo)
		      (err err)
		      (lel rle)
		      (lll rll)
		      (llo rol)
		      (llr rrl)
		      (lor rro)
		      (lre rer)
		      (lrl rlr)
		      (lrr rrr)
		      (oeo ooe)
		      (olr orl)
		      (ooe oeo)
		      (orl olr)
		      (rer lre)
		      (rle lel)
		      (rll lll)
		      (rlr lrl)
		      (rol llo)
		      (rrl llr)
		      (rro lor)
		      (rrr lrr)
		      )

  :shortcut-operation ((eee eee)
		       (ell lre)
		       (eoo ooe)
		       (err rle)
		       (lel lel)
		       (lll lrl)
		       (llo orl)
		       (llr rrl)
		       (lor rol)
		       (lre ell)
		       (lrl lll)
		       (lrr rll)
		       (oeo oeo)
		       (olr rro)
		       (ooe eoo)
		       (orl llo)
		       (rer rer)
		       (rle err)
		       (rll lrr)
		       (rlr rrr)
		       (rol lor)
		       (rrl llr)
		       (rro olr)
		       (rrr rlr)
		       )

  :homing-operation ((eee eee)
		     (ell lre)
		     (eoo ooe)
		     (err rle)
		     (lel err)
		     (lll lrr)
		     (llo lor)
		     (llr llr)
		     (lor olr)
		     (lre rer)
		     (lrl rrr)
		     (lrr rlr)
		     (oeo eoo)
		     (olr llo)
		     (ooe oeo)
		     (orl rro)
		     (rer ell)
		     (rle lel)
		     (rll lrl)
		     (rlr lll)
		     (rol orl)
		     (rrl rrl)
		     (rro rol)
		     (rrr rll)
		     )
  
  :base-relations ( eee ell eoo err 
		    lel lll llo llr 
		    lor lre lrl lrr 
		    oeo olr ooe orl 
		    rer rle rll rlr 
		    rol rrl rro rrr )
  
  :composition-operation ( 
			  ;; Case 1: b3 = b1' = e
			  ( eee eee (eee))
			  ( eee ell (ell))
			  ( eee eoo (eoo))
			  ( eee err (err))
			  ( lre eee (lre))
			  ( lre ell (lel ell lrl)) ;; E1
			  ( lre eoo (llo))
			  ( lre err (llr lor lrr)) ;; E2
			  ( ooe eee (ooe))
			  ( ooe ell (orl))
			  ( ooe eoo (oeo))
			  ( ooe err (olr))
			  ( rle eee (rle))
			  ( rle ell (rll rol rrl)) ;; E4
			  ( rle eoo (rro))
			  ( rle err (rer rlr rrr)) ;; E3

			  ;; Case 2: b3 = b1' = l
			  ( ell lel (ell))
			  ( ell lll (ell))
			  ( ell llo (eoo))
			  ( ell llr (err))
			  ( ell lor (err))
			  ( ell lre (eee))
			  ( ell lrl (ell))
			  ( ell lrr (err))
			  ( lel lel (lel))
			  ( lel lll (lll))
			  ( lel llo (llo))
			  ( lel llr (llr))
			  ( lel lor (lor))
			  ( lel lre (lre))
			  ( lel lrl (lrl))
			  ( lel lrr (lrr))

			  ( lll lel (lll))
			  ( lll lll (lll))
			  ( lll llo (llo))
			  ( lll llr (llr lor lrr)) ;; E2
			  ( lll lor (lrr))
			  ( lll lre (lre))
			  ( lll lrl (lel ell lrl)) ;; E1
			  ( lll lrr (lrr))

			  ( lrl lel (lrl))
			  ( lrl lll (lel ell lrl)) ;; E1
			  ( lrl llo (llo))
			  ( lrl llr (llr))
			  ( lrl lor (llr))
			  ( lrl lre (lre))
			  ( lrl lrl (lrl))
			  ( lrl lrr (llr lor lrr)) ;; E2

			  ( orl lel (orl))
			  ( orl lll (orl))
			  ( orl llo (oeo))
			  ( orl llr (olr))
			  ( orl lor (olr))
			  ( orl lre (ooe))
			  ( orl lrl (orl))
			  ( orl lrr (olr))

			  ( rll lel (rll))
			  ( rll lll (rll rol rrl)) ;; E4
			  ( rll llo (rro))
			  ( rll llr (rrr))
			  ( rll lor (rrr))
			  ( rll lre (rle))
			  ( rll lrl (rll))
			  ( rll lrr (rer rlr rrr)) ;; E3

			  ( rol lel (rol))
			  ( rol lll (rrl))
			  ( rol llo (rro))
			  ( rol llr (rrr))
			  ( rol lor (rer))
			  ( rol lre (rle))
			  ( rol lrl (rll))
			  ( rol lrr (rlr))

			  ( rrl lel (rrl))
			  ( rrl lll (rrl))
			  ( rrl llo (rro))
			  ( rrl llr (rer rlr rrr)) ;; E3
			  ( rrl lor (rlr))
			  ( rrl lre (rle))
			  ( rrl lrl (rll rol rrl)) ;; E4
			  ( rrl lrr (rlr))
			  
			  ;; Case 3: b3 = b1' = o
			  ( eoo oeo (eoo))
			  ( eoo olr (err))
			  ( eoo ooe (eee))
			  ( eoo orl (ell))
			  ( llo oeo (llo))
			  ( llo olr (llr lor lrr)) ;; E2
			  ( llo ooe (lre))
			  ( llo orl (lel lll lrl)) ;; E1
			  ( oeo oeo (oeo))
			  ( oeo olr (olr))
			  ( oeo ooe (ooe))
			  ( oeo orl (orl))
			  ( rro oeo (rro))
			  ( rro olr (rer rlr rrr)) ;; E3
			  ( rro ooe (rle))
			  ( rro orl (rll rol rrl)) ;; E4

			  ;; Case 4: b3 = b1' = r
			  ( err rer (err))
			  ( err rle (eee))
			  ( err rll (ell))
			  ( err rlr (err))
			  ( err rol (ell))
			  ( err rrl (ell))
			  ( err rro (eoo))
			  ( err rrr (err))

			  ( llr rer (llr))
			  ( llr rle (lre))
			  ( llr rll (lrl))
			  ( llr rlr (llr lor lrr)) ;; E2
			  ( llr rol (lrl))
			  ( llr rrl (lel ell lrl)) ;; E1
			  ( llr rro (llo))
			  ( llr rrr (llr))

			  ( lor rer (lor))
			  ( lor rle (lre))
			  ( lor rll (lrl))
			  ( lor rlr (lrr))
			  ( lor rol (lel))
			  ( lor rrl (lll))
			  ( lor rro (llo))
			  ( lor rrr (llr))

			  ( lrr rer (lrr))
			  ( lrr rle (lre))
			  ( lrr rll (lel ell lrl)) ;; E1
			  ( lrr rlr (lrr))
			  ( lrr rol (lll))
			  ( lrr rrl (lll))
			  ( lrr rro (llo))
			  ( lrr rrr (llr lor lrr)) ;; E2

			  ( olr rer (olr))
			  ( olr rle (ooe))
			  ( olr rll (orl))
			  ( olr rlr (olr))
			  ( olr rol (orl))
			  ( olr rrl (orl))
			  ( olr rro (oeo))
			  ( olr rrr (olr))

			  ( rer rer (rer))
			  ( rer rle (rle))
			  ( rer rll (rll))
			  ( rer rlr (rlr))
			  ( rer rol (rol))
			  ( rer rrl (rrl))
			  ( rer rro (rro))
			  ( rer rrr (rrr))

			  ( rlr rer (rlr))
			  ( rlr rle (rle))
			  ( rlr rll (rll rol rrl)) ;; E4
			  ( rlr rlr (rlr))
			  ( rlr rol (rrl))
			  ( rlr rrl (rrl))
			  ( rlr rro (rro))
			  ( rlr rrr (rer rlr rrr)) ;; E3

			  ( rrr rer (rrr))
			  ( rrr rle (rle))
			  ( rrr rll (rll))
			  ( rrr rlr (rer rlr rrr)) ;; E3
			  ( rrr rol (rll))
			  ( rrr rrl (rll rol rrl)) ;; E4
			  ( rrr rro (rro))
			  ( rrr rrr (rrr))
			  
			  ;;; Group 1 
			  ( ell eee ())
			  ( ell ell ())
			  ( ell eoo ())
			  ( ell err ())
			  
			  ( eoo eee ())
			  ( eoo ell ())
			  ( eoo eoo ())
			  ( eoo err ())
			  
			  ( err eee ())
			  ( err ell ())
			  ( err eoo ())
			  ( err err ())
			  
			  ( lel eee ())
			  ( lel ell ())
			  ( lel eoo ())
			  ( lel err ())
			  
			  ( lll eee ())
			  ( lll ell ())
			  ( lll eoo ())
			  ( lll err ())
			  
			  ( llo eee ())
			  ( llo ell ())
			  ( llo eoo ())
			  ( llo err ())
			  
			  ( llr eee ())
			  ( llr ell ())
			  ( llr eoo ())
			  ( llr err ())
			  
			  ( lor eee ())
			  ( lor ell ())
			  ( lor eoo ())
			  ( lor err ())
			  
			  ( lrl eee ())
			  ( lrl ell ())
			  ( lrl eoo ())
			  ( lrl err ())
			  
			  ( lrr eee ())
			  ( lrr ell ())
			  ( lrr eoo ())
			  ( lrr err ())
			  
			  ( oeo eee ())
			  ( oeo ell ())
			  ( oeo eoo ())
			  ( oeo err ())
			  
			  ( olr eee ())
			  ( olr ell ())
			  ( olr eoo ())
			  ( olr err ())
			  
			  ( orl eee ())
			  ( orl ell ())
			  ( orl eoo ())
			  ( orl err ())
			  
			  ( rer eee ())
			  ( rer ell ())
			  ( rer eoo ())
			  ( rer err ())
			  
			  ( rll eee ())
			  ( rll ell ())
			  ( rll eoo ())
			  ( rll err ())
			  
			  ( rlr eee ())
			  ( rlr ell ())
			  ( rlr eoo ())
			  ( rlr err ())
			  
			  ( rol eee ())
			  ( rol ell ())
			  ( rol eoo ())
			  ( rol err ())
			  
			  ( rrl eee ())
			  ( rrl ell ())
			  ( rrl eoo ())
			  ( rrl err ())

			  ( rro eee ())
			  ( rro ell ())
			  ( rro eoo ())
			  ( rro err ())
			  
			  ( rrr eee ())
			  ( rrr ell ())
			  ( rrr eoo ())
			  ( rrr err ())
			  
;;; Group 3 
			  ( eee oeo ())
			  ( eee olr ())
			  ( eee ooe ())
			  ( eee orl ())
			  
			  ( ell oeo ())
			  ( ell olr ())
			  ( ell ooe ())
			  ( ell orl ())
			  
			  ( err oeo ())
			  ( err olr ())
			  ( err ooe ())
			  ( err orl ())
			  
			  ( lel oeo ())
			  ( lel olr ())
			  ( lel ooe ())
			  ( lel orl ())
			  
			  ( lll oeo ())
			  ( lll olr ())
			  ( lll ooe ())
			  ( lll orl ())
			  
			  ( llr oeo ())
			  ( llr olr ())
			  ( llr ooe ())
			  ( llr orl ())

			  ( lor oeo ())
			  ( lor olr ())
			  ( lor ooe ())
			  ( lor orl ())
			  
			  ( lre oeo ())
			  ( lre olr ())
			  ( lre ooe ())
			  ( lre orl ())
			  
			  ( lrl oeo ())
			  ( lrl olr ())
			  ( lrl ooe ())
			  ( lrl orl ())
			  
			  ( lrr oeo ())
			  ( lrr olr ())
			  ( lrr ooe ())
			  ( lrr orl ())
			  
			  ( olr oeo ())
			  ( olr olr ())
			  ( olr ooe ())
			  ( olr orl ())
			  
			  ( ooe oeo ())
			  ( ooe olr ())
			  ( ooe ooe ())
			  ( ooe orl ())
			  
			  ( orl oeo ())
			  ( orl olr ())
			  ( orl ooe ())
			  ( orl orl ())
			  
			  ( rer oeo ())
			  ( rer olr ())
			  ( rer ooe ())
			  ( rer orl ())
			  
			  ( rle oeo ())
			  ( rle olr ())
			  ( rle ooe ())
			  ( rle orl ())
			  
			  ( rll oeo ())
			  ( rll olr ())
			  ( rll ooe ())
			  ( rll orl ())
			  
			  ( rlr oeo ())
			  ( rlr olr ())
			  ( rlr ooe ())
			  ( rlr orl ())
			  
			  ( rol oeo ())
			  ( rol olr ())
			  ( rol ooe ())
			  ( rol orl ())
			  
			  ( rrl oeo ())
			  ( rrl olr ())
			  ( rrl ooe ())
			  ( rrl orl ())
			  
			  ( rrr oeo ())
			  ( rrr olr ())
			  ( rrr ooe ())
			  ( rrr orl ())
			  
;;; Group 2 
			  ( eee lel ())
			  ( eee lll ())
			  ( eee llo ())
			  ( eee llr ())
			  ( eee lor ())
			  ( eee lre ())
			  ( eee lrl ())
			  ( eee lrr ())
			  
			  ( eoo lel ())
			  ( eoo lll ())
			  ( eoo llo ())
			  ( eoo llr ())
			  ( eoo lor ())
			  ( eoo lre ())
			  ( eoo lrl ())
			  ( eoo lrr ())
			  
			  ( err lel ())
			  ( err lll ())
			  ( err llo ())
			  ( err llr ())
			  ( err lor ())
			  ( err lre ())
			  ( err lrl ())
			  ( err lrr ())
			  
			  ( llo lel ())
			  ( llo lll ())
			  ( llo llo ())
			  ( llo llr ())
			  ( llo lor ())
			  ( llo lre ())
			  ( llo lrl ())
			  ( llo lrr ())
			  
			  ( llr lel ())
			  ( llr lll ())
			  ( llr llo ())
			  ( llr llr ())
			  ( llr lor ())
			  ( llr lre ())
			  ( llr lrl ())
			  ( llr lrr ())
			  
			  ( lor lel ())
			  ( lor lll ())
			  ( lor llo ())
			  ( lor llr ())
			  ( lor lor ())
			  ( lor lre ())
			  ( lor lrl ())
			  ( lor lrr ())
			  
			  ( lre lel ())
			  ( lre lll ())
			  ( lre llo ())
			  ( lre llr ())
			  ( lre lor ())
			  ( lre lre ())
			  ( lre lrl ())
			  ( lre lrr ())
			  
			  ( lrr lel ())
			  ( lrr lll ())
			  ( lrr llo ())
			  ( lrr llr ())
			  ( lrr lor ())
			  ( lrr lre ())
			  ( lrr lrl ())
			  ( lrr lrr ())
			  
			  ( oeo lel ())
			  ( oeo lll ())
			  ( oeo llo ())
			  ( oeo llr ())
			  ( oeo lor ())
			  ( oeo lre ())
			  ( oeo lrl ())
			  ( oeo lrr ())
			  
			  ( olr lel ())
			  ( olr lll ())
			  ( olr llo ())
			  ( olr llr ())
			  ( olr lor ())
			  ( olr lre ())
			  ( olr lrl ())
			  ( olr lrr ())
			  
			  ( ooe lel ())
			  ( ooe lll ())
			  ( ooe llo ())
			  ( ooe llr ())
			  ( ooe lor ())
			  ( ooe lre ())
			  ( ooe lrl ())
			  ( ooe lrr ())
			  
			  ( rer lel ())
			  ( rer lll ())
			  ( rer llo ())
			  ( rer llr ())
			  ( rer lor ())
			  ( rer lre ())
			  ( rer lrl ())
			  ( rer lrr ())
			  
			  ( rle lel ())
			  ( rle lll ())
			  ( rle llo ())
			  ( rle llr ())
			  ( rle lor ())
			  ( rle lre ())
			  ( rle lrl ())
			  ( rle lrr ())
			  
			  ( rlr lel ())
			  ( rlr lll ())
			  ( rlr llo ())
			  ( rlr llr ())
			  ( rlr lor ())
			  ( rlr lre ())
			  ( rlr lrl ())
			  ( rlr lrr ())
			  
			  ( rro lel ())
			  ( rro lll ())
			  ( rro llo ())
			  ( rro llr ())
			  ( rro lor ())
			  ( rro lre ())
			  ( rro lrl ())
			  ( rro lrr ())
			  
			  ( rrr lel ())
			  ( rrr lll ())
			  ( rrr llo ())
			  ( rrr llr ())
			  ( rrr lor ())
			  ( rrr lre ())
			  ( rrr lrl ())
			  ( rrr lrr ())
			  
;;; Group 4 
			  ( eee rer ())
			  ( eee rle ())
			  ( eee rll ())
			  ( eee rlr ())
			  ( eee rol ())
			  ( eee rrl ())
			  ( eee rro ())
			  ( eee rrr ())
			  
			  ( ell rer ())
			  ( ell rle ())
			  ( ell rll ())
			  ( ell rlr ())
			  ( ell rol ())
			  ( ell rrl ())
			  ( ell rro ())
			  ( ell rrr ())
			  
			  ( eoo rer ())
			  ( eoo rle ())
			  ( eoo rll ())
			  ( eoo rlr ())
			  ( eoo rol ())
			  ( eoo rrl ())
			  ( eoo rro ())
			  ( eoo rrr ())
			  
			  ( lel rer ())
			  ( lel rle ())
			  ( lel rll ())
			  ( lel rlr ())
			  ( lel rol ())
			  ( lel rrl ())
			  ( lel rro ())
			  ( lel rrr ())
			  
			  ( lll rer ())
			  ( lll rle ())
			  ( lll rll ())
			  ( lll rlr ())
			  ( lll rol ())
			  ( lll rrl ())
			  ( lll rro ())
			  ( lll rrr ())
			  
			  ( llo rer ())
			  ( llo rle ())
			  ( llo rll ())
			  ( llo rlr ())
			  ( llo rol ())
			  ( llo rrl ())
			  ( llo rro ())
			  ( llo rrr ())
			  
			  ( lre rer ())
			  ( lre rle ())
			  ( lre rll ())
			  ( lre rlr ())
			  ( lre rol ())
			  ( lre rrl ())
			  ( lre rro ())
			  ( lre rrr ())
			  
			  ( lrl rer ())
			  ( lrl rle ())
			  ( lrl rll ())
			  ( lrl rlr ())
			  ( lrl rol ())
			  ( lrl rrl ())
			  ( lrl rro ())
			  ( lrl rrr ())
			  
			  ( oeo rer ())
			  ( oeo rle ())
			  ( oeo rll ())
			  ( oeo rlr ())
			  ( oeo rol ())
			  ( oeo rrl ())
			  ( oeo rro ())
			  ( oeo rrr ())
			  
			  ( ooe rer ())
			  ( ooe rle ())
			  ( ooe rll ())
			  ( ooe rlr ())
			  ( ooe rol ())
			  ( ooe rrl ())
			  ( ooe rro ())
			  ( ooe rrr ())
			  
			  ( orl rer ())
			  ( orl rle ())
			  ( orl rll ())
			  ( orl rlr ())
			  ( orl rol ())
			  ( orl rrl ())
			  ( orl rro ())
			  ( orl rrr ())
			  
			  ( rle rer ())
			  ( rle rle ())
			  ( rle rll ())
			  ( rle rlr ())
			  ( rle rol ())
			  ( rle rrl ())
			  ( rle rro ())
			  ( rle rrr ())
			  
			  ( rll rer ())
			  ( rll rle ())
			  ( rll rll ())
			  ( rll rlr ())
			  ( rll rol ())
			  ( rll rrl ())
			  ( rll rro ())
			  ( rll rrr ())
			  
			  ( rol rer ())
			  ( rol rle ())
			  ( rol rll ())
			  ( rol rlr ())
			  ( rol rol ())
			  ( rol rrl ())
			  ( rol rro ())
			  ( rol rrr ())
			  
			  ( rrl rer ())
			  ( rrl rle ())
			  ( rrl rll ())
			  ( rrl rlr ())
			  ( rrl rol ())
			  ( rrl rrl ())
			  ( rrl rro ())
			  ( rrl rrr ())
			  
			  ( rro rer ())
			  ( rro rle ())
			  ( rro rll ())
			  ( rro rlr ())
			  ( rro rol ())
			  ( rro rrl ())
			  ( rro rro ())
			  ( rro rrr ())
			  
			  )
  ) ;; end def-calculus
