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.

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

end<br />

An irreflexive predicate always returns false when its operands are the same. (Note that it is possible for a predicate<br />

to be neither reflexive nor irreflexive.)<br />

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

extends { BinaryPredicateT, ∼ }<br />

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

end<br />

A symmetric predicate doesn’t care in which order its arguments are presented; the result is the same either way.<br />

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

extends { BinaryPredicateT, ∼ }<br />

property ∀(a:T, b: T, c:T) ((a ∼ b) ∧ (b ∼ c)) → (a ∼ c)<br />

end<br />

A transitive predicate has the property that if a is related to b and b is related to c , then a is related to c .<br />

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

extends { ReflexiveT, ∼, SymmetricT, ∼, TransitiveT, ∼ }<br />

end<br />

An equivalence relation is any predicate that is reflexive, symmetric, and transitive. You can think of an equivalence<br />

relation as describing a way to separate a set of items into categories, such that each item belongs to exactly one<br />

category; the predicate is true of two items if and only if they are in the same category.<br />

trait IdentityEqualityT extends IdentityEqualityT<br />

extends { EquivalenceRelationT, = }<br />

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

end<br />

This trait provides a concrete implementation of the operator = (defining it to behave the same as the operator = )<br />

and states that = is an equivalence relation over instances of the type T .<br />

trait UnaryPredicateSubstitutionLawsT extends UnaryPredicateSubstitutionLawsT, ∼, ≃,<br />

opr ∼,opr ≃<br />

extends { UnaryPredicateT, ∼, BinaryPredicateT, ≃ }<br />

property ∀(a:T, a ′ : T) (a ≃ a ′ ) →:((∼ a) ↔ (∼ a ′ ))<br />

end<br />

This handy trait states that the unary predicate ∼ is consistent under substitutions described by the relation ≃ (which<br />

is typically, but not always, an equivalence relation); that is, the result produced by ∼ is unchanged if its argument is<br />

replaced by some other value that is equivalent.<br />

trait BinaryPredicateSubstitutionLawsT extends BinaryPredicateSubstitutionLawsT, ∼, ≃,<br />

opr ∼,opr ≃<br />

extends { BinaryPredicateT, ∼, BinaryPredicateT, ≃ }<br />

property ∀(a:T, a ′ : T) (a ≃ a ′ ) →: ∀(b: T) (a ∼ b) ↔ (a ′ ∼ b)<br />

property ∀(b: T, b ′ : T) (b ≃ b ′ ) →: ∀(a: T) (a ∼ b) ↔ (a ∼ b ′ )<br />

end<br />

This equally handy trait states that the binary predicate ∼ is consistent under substitutions described by the relation<br />

≃ (which is typically, but not always, an equivalence relation); that is, the result produced by ∼ is unchanged if either<br />

247

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

Saved successfully!

Ooh no, something went wrong!