Module mathcomp.classical.boolp
From HB Require Import structures.From mathcomp Require Import all_ssreflect_compat.
From mathcomp Require Import mathcomp_extra.
From mathcomp Require internal_Eqdep_dec.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Declare Scope box_scope.
Declare Scope quant_scope.
Axiom functional_extensionality_dep :
forall (A : Type) (B : A -> Type) (f g : forall x : A, B x),
(forall x : A, f x = g x) -> f = g.
Axiom propositional_extensionality :
forall P Q : Prop, P <-> Q -> P = Q.
Axiom constructive_indefinite_description :
forall (A : Type) (P : A -> Prop),
(exists x : A, P x) -> {x : A | P x}.
Notation cid := constructive_indefinite_description.
Lemma cid2 (A : Type) (P Q : A -> Prop) :
(exists2 x : A, P x & Q x) -> {x : A | P x & Q x}.
Proof.
Lemma existT_inj1 (T : Type) (P : T -> Type) (x y : T) (Px : P x) (Py : P y) :
existT P x Px = existT P y Py -> x = y.
Proof.
Lemma existT_inj2 (T : eqType) (P : T -> Type) (x : T) (Px1 Px2 : P x) :
existT P x Px1 = existT P x Px2 -> Px1 = Px2.
Proof.
by have [|/eqP] := eqVneq y z; [left|right].
Qed.
Lemma surjective_existT (T : Type) (P : T -> Type) (p : {x : T & P x}):
existT [eta P] (projT1 p) (projT2 p) = p.
Proof.
Record mextensionality := {
_ : forall (P Q : Prop), (P <-> Q) -> (P = Q);
_ : forall {T U : Type} (f g : T -> U),
(forall x, f x = g x) -> f = g;
}.
Fact extensionality : mextensionality.
Proof.
- exact: propositional_extensionality.
- by move=> T U f g; apply: functional_extensionality_dep.
Qed.
Lemma propext (P Q : Prop) : (P <-> Q) -> (P = Q).
Proof.
Ltac eqProp := apply: propext; split.
Lemma funext {T U : Type} (f g : T -> U) : (f =1 g) -> f = g.
Proof.
Lemma propeqE (P Q : Prop) : (P = Q) = (P <-> Q).
Lemma propeqP (P Q : Prop) : (P = Q) <-> (P <-> Q).
Proof.
Lemma funeqE {T U : Type} (f g : T -> U) : (f = g) = (f =1 g).
Lemma funeq2E {T U V : Type} (f g : T -> U -> V) : (f = g) = (f =2 g).
Lemma funeq3E {T U V W : Type} (f g : T -> U -> V -> W) :
(f = g) = (forall x y z, f x y z = g x y z).
Lemma funeqP {T U : Type} (f g : T -> U) : (f = g) <-> (f =1 g).
Proof.
Lemma funeq2P {T U V : Type} (f g : T -> U -> V) : (f = g) <-> (f =2 g).
Proof.
Lemma funeq3P {T U V W : Type} (f g : T -> U -> V -> W) :
(f = g) <-> (forall x y z, f x y z = g x y z).
Proof.
Lemma predeqE {T} (P Q : T -> Prop) : (P = Q) = (forall x, P x <-> Q x).
Lemma predeq2E {T U} (P Q : T -> U -> Prop) :
(P = Q) = (forall x y, P x y <-> Q x y).
Lemma predeq3E {T U V} (P Q : T -> U -> V -> Prop) :
(P = Q) = (forall x y z, P x y z <-> Q x y z).
Lemma predeqP {T} (A B : T -> Prop) : (A = B) <-> (forall x, A x <-> B x).
Proof.
Lemma predeq2P {T U} (P Q : T -> U -> Prop) :
(P = Q) <-> (forall x y, P x y <-> Q x y).
Proof.
Lemma predeq3P {T U V} (P Q : T -> U -> V -> Prop) :
(P = Q) <-> (forall x y z, P x y z <-> Q x y z).
Proof.
Lemma propT {P : Prop} : P -> P = True.
Proof.
Lemma Prop_irrelevance (P : Prop) (x y : P) : x = y.
Proof.
Record mclassic := {
_ : forall (P : Prop), {P} + {~P};
_ : forall T, hasChoice T
}.
Lemma choice X Y (P : X -> Y -> Prop) :
(forall x, exists y, P x y) -> {f & forall x, P x (f x)}.
Proof.
Theorem EM P : P \/ ~ P.
Proof.
have Uex val : exists b, U val b by exists val; left.
pose f val := projT1 (cid (Uex val)).
pose Uf val : U val (f val) := projT2 (cid (Uex val)).
have : f true != f false \/ P.
have [] := (Uf true, Uf false); rewrite /U.
by move=> [->|?] [->|?] ; do ?[by right]; left.
move=> [/eqP fTFN|]; [right=> p|by left]; apply: fTFN.
have UTF : U true = U false by rewrite predeqE /U => b; split=> _; right.
rewrite /f; move: (Uex true) (Uex false); rewrite UTF => p1 p2.
by congr (projT1 (cid _)).
Qed.
Lemma pselect (P : Prop): {P} + {~P}.
Proof.
Lemma pselectT T : (T -> False) + T.
Proof.
Lemma classic : mclassic.
Proof.
Lemma gen_choiceMixin (T : Type) : hasChoice T.
Proof.
Lemma lem (P : Prop): P \/ ~P.
Proof.
Lemma trueE : true = True :> Prop.
Proof.
Lemma falseE : false = False :> Prop.
Proof.
Lemma propF (P : Prop) : ~ P -> P = False.
Proof.
Lemma eq_fun T rT (U V : T -> rT) :
(forall x : T, U x = V x) -> (fun x => U x) = (fun x => V x).
Proof.
Lemma eq2_fun T1 T2 rT (U V : T1 -> T2 -> rT) :
(forall x y, U x y = V x y) -> (fun x y => U x y) = (fun x y => V x y).
Proof.
Notation eq_fun2 := eq2_fun (only parsing).
Lemma eq3_fun T1 T2 T3 rT (U V : T1 -> T2 -> T3 -> rT) :
(forall x y z, U x y z = V x y z) ->
(fun x y z => U x y z) = (fun x y z => V x y z).
Proof.
Notation eq_fun3 := eq3_fun (only parsing).
Lemma eq_forall T (U V : T -> Prop) :
(forall x : T, U x = V x) -> (forall x, U x) = (forall x, V x).
Lemma eq2_forall T S (U V : forall x : T, S x -> Prop) :
(forall x y, U x y = V x y) -> (forall x y, U x y) = (forall x y, V x y).
#[deprecated(since="mathcomp-analysis 1.10.0", note="renamed to `eq2_forall`.")]
Notation eq_forall2 := eq2_forall (only parsing).
Lemma eq3_forall T S R (U V : forall (x : T) (y : S x), R x y -> Prop) :
(forall x y z, U x y z = V x y z) ->
(forall x y z, U x y z) = (forall x y z, V x y z).
Proof.
Notation eq_forall3 := eq3_forall (only parsing).
Lemma eq_exists T (U V : T -> Prop) :
(forall x : T, U x = V x) -> (exists x, U x) = (exists x, V x).
Lemma eq2_exists T S (U V : forall x : T, S x -> Prop) :
(forall x y, U x y = V x y) -> (exists x y, U x y) = (exists x y, V x y).
Lemma eq3_exists T S R (U V : forall (x : T) (y : S x), R x y -> Prop) :
(forall x y z, U x y z = V x y z) ->
(exists x y z, U x y z) = (exists x y z, V x y z).
Proof.
Notation eq_exists3 := eq3_exists (only parsing).
Lemma eq_exist T (P : T -> Prop) (s t : T) (p : P s) (q : P t) :
s = t -> exist P s p = exist P t q.
Proof.
Lemma forall_swap T S (U : forall (x : T) (y : S), Prop) :
(forall x y, U x y) = (forall y x, U x y).
Proof.
Lemma exists_swap T S (U : forall (x : T) (y : S), Prop) :
(exists x y, U x y) = (exists y x, U x y).
Proof.
Lemma reflect_eq (P : Prop) (b : bool) : reflect P b -> P = b.
Definition
asbool : Prop -> bool asbool is not universe polymorphic Arguments asbool P%_type_scope asbool is transparent Expands to: Constant mathcomp.classical.boolp.asbool Declared in library mathcomp.classical.boolp, line 332, characters 11-17
Notation "`[< P >]" := (asbool P) : bool_scope.
Lemma asboolE (P : Prop) : `[<P>] = P :> Prop.
Lemma asboolP (P : Prop) : reflect P `[<P>].
Lemma asboolb (b : bool) : `[< b >] = b.
Lemma asboolPn (P : Prop) : reflect (~ P) (~~ `[<P>]).
Lemma asboolW (P : Prop) : `[<P>] -> P.
Proof.
Lemma orW A B : A \/ B -> A + B.
Proof.
Lemma or3W A B C : [\/ A, B | C] -> A + B + C.
Proof.
Lemma or4W A B C D : [\/ A, B, C | D] -> A + B + C + D.
Proof.
Lemma asboolT (P : Prop) : P -> `[<P>].
Proof.
Lemma asboolF (P : Prop) : ~ P -> `[<P>] = false.
Lemma eq_opE (T : eqType) (x y : T) : (x == y : Prop) = (x = y).
Lemma is_true_inj : injective is_true.
Definition
gen_eq : forall [T : Type], T -> T -> bool gen_eq is not universe polymorphic Arguments gen_eq [T]%_type_scope u v gen_eq is transparent Expands to: Constant mathcomp.classical.boolp.gen_eq Declared in library mathcomp.classical.boolp, line 388, characters 11-17
Lemma gen_eqP (T : Type) : Equality.axiom (@gen_eq T).
Definition
gen_eqMixin : forall T : Type, hasDecEq.phant_axioms T gen_eqMixin is not universe polymorphic Arguments gen_eqMixin T%_type_scope gen_eqMixin is transparent Expands to: Constant mathcomp.classical.boolp.gen_eqMixin Declared in library mathcomp.classical.boolp, line 391, characters 11-22
hasDecEq.Build T (@gen_eqP T).
HB.instance Definition _ (T : Type) (T' : T -> eqType) :=
gen_eqMixin (forall t : T, T' t).
HB.instance Definition _ (T : Type) (T' : T -> choiceType) :=
gen_choiceMixin (forall t : T, T' t).
HB.instance Definition _ := gen_eqMixin Prop.
HB.instance Definition _ := gen_choiceMixin Prop.
Section classicType.
Variable T : Type.
Definition
classicType : Type -> Type classicType is not universe polymorphic Arguments classicType T%_type_scope classicType is transparent Expands to: Constant mathcomp.classical.boolp.classicType Declared in library mathcomp.classical.boolp, line 405, characters 11-22
HB.instance Definition _ := gen_eqMixin classicType.
HB.instance Definition _ := gen_choiceMixin classicType.
End classicType.
Notation "'{classic' T }" := (classicType T)
(format "'{classic' T }") : type_scope.
Section eclassicType.
Variable T : eqType.
Definition
eclassicType : eqType -> Type eclassicType is not universe polymorphic Arguments eclassicType T eclassicType is transparent Expands to: Constant mathcomp.classical.boolp.eclassicType Declared in library mathcomp.classical.boolp, line 414, characters 11-23
HB.instance Definition _ := Equality.copy eclassicType T.
HB.instance Definition _ := gen_choiceMixin eclassicType.
End eclassicType.
Notation "'{eclassic' T }" := (eclassicType T)
(format "'{eclassic' T }") : type_scope.
Definition
canonical_of : forall [T U : Type], (U -> T) -> Type canonical_of is not universe polymorphic Arguments canonical_of [T U]%_type_scope sort%_function_scope canonical_of is transparent Expands to: Constant mathcomp.classical.boolp.canonical_of Declared in library mathcomp.classical.boolp, line 421, characters 11-23
(forall x', G (sort x')) -> forall x, G x.
Notation canonical_ sort := (@canonical_of _ _ sort).
Notation canonical T E := (@canonical_of T E id).
Lemma canon T U (sort : U -> T) :
(forall x, exists y, sort y = x) -> canonical_ sort.
Proof.
Lemma Peq : canonical Type eqType.
Lemma Pchoice : canonical Type choiceType.
Lemma eqPchoice : canonical eqType choiceType.
Lemma not_True : (~ True) = False
Proof.
Proof.
Lemma asbool_equiv_eq {P Q : Prop} : (P <-> Q) -> `[<P>] = `[<Q>].
Proof.
Lemma asbool_equiv_eqP {P Q : Prop} b : reflect Q b -> (P <-> Q) -> `[<P>] = b.
Proof.
Lemma asbool_equiv {P Q : Prop} : (P <-> Q) -> (`[<P>] <-> `[<Q>]).
Proof.
Lemma asbool_eq_equiv {P Q : Prop} : `[<P>] = `[<Q>] -> (P <-> Q).
Lemma and_asboolP (P Q : Prop) : reflect (P /\ Q) (`[< P >] && `[< Q >]).
Proof.
Lemma and3_asboolP (P Q R : Prop) :
reflect [/\ P, Q & R] [&& `[< P >], `[< Q >] & `[< R >]].
Proof.
Lemma or_asboolP (P Q : Prop) : reflect (P \/ Q) (`[< P >] || `[< Q >]).
Proof.
Lemma or3_asboolP (P Q R : Prop) :
reflect [\/ P, Q | R] [|| `[< P >], `[< Q >] | `[< R >]].
Proof.
Lemma asbool_neg {P : Prop} : `[<~ P>] = ~~ `[<P>].
Lemma asbool_or {P Q : Prop} : `[<P \/ Q>] = `[<P>] || `[<Q>].
Proof.
Lemma asbool_and {P Q : Prop} : `[<P /\ Q>] = `[<P>] && `[<Q>].
Proof.
Lemma imply_asboolP {P Q : Prop} : reflect (P -> Q) (`[<P>] ==> `[<Q>]).
Proof.
Lemma asbool_imply {P Q : Prop} : `[<P -> Q>] = `[<P>] ==> `[<Q>].
Proof.
Lemma imply_asboolPn (P Q : Prop) : reflect (P /\ ~ Q) (~~ `[<P -> Q>]).
Proof.
by rewrite asbool_imply negb_imply -asbool_neg => /and_asboolP.
by move/and_asboolP; rewrite asbool_neg -negb_imply asbool_imply.
Qed.
Lemma forall_asboolP {T : Type} (P : T -> Prop) :
reflect (forall x, `[<P x>]) (`[<forall x, P x>]).
Proof.
Lemma exists_asboolP {T : Type} (P : T -> Prop) :
reflect (exists x, `[<P x>]) (`[<exists x, P x>]).
Proof.
Variant BoolProp : Prop -> Type :=
| TrueProp : BoolProp True
| FalseProp : BoolProp False.
Lemma PropB P : BoolProp P.
Lemma notB : ((~ True) = False) * ((~ False) = True).
Proof.
Lemma andB : left_id True and * right_id True and
* (left_zero False and * right_zero False and * idempotent_op and).
Proof.
Lemma orB : left_id False or * right_id False or
* (left_zero True or * right_zero True or * idempotent_op or).
Proof.
Lemma implyB : let imply (P Q : Prop) := P -> Q in
(imply False =1 fun=> True) * (imply^~ False =1 not)
* (left_id True imply * right_zero True imply * self_inverse True imply).
Proof.
Lemma decide_or P Q : P \/ Q -> {P} + {Q}.
Lemma notT (P : Prop) : P = False -> ~ P.
Proof.
Lemma contrapT P : ~ ~ P -> P.
Lemma notTE (P : Prop) : (~ P) -> P = False
Proof.
Lemma notFE (P : Prop) : (~ P) = False -> P.
Lemma notK : involutive not.
Lemma contra_notP (Q P : Prop) : (~ Q -> P) -> ~ P -> Q.
Lemma contraPP (Q P : Prop) : (~ Q -> ~ P) -> P -> Q.
Lemma contra_notT b (P : Prop) : (~~ b -> P) -> ~ P -> b.
Proof.
Lemma contraPT (P : Prop) b : (~~ b -> ~ P) -> P -> b.
Proof.
Lemma contraTP b (Q : Prop) : (~ Q -> ~~ b) -> b -> Q.
Lemma contraNP (P : Prop) (b : bool) : (~ P -> b) -> ~~ b -> P.
Proof.
Lemma contra_neqP (T : eqType) (x y : T) P : (~ P -> x = y) -> x != y -> P.
Lemma contra_eqP (T : eqType) (x y : T) Q : (~ Q -> x != y) -> x = y -> Q.
Lemma contra_leP {disp1} {T1 : porderType disp1} [P : Prop] [x y : T1] :
(~ P -> (x < y)%O) -> (y <= x)%O -> P.
Proof.
Lemma contra_ltP {disp1} {T1 : porderType disp1} [P : Prop] [x y : T1] :
(~ P -> (x <= y)%O) -> (y < x)%O -> P.
Proof.
Lemma wlog_neg P : (~ P -> P) -> P.
Proof.
Lemma not_inj : injective not
Lemma notLR P Q : (P = (~ Q)) -> (~ P) = Q
Lemma notRL P Q : (~ P) = Q -> P = (~ Q)
Lemma iff_notr (P Q : Prop) : (P <-> ~ Q) <-> (~ P <-> Q).
Lemma iff_not2 (P Q : Prop) : (~ P <-> ~ Q) <-> (P <-> Q).
Definition
predp : Type -> Type predp is not universe polymorphic Arguments predp T%_type_scope predp is transparent Expands to: Constant mathcomp.classical.boolp.predp Declared in library mathcomp.classical.boolp, line 619, characters 11-16
Identity Coercion fun_of_pred : predp >-> Funclass.
Definition
relp : Type -> Type relp is not universe polymorphic Arguments relp T%_type_scope relp is transparent Expands to: Constant mathcomp.classical.boolp.relp Declared in library mathcomp.classical.boolp, line 623, characters 11-15
Identity Coercion fun_of_rel : rel >-> Funclass.
Notation xpredp0 := (fun _ => False).
Notation xpredpT := (fun _ => True).
Notation xpredpI := (fun (p1 p2 : predp _) x => p1 x /\ p2 x).
Notation xpredpU := (fun (p1 p2 : predp _) x => p1 x \/ p2 x).
Notation xpredpC := (fun (p : predp _) x => ~ p x).
Notation xpredpD := (fun (p1 p2 : predp _) x => ~ p2 x /\ p1 x).
Notation xpreimp := (fun f (p : predp _) x => p (f x)).
Notation xrelpU := (fun (r1 r2 : relp _) x y => r1 x y \/ r2 x y).
Definition
pred0p : forall {T : Type}, predp T -> bool pred0p is not universe polymorphic Arguments pred0p {T}%_type_scope P pred0p is transparent Expands to: Constant mathcomp.classical.boolp.pred0p Declared in library mathcomp.classical.boolp, line 636, characters 11-17
Prenex Implicits pred0p.
Lemma pred0pP (T : Type) (P : predp T) : reflect (P =1 xpredp0) (pred0p P).
Lemma forallp_asboolPn {T} {P : T -> Prop} :
reflect (forall x : T, ~ P x) (~~ `[<exists x : T, P x>]).
Proof.
Lemma existsp_asboolPn {T} {P : T -> Prop} :
reflect (exists x : T, ~ P x) (~~ `[<forall x : T, P x>]).
Proof.
Lemma asbool_forallNb {T : Type} (P : pred T) :
`[< forall x : T, ~~ (P x) >] = ~~ `[< exists x : T, P x >].
Proof.
Lemma asbool_existsNb {T : Type} (P : pred T) :
`[< exists x : T, ~~ (P x) >] = ~~ `[< forall x : T, P x >].
Proof.
Lemma not_implyP (P Q : Prop) : ~ (P -> Q) <-> P /\ ~ Q.
Proof.
Lemma not_andE (P Q : Prop) : (~ (P /\ Q)) = (~ P \/ ~ Q).
Proof.
by rewrite asbool_and negb_and => /orP[]/asboolPn; [left|right].
Qed.
Lemma not_andP (P Q : Prop) : ~ (P /\ Q) <-> ~ P \/ ~ Q.
Proof.
Lemma not_and3P (P Q R : Prop) : ~ [/\ P, Q & R] <-> [\/ ~ P, ~ Q | ~ R].
Proof.
by rewrite 2!negb_and -3!asbool_neg => /or3_asboolP.
by rewrite 3!asbool_neg -2!negb_and => /and3_asboolP.
Qed.
Lemma not_notP (P : Prop) : ~ ~ P <-> P.
Proof.
Notation notP := not_notP (only parsing).
Lemma not_notE (P : Prop) : (~ ~ P) = P.
#[deprecated(since="mathcomp-analysis 1.15.0", note="Renamed to `not_notE`. Warning: a different `notE` is provided by `contra.v`.")]
Notation notE := not_notE (only parsing).
Lemma not_orE (P Q : Prop) : (~ (P \/ Q)) = (~ P /\ ~ Q).
Lemma not_orP (P Q : Prop) : ~ (P \/ Q) <-> ~ P /\ ~ Q.
Proof.
Lemma not_implyE (P Q : Prop) : (~ (P -> Q)) = (P /\ ~ Q).
Proof.
Lemma implyE (P Q : Prop) : (P -> Q) = (~ P \/ Q).
Lemma orC : commutative or.
Lemma orA : associative or.
Proof.
Lemma orCA : left_commutative or.
Lemma orAC : right_commutative or.
Lemma orACA : interchange or or.
Lemma orNp P Q : (~ P \/ Q) = (P -> Q).
Lemma orpN P Q : (P \/ ~ Q) = (Q -> P)
Lemma or3E P Q R : [\/ P, Q | R] = (P \/ Q \/ R).
Proof.
by rewrite -2!(reflect_eq orP).
Qed.
Lemma or4E P Q R S : [\/ P, Q, R | S] = (P \/ Q \/ R \/ S).
Proof.
by rewrite -3!(reflect_eq orP).
Qed.
Lemma andC : commutative and.
Lemma andA : associative and.
Proof.
Lemma andCA : left_commutative and.
Lemma andAC : right_commutative and.
Lemma andACA : interchange and and.
Lemma and3E P Q R : [/\ P, Q & R] = (P /\ Q /\ R).
Proof.
Lemma and4E P Q R S : [/\ P, Q, R & S] = (P /\ Q /\ R /\ S).
Proof.
Lemma and5E P Q R S T : [/\ P, Q, R, S & T] = (P /\ Q /\ R /\ S /\ T).
Proof.
Lemma implyNp P Q : (~ P -> Q : Prop) = (P \/ Q).
Lemma implypN (P Q : Prop) : (P -> ~ Q) = (~ (P /\ Q)).
Lemma implyNN P Q : (~ P -> ~ Q) = (Q -> P).
Lemma or_andr : right_distributive or and.
Lemma or_andl : left_distributive or and.
Lemma and_orr : right_distributive and or.
Lemma and_orl : left_distributive and or.
Lemma forallNE {T} (P : T -> Prop) : (forall x, ~ P x) = (~ exists x, P x).
Proof.
Lemma existsNE {T} (P : T -> Prop) : (exists x, ~ P x) = (~ forall x, P x).
Proof.
Lemma existsNP T (P : T -> Prop) : (exists x, ~ P x) <-> ~ forall x, P x.
Proof.
Lemma not_existsP T (P : T -> Prop) : (exists x, P x) <-> ~ forall x, ~ P x.
Lemma forallNP T (P : T -> Prop) : (forall x, ~ P x) <-> ~ exists x, P x.
Proof.
Lemma not_forallP T (P : T -> Prop) : (forall x, P x) <-> ~ exists x, ~ P x.
Lemma exists2E A P Q : (exists2 x : A, P x & Q x) = (exists x, P x /\ Q x).
Proof.
Lemma exists2P T (P Q : T -> Prop) :
(exists2 x, P x & Q x) <-> exists x, P x /\ Q x.
Proof.
Lemma not_exists2P T (P Q : T -> Prop) :
(exists2 x, P x & Q x) <-> ~ forall x, ~ P x \/ ~ Q x.
Proof.
by split; apply: contra_not => PQx x; apply/not_andP; apply: PQx.
Qed.
Lemma forall2NP T (P Q : T -> Prop) :
(forall x, ~ P x \/ ~ Q x) <-> ~ (exists2 x, P x & Q x).
Proof.
by rewrite -not_andP => -[Pt Qt]; apply PQ; exists t.
Qed.
Lemma forallPNP T (P Q : T -> Prop) :
(forall x, P x -> ~ Q x) <-> ~ (exists2 x, P x & Q x).
Proof.
by move=> Pt Qt; apply: PQ; exists t.
Qed.
Lemma existsPNP T (P Q : T -> Prop) :
(exists2 x, P x & ~ Q x) <-> ~ (forall x, P x -> Q x).
Proof.
by apply: contra_notP => NQx; exists x.
Qed.
Lemma forallp_asboolPn2 {T} {P Q : T -> Prop} :
reflect (forall x : T, ~ P x \/ ~ Q x) (~~ `[<exists2 x : T, P x & Q x>]).
Proof.
Section bigmaxmin.
Local Notation max := Order.max.
Local Notation min := Order.min.
Local Open Scope order_scope.
Variables (d : Order.disp_t) (T : orderType d).
Variables (x : T) (I : finType) (P : pred I) (m : T) (F : I -> T).
Import Order.TTheory.
Lemma bigmax_geP : reflect (m <= x \/ exists2 i, P i & m <= F i)
(m <= \big[max/x]_(i | P i) F i).
Proof.
- rewrite leNgt => /bigmax_ltP /not_andP[/negP|]; first by rewrite -leNgt; left.
by move=> /existsNP[i /not_implyP[Pi /negP]]; rewrite -leNgt; right; exists i.
- by rewrite bigmax_idl le_max mx.
- by rewrite (bigmaxD1 i)// le_max mFi.
Qed.
Lemma bigmax_gtP : reflect (m < x \/ exists2 i, P i & m < F i)
(m < \big[max/x]_(i | P i) F i).
Proof.
- rewrite ltNge => /bigmax_leP /not_andP[/negP|]; first by rewrite -ltNge; left.
by move=> /existsNP[i /not_implyP[Pi /negP]]; rewrite -ltNge; right; exists i.
- by rewrite bigmax_idl lt_max mx.
- by rewrite (bigmaxD1 i)// lt_max mFi.
Qed.
Lemma bigmin_leP : reflect (x <= m \/ exists2 i, P i & F i <= m)
(\big[min/x]_(i | P i) F i <= m).
Proof.
- rewrite leNgt => /bigmin_gtP /not_andP[/negP|]; first by rewrite -leNgt; left.
by move=> /existsNP[i /not_implyP[Pi /negP]]; rewrite -leNgt; right; exists i.
- by rewrite bigmin_idl ge_min xm.
- by rewrite (bigminD1 i)// ge_min Fim.
Qed.
Lemma bigmin_ltP : reflect (x < m \/ exists2 i, P i & F i < m)
(\big[min/x]_(i | P i) F i < m).
Proof.
- rewrite ltNge => /bigmin_geP /not_andP[/negP|]; first by rewrite -ltNge; left.
by move=> /existsNP[i /not_implyP[Pi /negP]]; rewrite -ltNge; right; exists i.
- by rewrite bigmin_idl gt_min xm.
- by rewrite (bigminD1 _ _ _ Pi) gt_min Fim.
Qed.
End bigmaxmin.
Module FunOrder.
Section FunOrder.
Import Order.TTheory.
Variables (aT : Type) (d : Order.disp_t) (T : porderType d).
Implicit Types f g h : aT -> T.
Lemma fun_display : Order.disp_t
Proof.
Definition
FunOrder.lef : forall [aT : Type] [d : disp_t] [T : porderType d], (aT -> T) -> (aT -> T) -> bool FunOrder.lef is not universe polymorphic Arguments FunOrder.lef [aT]%_type_scope [d T] (f g)%_function_scope FunOrder.lef is transparent Expands to: Constant mathcomp.classical.boolp.FunOrder.lef Declared in library mathcomp.classical.boolp, line 917, characters 11-14
Local Notation "f <= g" := (lef f g).
Definition
FunOrder.ltf : forall [aT : Type] [d : disp_t] [T : porderType d], (aT -> T) -> (aT -> T) -> bool FunOrder.ltf is not universe polymorphic Arguments FunOrder.ltf [aT]%_type_scope [d T] (f g)%_function_scope FunOrder.ltf is transparent Expands to: Constant mathcomp.classical.boolp.FunOrder.ltf Declared in library mathcomp.classical.boolp, line 920, characters 11-14
Local Notation "f < g" := (ltf f g).
Lemma ltf_def f g : (f < g) = (g != f) && (f <= g).
Proof.
- by apply/eqP => gf; move: fg => /asboolP[fg] [x /eqP]; apply; rewrite gf.
- apply/asboolP => x; rewrite le_eqVlt; move/asboolP : fg => [fg [y gfy]].
by have [//|gfx /=] := boolP (f x == g x); rewrite lt_neqAle gfx /= fg.
- apply/not_existsP => h.
have : f =1 g by move=> x; have /negP/negPn/eqP := h x.
by rewrite -funeqE; apply/nesym/eqP.
Qed.
Fact lef_refl : reflexive lef
Proof.
Fact lef_anti : antisymmetric lef.
Proof.
Fact lef_trans : transitive lef.
#[export]
HB.instance Definition _ := @Order.isPOrder.Build
fun_display (aT -> T) lef ltf ltf_def lef_refl lef_anti lef_trans.
End FunOrder.
Section FunLattice.
Import Order.TTheory.
Variables (aT : Type) (d : Order.disp_t) (T : latticeType d).
Implicit Types f g h : aT -> T.
Definition
FunOrder.meetf : forall [aT : Type] [d : disp_t] [T : latticeType d], (aT -> T) -> (aT -> T) -> aT -> T FunOrder.meetf is not universe polymorphic Arguments FunOrder.meetf [aT]%_type_scope [d T] (f g)%_function_scope x FunOrder.meetf is transparent Expands to: Constant mathcomp.classical.boolp.FunOrder.meetf Declared in library mathcomp.classical.boolp, line 959, characters 11-16
Definition
FunOrder.joinf : forall [aT : Type] [d : disp_t] [T : latticeType d], (aT -> T) -> (aT -> T) -> aT -> T FunOrder.joinf is not universe polymorphic Arguments FunOrder.joinf [aT]%_type_scope [d T] (f g)%_function_scope x FunOrder.joinf is transparent Expands to: Constant mathcomp.classical.boolp.FunOrder.joinf Declared in library mathcomp.classical.boolp, line 960, characters 11-16
Lemma meetfC : commutative meetf.
Lemma joinfC : commutative joinf.
Lemma meetfA : associative meetf.
Lemma joinfA : associative joinf.
Lemma joinfKI g f : meetf f (joinf f g) = f.
Lemma meetfKU g f : joinf f (meetf f g) = f.
Lemma lef_meet f g : (f <= g)%O = (meetf f g == f).
Proof.
#[export]
HB.instance Definition _ := Order.POrder_isLattice.Build _ (aT -> T)
meetfC joinfC meetfA joinfA joinfKI meetfKU lef_meet.
End FunLattice.
Module Exports.
HB.reexport.
End Exports.
End FunOrder.
Export FunOrder.Exports.
Lemma lefP (aT : Type) d (T : porderType d) (f g : aT -> T) :
reflect (forall x, (f x <= g x)%O) (f <= g)%O.
Lemma meetfE (aT : Type) d (T : latticeType d) (f g : aT -> T) x :
((f `&` g) x = f x `&` g x)%O.
Proof.
Lemma joinfE (aT : Type) d (T : latticeType d) (f g : aT -> T) x :
((f `|` g) x = f x `|` g x)%O.
Proof.
Lemma iterfS {T} (f : T -> T) (n : nat) : iter n.+1 f = f \o iter n f.
Proof.
Lemma iterfSr {T} (f : T -> T) (n : nat) : iter n.+1 f = iter n f \o f.
Lemma iter0 {T} (f : T -> T) : iter 0 f = id.
Proof.
Section Inhabited.
Variable (T : Type).
Lemma inhabitedE : inhabited T = exists x : T, True.
Proof.
Lemma inhabited_witness : inhabited T -> T.
Proof.
End Inhabited.
Lemma uncurryK {X Y Z : Type} : cancel (@uncurry X Y Z) curry.
Proof.
Lemma curryK {X Y Z : Type} : cancel curry (@uncurry X Y Z).