library colibrilib.stdq — module StdQmodule StdQ : colibrilib.q.Q_intf157use int.Int158use int.Abs as IA159use real.RealInfix160use real.FromInt161use real.Truncate162use real.Abs as RA163use mach.int.Int63164use colibrilib.zarith.Z as Z165use colibrilib.zarith.Q as Q166use colibrilib.q.Real as Real167use number.Gcd as Gcd168use int.EuclideanDivision as E169170type t = Q.t171172function real (q:t) : real = Q.real q173174predicate is_rat (r:real) = exists q:t. real q = r175
The operations of q.Q_intf that Zarith provides: StdQ has all of them, it is the instance of the interface
Valid (30ms) (colibri2)let equal (a b:Q.t) : bool ensures { result <-> Q.real a = Q.real b } = Q.equal a b Valid (27ms) (colibri2)179let le (a b:Q.t) : bool ensures { result <-> Q.real a <=. Q.real b } = Q.leq a b Valid (24ms) (colibri2)180let lt (a b:Q.t) : bool ensures { result <-> Q.real a <. Q.real b } = Q.lt a b Valid (26ms) (colibri2)181let abs (a:Q.t) : Q.t ensures { Q.real result = RA.abs (Q.real a) } = Q.abs a Valid (24ms) (colibri2)182let function add (a b:Q.t) : Q.t ensures { Q.real result = Q.real a +. Q.real b } = Q.add a b Valid (23ms) (colibri2)183let function sub (a b:Q.t) : Q.t ensures { Q.real result = Q.real a -. Q.real b } = Q.sub a b Valid (28ms) (colibri2)184let function mul (a b:Q.t) : Q.t ensures { Q.real result = Q.real a *. Q.real b } = Q.mul a b Valid (25ms) (colibri2)185let function div (a b:Q.t) : Q.t requires { Q.real b <> 0. } ensures { Q.real result = Q.real a /. Q.real b } = Q.div a b Valid (32ms) (colibri2)186let of_int (n:int63) : Q.t ensures { Q.real result = from_int n } = Q.of_int n Valid (28ms) (colibri2)187let of_bigint (n:int) : Q.t ensures { Q.real result = from_int n } = Q.of_bigint n188
q = n / d with n between k * d and k * d + d (excluded)
Valid (124ms) (cvc4)let ghost frac_bounds (n d k:int) : unit191requires { 0 < d }192requires { k * d <= n < k * d + d }193ensures { from_int k <=. from_int n /. from_int d <. from_int k +. 1. }194= {proof…} let rd = from_int d in195assert { 0. <. rd };196assert { from_int (k * d) <=. from_int n <. from_int (k * d + d) };197assert { from_int k *. rd <=. from_int n <. (from_int k +. 1.) *. rd };198assert { from_int n /. rd *. rd = from_int n } {qed}199Valid (4.2s) (colibri2 7) (split_vc 2) (depth 2)200let function is_integer (q:Q.t) : bool201ensures { result <-> q.Q.den = 1 }202ensures { result <-> exists z. Q.real q = from_int z }203= {proof…} if pure { exists z. Q.real q = from_int z } then begin204let ghost z = any int ensures { Q.real q = from_int result } in205assert { from_int q.Q.num = from_int z *. from_int q.Q.den206by from_int q.Q.num /. from_int q.Q.den *. from_int q.Q.den = from_int q.Q.num };207assert { q.Q.num = z * q.Q.den };208assert { Gcd.gcd q.Q.num q.Q.den = q.Q.den209by Gcd.gcd (z * q.Q.den) (0 * z + q.Q.den) = Gcd.gcd (z * q.Q.den) q.Q.den };210end; {qed}211Z.is_one q.Q.den212Valid (1.0s) (colibri2)213let function floor (x:Q.t) : Q.t214ensures { result.Q.den = 1 }215ensures { Q.real result = from_int (floor (Q.real x)) }216= if is_integer x then x217else begin218let r = Z.fdiv x.Q.num x.Q.den in219frac_bounds x.Q.num x.Q.den r;220Q.of_bigint r221end222Valid (878ms) (cvc4)223let ghost cdiv_bounds (a b:int) : unit224requires { 0 < b }225ensures { let r = - E.div (- a) b in r * b - b < a <= r * b }226= assert { E.div (- a) b * b + E.mod (- a) b = - a };227assert { 0 <= E.mod (- a) b < b }228Valid (1.5s) (colibri2 12) (split_vc 2) (depth 2)229let function ceil (x:Q.t) : Q.t230ensures { result.Q.den = 1 }231ensures { Q.real result = from_int (ceil (Q.real x)) }232= if is_integer x then x233else begin234let r = Z.cdiv x.Q.num x.Q.den in235cdiv_bounds x.Q.num x.Q.den;236assert { (r - 1) * x.Q.den < x.Q.num <= r * x.Q.den };237if pure { x.Q.num = r * x.Q.den } then begin238assert { Gcd.gcd x.Q.num x.Q.den = Gcd.gcd x.Q.den x.Q.num };239assert { Gcd.gcd x.Q.den x.Q.num = Gcd.gcd x.Q.den (x.Q.num - r * x.Q.den) };240assert { Gcd.gcd x.Q.den 0 = x.Q.den };241absurd242end;243frac_bounds x.Q.num x.Q.den (r - 1);244Q.of_bigint r245end246Valid (452ms) (colibri2)247let function truncate (d:Q.t) : Q.t248ensures { result.Q.den = 1 }249ensures { Q.real result = from_int (truncate (Q.real d)) }250= if is_integer d then d251else if Q.sign d > 0 then floor d252else ceil d253Valid (52ms) (colibri2)254let function div_e (a b:Q.t) : Q.t255requires { Q.real b <> 0. }256ensures { Q.real result = from_int (Real.div_e a b) }257= let s = Q.sign b in258let d = Q.div a b in259if s > 0 then floor d else ceil d260Valid (37ms) (colibri2)261let function div_t (a b:Q.t) : Q.t262requires { Q.real b <> 0. }263ensures { Q.real result = from_int (Real.div_t a b) }264= truncate (Q.div a b)265Valid (29ms) (colibri2)266let function div_f (a b:Q.t) : Q.t267requires { Q.real b <> 0. }268ensures { Q.real result = from_int (Real.div_f a b) }269= floor (Q.div a b)270Valid (52ms) (colibri2)271let function mod_e (a b:Q.t) : Q.t272requires { Q.real b <> 0. }273ensures { Q.real result = Real.mod_e a b }274= Q.sub a (Q.mul (div_e a b) b)275Valid (28ms) (colibri2)276let function mod_t (a b:Q.t) : Q.t277requires { Q.real b <> 0. }278ensures { Q.real result = Real.mod_t a b }279= Q.sub a (Q.mul (div_t a b) b)280Valid (33ms) (colibri2)281let function mod_f (a b:Q.t) : Q.t282requires { Q.real b <> 0. }283ensures { Q.real result = Real.mod_f a b }284= Q.sub a (Q.mul (div_f a b) b)285Valid (52ms) (colibri2)286let function is_zero (c:Q.t) : bool287ensures { result <-> Q.real c = 0. }288= Q.sign c = 0289
The largest multiple of m below a, and the smallest above
Valid (75ms) (colibri2)let round_down_to (a m:Q.t) : Q.t292requires { 0. <. Q.real m }293ensures { exists k. Q.real result = from_int k *. Q.real m }294ensures { Q.real result <=. Q.real a <. Q.real result +. Q.real m }295= let q' = floor (Q.div a m) in296Q.mul q' m297Valid (63ms) (colibri2)298let round_up_to (a m:Q.t) : Q.t299requires { 0. <. Q.real m }300ensures { exists k. Q.real result = from_int k *. Q.real m }301ensures { Q.real result -. Q.real m <. Q.real a <=. Q.real result }302= let q' = ceil (Q.div a m) in303Q.mul q' m304
The functions of q.Q_intf that return an integer
Valid (37ms) (colibri2)let to_bigint (q:Q.t) : int307requires { q.Q.den = 1 }308ensures { from_int result = Q.real q }309= q.Q.num310Valid (32ms) (colibri2)311let floor_z (x:Q.t) : int312ensures { result = Truncate.floor (Q.real x) }313= to_bigint (floor x)314Valid (38ms) (colibri2)315let ceil_z (x:Q.t) : int316ensures { result = Truncate.ceil (Q.real x) }317= to_bigint (ceil x)318Valid (23ms) (colibri2)319let truncate_z (x:Q.t) : int320ensures { result = Truncate.truncate (Q.real x) }321= to_bigint (truncate x)322323use colibrilib.q.Ord as Ord324Valid (52ms) (colibri2)325let compare (a b:Q.t) : Ord.t326ensures { match result with327| Ord.Eq -> Q.real a = Q.real b328| Ord.Lt -> Q.real a <. Q.real b329| Ord.Gt -> Q.real b <. Q.real a330end }331= let c = Q.compare a b in332if c = 0 then Ord.Eq else if c < 0 then Ord.Lt else Ord.Gt333334use number.Divisibility as D335use number.Coprime as C336use colibrilib.dv.Dv337
n1/d1 = k * n2/d2 in integers
Valid (44ms) (colibri2)let ghost cross_mul (n1 d1 n2 d2 k:int) : unit340requires { 0 < d1 /\ 0 < d2 }341ensures { from_int n1 /. from_int d1 = from_int k *. (from_int n2 /. from_int d2)342<-> n1 * d2 = k * n2 * d1 }343= {proof…} let x1 = from_int n1 in let y1 = from_int d1 in344let x2 = from_int n2 in let y2 = from_int d2 in let rk = from_int k in345assert { y1 <> 0. /\ y2 <> 0. };346assert { x1 /. y1 = rk *. (x2 /. y2) <-> x1 *. y2 = rk *. x2 *. y1347by x1 /. y1 *. (y1 *. y2) = x1 *. y2348/\ rk *. (x2 /. y2) *. (y1 *. y2) = rk *. x2 *. y1 };349assert { from_int (n1 * d2) = x1 *. y2 };350assert { from_int (k * n2 * d1) = rk *. x2 *. y1 } {qed}351
For fractions in lowest terms, b divides a iff the numerator of b divides that of a and the denominator of a that of b
Valid (1.9s) (colibri2 15) (split_vc) (depth 1)let ghost dv_frac (a b:Q.t) : unit355ensures { dv (Q.real a) (Q.real b)356<-> D.divides b.Q.num a.Q.num /\ D.divides a.Q.den b.Q.den }357= {proof…} let n1 = a.Q.num in let d1 = a.Q.den in358let n2 = b.Q.num in let d2 = b.Q.den in359if pure { dv (Q.real a) (Q.real b) } then begin360let k = quot (Q.real a) (Q.real b) in361cross_mul n1 d1 n2 d2 k;362assert { n1 * d2 = (k * n2) * d1 };363assert { D.divides d1 (n1 * d2) };364assert { C.coprime d1 n1 by Gcd.gcd d1 n1 = Gcd.gcd n1 d1 };365assert { D.divides d1 d2 };366assert { D.divides n2 (d2 * n1) by d2 * n1 = (k * d1) * n2 };367assert { C.coprime n2 d2 };368assert { D.divides n2 n1 }369end;370if pure { D.divides n2 n1 /\ D.divides d1 d2 } then begin371let x = any int ensures { n1 = result * n2 } in372let y = any int ensures { d2 = result * d1 } in373cross_mul n1 d1 n2 d2 (x * y);374assert { n1 * d2 = (x * y) * n2 * d1 };375dv_intro (Q.real a) (Q.real b) (x * y)376end {qed}377
a is an integer multiple of b, and the multiple (Std.Q.divisible)
Valid (52ms) (colibri2)let divisible (a b:Q.t) : (r:bool, ghost d:int)380ensures { r <-> dv (Q.real a) (Q.real b) }381ensures { r -> Q.real a = from_int d *. Q.real b }382= dv_frac a b;383let r = Z.divisible a.Q.num b.Q.num && Z.divisible b.Q.den a.Q.den in384(r, if r then quot (Q.real a) (Q.real b) else 0)385
The multiple: a = result * b (Std.Q.divexact)
Valid (337ms) (colibri2)let divexact (a b:Q.t) : int388requires { Q.real b <> 0. }389requires { dv (Q.real a) (Q.real b) }390ensures { Q.real a = from_int result *. Q.real b }391= dv_frac a b;392assert { b.Q.num <> 0 };393let x = Z.divexact a.Q.num b.Q.num in394let y = Z.divexact b.Q.den a.Q.den in395cross_mul a.Q.num a.Q.den b.Q.num b.Q.den (x * y);396assert { a.Q.num * b.Q.den = (x * y) * b.Q.num * a.Q.den };397x * y398
The value of an integer
Valid (32ms) (colibri2)let to_z (a:Q.t) : int401requires { exists z. Q.real a = from_int z }402ensures { from_int result = Q.real a }403= let _ = is_integer a in to_bigint a404
Bezout on the rationals (Std.Q.gcdext): g = u * a + v * b with g the non negative generator of the group generated by a and b
Valid (986ms) (colibri2)let gcdext3 (a b:Q.t) : (g:Q.t, u:int, v:int)408ensures { 0. <=. Q.real g }409ensures { dv (Q.real a) (Q.real g) }410ensures { dv (Q.real b) (Q.real g) }411ensures { Q.real g = from_int u *. Q.real a +. from_int v *. Q.real b }412= let x = a.Q.num * b.Q.den in413let y = b.Q.num * a.Q.den in414let (g, u, v) = Z.gcdext x y in415let dd = a.Q.den * b.Q.den in416let r = Q.make g dd in417{proof…}418let ghost rd = from_int dd in419assert { 0. <. rd };420assert { Q.real a = from_int x /. rd421by from_int x /. rd = (from_int a.Q.num *. from_int b.Q.den)422/. (from_int a.Q.den *. from_int b.Q.den) };423assert { Q.real b = from_int y /. rd424by from_int y /. rd = (from_int b.Q.num *. from_int a.Q.den)425/. (from_int a.Q.den *. from_int b.Q.den) };426assert { 0 <= g };427assert { Q.real r = from_int g /. rd };428assert { from_int g = from_int u *. from_int x +. from_int v *. from_int y };429assert { Q.real r = from_int u *. Q.real a +. from_int v *. Q.real b };430assert { D.divides g x /\ D.divides g y };431let ghost kx = any int ensures { x = result * g } in432let ghost ky = any int ensures { y = result * g } in433assert { Q.real a = from_int kx *. Q.real r434by from_int x = from_int kx *. from_int g };435assert { Q.real b = from_int ky *. Q.real r436by from_int y = from_int ky *. from_int g };437dv_intro (Q.real a) (Q.real r) kx;438dv_intro (Q.real b) (Q.real r) ky;439{qed}440(r, u, v)441442use ZFacts as ZF443
The value of gcd a b
function gcd_q (a b:Q.t) : real =446from_int (Gcd.gcd a.Q.num b.Q.num) /. from_int (Z.lcm a.Q.den b.Q.den)447
a = (y * n1) / l and b = (x * n2) / l with l = lcm d1 d2
Valid (41ms) (colibri2)let ghost common_den (a b:Q.t) (g x y:int) : unit450requires { a.Q.den = g * x /\ b.Q.den = g * y /\ 0 < g /\ 0 < x /\ 0 < y }451ensures { Q.real a = from_int (y * a.Q.num) /. from_int (g * x * y) }452ensures { Q.real b = from_int (x * b.Q.num) /. from_int (g * x * y) }453= {proof…} let ry = from_int y in let rx = from_int x in454assert { 0. <. ry /\ 0. <. rx };455assert { from_int (y * a.Q.num) /. from_int (g * x * y)456= (ry *. from_int a.Q.num) /. (ry *. from_int a.Q.den) };457assert { from_int (x * b.Q.num) /. from_int (g * x * y)458= (rx *. from_int b.Q.num) /. (rx *. from_int b.Q.den) } {qed}459
The greatest common divisor (Std.Q.gcd): the non negative generator of the group generated by a and b
Valid (357ms) (colibri2 50) (split_vc) (depth 1)let gcd (a b:Q.t) : Q.t463ensures { Q.real result = gcd_q a b }464ensures { 0. <=. Q.real result }465ensures { dv (Q.real a) (Q.real result) }466ensures { dv (Q.real b) (Q.real result) }467ensures { forall r. dv (Q.real a) r -> dv (Q.real b) r -> dv (Q.real result) r }468= let n1 = a.Q.num in let d1 = a.Q.den in469let n2 = b.Q.num in let d2 = b.Q.den in470let gg = Z.gcd n1 n2 in471let l = Z.lcm d1 d2 in472{proof…}473let ghost (x, y) = ZF.lcm_decomp d1 d2 in474let ghost g = Gcd.gcd d1 d2 in475assert { l = d1 * y /\ l = d2 * x /\ 0 < l };476ZF.coprime_div n1 d1 gg;477ZF.coprime_div n2 d2 gg;478ZF.coprime_sym gg d2;479ZF.coprime_div d2 gg y;480ZF.coprime_sym y gg;481ZF.coprime_mul d1 y gg;482assert { C.coprime gg l };483{qed}484let r = Q.make_exact gg l in485{proof…}486ZF.coprime_sym n2 d2;487ZF.coprime_div d2 n2 y;488ZF.coprime_sym n1 d1;489ZF.coprime_div d1 n1 x;490ZF.coprime_sym x n1;491ZF.coprime_sym x y;492ZF.coprime_sym y n2;493ZF.coprime_mul n2 x y;494ZF.gcd_cancel n1 (n2 * x) y;495assert { Gcd.gcd n1 (x * n2) = gg };496assert { Gcd.gcd (y * n1) (x * n2) = gg };497let ghost (u, v) = ZF.bezout (y * n1) (x * n2) in498common_den a b g x y;499let ghost rl = from_int l in500assert { Q.real r = from_int gg /. rl };501assert { Q.real r = from_int u *. Q.real a +. from_int v *. Q.real b502by from_int gg = from_int u *. from_int (y * n1) +. from_int v *. from_int (x * n2) };503assert { D.divides gg n1 by gg = Gcd.gcd n1 n2 };504let ghost k1 = any int ensures { n1 = result * gg } in505assert { D.divides gg n2 by gg = Gcd.gcd n1 n2 };506let ghost k2 = any int ensures { n2 = result * gg } in507assert { Q.real a = from_int (y * k1) *. Q.real r508by from_int (y * n1) = from_int (y * k1) *. from_int gg };509assert { Q.real b = from_int (x * k2) *. Q.real r510by from_int (x * n2) = from_int (x * k2) *. from_int gg };511dv_intro (Q.real a) (Q.real r) (y * k1);512dv_intro (Q.real b) (Q.real r) (x * k2);513let lemma common (r':real)514requires { dv (Q.real a) r' }515requires { dv (Q.real b) r' }516ensures { dv (Q.real r) r' }517= let ka = quot (Q.real a) r' in518let kb = quot (Q.real b) r' in519assert { Q.real r = from_int (u * ka + v * kb) *. r'520by Q.real r = from_int u *. (from_int ka *. r') +. from_int v *. (from_int kb *. r') };521dv_intro (Q.real r) r' (u * ka + v * kb) in522assert { 0. <=. Q.real r by 0 <= gg /\ 0. <. rl };523{qed}524r525
The least common multiple (Std.Q.lcm): the non negative generator of the intersection of the groups generated by a and by b
Valid (1.2s) (colibri2 63) (cvc5 3) (split_vc) (depth 1)let lcm (a b:Q.t) : Q.t529ensures { 0. <=. Q.real result }530ensures { dv (Q.real result) (Q.real a) }531ensures { dv (Q.real result) (Q.real b) }532ensures { forall r. dv r (Q.real a) -> dv r (Q.real b) -> dv r (Q.real result) }533= let n1 = a.Q.num in let d1 = a.Q.den in534let n2 = b.Q.num in let d2 = b.Q.den in535let m = Z.lcm n1 n2 in536let h = Z.gcd d1 d2 in537{proof…}538let ghost (x, y) = ZF.lcm_decomp d1 d2 in539ZF.lcm_gcd n1 n2;540ZF.lcm_multiple n1 n2;541assert { 0 < h by h <> 0 };542if n1 = 0 || n2 = 0 then begin543assert { m = 0 };544assert { n1 = 0 -> d1 = 1 by Gcd.gcd 0 d1 = d1 };545assert { n2 = 0 -> d2 = 1 by Gcd.gcd 0 d2 = d2 };546assert { h = 1 by D.divides h 1 }547end else begin548ZF.coprime_sym n1 d1;549ZF.coprime_div d1 n1 h;550ZF.coprime_sym n2 d2;551ZF.coprime_div d2 n2 h;552ZF.coprime_mul n1 n2 h;553ZF.coprime_sym h (n1 * n2);554let ghost gg = Gcd.gcd n1 n2 in555assert { IA.abs (n1 * n2) = m * gg };556if n1 * n2 < 0 then begin557assert { IA.abs (n1 * n2) = - (n1 * n2) };558assert { n1 * n2 = m * (- gg) }559end else assert { n1 * n2 = m * gg };560assert { D.divides m (n1 * n2) };561ZF.coprime_div (n1 * n2) h m562end;563assert { C.coprime m h };564{qed}565let r = Q.make_exact m h in566{proof…}567let ghost rh = from_int h in568assert { 0. <. rh };569let ghost k1 = any int ensures { m = result * n1 } in570let ghost k2 = any int ensures { m = result * n2 } in571assert { Q.real r = from_int (k1 * x) *. Q.real a572by from_int m /. rh = (from_int (k1 * x) *. from_int n1) /. (from_int x *. rh) };573assert { Q.real r = from_int (k2 * y) *. Q.real b574by from_int m /. rh = (from_int (k2 * y) *. from_int n2) /. (from_int y *. rh) };575dv_intro (Q.real r) (Q.real a) (k1 * x);576dv_intro (Q.real r) (Q.real b) (k2 * y);577common_den a b h x y;578let lemma common (r':real)579requires { dv r' (Q.real a) }580requires { dv r' (Q.real b) }581ensures { dv r' (Q.real r) }582= let ka = quot r' (Q.real a) in583let kb = quot r' (Q.real b) in584if n1 = 0 || n2 = 0 then begin585assert { r' = 0. };586dv_intro r' (Q.real r) 0587end else begin588let aa = y * n1 in let bb = x * n2 in589let ll = h * x * y in590assert { from_int (ka * aa) = from_int (kb * bb)591by r' = from_int ka *. (from_int aa /. from_int ll)592/\ r' = from_int kb *. (from_int bb /. from_int ll)593/\ 0. <. from_int ll };594assert { ka * aa = kb * bb };595ZF.lcm_least aa bb (ka * aa);596let q = any int ensures { ka * aa = result * Z.lcm aa bb } in597(* gcd aa bb = gcd n1 n2 *)598ZF.coprime_sym n2 d2;599ZF.coprime_div d2 n2 y;600ZF.coprime_sym n1 d1;601ZF.coprime_div d1 n1 x;602ZF.coprime_sym x n1;603ZF.coprime_sym x y;604ZF.coprime_sym y n2;605ZF.coprime_mul n2 x y;606ZF.gcd_cancel n1 (n2 * x) y;607assert { Gcd.gcd n1 (x * n2) = Gcd.gcd n1 n2 };608assert { Gcd.gcd aa bb = Gcd.gcd n1 n2 };609ZF.lcm_gcd aa bb;610let gg = Gcd.gcd n1 n2 in611assert { 0 < gg by gg <> 0 };612assert { IA.abs (aa * bb) = (x * y) * IA.abs (n1 * n2) };613assert { Z.lcm aa bb * gg = (x * y * m) * gg };614assert { Z.lcm aa bb = x * y * m };615assert { r' = from_int q *. Q.real r616by r' = from_int (ka * aa) /. from_int ll617/\ from_int (ka * aa) = from_int q *. (from_int (x * y) *. from_int m)618/\ from_int ll = from_int (x * y) *. rh };619dv_intro r' (Q.real r) q620end in621assert { 0. <=. Q.real r by 0 <= m };622{qed}623r624Valid (41ms) (colibri2)625let gcdext (a b:Q.t) : (g:Q.t, u:int, ghost v:int)626ensures { 0. <=. Q.real g }627ensures { dv (Q.real a) (Q.real g) }628ensures { dv (Q.real b) (Q.real g) }629ensures { Q.real g = from_int u *. Q.real a +. from_int v *. Q.real b }630= let (g, u, v) = gcdext3 a b in (g, u, v)631
The fraction in lowest terms
function num (q:t) : int = q.Q.num635function den (q:t) : int = q.Q.den636Valid (45ms) (colibri2)637let ghost num_den (q:t) : unit638ensures { 0 < den q }639ensures { real q = from_int (num q) /. from_int (den q) }640= ()641Valid (32ms) (colibri2)642let to_zarith (q:t) : Q.t643ensures { Q.real result = real q }644ensures { result.Q.num = num q /\ result.Q.den = den q }645= q646Valid (39ms) (colibri2)647let of_zarith (q:Q.t) : t648ensures { real result = Q.real q }649ensures { num result = q.Q.num /\ den result = q.Q.den }650= q651end652