@@ -31,6 +31,12 @@ From mathcomp Require Import mathcomp_extra interval_inference.
3131(* | `\bar R` |==| coproduct of `R` and $\{+\infty, -\infty\}$| *)
3232(* | | | notation for `extended (R:Type)` | *)
3333(* | `r%:E` |==| injects real numbers into `\bar R` | *)
34+ (* | - x |==| opposite of x : \bar R | *)
35+ (* | 0, 1, -1 |==| 0%R, 1%R%:E, - 1%R%:E | *)
36+ (* | <number> |==| <number>%:R%:E with <number> a sequence | *)
37+ (* | | | of digits | *)
38+ (* | -<number> |==| - <number>%:R%:E with <number> a sequence | *)
39+ (* | | | of digits | *)
3440(* | `+%E, -%E, *%E` |==| addition/opposite/multiplication for | *)
3541(* | | | extended reals | *)
3642(* | `x^-1`, `x / y` |==| inverse and division for extended reals | *)
@@ -59,6 +65,12 @@ From mathcomp Require Import mathcomp_extra interval_inference.
5965(* \bar R == coproduct of R and {+oo, -oo}; *)
6066(* notation for extended (R:Type) *)
6167(* r%:E == injects real numbers into \bar R *)
68+ (* - x == opposite of x : \bar R *)
69+ (* 0, 1, -1 == 0%R, 1%R%:E, - 1%R%:E *)
70+ (* <number> == <number>%:R%:E with <number> a sequence *)
71+ (* of digits *)
72+ (* -<number> == - <number>%:R%:E with <number> a sequence *)
73+ (* of digits *)
6274(* +%E, -%E, *%E == addition/opposite/multiplication for extended *)
6375(* reals *)
6476(* x^-1, x / y == inverse and division for extended reals *)
@@ -582,6 +594,53 @@ Notation "x ^+ n" := (expe x%E n) : ereal_scope.
582594Notation "x *+ n" := (ednatmul x%dE n) : ereal_dual_scope.
583595Notation "x *+ n" := (enatmul x%E n) : ereal_scope.
584596
597+ (**md Notation for constant numerals. This has been introduced so
598+ that, e.g., in the scope `ereal_scope`, `-<n>` is correctly parsed
599+ without requiring one writes `- <n>%:E`. See the Rocq reference manual
600+ for the `Number Notation` command
601+ and [PR #1704](https://github.com/math-comp/analysis/pull/1704)
602+ for more explanations. *)
603+ Variant Ione := IOne : Ione.
604+ Inductive Inatmul := INatmul : Ione -> nat -> Inatmul.
605+ Inductive IEFin := IEFinP : Inatmul -> IEFin | IEFinN : IEFin -> IEFin.
606+ Variant Idummy_placeholder :=.
607+
608+ Definition parse (x : Number.int) : IEFin :=
609+ match x with
610+ | Number.IntDecimal (Decimal.Pos u) => IEFinP (INatmul IOne (Nat.of_uint u))
611+ | Number.IntDecimal (Decimal.Neg u) =>
612+ IEFinN (IEFinP (INatmul IOne (Nat.of_uint u)))
613+ | Number.IntHexadecimal (Hexadecimal.Pos u) =>
614+ IEFinP (INatmul IOne (Nat.of_hex_uint u))
615+ | Number.IntHexadecimal (Hexadecimal.Neg u) =>
616+ IEFinN (IEFinP (INatmul IOne (Nat.of_hex_uint u)))
617+ end .
618+
619+ Definition print (x : IEFin) : option Number.int :=
620+ match x with
621+ | IEFinP (INatmul IOne n) =>
622+ Some (Number.IntDecimal (Decimal.Pos (Nat.to_uint n)))
623+ | IEFinN (IEFinP (INatmul IOne n)) =>
624+ Some (Number.IntDecimal (Decimal.Neg (Nat.to_uint n)))
625+ | _ => None
626+ end .
627+
628+ Arguments GRing.one {_}.
629+ #[warnings="-via-type-remapping,-via-type-mismatch"]
630+ Number Notation Idummy_placeholder parse print (via IEFin
631+ mapping [[EFin] => IEFinP, [oppe] => IEFinN,
632+ [GRing.natmul] => INatmul, [GRing.one] => IOne])
633+ : ereal_scope.
634+ #[warnings="-via-type-remapping,-via-type-mismatch"]
635+ Number Notation Idummy_placeholder parse print (via IEFin
636+ mapping [[EFin] => IEFinP, [oppe] => IEFinN,
637+ [GRing.natmul] => INatmul, [GRing.one] => IOne])
638+ : ereal_dual_scope.
639+ Arguments GRing.one : clear implicits.
640+
641+ Notation "- 1" := (oppe 1 : dual_extended _) : ereal_dual_scope.
642+ Notation "- 1" := (oppe 1) : ereal_scope.
643+
585644Notation "\- f" := (fun x => - f x)%dE : ereal_dual_scope.
586645Notation "\- f" := (fun x => - f x)%E : ereal_scope.
587646Notation "f \+ g" := (fun x => f x + g x)%dE : ereal_dual_scope.
@@ -684,10 +743,10 @@ Proof. by rewrite lee_fin ler0N1. Qed.
684743Lemma lte0N1 : 0 < (-1)%:E :> \bar R = false.
685744Proof . by rewrite lte_fin ltr0N1. Qed .
686745
687- Lemma lteN10 : - 1%E < 0 :> \bar R.
746+ Lemma lteN10 : -1 < 0 :> \bar R.
688747Proof . by rewrite lte_fin ltrN10. Qed .
689748
690- Lemma leeN10 : - 1%E <= 0 :> \bar R.
749+ Lemma leeN10 : -1 <= 0 :> \bar R.
691750Proof . by rewrite lee_fin lerN10. Qed .
692751
693752Lemma lte0n n : (0 < n%:R%:E :> \bar R) = (0 < n)%N.
@@ -1273,13 +1332,13 @@ Proof. by move=> rreal; rewrite muleC real_mulrNy. Qed.
12731332
12741333Definition real_mulr_infty := (real_mulry, real_mulyr, real_mulrNy, real_mulNyr).
12751334
1276- Lemma mulN1e x : (- 1%E) * x = - x.
1335+ Lemma mulN1e x : -1 * x = - x.
12771336Proof .
12781337by case: x => [r| |]/=;
12791338 rewrite /mule ?mulN1r// eqe oppr_eq0 oner_eq0/= lte_fin oppr_gt0 ltr10.
12801339Qed .
12811340
1282- Lemma muleN1 x : x * (- 1%E) = - x. Proof . by rewrite muleC mulN1e. Qed .
1341+ Lemma muleN1 x : x * -1 = - x. Proof . by rewrite muleC mulN1e. Qed .
12831342
12841343Lemma mule_neq0 x y : x != 0 -> y != 0 -> x * y != 0.
12851344Proof .
@@ -2311,7 +2370,7 @@ Qed.
23112370Lemma iter_mule n x y : iter n ( *%E x) y = x ^+ n * y.
23122371Proof . by elim: n => [|n ih]; rewrite ?mul1e// [LHS]/= ih expeS muleA. Qed .
23132372
2314- HB.instance Definition _ := Monoid.isComLaw.Build (\bar R) 1%E mule
2373+ HB.instance Definition _ := Monoid.isComLaw.Build (\bar R) 1 mule
23152374 muleA muleC mul1e.
23162375
23172376Lemma muleCA : left_commutative ( *%E : \bar R -> \bar R -> \bar R ).
0 commit comments