Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
Require Import Decimal DecimalFacts DecimalPos DecimalN ZArith.z:ZZ.of_int (Z.to_int z) = zz:ZZ.of_int (Z.to_int z) = zZ.of_uint 0 = 0%Zp:positiveZ.of_uint (Pos.to_uint p) = Z.pos pp:positive(- Z.of_uint (Pos.to_uint p))%Z = Z.neg ptrivial.Z.of_uint 0 = 0%Zp:positiveZ.of_uint (Pos.to_uint p) = Z.pos pp:positiveZ.of_N (Pos.of_uint (Pos.to_uint p)) = Z.pos pnow destruct p.p:positiveZ.of_N (N.pos p) = Z.pos pp:positive(- Z.of_uint (Pos.to_uint p))%Z = Z.neg pp:positive(- Z.of_N (Pos.of_uint (Pos.to_uint p)))%Z = Z.neg pdestruct p; auto. Qed.p:positive(- Z.of_N (N.pos p))%Z = Z.neg pd:intZ.to_int (Z.of_int d) = norm dd:intZ.to_int (Z.of_int d) = norm dd:uintmatch Z.of_N (Pos.of_uint d) with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = Pos (unorm d)d:uintmatch (- Z.of_N (Pos.of_uint d))%Z with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintmatch Z.of_N (Pos.of_uint d) with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = Pos (unorm d)d:uintmatch Z.of_N (Pos.of_uint d) with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = Pos (N.to_uint (N.of_uint d))now destruct (Pos.of_uint d).d:uintmatch Z.of_N (Pos.of_uint d) with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = Pos (N.to_uint (Pos.of_uint d))d:uintmatch (- Z.of_N (Pos.of_uint d))%Z with | 0%Z => 0%int | Z.pos p => Pos (Pos.to_uint p) | Z.neg p => Neg (Pos.to_uint p) end = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%N0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pNeg (Pos.to_uint p) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%N0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%NN.to_uint (Pos.of_uint d) = unorm d -> 0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%NN.to_uint 0 = unorm d -> 0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%N0%uint = unorm d -> 0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%NH:0%uint = unorm d0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintHd:Pos.of_uint d = 0%NH:unorm d = 0%uint0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endnow rewrite H.d:uintHd:Pos.of_uint d = 0%NH:nzhead d = Nil0%int = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pNeg (Pos.to_uint p) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:N.to_uint (Pos.of_uint d) = unorm dNeg (Pos.to_uint p) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:N.to_uint (N.pos p) = unorm dNeg (Pos.to_uint p) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:Pos.to_uint p = unorm dNeg (Pos.to_uint p) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:Pos.to_uint p = unorm dNeg (unorm d) = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:Pos.to_uint p = match nzhead d with | Nil => 0%uint | D0 u => D0 u | D1 u => D1 u | D2 u => D2 u | D3 u => D3 u | D4 u => D4 u | D5 u => D5 u | D6 u => D6 u | D7 u => D7 u | D8 u => D8 u | D9 u => D9 u endNeg match nzhead d with | Nil => 0 | D0 u => D0 u | D1 u => D1 u | D2 u => D2 u | D3 u => D3 u | D4 u => D4 u | D5 u => D5 u | D6 u => D6 u | D7 u => D7 u | D8 u => D8 u | D9 u => D9 u end = match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) endd:uintp:positiveHd:Pos.of_uint d = N.pos pHp:Pos.to_uint p = 0%uint(-0)%int = 0%intnow rewrite Hp. Qed.d:uintp:positiveHd:Pos.of_uint d = N.pos pHp:Pos.to_uint p = 0%uintPos.of_uint (Pos.to_uint p) = N.pos p -> (-0)%int = 0%int
Some consequences
n, n':ZZ.to_int n = Z.to_int n' -> n = n'n, n':ZZ.to_int n = Z.to_int n' -> n = n'now rewrite <- (of_to n), <- (of_to n'), EQ. Qed.n, n':ZEQ:Z.to_int n = Z.to_int n'n = n'd:intexists n : Z, Z.to_int n = norm dd:intexists n : Z, Z.to_int n = norm dapply to_of. Qed.d:intZ.to_int (Z.of_int d) = norm dd:intZ.of_int (norm d) = Z.of_int dd:intZ.of_int (norm d) = Z.of_int dd:intmatch norm d with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = match d with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z endd:uintmatch norm (Pos d) with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = Z.of_N (Pos.of_uint d)d:uintmatch norm (Neg d) with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = (- Z.of_N (Pos.of_uint d))%Zd:uintmatch norm (Pos d) with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = Z.of_N (Pos.of_uint d)now rewrite DecimalPos.Unsigned.of_uint_norm.d:uintZ.of_N (Pos.of_uint (unorm d)) = Z.of_N (Pos.of_uint d)d:uintmatch norm (Neg d) with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = (- Z.of_N (Pos.of_uint d))%Zdestruct (nzhead d) eqn:H; [ induction d; simpl; auto; discriminate | destruct (nzhead_nonzero _ _ H) | .. ]; f_equal; f_equal; apply DecimalPos.Unsigned.of_iff; unfold unorm; now rewrite H. Qed.d:uintmatch match nzhead d with | Nil => 0%int | D0 u => Neg (D0 u) | D1 u => Neg (D1 u) | D2 u => Neg (D2 u) | D3 u => Neg (D3 u) | D4 u => Neg (D4 u) | D5 u => Neg (D5 u) | D6 u => Neg (D6 u) | D7 u => Neg (D7 u) | D8 u => Neg (D8 u) | D9 u => Neg (D9 u) end with | Pos d0 => Z.of_N (Pos.of_uint d0) | Neg d0 => (- Z.of_N (Pos.of_uint d0))%Z end = (- Z.of_N (Pos.of_uint d))%Zd, d':intZ.of_int d = Z.of_int d' -> norm d = norm d'd, d':intZ.of_int d = Z.of_int d' -> norm d = norm d'd, d':intH:Z.of_int d = Z.of_int d'norm d = norm d'now f_equal. Qed.d, d':intH:Z.of_int d = Z.of_int d'Z.to_int (Z.of_int d) = Z.to_int (Z.of_int d')d, d':intZ.of_int d = Z.of_int d' <-> norm d = norm d'd, d':intZ.of_int d = Z.of_int d' <-> norm d = norm d'd, d':intZ.of_int d = Z.of_int d' -> norm d = norm d'd, d':intnorm d = norm d' -> Z.of_int d = Z.of_int d'd, d':intnorm d = norm d' -> Z.of_int d = Z.of_int d'd, d':intE:norm d = norm d'Z.of_int d = Z.of_int d'apply of_int_norm. Qed.d, d':intE:norm d = norm d'Z.of_int (norm d') = Z.of_int d'