Module type_level_logic::strong::ternary [] [src]

Type-level ternary operations, with "strongly" enforced validity. In this module documentation, unsigned ternary numbers will be referred to as Nats (because they're a representation of the natural numbers), "natural numbers" (see preceding), or "unsigned numbers".

For more information, see the documentation for the Nat trait.

Reexports

pub use types::ternary::*;

Traits

Nat2P1

Project the first value in a NatPair.

Nat2P2

Project the second value in a NatPair.

NatAdd

Nat addition. Used as Add<X, Y> or <X as NatAdd<Y>>::Output.

NatCmp

Nat comparison. If the first argument is less than the second, return the third argument; else if the first argument is equal to the second, then return the fourth argument; else, return the fifth argument.

NatDiv

Nat truncating division. Used as Div<X, Y> or <X as NatDiv<Y>>::Output. Returns Undefined in the case of a division by zero.

NatDivInternal
NatDoublePred

The DoublePred operator subtracts two from a Nat. It is defined for Nats greater than one, and can be used as DoublePred<X> or <X as NatDoublePred>::Output.

NatMul

Nat multiplication. Used as Mul<X, Y> or <X as NatMul<Y>>::Output.

NatPred

The Pred operator subtracts one from a Nat. It is defined for non-zero Nats, and can be used as Pred<X> or <X as NatPred>::Output.

NatRem

Nat remainder. Used as Rem<X, Y> or <X as NatRem<Y>>::Output. Returns Undefined in the case of a division by zero.

NatRev

Nat reversal. This is probably something you never want to do! However, it's useful in implementing division, in which we wish to access trits with the most-significant trits first. This reverses all the trits of the integer.

NatRevInternal
NatSub

Nat subtraction. Used as Sub<X, Y> or <X as NatSub<Y>>::Output. Undefined for any inputs which would result in an output less than zero. If you need signed numbers, you should probably be using a signed representation, such as balanced ternary.

NatSucc

The Succ operator adds one to a Nat. It is always defined. It can be used as Succ<X> or <X as NatSucc>::Output.

NatTriple

The Triple operator triples a Nat, and avoids a single level of redundant zeroes (and thus helps to preserve unique representations.) It is equivalent to Zero<N> unless N is Term, in which case Triple<Term> = Term. Its collapsing acts at only one level, which should be sufficient unless multiple levels of redundant zeroes are introduced by user error. It also propagates undefined values: Triple<Undefined> = Undefined.

NatTriplePlusOne

A convenience operator for propagating undefined values.

NatTriplePlusTwo

A convenience operator for propagating undefined values.

NatUndefOr2

Nat undefined-or with pair - if the first argument is undefined, return the pair passed in as the third argument; else, return the first paired with the second argument.

NatUnique

The Unique operator collapses one level of redundant zeroes in a ternary representation. Using Unique every time we might get a redundant zero should get rid of any potential problems with non-unique representations of zero.

Type Definitions

Add
Cmp
Div
DivInternal
DoublePred
Mul
Nat2First
Nat2Second
Pred
Rem
Rev
RevInternal
Sub
Succ
Triple
TriplePlusOne
TriplePlusTwo
UndefOr2
Unique