(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \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 Export Rlimit.
Require Export Rderiv.
Local Open Scope R_scope.
Implicit Type f : R -> R.
(****************************************************)
(** *         Basic operations on functions         *)
(****************************************************)
Definition plus_fct f1 f2 (x:R) : R := f1 x + f2 x.
Definition opp_fct f (x:R) : R := - f x.
Definition mult_fct f1 f2 (x:R) : R := f1 x * f2 x.
Definition mult_real_fct (a:R) f (x:R) : R := a * f x.
Definition minus_fct f1 f2 (x:R) : R := f1 x - f2 x.
Definition div_fct f1 f2 (x:R) : R := f1 x / f2 x.
Definition div_real_fct (a:R) f (x:R) : R := a / f x.
Definition comp f1 f2 (x:R) : R := f1 (f2 x).
Definition inv_fct f (x:R) : R := / f x.
Definition mirr_fct f (x:R) : R := f (- x).
Declare Scope Rfun_scope.
Delimit Scope Rfun_scope with F.
Arguments plus_fct (f1 f2)%_F x%_R.
Arguments mult_fct (f1 f2)%_F x%_R.
Arguments minus_fct (f1 f2)%_F x%_R.
Arguments div_fct (f1 f2)%_F x%_R.
Arguments inv_fct f%_F x%_R.
Arguments opp_fct f%_F x%_R.
Arguments mult_real_fct a%_R f%_F x%_R.
Arguments div_real_fct a%_R f%_F x%_R.
Arguments comp (f1 f2)%_F x%_R.
Arguments mirr_fct f%_F x%_R.
Infix "+" := plus_fct : Rfun_scope.
Notation "- x" := (opp_fct x) : Rfun_scope.
Infix "*" := mult_fct : Rfun_scope.
Infix "-" := minus_fct : Rfun_scope.
Infix "/" := div_fct : Rfun_scope.
Local Notation "f1 'o' f2" := (comp f1 f2)
(at level 20, right associativity) : Rfun_scope.
Notation "/ x" := (inv_fct x) : Rfun_scope.
Definition fct_cte (a x:R) : R := a.
Definition id (x:R) := x.
(****************************************************)
(** *          Variations of functions              *)
(****************************************************)
Definition increasing f : Prop := forall x y:R, x <= y -> f x <= f y.
Definition decreasing f : Prop := forall x y:R, x <= y -> f y <= f x.
Definition strict_increasing f : Prop := forall x y:R, x < y -> f x < f y.
Definition strict_decreasing f : Prop := forall x y:R, x < y -> f y < f x.
Definition constant f : Prop := forall x y:R, f x = f y.
(**********)
Definition no_cond (x:R) : Prop := True.
(**********)
Definition constant_D_eq f (D:R -> Prop) (c:R) : Prop :=
forall x:R, D x -> f x = c.
(***************************************************)
(** *    Definition of continuity as a limit       *)
(***************************************************)
(**********)
Definition continuity_pt f (x0:R) : Prop := continue_in f no_cond x0.
Definition continuity f : Prop := forall x:R, continuity_pt f x.
Arguments continuity_pt f%_F x0%_R.
Arguments continuity f%_F.

Lemma continuity_pt_locally_ext :
forall f g a x, 0 < a -> (forall y, Rdist y x < a -> f y = g y) ->
continuity_pt f x -> continuity_pt g x.