19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

end<br />

<strong>The</strong> trait PartialOrderBasedOnLE specifies a partial order by assuming that the “less than or equal to” predicate is<br />

already defined and providing definitions for the comparison operator, the “less than” predicate, the equality predicate,<br />

the “greater than or equal to” predicate, and the “greater than” predicate in terms of the “less than or equal to” predicate.<br />

trait TotalOrderBasedOnLET extends TotalOrderBasedOnLET, ≺, , , ≻,CMP,<br />

opr ≺,opr ,opr ,opr ≻,opr CMP<br />

extends { TotalOrderOperatorsT, ≺, , , ≻,CMP }<br />

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

if a b then (if b a then EqualTo else LessThan end) else GreaterThan end<br />

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

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

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

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

end<br />

<strong>The</strong> trait TotalOrderBasedOnLE specifies a total order by assuming that the “less than or equal to” predicate is<br />

already defined and providing definitions for the comparison operator, the “less than” predicate, the equality predicate,<br />

the “greater than or equal to” predicate, and the “greater than” predicate in terms of the “less than or equal to” predicate.<br />

trait TotalOrderBasedOnLTT extends TotalOrderBasedOnLTT, ≺, , , ≻,CMP,<br />

opr ≺,opr ,opr ,opr ≻,opr CMP<br />

extends { TotalOrderOperatorsT, ≺, , , ≻,CMP }<br />

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

if a ≺ b then LessThan elif b ≺ a then GreaterThan else EqualTo end<br />

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

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

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

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

end<br />

<strong>The</strong> trait TotalOrderBasedOnLT specifies a total order by assuming that the “less than” predicate is already defined<br />

and providing definitions for the comparison operator, the “less than or equal to” predicate, the equality predicate, the<br />

“greater than or equal to” predicate, and the “greater than” predicate in terms of the “less than” predicate.<br />

value object MaximalElementopr end<br />

trait HasMaximalElementT extends HasMaximalElementT, ,opr <br />

extends { PartialOrderT, }<br />

where { T coerces MaximalElement≼ }<br />

property ∀(a :T) a MaximalElement≼<br />

end<br />

<strong>The</strong> HasMaximalElement trait specifies that a partial order has a maximal element, that is, one to which every other<br />

element is related by the ordering predicate . <strong>The</strong> maximal element may be identified by coercing the object named<br />

MaximalElement≼ to type T .<br />

value object MinimalElementopr end<br />

trait HasMinimalElementT extends HasMinimalElementT, ,opr <br />

extends { PartialOrderT, }<br />

where { T coerces MinimalElement≼ }<br />

property ∀(a :T) MinimalElement≼ a<br />

end<br />

250

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

Saved successfully!

Ooh no, something went wrong!