Commit f9ed8bcc by Martin Clochard

verifythis_2016_matrix_multiplication: change exists to even

parent 16684355
This diff is collapsed.
This diff is collapsed.
 ... ... @@ -16,7 +16,7 @@ module MatrixMultiplication ensures { result.rows = a.rows /\ result.columns = b.columns } ensures { matrix_product result a b } = let rs = make (rows a) (columns b) 0 in for i = 0 to rows a - 1 do for i = 0 to a.rows - 1 do invariant { forall i0 j0. i <= i0 < rows a /\ 0 <= j0 < columns b -> rs.elts[i0][j0] = 0 } invariant { forall i0 j0. 0 <= i0 < i /\ 0 <= j0 < columns b -> ... ...
 ... ... @@ -2,85 +2,85 @@ ... ...
 ... ... @@ -264,23 +264,20 @@ module MatrixMultiplication use import int.EuclideanDivision use import number.Parity let rec strassen (a b: matrix int) (ghost flag:int) : matrix int requires { a.mdl.F.cols = b.mdl.F.rows } requires { flag >= 0 } requires { flag = 0 -> a.mdl.F.rows = 1 \/ a.mdl.F.cols = 1 \/ b.mdl.F.cols = 1 \/ exists k l m. a.mdl.F.rows = 2*k /\ a.mdl.F.cols = 2*l /\ b.mdl.F.cols = 2*m } (even a.mdl.F.rows /\ even a.mdl.F.cols /\ even b.mdl.F.cols) } ensures { result.mdl = mul a.mdl b.mdl } ensures { result.mdl.F.rows = a.mdl.F.rows } ensures { result.mdl.F.cols = b.mdl.F.cols } variant { a.mdl.F.rows + a.mdl.F.cols + b.mdl.F.cols + 3 * flag, flag } = let cut_off = abstract ensures { result >= 1 } 42 end in let rw = a.rows in let md = a.columns in let cl = b.columns in let (rw, md, cl)= (a.rows, a.columns, b.columns) in assert { rw = a.mdl.F.rows /\ md = a.mdl.F.cols /\ cl = b.mdl.F.cols }; if rw <= cut_off || md <= cut_off || cl <= cut_off then mul_naive a b else ... ... @@ -288,14 +285,12 @@ module MatrixMultiplication requires { 0 <= n } returns { (q,r) -> n = 2 * q + r /\ 0 <= r <= 1 /\ n + r = 2 * (q+r) } = (div n 2,mod n 2) in let (qr,rr) = div2 rw in let (qm,rm) = div2 md in let (qc,rc) = div2 cl in let (qr, rr) = div2 rw in let (qm, rm) = div2 md in let (qc, rc) = div2 cl in if rr <> 0 || rm <> 0 || rc <> 0 then begin (* Padding *) let rw' = rw + rr in let md' = md + rm in let cl' = cl + rc in let (rw', md', cl') = (rw + rr, md + rm, cl + rc) in let ap = padding a rw' md' in let bp = padding b md' cl' in let m = strassen ap bp 0 in ... ...
This diff is collapsed.
No preview for this file type
 ... ... @@ -2,46 +2,46 @@ ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!