author | paulson <lp15@cam.ac.uk> |
Mon, 30 Nov 2020 22:00:23 +0000 | |
changeset 72797 | 402afc68f2f9 |
parent 71469 | d7ef73df3d15 |
child 73398 | 180981b87929 |
permissions | -rw-r--r-- |
71393
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
1 |
theory Cyclic_List imports |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
2 |
"HOL-Library.Confluent_Quotient" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
3 |
begin |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
4 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
5 |
inductive cyclic1 :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" for xs where |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
6 |
"cyclic1 xs (rotate1 xs)" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
7 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
8 |
abbreviation cyclic :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" where |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
9 |
"cyclic \<equiv> equivclp cyclic1" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
10 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
11 |
lemma cyclic_mapI: "cyclic xs ys \<Longrightarrow> cyclic (map f xs) (map f ys)" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
12 |
by(induction rule: equivclp_induct) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
13 |
(auto 4 4 elim!: cyclic1.cases simp add: rotate1_map[symmetric] intro: equivclp_into_equivclp cyclic1.intros) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
14 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
15 |
quotient_type 'a cyclic_list = "'a list" / cyclic by simp |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
16 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
17 |
lemma map_respect_cyclic: includes lifting_syntax shows |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
18 |
"((=) ===> cyclic ===> cyclic) map map" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
19 |
by(auto simp add: rel_fun_def cyclic_mapI) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
20 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
21 |
lemma confluentp_cyclic1: "confluentp cyclic1" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
22 |
by(intro strong_confluentp_imp_confluentp strong_confluentpI)(auto simp add: cyclic1.simps) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
23 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
24 |
lemma cyclic_set_eq: "cyclic xs ys \<Longrightarrow> set xs = set ys" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
25 |
by(induction rule: converse_equivclp_induct)(simp_all add: cyclic1.simps, safe, simp_all) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
26 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
27 |
lemma retract_cyclic1: |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
28 |
assumes "cyclic1 (map f xs) ys" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
29 |
shows "\<exists>zs. cyclic xs zs \<and> ys = map f zs" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
30 |
using assms by(auto simp add: cyclic1.simps rotate1_map intro: cyclic1.intros symclpI1) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
31 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
32 |
lemma confluent_quotient_cyclic1: |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
33 |
"confluent_quotient cyclic1 cyclic cyclic cyclic cyclic cyclic (map fst) (map snd) (map fst) (map snd) list_all2 list_all2 list_all2 set set" |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
34 |
by(unfold_locales) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
35 |
(auto dest: retract_cyclic1 cyclic_set_eq simp add: list.in_rel list.rel_compp map_respect_cyclic[THEN rel_funD, OF refl] confluentp_cyclic1 intro: rtranclp_mono[THEN predicate2D, OF symclp_greater]) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
36 |
|
71469
d7ef73df3d15
lift BNF witnesses for quotients (unless better ones are specified by the user)
traytel
parents:
71393
diff
changeset
|
37 |
lift_bnf 'a cyclic_list |
71393
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
38 |
subgoal by(rule confluent_quotient.subdistributivity[OF confluent_quotient_cyclic1]) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
39 |
subgoal by(force dest: cyclic_set_eq) |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
40 |
done |
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
41 |
|
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
traytel
parents:
diff
changeset
|
42 |
end |