@@ -90,7 +90,7 @@ type Zero = typeof zeroSymbol;
9090export type Tan = Zero | Var ;
9191
9292/** An abstract natural number, which can be used to index into a vector. */
93- type Nat = number | symbol ;
93+ export type Nat = number | symbol ;
9494
9595/** The portion of an abstract vector that can be directly indexed. */
9696interface VecIndex < T > {
@@ -954,6 +954,56 @@ export const xor = (p: Bool, q: Bool): Bool => {
954954 return newVar ( ctx . block . xor ( ctx . func , boolId ( ctx , p ) , boolId ( ctx , q ) ) ) ;
955955} ;
956956
957+ /** Return an abstract boolean for if `i` is not equal to `j`. */
958+ export const ineq = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
959+ const ctx = getCtx ( ) ;
960+ const t = tyId ( ctx , ty ) ;
961+ return newVar ( ctx . block . ineq ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
962+ } ;
963+
964+ /** Return an abstract boolean for if `i` is less than `j`. */
965+ export const ilt = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
966+ const ctx = getCtx ( ) ;
967+ const t = tyId ( ctx , ty ) ;
968+ return newVar ( ctx . block . ilt ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
969+ } ;
970+
971+ /** Return an abstract boolean for if `i` is less than or equal to `j`. */
972+ export const ileq = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
973+ const ctx = getCtx ( ) ;
974+ const t = tyId ( ctx , ty ) ;
975+ return newVar ( ctx . block . ileq ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
976+ } ;
977+
978+ /** Return an abstract boolean for if `i` is equal to `j`. */
979+ export const ieq = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
980+ const ctx = getCtx ( ) ;
981+ const t = tyId ( ctx , ty ) ;
982+ return newVar ( ctx . block . ieq ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
983+ } ;
984+
985+ /** Return an abstract boolean for if `i` is greater than `j`. */
986+ export const igt = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
987+ const ctx = getCtx ( ) ;
988+ const t = tyId ( ctx , ty ) ;
989+ return newVar ( ctx . block . igt ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
990+ } ;
991+
992+ /** Return an abstract boolean for if `i` is greater than or equal to `j`. */
993+ export const igeq = ( ty : Nats , i : Nat , j : Nat ) : Bool => {
994+ const ctx = getCtx ( ) ;
995+ const t = tyId ( ctx , ty ) ;
996+ return newVar ( ctx . block . igeq ( ctx . func , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ) ;
997+ } ;
998+
999+ /** Return the abstract index `i` plus the abstract index `y`. */
1000+ export const iadd = ( ty : Nats , i : Nat , j : Nat ) : Nat => {
1001+ const ctx = getCtx ( ) ;
1002+ const t = tyId ( ctx , ty ) ;
1003+ const k = ctx . block . iadd ( ctx . func , t , valId ( ctx , t , i ) , valId ( ctx , t , j ) ) ;
1004+ return idVal ( ctx , t , k ) as Nat ;
1005+ } ;
1006+
9571007/** Return an abstract value selecting between `then` and `els` via `cond`. */
9581008export const select = < const T > (
9591009 cond : Bool ,
0 commit comments