| shearsort#(; mx) {let n = log2↑(#r mx) in while n > 0 do {/* invariant perm(mx`.toArr, mx.toArr) ∧ #c mx = #c mx` ∧ #r mx = #r mx` ∧ #c mx ≠ 0 ∧ mx.dirtyrows≤(#r mx /↑ 2^(n` - n)) ∧ n ≤ n` ∧ (n = 0 → scolsorted(mx, #c mx, mx)) wfbound n */; /* use contract sortrowssnake-correct and skip call */; sortrowssnake#(; mx); /* use contract sortcols-correct and skip call */; sortcols#(; mx); n := n - 1}; /* use contract sortrows-correct and skip call */; sortrows#(; mx) } |