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.

argument is replaced by some other value that is equivalent. (It is then easy to prove that the result is unchanged even<br />

when both arguments are replaced by equivalent values.)<br />

37.2 Partial and Total Orders<br />

trait AntisymmetricT extends AntiSymmetricT, ∼,opr ∼<br />

extends { BinaryPredicateT, ∼, EquivalenceRelationT, =,<br />

BinaryPredicateSubstitutionLawsT, ∼, = }<br />

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

end<br />

A binary predicate ∼ is antisymmetric if and only if two conditions are true: (a) ∼ is consistent under substitutions<br />

described by the predicate = , which must be an equivalence relation; (b) whenever ∼ holds true for a pair of<br />

arguments and for those same arguments in reverse order, those arguments are equivalent as specified by = .<br />

trait PartialOrderT extends PartialOrderT, ,opr <br />

extends { ReflexiveT, , AntisymmetricT, , TransitiveT, }<br />

end<br />

A partial order is a binary predicate that is reflexive, antisymmetric, and transitive.<br />

trait StrictPartialOrderT extends StrictPartialOrderT, ≺,opr ≺<br />

extends { IrreflexiveT, ≺, AntisymmetricT, ≺, TransitiveT, ≺ }<br />

end<br />

A strict partial order is a binary predicate that is irreflexive, antisymmetric, and transitive. (Thus it differs from an<br />

ordinary partial order in being irreflexive rather than reflexive.)<br />

It is easy to prove that, because ≺ is irreflexive and antisymmetric, that a ≺ b and a = b cannot both be true. (If<br />

they were both true, then because antisymmetry requires that ≺ obey substitution laws, a ≺ a would be true—but<br />

that contradicts the fact that ≺ is irreflexive.) It is then easy to prove that a ≺ b and b ≺ a cannot both be true. (If<br />

they were both true, then by antisymmetry a = b must be true—but a ≺ b and a = b cannot both be true.)<br />

trait TotalOrderT extends TotalOrderT, ,opr <br />

extends { PartialOrderT, }<br />

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

end<br />

A total order is a partial order in which every pair of operands must be related by the predicate in one order or the<br />

other; thus no two values are ever unordered with respect to each other.<br />

trait StrictTotalOrderT extends StrictTotalOrderT, ≺,opr ≺<br />

extends { StrictPartialOrderT, ≺ }<br />

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

end<br />

A strict total order is a strict partial order in which every pair of operands must be related, either by equality = or by<br />

the predicate ≺ in one order or the other; thus no two values are ever unordered with respect to each other.<br />

For a strict total order at least one of a ≺ b and a = b and b ≺ a is true; but a strict total order is also a strict partial<br />

order, for which at most one of a ≺ b and a = b and b ≺ a is true. <strong>The</strong>refore a strict total order obeys the law of<br />

trichotomy: for any a and b , exactly one of a ≺ b and a = b and b ≺ a is true.<br />

248

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

Saved successfully!

Ooh no, something went wrong!