Debian Codegraph @

theories/Corelib/Classes/Morphisms_Prop.v

raw
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** * [Proper] instances for propositional connectives.
12
13 Author: Matthieu Sozeau
14 Institution: LRI, CNRS UMR 8623 - University Paris Sud
15 *)
16
17 Require Import Corelib.Classes.Morphisms.
18 Require Import Corelib.Program.Basics.
19 Require Import Corelib.Program.Tactics.
20
21 Local Obligation Tactic := try solve [simpl_relation | firstorder auto].
22
23 (** Standard instances for [not], [iff] and [impl]. *)
24
25 (** Logical negation. *)
26
27 #[global]
28 Program Instance not_impl_morphism :
29 Proper (impl --> impl) not | 1.
30
31 #[global]
32 Program Instance not_iff_morphism :
33 Proper (iff ++> iff) not.
34
35 (** Logical conjunction. *)
36
37 #[global]
38 Program Instance and_impl_morphism :
39 Proper (impl ==> impl ==> impl) and | 1.
40
41 #[global]
42 Program Instance and_iff_morphism :
43 Proper (iff ==> iff ==> iff) and.
44
45 (** Logical disjunction. *)
46
47 #[global]
48 Program Instance or_impl_morphism :
49 Proper (impl ==> impl ==> impl) or | 1.
50
51 #[global]
52 Program Instance or_iff_morphism :
53 Proper (iff ==> iff ==> iff) or.
54
55 (** Logical implication [impl] is a morphism for logical equivalence. *)
56
57 #[global]
58 Program Instance iff_iff_iff_impl_morphism : Proper (iff ==> iff ==> iff) impl.
59
60 (** Morphisms for quantifiers *)
61
62 #[global]
63 Program Instance ex_iff_morphism {A : Type} : Proper (pointwise_relation A iff ==> iff) (@ex A).
64
65 #[global]
66 Program Instance ex_impl_morphism {A : Type} :
67 Proper (pointwise_relation A impl ==> impl) (@ex A) | 1.
68
69 #[global]
70 Program Instance ex_flip_impl_morphism {A : Type} :
71 Proper (pointwise_relation A (flip impl) ==> flip impl) (@ex A) | 1.
72
73 #[global]
74 Program Instance all_iff_morphism {A : Type} :
75 Proper (pointwise_relation A iff ==> iff) (@all A).
76
77 #[global]
78 Program Instance all_impl_morphism {A : Type} :
79 Proper (pointwise_relation A impl ==> impl) (@all A) | 1.
80
81 #[global]
82 Program Instance all_flip_impl_morphism {A : Type} :
83 Proper (pointwise_relation A (flip impl) ==> flip impl) (@all A) | 1.
84
85 (** Equivalent points are simultaneously accessible or not *)
86
87 #[global]
88 Instance Acc_pt_morphism {A:Type}(E R : A->A->Prop)
89 `(Equivalence _ E) `(Proper _ (E==>E==>iff) R) :
90 Proper (E==>iff) (Acc R).
91 Proof.
92 apply proper_sym_impl_iff.
93 - auto with relations.
94 - intros x y EQ WF. apply Acc_intro; intros z Hz.
95 rewrite <- EQ in Hz. now apply Acc_inv with x.
96 Qed.
97
98 (** Equivalent relations have the same accessible points *)
99
100 #[global]
101 Instance Acc_rel_morphism {A:Type} :
102 Proper (relation_equivalence ==> Logic.eq ==> iff) (@Acc A).
103 Proof.
104 apply proper_sym_impl_iff_2.
105 - red; now symmetry.
106 - red; now symmetry.
107 - intros R R' EQ a a' Ha WF. subst a'.
108 induction WF as [x _ WF']. constructor.
109 intros y Ryx. now apply WF', EQ.
110 Qed.
111
112 (** Equivalent relations are simultaneously well-founded or not *)
113
114 #[global]
115 Instance well_founded_morphism {A : Type} :
116 Proper (relation_equivalence ==> iff) (@well_founded A).
117 Proof.
118 unfold well_founded. solve_proper.
119 Qed.