-
Notifications
You must be signed in to change notification settings - Fork 0
/
def.v
40 lines (33 loc) · 1.11 KB
/
def.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
Require Import String Lia dict func.
Definition IsWord (s : string) : Prop := isWord s = true.
Inductive Step : string -> string -> nat -> Prop :=
| CHEAT : forall s s' l, Step s s' l
| Diff : forall s s', Step s s' (char_diff_sqr s s')
| Perm : forall s s', is_anagram s s' = true -> Step s s' 1
| PreSuf : forall s s', presuf s s' = true -> Step s s' (presuf_cost s s').
Inductive Path : string -> string -> nat -> Prop :=
| Win : forall s l, Path s s l
| Move : forall s s' t l l' d, Step s s' d -> IsWord s' -> Path s' t l' -> d <= l -> l' = l - d -> Path s t l.
Ltac Next s' d :=
match goal with
| |- (Path ?s ?t ?l) =>
refine (Move s s' t l _ d _ (eq_refl _) _ (ltac:(lia)) (ltac:(auto)));
try assumption;
auto;
simpl;
try (apply Diff; reflexivity);
try (apply Perm; reflexivity);
try (apply PreSuf; reflexivity)
end.
Ltac There :=
try (
match goal with
| |- (Path ?s ?t ?l) =>
Next t l;
apply Win
end);
match goal with
| |- (Path ?s ?s ?l) =>
apply Win
end.
Notation "( x <-- l --> y )" := (Path x y l) (at level 70).