-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemp.v
263 lines (215 loc) · 6.04 KB
/
temp.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
Require Import Bool List ListDec String.
Require Import bt basic micro_smv bt2spec fsm.
Inductive my_skills :=
sk1 | sk2 | sk3 | sk4.
Definition my_names (x: my_skills) :=
match x with
| sk1 => "Go_to_kitchen"
| sk2 => "find"
| sk3 => "fetch"
| sk4 => "ask"
end.
Module ex_skills.
Definition skillSet := my_skills.
Definition skillName := my_names.
End ex_skills.
Module my_bt := BT_gen_semantics ex_skills.
Import my_bt.
Definition triv := Skill sk1.
(*Compute tick triv (fun x => match x with _ => Succ end).*)
Definition sconst_of_ret (x: return_enum) :=
match x with
| Succ => "Succ"
| Runn => "Runn"
| Fail => "Fail"
end.
Definition make_inputs (f: skills_input) :=
cons (sconst_of_ret (f sk1)) nil.
(* equality of states *)
Scheme Equality for list.
(* specialization for states (= list of strings) *)
Definition state_beq := list_beq string string_beq.
(* state -> state -> bool *)
Definition state_eq_dec := list_eq_dec string string_beq string_beq_correct1 string_beq_correct2.
(* forall x y : state, {x = y} + {x <> y} *)
Definition state_beq_correct1 := internal_list_dec_bl string string_beq string_beq_correct1.
(* forall x y : state, state_beq x y = true -> x = y *)
Definition state_beq_correct2 := internal_list_dec_lb string string_beq string_beq_correct2.
(* forall x y : state, x = y -> state_beq x y = true *)
(* other desirable lemmas having to do with list equality *)
Lemma list_eq_1: forall A (x1 x2 : A) (l1 l2 : list A),
x1 :: l1 = x2 :: l2 -> x1 = x2 /\ l1 = l2.
Proof.
intros; split; injection H; auto.
Qed.
Lemma list_eq_2: forall A (x1 x2 : A) (l1 l2 : list A),
x1 = x2 /\ l1 = l2 -> x1 :: l1 = x2 :: l2.
Proof.
intros.
destruct H as [H1 H2].
rewrite H1.
rewrite H2.
trivial.
Qed.
(* Trying to prove something for the inverter... *)
Theorem inverter_ini_ex: exists x: state, is_initial inverter x = true.
Proof.
exists ("FALSE"::nil).
unfold is_initial; simpl; auto.
Qed.
(*
Theorem inverter_ini_uniq: forall x: state,
is_initial inverter x = true -> x = ("FALSE"::nil).
Proof.
intros.
destruct x.
- easy.
- destruct (string_dec s "FALSE").
-- rewrite e.
apply list_eq_2.
split.
--- trivial.
--- rewrite e in H.
simpl in H.
compute in H.
destruct x.
+ trivial.
+ exfalso; apply diff_false_true; exact H.
-- red in n.
exfalso.
apply n.
compute in H.
(*
bool_choice:
forall (S : Set) (R1 R2 : S -> Prop),
(forall x : S, {R1 x} + {R2 x}) ->
{f : S -> bool | forall x : S, f x = true /\ R1 x \/ f x = false /\ R2 x}
forall (S : Set) (R1 R2 : S -> Prop),
(forall x : S, {R1 x} + {R2 x}) ->
{f : S -> bool | forall x : S, f x = true /\ R1 x \/ f x = false /\ R2 x}
*)
Qed.
*)
Theorem inverter_det: forall x n1 n2: state, forall i: inputs,
(is_next_of inverter x i n1 = true) /\
(is_next_of inverter x i n2 = true) -> n1 = n2.
Proof.
intros.
destruct H.
induction n1; induction n2.
- trivial.
- easy.
- easy.
- apply list_eq_2.
split.
-- unfold is_next_of in H.
simpl in H.
Qed.
(* proof that single_leaf is deterministic *)
Theorem init_state_ex: exists x: state, is_initial single_leaf x = true.
Proof.
exists ("none"::"TRUE"::nil).
unfold is_initial; simpl; auto.
Qed.
Lemma btriv_t: forall b: bool, (if b then true else true) = true.
Proof.
intro; destruct b; auto.
Qed.
Lemma btriv_f: forall b: bool, (if b then false else false) = false.
Proof.
intro; destruct b; auto.
Qed.
(*
Goal forall P Q: Prop, (P -> Q) -> (~Q -> ~P).
intros.
red.
intro.
assert Q by apply (H H1).
easy.
Qed.
Search (_ = false).
not_false_is_true: forall b : bool, b <> false -> b = true
eq_true_false_abs: forall b : bool, b = true -> b = false -> False
not_true_is_false: forall b : bool, b <> true -> b = false
*)
Lemma contrapp_sbc1: forall s1 s2 : string, s1 <> s2 -> string_beq s1 s2 = false.
Proof.
intros s1 s2 H.
apply (not_true_is_false (string_beq s1 s2)).
red; intro.
red in H.
apply H.
apply (string_beq_correct1 s1 s2 H0).
Qed.
(*
Theorem init_state_uniq: forall x: state,
is_initial single_leaf x = true -> x = ("none"::"TRUE"::nil).
Proof.
intro x.
(* unfold is_initial; simpl.*)
destruct x.
- easy.
- destruct (string_dec s "none").
-- rewrite e.
intro H.
apply list_eq_2.
split.
+ auto.
+ destruct x.
++ easy.
++ destruct (string_dec s0 "TRUE").
* rewrite e0 in *.
apply list_eq_2.
split.
** auto.
** destruct x.
--- trivial.
--- easy.
* assert (string_beq s0 "TRUE" = false).
** apply (contrapp_sbc1 s0 "TRUE" n).
** compute in H.
compute in H0.
fold string_beq in H.
(* come fargli capire che questo contesto è inconsistente? *)
vecchia roba:
rewrite btriv_f.
intros [Hc _].
exfalso.
pose proof diff_false_true.
red in H.
apply (H Hc).
-- destruct x2.
++ set (b := string_equal "none" s0).
rewrite btriv_f.
intros [_ Hc]; exfalso.
pose proof diff_false_true.
red in H.
apply (H Hc).
++
*)
(*
Theorem sl_is_det2: forall x n1 n2: state, forall i: inputs,
(is_next_of single_leaf x i n1 = true) /\
(is_next_of single_leaf x i n2 = true) -> n1 = n2.
Proof.
intros x n1 n2 i.
unfold is_next_of; simpl.
*)
Theorem prova: forall input_f: skills_input,
(tick triv input_f = Succ) <->
(exec_determ single_leaf (make_inputs input_f) = Some ("Succ" :: nil)).
Proof.
intros.
split.
- intro.
unfold exec_determ.
simpl.
unfold next_states.
simpl. (* discreto chiodo... *)
Search filter.
(* in general:
forall t, forall input_f, (tick t input_f = Succ) <->
(exec_determ (flatten (make_main t)) (make_inputs input_f)
= Some ("Succ"::nil))
+ other cases...
*)