-
Notifications
You must be signed in to change notification settings - Fork 2
/
Ensf_types.v
147 lines (125 loc) · 4.94 KB
/
Ensf_types.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
(* This program is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1 *)
(* of the License, or (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this program; if not, write to the Free *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
(* Contribution to the Coq Library V6.3 (July 1999) *)
(****************************************************************************)
(* The Calculus of Inductive Constructions *)
(* *)
(* Projet Coq *)
(* *)
(* INRIA ENS-CNRS *)
(* Rocquencourt Lyon *)
(* *)
(* Coq V5.10 *)
(* Nov 25th 1994 *)
(* *)
(****************************************************************************)
(* Ensf_types.v *)
(****************************************************************************)
(* Formal Language Theory *)
(* *)
(* Judicael Courant - Jean-Christophe Filliatre *)
(* *)
(* Developped in V5.8 June-July 1993 *)
(* Ported to V5.10 October 1994 *)
(****************************************************************************)
(* On definit 3 "types" mutuellement inductifs : Elt, Ensf et Word *)
(* On distingue elt et mot, car on a besoin du type mot plus tard. *)
(* Les constructeurs up et word permettent repectivement de considerer *)
(* un ensemble ou un mot en tant qu'element. *)
Inductive Ensf : Set :=
| empty : Ensf
| add : Elt -> Ensf -> Ensf
with Elt : Set :=
| natural : nat -> Elt
| couple : Elt -> Elt -> Elt
| up : Ensf -> Elt
| word : Word -> Elt
with Word : Set :=
| nil : Word
| cons : Elt -> Word -> Word.
(* Inversion de quelques constructeurs... *)
(*
Definition natural_inv : Elt -> nat :=
[e:Elt]
(<nat>Case e of
(* natural *) [n:nat]n
(* couple *) [a:Elt][b:Elt]O
(* up *) [e:Ensf]O
(* word *) [w:Word]O
end ).
*)
Definition natural_inv (e : Elt) : nat :=
match e with
| natural n => n
| _ => 0
end.
Lemma nat_invol : forall n : nat, natural_inv (natural n) = n.
auto.
Qed.
(*
Definition word_inv : Elt -> Word :=
[e:Elt]
(<Word>Case e of
(* natural *) [n:nat]nil
(* couple *) [a:Elt][b:Elt]nil
(* up *) [e:Ensf]nil
(* word *) [w:Word]w
end ).
*)
Definition word_inv (e : Elt) : Word :=
match e with
| word w => w
| _ => nil
end.
(* Quelques resultats triviaux sur les constructeurs... *)
Lemma add_add :
forall (a b : Elt) (c d : Ensf), a = b -> c = d -> add a c = add b d.
intros.
rewrite H.
rewrite H0.
trivial.
Qed.
Hint Resolve add_add.
Lemma couple_couple :
forall a b c d : Elt, a = b -> c = d -> couple a c = couple b d.
intros.
rewrite H.
rewrite H0.
trivial.
Qed.
Lemma word_word : forall a b : Word, a = b -> word a = word b.
intros.
apply (f_equal (A:=Word) (B:=Elt)); auto.
Qed.
Hint Resolve word_word.
Lemma word_word_inv : forall a b : Word, word a = word b -> a = b.
intros a b H.
injection H.
trivial.
Qed.
(* Quelques simplifications *)
Definition zero : Elt := natural 0.
Definition un : Elt := natural 1.
Definition singleton (e : Elt) : Ensf := add e empty.
(* Quelques petits lemmes divers... *)
Lemma False_imp_P : forall P : Prop, False -> P.
intros.
elimtype False.
assumption.
Qed.
Lemma equal_add : forall (a b : Ensf) (e : Elt), a = b -> add e a = add e b.
intros.
apply (f_equal (A:=Ensf) (B:=Ensf)); auto.
Qed.