The following spec describes the behavior required of a program that sorts sets of some type T with a "<=" comparison="comparison" method.="method." we="We" do="do" not="not" assume="assume" that="that"><=" is="is" antisymmetric;="antisymmetric;" in="in" other="other" words,="words," we="we" can="can" have="have" t1="t1"><= t2="t2" and="and"><= t1="t2," without="without" having="having" so="so" that="that"><=" is="is" not="not" enough="enough" to="to" distinguish="distinguish" values="values" of="of" t.="T." for="For" instance,="instance," t="T" might="might" be="be" the="the" record="record" type="type" [name:string,="[name:String," salary:="salary:" int]="Int]" with="with"><=" comparison="comparison" of="of" the="the" salary="salary" field.="field." several="Several" t’s="T’s" can="can" have="have" different="different" names="names" but="but" same="same" salary.="salary." type="TYPE" s="SET" t="T" q="SEQ" aproc="APROC" sort(s)="Sort(s)" -="-"> Q = <> RET q This spec uses the auxiliary function Sorted, defined as follows. FUNC Sorted(q) - Bool = RET (ALL i :IN q.dom – {0} | q(i-1) <= q(i))="q(i))" if="If" we="We" made="made" sort="Sort" a="a" func="FUNC" rather="rather" than="than" proc,="PROC," what="What" would="would" be="be" wrong?1="wrong?1" could="could" change="change" to="to" make="make" it="it" func?="FUNC?" have="have" written="written" this="this" more="more" concisely="concisely" as="as" aproc="APROC" sort(s)="Sort(s)" -="-"> Q = <> RET q using the perms method for sets that returns a set of sequences that contains all the possible permutations of the set. </></=></></="></="></=></=></="></=">
Comments
0 comments
Please sign in to leave a comment.