19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

extends { BinaryOperatorT, ⊙, UnaryOperatorT, ∼, EquivalenceRelationT, = }<br />

where { T coerces ComplementBound⊙ }<br />

property ∀(a:T) (a ⊙ (∼ a)) :=: ComplementBound⊙<br />

end<br />

A set of values with a binary operator ⊙ has complements if and only if there is a specific value e such that for every<br />

value a there is another value a ′ such that the result of applying ⊙ to a and a ′ (in either order) equals the specified<br />

value e . This value may be obtained by coercing the object named ComplementBound⊙ to type T . <strong>The</strong> unary<br />

operator ∼ returns the complement of its argument with respect to the operator ⊙ .<br />

Note that the trait HasComplements is similar to the trait HasInverses, but HasComplements does not require that<br />

that specified element be an identity of the binary operator.<br />

trait DeMorganT extends DeMorganT, , , ∼,opr ,opr ,opr ∼<br />

extends { BinaryOperatorT, , BinaryOperatorT, ,<br />

UnaryOperatorT, ∼, EquivalenceRelationT, = }<br />

property ∀(a:T, b: T) (∼ (a b)) :=: ((∼ a) (∼ b))<br />

end<br />

This trait expresses De Morgan’s law for two binary operators and and a unary operator ∼ : the expressions<br />

∼ (a b) and (∼ a) (∼ b) produce equal results.<br />

trait BooleanAlgebraT extends BooleanAlgebraT, , , ∼, ∨,opr ,opr ,opr ∼,opr ∨<br />

extends { CommutativeT, , AssociativeT, ,<br />

CommutativeT, , AssociativeT, ,<br />

IdempotentBinaryOperatorT, ,<br />

IdempotentBinaryOperatorT, ,<br />

HasIdentityT, , HasIdentityT, ,<br />

HasComplementsT, , ∼, HasComplementsT, , ∼,<br />

DistributiveT, , , DistributiveT, , ,<br />

DeMorganT, , , ∼, DeMorganT, , , ∼,<br />

RingT, ∨,IDENTITY, }<br />

property ∀(a:T) (∼ (∼ a)) :=: a<br />

opr ∨(self,other: T):T = (self (∼ other)) ((∼ self) other)<br />

property castT(Identity∨) = castT(Identity)<br />

property castT(ComplementBound) = castT(Identity)<br />

property castT(ComplementBound) = castT(Identity)<br />

end<br />

A boolean algebra is an algebraic structure consisting of a set of values, three binary operators , , and ∨ , and a<br />

unary operator ∼ , such that the operators obey a number of specific properties:<br />

• is commutative, associative, and idempotent, and has a unique identity<br />

• is commutative, associative, and idempotent, and has a unique identity<br />

• has complements with respect to ∼<br />

• has complements with respect to ∼<br />

• and distribute over each other<br />

• De Morgan’s law applies to , , and ∼ , and also to , , and ∼<br />

• <strong>The</strong> values form a ring with ∨ as the addition operator, IDENTITY as the additive inverse operator, and as<br />

the multiplication operator<br />

260

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!