| # lpt = # avol, # buf1 = EB_PAGE_SIZE, avol[m4] = mapped(buf2), buf = copy(buf3, 0, copy(buf1, 0, mkbuf(align↓(m2 + n3, EB_PAGE_SIZE)), 0, m2), m2, align↓(m2 + n3, EB_PAGE_SIZE) - m2), m0 = m3, m1 = buffered(m4).leb, n0 = align↓(m2 + n3, EB_PAGE_SIZE), n1 = 0, buffered(m4).isbuf?, avol[m1].mapped?, m1 < # avol, m4 < # avol, ebm-vol-inv(avol), is-aligned(m0, EB_PAGE_SIZE), is-aligned(n0, EB_PAGE_SIZE), is-aligned(m3, EB_PAGE_SIZE), wbuf-cons(mkwbuf(buf1, m3, m2), mapped(buf2), false), # avol[m1].data ≤ m0, m0 + n0 ≤ LEB_SIZE, n1 + n0 ≤ # buf, # buf2 ≤ m3, n3 ≤ # buf3, m3 + m2 + n3 ≤ LEB_SIZE, align↓(m2 + n3, EB_PAGE_SIZE) ≤ # buf3 + m2, m2 ≤ EB_PAGE_SIZE, m2 ≤ align↓(m2 + n3, EB_PAGE_SIZE), EB_PAGE_SIZE ≤ m2 + n3, m3 + align↓(m2 + n3, EB_PAGE_SIZE) ≤ LEB_SIZE, 0 + m2 ≤ # mkbuf(align↓(m2 + n3, EB_PAGE_SIZE)), 0 + m2 ≤ # buf1, m2 + (align↓(m2 + n3, EB_PAGE_SIZE) - m2) ≤ # copy(buf1, 0, mkbuf(align↓(m2 + n3, EB_PAGE_SIZE)), 0, m2), 0 + (align↓(m2 + n3, EB_PAGE_SIZE) - m2) ≤ # buf3, align↓(m2 + n3, EB_PAGE_SIZE) ≥ m2, m1 < # avol → m1 < # avol ∧ (avol[m1].mapped? → avol[m1].mapped? ∧ m1 < # avol) ⊦ [fail_or_success#(; ; err); if err = ESUCCESS then if n0 ≠ 0 then avol[m1] := mapped(avol[m1].data + mkempbuf(m0 - # avol[m1].data) + subarray(buf, n1, n0)) else choose n with n < n0 ∧ is-aligned(n, EB_PAGE_SIZE) in if n ≠ 0 then avol[m1] := mapped(avol[m1].data + mkempbuf(m0 - # avol[m1].data) + subarray(buf, n1, n)) ifnone skip] ( ebm-vol-inv(avol) ∧ # lpt = # avol → ⟪wbuf := mkwbuf(buf1, m3, m2); rofs := false; if err = ESUCCESS then {wbuf.content := copy(buf3, align↓(m2 + n3, EB_PAGE_SIZE) - m2, wbuf.content, 0, (m2 + n3) % EB_PAGE_SIZE); wbuf.offset := wbuf.offset + align↓(m2 + n3, EB_PAGE_SIZE); wbuf.nbytes := (m2 + n3) % EB_PAGE_SIZE} else rofs := true⟫ (# wbuf.content = EB_PAGE_SIZE ∧ m4 < # avol ∧ wbuf-cons(wbuf, avol[m4], rofs))) |
# buf1 = EB_PAGE_SIZE, # lpt = # avol, avol[m4] = mapped(buf2), m4 < # avol, ebm-vol-inv(avol), is-aligned(m3, EB_PAGE_SIZE), wbuf-cons(mkwbuf(buf1, m3, m2), mapped(buf2), false), EB_PAGE_SIZE ≤ m2 + n3, m2 ≤ align↓(m2 + n3, EB_PAGE_SIZE), m2 ≤ EB_PAGE_SIZE, align↓(m2 + n3, EB_PAGE_SIZE) ≤ # buf3 + m2, m3 + m2 + n3 ≤ LEB_SIZE, n3 ≤ # buf3, # buf2 ≤ m3, m3 + align↓(m2 + n3, EB_PAGE_SIZE) ≤ LEB_SIZE ⊦ [fail_or_success#(; ; err); if err = ESUCCESS then if ¬ m2 + n3 < EB_PAGE_SIZE then avol[buffered(m4).leb] := mapped ( avol[buffered(m4).leb].data + mkempbuf(m3 - # avol[buffered(m4).leb].data) + subarray (copy(buf3, 0, copy(buf1, 0, mkbuf(align↓(m2 + n3, EB_PAGE_SIZE)), 0, m2), m2, align↓(m2 + n3, EB_PAGE_SIZE) - m2), 0, align↓(m2 + n3, EB_PAGE_SIZE))) else {n1 := 0; n0 := align↓(m2 + n3, EB_PAGE_SIZE); m1 := buffered(m4).leb; m0 := m3; buf2 := copy(buf3, 0, copy(buf1, 0, mkbuf(align↓(m2 + n3, EB_PAGE_SIZE)), 0, m2), m2, align↓(m2 + n3, EB_PAGE_SIZE) - m2); choose n with n < n0 ∧ is-aligned(n, EB_PAGE_SIZE) in if n ≠ 0 then avol[m1] := mapped(avol[m1].data + mkempbuf(m0 - # avol[m1].data) + subarray(buf2, n1, n)) ifnone skip}] ( ebm-vol-inv(avol) ∧ # lpt = # avol → ⟪wbuf := mkwbuf(buf1, m3, m2); rofs := false; if err = ESUCCESS then {wbuf.content := copy(buf3, align↓(m2 + n3, EB_PAGE_SIZE) - m2, wbuf.content, 0, (m2 + n3) % EB_PAGE_SIZE); wbuf.offset := wbuf.offset + align↓(m2 + n3, EB_PAGE_SIZE); wbuf.nbytes := (m2 + n3) % EB_PAGE_SIZE} else rofs := true⟫ (# wbuf.content = EB_PAGE_SIZE ∧ m4 < # avol ∧ wbuf-cons(wbuf, avol[m4], rofs)))
Used simplifier rules: ⊦ mapped(buf).data = buf; (s)% ⊦ mapped(buf) = mapped(buf0) ↔ buf = buf0; (s)%n ≠ 0 ⊦ align↓(m, n) = 0 ↔ m < n; (s)% ⊦ buffered(m).isbuf?; (s)% ⊦ aleb.mapped? ↔ (∃ buf. aleb = mapped(buf)); (as)%m ≠ 0 ⊦ is-aligned(align↓(n, m), m); (s)% ⊦ EB_PAGE_SIZE ≠ 0; (s)% ⊦ buffered(m).leb = m; (s)% ⊦ m ≤ m; (s)% ⊦ m + n ≤ m + n0 ↔ n ≤ n0; (s)%n ≤ m ⊦ (m - n) + m0 ≤ n0 ↔ m + m0 ≤ n0 + n; (s)% ⊦ # mkbuf(n) = n; (s)% ⊦ # copy(buf, m, buf0, m0, n) = # buf0; (s)%n0 ≤ n ⊦ n - n0 ≤ m ↔ n ≤ m + n0; (s)% ⊦ m ≤ n → (n < m ↔ false); (s)% ⊦ m ≤ n ↔ ¬ n < m; (ss)%c: ⊦ m + n = n + m; from specification nat-basic%a: ⊦ (m + n0) + n1 = m + n0 + n1; from specification nat-basic% ⊦ n + 0 = n; (s)% ⊦ n ≥ m ↔ m ≤ n; (s)