1479 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
1440 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
1480 by (rule_tac x = "[]" in exI, auto) |
1441 by (rule_tac x = "[]" in exI, auto) |
1481 moreover have "x = {[c]} \<Longrightarrow> x \<in> QUOT {[c]}" |
1442 moreover have "x = {[c]} \<Longrightarrow> x \<in> QUOT {[c]}" |
1482 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
1443 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
1483 apply (rule_tac x = "[c]" in exI, simp) |
1444 apply (rule_tac x = "[c]" in exI, simp) |
1484 apply (rule temp_set_ext, rule iffI, simp+) |
1445 apply (rule set_ext, rule iffI, simp+) |
1485 by (drule_tac x = "[]" in spec, simp) |
1446 by (drule_tac x = "[]" in spec, simp) |
1486 moreover have "x = UNIV - {[],[c]} \<Longrightarrow> x \<in> QUOT {[c]}" |
1447 moreover have "x = UNIV - {[],[c]} \<Longrightarrow> x \<in> QUOT {[c]}" |
1487 using exist_another |
1448 using exist_another |
1488 apply (clarsimp simp add:QUOT_def equiv_class_def equiv_str_def) |
1449 apply (clarsimp simp add:QUOT_def equiv_class_def equiv_str_def) |
1489 apply (rule_tac x = "[a]" in exI, simp) |
1450 apply (rule_tac x = "[a]" in exI, simp) |
1490 apply (rule temp_set_ext, rule iffI, simp) |
1451 apply (rule set_ext, rule iffI, simp) |
1491 apply (clarsimp simp:quot_single_aux, simp) |
1452 apply (clarsimp simp:quot_single_aux, simp) |
1492 apply (rule conjI) |
1453 apply (rule conjI) |
1493 apply (drule_tac x = "[c]" in spec, simp) |
1454 apply (drule_tac x = "[c]" in spec, simp) |
1494 by (drule_tac x = "[]" in spec, simp) |
1455 by (drule_tac x = "[]" in spec, simp) |
1495 ultimately show ?thesis using in_res by blast |
1456 ultimately show ?thesis using in_res by blast |
1496 qed |
1457 qed |
1497 qed |
1458 qed |
1498 qed |
1459 qed |
1499 qed |
1460 qed |
1500 |
1461 |
1501 lemma quot_seq: |
1462 lemma eq_class_imp_eq_str: |
1502 assumes finite1: "finite (QUOT L\<^isub>1)" |
1463 "\<lbrakk>x\<rbrakk>lang = \<lbrakk>y\<rbrakk>lang \<Longrightarrow> x \<equiv>lang\<equiv> y" |
1503 and finite2: "finite (QUOT L\<^isub>2)" |
1464 by (auto simp:equiv_class_def equiv_str_def) |
1504 shows "finite (QUOT (L\<^isub>1;L\<^isub>2))" |
|
1505 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
|
1506 sorry |
|
1507 |
|
1508 |
|
1509 lemma a: |
|
1510 "\<lbrakk>x \<equiv>L1\<equiv> y \<and> x \<equiv>L2\<equiv> y\<rbrakk> \<Longrightarrow> x \<equiv>(L1 \<union> L2)\<equiv> y" |
|
1511 apply(simp add: equiv_str_def) |
|
1512 done |
|
1513 |
|
1514 |
|
1515 (* |
|
1516 lemma quot_star: |
|
1517 assumes finite1: "finite (QUOT L\<^isub>1)" |
|
1518 shows "finite (QUOT (L\<^isub>1\<star>))" |
|
1519 sorry |
|
1520 |
|
1521 |
|
1522 lemma other_direction: |
|
1523 "Lang = L (r::rexp) \<Longrightarrow> finite (QUOT Lang)" |
|
1524 apply (induct arbitrary:Lang rule:rexp.induct) |
|
1525 apply (simp add:QUOT_def equiv_class_def equiv_str_def) |
|
1526 by (simp_all add:quot_lambda quot_single quot_seq quot_alt quot_star) |
|
1527 |
|
1528 lemma test: |
|
1529 "UNIV Quo Lang = QUOT Lang" |
|
1530 by (auto simp add: quot_def QUOT_def) |
|
1531 *) |
|
1532 |
|
1533 |
|
1534 (* by chunhan *) |
|
1535 |
|
1536 |
1465 |
1537 lemma finite_tag_image: |
1466 lemma finite_tag_image: |
1538 "finite (range tag) \<Longrightarrow> finite (((op `) tag) ` S)" |
1467 "finite (range tag) \<Longrightarrow> finite (((op `) tag) ` S)" |
1539 apply (rule_tac B = "Pow (tag ` UNIV)" in finite_subset) |
1468 apply (rule_tac B = "Pow (tag ` UNIV)" in finite_subset) |
1540 by (auto simp add:image_def Pow_def) |
1469 by (auto simp add:image_def Pow_def) |
1541 |
1470 |
1542 term image |
|
1543 term "(op `) tag" |
|
1544 |
|
1545 lemma str_inj_imps: |
1471 lemma str_inj_imps: |
1546 assumes str_inj: "\<And> m n. tag m = tag (n::string) \<Longrightarrow> m \<equiv>lang\<equiv> n" |
1472 assumes str_inj: "\<And> m n. tag m = tag (n::string) \<Longrightarrow> m \<equiv>lang\<equiv> n" |
1547 shows "inj_on (image tag) (QUOT lang)" |
1473 shows "inj_on ((op `) tag) (QUOT lang)" |
1548 proof (clarsimp simp add:inj_on_def QUOT_def) |
1474 proof (clarsimp simp add:inj_on_def QUOT_def) |
1549 fix x y |
1475 fix x y |
1550 assume eq_tag: "tag ` \<lbrakk>x\<rbrakk>lang = tag ` \<lbrakk>y\<rbrakk>lang" |
1476 assume eq_tag: "tag ` \<lbrakk>x\<rbrakk>lang = tag ` \<lbrakk>y\<rbrakk>lang" |
1551 show "\<lbrakk>x\<rbrakk>lang = \<lbrakk>y\<rbrakk>lang" |
1477 show "\<lbrakk>x\<rbrakk>lang = \<lbrakk>y\<rbrakk>lang" |
1552 proof - |
1478 proof - |
1593 |
1512 |
1594 lemma quot_alt: |
1513 lemma quot_alt: |
1595 assumes finite1: "finite (QUOT L\<^isub>1)" |
1514 assumes finite1: "finite (QUOT L\<^isub>1)" |
1596 and finite2: "finite (QUOT L\<^isub>2)" |
1515 and finite2: "finite (QUOT L\<^isub>2)" |
1597 shows "finite (QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1516 shows "finite (QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1598 proof - |
1517 proof (rule_tac f = "(op `) (tag_str_ALT L\<^isub>1 L\<^isub>2)" in finite_imageD) |
1599 have "finite (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2) ` QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1518 show "finite (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2) ` QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1600 using finite_tag_image tag_str_alt_range_finite finite1 finite2 |
1519 using finite_tag_image tag_str_alt_range_finite finite1 finite2 |
1601 by auto |
1520 by auto |
1602 moreover |
1521 next |
1603 have "inj_on (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2)) (QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1522 show "inj_on (op ` (tag_str_ALT L\<^isub>1 L\<^isub>2)) (QUOT (L\<^isub>1 \<union> L\<^isub>2))" |
1604 apply (rule_tac str_inj_imps) |
1523 apply (rule_tac str_inj_imps) |
1605 by (erule_tac tag_str_alt_inj) |
1524 by (erule_tac tag_str_alt_inj) |
1606 ultimately |
1525 qed |
1607 show "finite (QUOT (L\<^isub>1 \<union> L\<^isub>2))" by (rule finite_imageD) |
|
1608 qed |
|
1609 |
|
1610 |
|
1611 (*by cu *) |
|
1612 |
|
1613 |
|
1614 definition |
|
1615 str_eq ("_ \<approx>_ _") |
|
1616 where |
|
1617 "x \<approx>Lang y \<equiv> (\<forall>z. x @ z \<in> Lang \<longleftrightarrow> y @ z \<in> Lang)" |
|
1618 |
|
1619 definition |
|
1620 str_eq_rel ("\<approx>_") |
|
1621 where |
|
1622 "\<approx>Lang \<equiv> {(x, y). x \<approx>Lang y}" |
|
1623 |
|
1624 lemma [simp]: |
|
1625 "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y" |
|
1626 by simp |
|
1627 |
|
1628 lemma inj_image_lang: |
|
1629 fixes f::"string \<Rightarrow> 'a" |
|
1630 assumes str_inj: "\<And>x y. f x = f y \<Longrightarrow> x \<approx>Lang y" |
|
1631 shows "inj_on (image f) (UNIV // (\<approx>Lang))" |
|
1632 proof - |
|
1633 { fix x y::string |
|
1634 assume eq_tag: "f ` {z. x \<approx>Lang z} = f ` {z. y \<approx>Lang z}" |
|
1635 moreover |
|
1636 have "{z. x \<approx>Lang z} \<noteq> {}" unfolding str_eq_def by auto |
|
1637 ultimately obtain a b where "x \<approx>Lang a" "y \<approx>Lang b" "f a = f b" by blast |
|
1638 then have "x \<approx>Lang a" "y \<approx>Lang b" "a \<approx>Lang b" using str_inj by auto |
|
1639 then have "x \<approx>Lang y" unfolding str_eq_def by simp |
|
1640 then have "{z. x \<approx>Lang z} = {z. y \<approx>Lang z}" unfolding str_eq_def by simp |
|
1641 } |
|
1642 then have "\<forall>x\<in>UNIV // \<approx>Lang. \<forall>y\<in>UNIV // \<approx>Lang. f ` x = f ` y \<longrightarrow> x = y" |
|
1643 unfolding quotient_def Image_def str_eq_rel_def by simp |
|
1644 then show "inj_on (image f) (UNIV // (\<approx>Lang))" |
|
1645 unfolding inj_on_def by simp |
|
1646 qed |
|
1647 |
|
1648 |
|
1649 lemma finite_range_image: |
|
1650 assumes fin: "finite (range f)" |
|
1651 shows "finite ((image f) ` X)" |
|
1652 proof - |
|
1653 from fin have "finite (Pow (f ` UNIV))" by auto |
|
1654 moreover |
|
1655 have "(image f) ` X \<subseteq> Pow (f ` UNIV)" by auto |
|
1656 ultimately show "finite ((image f) ` X)" using finite_subset by auto |
|
1657 qed |
|
1658 |
|
1659 definition |
|
1660 tag1 :: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set)" |
|
1661 where |
|
1662 "tag1 L\<^isub>1 L\<^isub>2 \<equiv> \<lambda>x. ((\<approx>L\<^isub>1) `` {x}, (\<approx>L\<^isub>2) `` {x})" |
|
1663 |
|
1664 lemma tag1_range_finite: |
|
1665 assumes finite1: "finite (UNIV // \<approx>L\<^isub>1)" |
|
1666 and finite2: "finite (UNIV // \<approx>L\<^isub>2)" |
|
1667 shows "finite (range (tag1 L\<^isub>1 L\<^isub>2))" |
|
1668 proof - |
|
1669 have "finite (UNIV // \<approx>L\<^isub>1 \<times> UNIV // \<approx>L\<^isub>2)" using finite1 finite2 by auto |
|
1670 moreover |
|
1671 have "range (tag1 L\<^isub>1 L\<^isub>2) \<subseteq> (UNIV // \<approx>L\<^isub>1) \<times> (UNIV // \<approx>L\<^isub>2)" |
|
1672 unfolding tag1_def quotient_def by auto |
|
1673 ultimately show "finite (range (tag1 L\<^isub>1 L\<^isub>2))" |
|
1674 using finite_subset by blast |
|
1675 qed |
|
1676 |
|
1677 lemma tag1_inj: |
|
1678 "tag1 L\<^isub>1 L\<^isub>2 x = tag1 L\<^isub>1 L\<^isub>2 y \<Longrightarrow> x \<approx>(L\<^isub>1 \<union> L\<^isub>2) y" |
|
1679 unfolding tag1_def Image_def str_eq_rel_def str_eq_def |
|
1680 by auto |
|
1681 |
|
1682 lemma quot_alt_cu: |
|
1683 fixes L\<^isub>1 L\<^isub>2::"string set" |
|
1684 assumes fin1: "finite (UNIV // \<approx>L\<^isub>1)" |
|
1685 and fin2: "finite (UNIV // \<approx>L\<^isub>2)" |
|
1686 shows "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" |
|
1687 proof - |
|
1688 have "finite (range (tag1 L\<^isub>1 L\<^isub>2))" |
|
1689 using fin1 fin2 tag1_range_finite by simp |
|
1690 then have "finite (image (tag1 L\<^isub>1 L\<^isub>2) ` (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2)))" |
|
1691 using finite_range_image by blast |
|
1692 moreover |
|
1693 have "\<And>x y. tag1 L\<^isub>1 L\<^isub>2 x = tag1 L\<^isub>1 L\<^isub>2 y \<Longrightarrow> x \<approx>(L\<^isub>1 \<union> L\<^isub>2) y" |
|
1694 using tag1_inj by simp |
|
1695 then have "inj_on (image (tag1 L\<^isub>1 L\<^isub>2)) (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" |
|
1696 using inj_image_lang by blast |
|
1697 ultimately |
|
1698 show "finite (UNIV // \<approx>(L\<^isub>1 \<union> L\<^isub>2))" by (rule finite_imageD) |
|
1699 qed |
|
1700 |
|
1701 (* by chunhan *) |
|
1702 |
1526 |
1703 (* list_diff:: list substract, once different return tailer *) |
1527 (* list_diff:: list substract, once different return tailer *) |
1704 fun list_diff :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infix "-" 51) |
1528 fun list_diff :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infix "-" 51) |
1705 where |
1529 where |
1706 "list_diff [] xs = []" | |
1530 "list_diff [] xs = []" | |
1707 "list_diff (x#xs) [] = x#xs" | |
1531 "list_diff (x#xs) [] = x#xs" | |
1708 "list_diff (x#xs) (y#ys) = (if x = y then list_diff xs ys else (x#xs))" |
1532 "list_diff (x#xs) (y#ys) = (if x = y then list_diff xs ys else (x#xs))" |
1709 |
1533 |
1710 definition tag_str_SEQ:: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set) set" |
1534 lemma [simp]: "(x @ y) - x = y" |
1711 where |
1535 apply (induct x) |
1712 "tag_str_SEQ L\<^isub>1 L\<^isub>2 x \<equiv> if (\<exists> y. y \<le> x \<and> y \<in> L\<^isub>1) |
1536 by (case_tac y, simp+) |
1713 then {(\<lbrakk>(x - y)\<rbrakk>L\<^isub>2) | y. y \<le> x \<and> y \<in> L\<^isub>1} |
1537 |
1714 else { \<lbrakk>x\<rbrakk>L\<^isub>1 }" |
1538 lemma [simp]: "x - x = []" |
|
1539 by (induct x, auto) |
|
1540 |
|
1541 lemma [simp]: "x = xa @ y \<Longrightarrow> x - xa = y " |
|
1542 by (induct x, auto) |
|
1543 |
|
1544 lemma [simp]: "x - [] = x" |
|
1545 by (induct x, auto) |
|
1546 |
|
1547 lemma [simp]: "xa \<le> x \<Longrightarrow> (x @ y) - xa = (x - xa) @ y" |
|
1548 by (auto elim:prefixE) |
|
1549 |
|
1550 definition tag_str_SEQ:: "string set \<Rightarrow> string set \<Rightarrow> string \<Rightarrow> (string set \<times> string set set)" |
|
1551 where |
|
1552 "tag_str_SEQ L\<^isub>1 L\<^isub>2 x \<equiv> if (\<exists> xa \<le> x. xa \<in> L\<^isub>1) |
|
1553 then (\<lbrakk>x\<rbrakk>L\<^isub>1, {\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa. xa \<le> x \<and> xa \<in> L\<^isub>1}) |
|
1554 else (\<lbrakk>x\<rbrakk>L\<^isub>1, {})" |
|
1555 |
|
1556 lemma tag_seq_eq_E: |
|
1557 "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y \<Longrightarrow> |
|
1558 ((\<exists> xa \<le> x. xa \<in> L\<^isub>1) \<and> \<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1 \<and> |
|
1559 {\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa. xa \<le> x \<and> xa \<in> L\<^isub>1} = {\<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 | ya. ya \<le> y \<and> ya \<in> L\<^isub>1} ) \<or> |
|
1560 ((\<forall> xa \<le> x. xa \<notin> L\<^isub>1) \<and> \<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1)" |
|
1561 by (simp add:tag_str_SEQ_def split:if_splits, blast) |
1715 |
1562 |
1716 lemma tag_str_seq_range_finite: |
1563 lemma tag_str_seq_range_finite: |
1717 assumes finite1: "finite (QUOT L\<^isub>1)" |
1564 assumes finite1: "finite (QUOT L\<^isub>1)" |
1718 and finite2: "finite (QUOT L\<^isub>2)" |
1565 and finite2: "finite (QUOT L\<^isub>2)" |
1719 shows "finite (range (tag_str_SEQ L\<^isub>1 L\<^isub>2))" |
1566 shows "finite (range (tag_str_SEQ L\<^isub>1 L\<^isub>2))" |
1720 proof - |
1567 proof - |
1721 have "(range (tag_str_SEQ L\<^isub>1 L\<^isub>2)) \<subseteq> Pow ((QUOT L\<^isub>1) \<union> (QUOT L\<^isub>2))" |
1568 have "(range (tag_str_SEQ L\<^isub>1 L\<^isub>2)) \<subseteq> (QUOT L\<^isub>1) \<times> (Pow (QUOT L\<^isub>2))" |
1722 by (auto simp:image_def tag_str_SEQ_def QUOT_def) |
1569 by (auto simp:image_def tag_str_SEQ_def QUOT_def) |
1723 thus ?thesis using finite1 finite2 |
1570 thus ?thesis using finite1 finite2 |
1724 by (rule_tac B = "Pow ((QUOT L\<^isub>1) \<union> (QUOT L\<^isub>2))" in finite_subset, auto) |
1571 by (rule_tac B = "(QUOT L\<^isub>1) \<times> (Pow (QUOT L\<^isub>2))" in finite_subset, auto) |
1725 qed |
1572 qed |
1726 |
1573 |
|
1574 lemma app_in_seq_decom[rule_format]: |
|
1575 "\<forall> x. x @ z \<in> L\<^isub>1 ; L\<^isub>2 \<longrightarrow> (\<exists> xa \<le> x. xa \<in> L\<^isub>1 \<and> (x - xa) @ z \<in> L\<^isub>2) \<or> |
|
1576 (\<exists> za \<le> z. (x @ za) \<in> L\<^isub>1 \<and> (z - za) \<in> L\<^isub>2)" |
|
1577 apply (induct z) |
|
1578 apply (simp, rule allI, rule impI, rule disjI1) |
|
1579 apply (clarsimp simp add:lang_seq_def) |
|
1580 apply (rule_tac x = s1 in exI, simp) |
|
1581 apply (rule allI | rule impI)+ |
|
1582 apply (drule_tac x = "x @ [a]" in spec, simp) |
|
1583 apply (erule exE | erule conjE | erule disjE)+ |
|
1584 apply (rule disjI2, rule_tac x = "[a]" in exI, simp) |
|
1585 apply (rule disjI1, rule_tac x = xa in exI, simp) |
|
1586 apply (erule exE | erule conjE)+ |
|
1587 apply (rule disjI2, rule_tac x = "a # za" in exI, simp) |
|
1588 done |
|
1589 |
1727 lemma tag_str_seq_inj: |
1590 lemma tag_str_seq_inj: |
1728 assumes tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y" |
1591 assumes tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y" |
1729 shows "(x::string) \<equiv>(L\<^isub>1 ; L\<^isub>2)\<equiv> y" |
1592 shows "(x::string) \<equiv>(L\<^isub>1 ; L\<^isub>2)\<equiv> y" |
1730 proof (cases "\<exists> xa. xa \<le> x \<and> xa \<in> L\<^isub>1") |
1593 proof - |
1731 have equiv_str_sym: "\<And> x y lang. (x::string) \<equiv>lang\<equiv> y \<Longrightarrow> y \<equiv>lang\<equiv> x" |
1594 have aux: "\<And> x y z. \<lbrakk>tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y; x @ z \<in> L\<^isub>1 ; L\<^isub>2\<rbrakk> |
1732 by (auto simp:equiv_str_def) |
1595 \<Longrightarrow> y @ z \<in> L\<^isub>1 ; L\<^isub>2" |
1733 have set_equ_D: "\<And> A a B b. \<lbrakk>A = B; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists> a b. a \<in> A \<and> b \<in> B \<and> a = b " by auto |
1596 proof (drule app_in_seq_decom, erule disjE) |
1734 have eqset_equ_D: "\<And> x y lang. {y. x \<equiv>lang\<equiv> y} = {ya. y \<equiv>lang\<equiv> ya} \<Longrightarrow> x \<equiv>lang\<equiv> y" |
1597 fix x y z |
1735 by (drule set_equ_D, auto simp:equiv_str_def) |
1598 assume tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y" |
1736 assume x_left_l1: "\<exists>xa\<le>x. xa \<in> L\<^isub>1" |
1599 and x_gets_l2: "\<exists>xa\<le>x. xa \<in> L\<^isub>1 \<and> (x - xa) @ z \<in> L\<^isub>2" |
1737 show "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
1600 from x_gets_l2 have "\<exists> xa \<le> x. xa \<in> L\<^isub>1" by blast |
1738 proof (cases "\<exists> ya. ya \<le> y \<and> ya \<in> L\<^isub>1") |
1601 hence xy_l2:"{\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 | xa. xa \<le> x \<and> xa \<in> L\<^isub>1} = {\<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 | ya. ya \<le> y \<and> ya \<in> L\<^isub>1}" |
1739 assume y_left_l1: "\<exists>ya\<le>y. ya \<in> L\<^isub>1" |
1602 using tag_eq tag_seq_eq_E by blast |
1740 with tag_eq x_left_l1 |
1603 from x_gets_l2 obtain xa where xa_le_x: "xa \<le> x" |
1741 show "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
1604 and xa_in_l1: "xa \<in> L\<^isub>1" |
1742 apply (simp add:tag_str_SEQ_def) |
1605 and rest_in_l2: "(x - xa) @ z \<in> L\<^isub>2" by blast |
1743 apply (drule set_equ_D) |
1606 hence "\<exists> ya. \<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 = \<lbrakk>(y - ya)\<rbrakk>L\<^isub>2 \<and> ya \<le> y \<and> ya \<in> L\<^isub>1" using xy_l2 by auto |
1744 apply (auto simp:equiv_class_def equiv_str_def)[1] |
1607 then obtain ya where ya_le_x: "ya \<le> y" |
1745 apply (clarsimp simp:equiv_str_def) |
1608 and ya_in_l1: "ya \<in> L\<^isub>1" |
1746 apply (rule iffI) |
1609 and rest_eq: "\<lbrakk>(x - xa)\<rbrakk>L\<^isub>2 = \<lbrakk>(y - ya)\<rbrakk>L\<^isub>2" by blast |
1747 apply |
1610 from rest_eq rest_in_l2 have "(y - ya) @ z \<in> L\<^isub>2" |
1748 apply ( |
1611 by (auto simp:equiv_class_def equiv_str_def) |
|
1612 hence "ya @ ((y - ya) @ z) \<in> L\<^isub>1 ; L\<^isub>2" using ya_in_l1 |
|
1613 by (auto simp:lang_seq_def) |
|
1614 thus "y @ z \<in> L\<^isub>1 ; L\<^isub>2" using ya_le_x |
|
1615 by (erule_tac prefixE, simp) |
1749 next |
1616 next |
1750 assume y_in_l1: "\<not> (\<exists>ya\<le>y. ya \<in> L\<^isub>1)" |
1617 fix x y z |
1751 show "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
1618 assume tag_eq: "tag_str_SEQ L\<^isub>1 L\<^isub>2 x = tag_str_SEQ L\<^isub>1 L\<^isub>2 y" |
1752 sorry |
1619 and x_gets_l1: "\<exists>za\<le>z. x @ za \<in> L\<^isub>1 \<and> z - za \<in> L\<^isub>2" |
|
1620 from tag_eq tag_seq_eq_E have x_y_eq: "\<lbrakk>x\<rbrakk>L\<^isub>1 = \<lbrakk>y\<rbrakk>L\<^isub>1" by blast |
|
1621 from x_gets_l1 obtain za where za_le_z: "za \<le> z" |
|
1622 and x_za_in_l1: "(x @ za) \<in> L\<^isub>1" |
|
1623 and rest_in_l2: "z - za \<in> L\<^isub>2" by blast |
|
1624 from x_y_eq x_za_in_l1 have y_za_in_l1: "y @ za \<in> L\<^isub>1" |
|
1625 by (auto simp:equiv_class_def equiv_str_def) |
|
1626 hence "(y @ za) @ (z - za) \<in> L\<^isub>1 ; L\<^isub>2" using rest_in_l2 |
|
1627 apply (simp add:lang_seq_def) |
|
1628 by (rule_tac x = "y @ za" in exI, rule_tac x = "z - za" in exI, simp) |
|
1629 thus "y @ z \<in> L\<^isub>1 ; L\<^isub>2" using za_le_z |
|
1630 by (erule_tac prefixE, simp) |
1753 qed |
1631 qed |
1754 next |
1632 show ?thesis using tag_eq |
1755 assume x_in_l1: "\<not> (\<exists>xa\<le>x. xa \<in> L\<^isub>1)" |
1633 apply (simp add:equiv_str_def) |
1756 show "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
1634 by (auto intro:aux) |
1757 proof (cases "\<exists> ya. ya \<le> y \<and> ya \<in> L\<^isub>1") |
1635 qed |
1758 assume y_left_l1: "\<exists>ya\<le>y. ya \<in> L\<^isub>1" |
|
1759 show "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
|
1760 sorry |
|
1761 next |
|
1762 assume y_in_l1: "\<not> (\<exists>ya\<le>y. ya \<in> L\<^isub>1)" |
|
1763 with tag_eq x_in_l1 |
|
1764 have "\<lbrakk>x\<rbrakk>(L\<^isub>1;L\<^isub>2) = \<lbrakk>y\<rbrakk>(L\<^isub>1;L\<^isub>2)" |
|
1765 sorry |
|
1766 thus "x \<equiv>L\<^isub>1 ; L\<^isub>2\<equiv> y" |
|
1767 by (auto simp:equiv_class_def equiv_str_def) |
|
1768 qed |
|
1769 qed |
|
1770 |
|
1771 apply (simp add:tag_str_SEQ_def split:if_splits) |
|
1772 prefer 4 |
|
1773 apply (clarsimp simp add:equiv_str_def) |
|
1774 apply (rule iffI) |
|
1775 apply (simp add:lang_seq_def equiv_class_def equiv_str_def) |
|
1776 apply blast |
|
1777 apply ( |
|
1778 sorry |
|
1779 |
|
1780 |
1636 |
1781 lemma quot_seq: |
1637 lemma quot_seq: |
1782 assumes finite1: "finite (QUOT L\<^isub>1)" |
1638 assumes finite1: "finite (QUOT L\<^isub>1)" |
1783 and finite2: "finite (QUOT L\<^isub>2)" |
1639 and finite2: "finite (QUOT L\<^isub>2)" |
1784 shows "finite (QUOT (L\<^isub>1;L\<^isub>2))" |
1640 shows "finite (QUOT (L\<^isub>1;L\<^isub>2))" |
1804 by (auto simp:image_def tag_str_STAR_def QUOT_def) |
1671 by (auto simp:image_def tag_str_STAR_def QUOT_def) |
1805 thus ?thesis using finite1 |
1672 thus ?thesis using finite1 |
1806 by (rule_tac B = "Pow (QUOT L\<^isub>1)" in finite_subset, auto) |
1673 by (rule_tac B = "Pow (QUOT L\<^isub>1)" in finite_subset, auto) |
1807 qed |
1674 qed |
1808 |
1675 |
|
1676 lemma star_prop[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall> y. y \<in> lang\<star> \<longrightarrow> x @ y \<in> lang\<star>" |
|
1677 by (erule Star.induct, auto) |
|
1678 |
|
1679 lemma star_prop2: "y \<in> lang \<Longrightarrow> y \<in> lang\<star>" |
|
1680 by (drule step[of y lang "[]"], auto simp:start) |
|
1681 |
|
1682 lemma star_prop3[rule_format]: "x \<in> lang\<star> \<Longrightarrow> \<forall>y . y \<in> lang \<longrightarrow> x @ y \<in> lang\<star>" |
|
1683 by (erule Star.induct, auto intro:star_prop2) |
|
1684 |
|
1685 lemma postfix_prop: "y >>= (x @ y) \<Longrightarrow> x = []" |
|
1686 by (erule postfixE, induct x arbitrary:y, auto) |
|
1687 |
|
1688 lemma inj_aux: |
|
1689 "\<lbrakk>(m @ z) \<in> L\<^isub>1\<star>; m \<equiv>L\<^isub>1\<equiv> yb; xa @ m = x; xa \<in> L\<^isub>1\<star>; m \<noteq> []; |
|
1690 \<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m\<rbrakk> |
|
1691 \<Longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>" |
|
1692 proof- |
|
1693 have "\<And>s. s \<in> L\<^isub>1\<star> \<Longrightarrow> \<forall> m z yb. (s = m @ z \<and> m \<equiv>L\<^isub>1\<equiv> yb \<and> x = xa @ m \<and> xa \<in> L\<^isub>1\<star> \<and> m \<noteq> [] \<and> |
|
1694 (\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m) \<longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>)" |
|
1695 apply (erule Star.induct, simp) |
|
1696 apply (rule allI | rule impI | erule conjE)+ |
|
1697 apply (drule app_eq_elim) |
|
1698 apply (erule disjE | erule exE | erule conjE)+ |
|
1699 apply simp |
|
1700 apply (simp (no_asm) only:append_assoc[THEN sym]) |
|
1701 apply (rule step) |
|
1702 apply (simp add:equiv_str_def) |
|
1703 apply simp |
|
1704 |
|
1705 apply (erule exE | erule conjE)+ |
|
1706 apply (rotate_tac 3) |
|
1707 apply (frule_tac x = "xa @ s1" in spec) |
|
1708 apply (rotate_tac 12) |
|
1709 apply (drule_tac x = ba in spec) |
|
1710 apply (erule impE) |
|
1711 apply ( simp add:star_prop3) |
|
1712 apply (simp) |
|
1713 apply (drule postfix_prop) |
|
1714 apply simp |
|
1715 done |
|
1716 thus "\<lbrakk>(m @ z) \<in> L\<^isub>1\<star>; m \<equiv>L\<^isub>1\<equiv> yb; xa @ m = x; xa \<in> L\<^isub>1\<star>; m \<noteq> []; |
|
1717 \<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= m\<rbrakk> |
|
1718 \<Longrightarrow> (yb @ z) \<in> L\<^isub>1\<star>" by blast |
|
1719 qed |
|
1720 |
|
1721 |
|
1722 lemma min_postfix_exists[rule_format]: |
|
1723 "finite A \<Longrightarrow> A \<noteq> {} \<and> (\<forall> a \<in> A. \<forall> b \<in> A. ((b >>= a) \<or> (a >>= b))) |
|
1724 \<longrightarrow> (\<exists> min. (min \<in> A \<and> (\<forall> a \<in> A. a >>= min)))" |
|
1725 apply (erule finite.induct) |
|
1726 apply simp |
|
1727 apply simp |
|
1728 apply (case_tac "A = {}") |
|
1729 apply simp |
|
1730 apply clarsimp |
|
1731 apply (case_tac "a >>= min") |
|
1732 apply (rule_tac x = min in exI, simp) |
|
1733 apply (rule_tac x = a in exI, simp) |
|
1734 apply clarify |
|
1735 apply (rotate_tac 5) |
|
1736 apply (erule_tac x = aa in ballE) defer apply simp |
|
1737 apply (erule_tac ys = min in postfix_trans) |
|
1738 apply (erule_tac x = min in ballE) |
|
1739 by simp+ |
|
1740 |
1809 lemma tag_str_star_inj: |
1741 lemma tag_str_star_inj: |
1810 "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 (y::string) \<Longrightarrow> x \<equiv>L\<^isub>1\<star>\<equiv> y" |
1742 "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 (y::string) \<Longrightarrow> x \<equiv>L\<^isub>1\<star>\<equiv> y" |
1811 proof - |
1743 proof - |
1812 have "\<forall> x lang. (x = []) = (tag_str_STAR lang x = {\<lbrakk>[]\<rbrakk>lang})" |
1744 have aux: "\<And> x y z. \<lbrakk>tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y; x @ z \<in> L\<^isub>1\<star>\<rbrakk> \<Longrightarrow> y @ z \<in> L\<^isub>1\<star>" |
1813 proof (rule_tac allI, rule_tac allI, rule_tac iffI) |
1745 proof- |
1814 fix x lang |
1746 fix x y z |
1815 show "x = [] \<Longrightarrow> tag_str_STAR lang x = {\<lbrakk>[]\<rbrakk>lang}" |
1747 assume tag_eq: "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y" |
1816 by (simp add:tag_str_STAR_def) |
1748 and x_z: "x @ z \<in> L\<^isub>1\<star>" |
1817 next |
1749 show "y @ z \<in> L\<^isub>1\<star>" |
1818 fix x lang |
1750 proof (cases "x = []") |
1819 show "tag_str_STAR lang x = {\<lbrakk>[]\<rbrakk>lang} \<Longrightarrow> x = []" |
1751 case True |
1820 apply (simp add:tag_str_STAR_def) |
1752 with tag_eq have "y = []" by (simp add:tag_str_STAR_def split:if_splits, blast) |
1821 apply (drule equalityD1) |
1753 thus ?thesis using x_z True by simp |
1822 apply (case_tac x) |
1754 next |
1823 apply simp |
1755 case False |
1824 thm in_mono |
1756 hence not_empty: "{xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>} \<noteq> {}" using x_z |
1825 apply (drule_tac x = "\<lbrakk>[a]\<rbrakk>lang" in in_mono) |
1757 by (simp, rule_tac x = x in exI, rule_tac x = "[]" in exI, simp add:start) |
1826 apply simp |
1758 have finite_set: "finite {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}" |
1827 apply auto |
1759 apply (rule_tac B = "{xb. \<exists> xa. x = xa @ xb}" in finite_subset) |
1828 |
1760 apply auto |
1829 apply (erule subsetCE) |
1761 apply (induct x, simp) |
1830 |
1762 apply (subgoal_tac "{xb. \<exists>xa. a # x = xa @ xb} = insert (a # x) {xb. \<exists>xa. x = xa @ xb}") |
1831 apply (case_tac y) |
1763 apply auto |
1832 |
1764 by (case_tac xaa, simp+) |
1833 sorry |
1765 have comparable: "\<forall> a \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}. |
1834 next |
1766 \<forall> b \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>}. |
|
1767 ((b >>= a) \<or> (a >>= b))" |
|
1768 by (auto simp:postfix_def, drule app_eq_elim, blast) |
|
1769 hence "\<exists> min. min \<in> {xb. \<exists> xa. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star>} |
|
1770 \<and> (\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= min)" |
|
1771 using finite_set not_empty comparable |
|
1772 apply (drule_tac min_postfix_exists, simp) |
|
1773 by (erule exE, rule_tac x = min in exI, auto) |
|
1774 then obtain min xa where x_decom: "x = xa @ min \<and> xa \<in> L\<^isub>1\<star>" |
|
1775 and min_not_empty: "min \<noteq> []" |
|
1776 and min_z_in_star: "min @ z \<in> L\<^isub>1\<star>" |
|
1777 and is_min: "\<forall> xa xb. x = xa @ xb \<and> xa \<in> L\<^isub>1\<star> \<and> xb \<noteq> [] \<and> xb @ z \<in> L\<^isub>1\<star> \<longrightarrow> xb >>= min" by blast |
|
1778 from x_decom min_not_empty have "\<lbrakk>min\<rbrakk>L\<^isub>1 \<in> tag_str_STAR L\<^isub>1 x" by (auto simp:tag_str_STAR_def) |
|
1779 hence "\<exists> yb. \<lbrakk>yb\<rbrakk>L\<^isub>1 \<in> tag_str_STAR L\<^isub>1 y \<and> \<lbrakk>min\<rbrakk>L\<^isub>1 = \<lbrakk>yb\<rbrakk>L\<^isub>1" using tag_eq by auto |
|
1780 hence "\<exists> ya yb. y = ya @ yb \<and> ya \<in> L\<^isub>1\<star> \<and> min \<equiv>L\<^isub>1\<equiv> yb \<and> yb \<noteq> [] " |
|
1781 by (simp add:tag_str_STAR_def equiv_class_def equiv_str_def split:if_splits, blast) |
|
1782 then obtain ya yb where y_decom: "y = ya @ yb" |
|
1783 and ya_in_star: "ya \<in> L\<^isub>1\<star>" |
|
1784 and yb_not_empty: "yb \<noteq> []" |
|
1785 and min_yb_eq: "min \<equiv>L\<^isub>1\<equiv> yb" by blast |
|
1786 from min_z_in_star min_yb_eq min_not_empty is_min x_decom |
|
1787 have "yb @ z \<in> L\<^isub>1\<star>" |
|
1788 by (rule_tac x = x and xa = xa in inj_aux, simp+) |
|
1789 thus ?thesis using ya_in_star y_decom |
|
1790 by (auto dest:star_prop) |
|
1791 qed |
1835 qed |
1792 qed |
1836 apply (simp add:tag_str_STAR_def equiv_class_def equiv_str_def) |
1793 show "tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 (y::string) \<Longrightarrow> x \<equiv>L\<^isub>1\<star>\<equiv> y" |
1837 apply (rule iffI) |
1794 by (auto intro:aux simp:equiv_str_def) |
1838 |
1795 qed |
1839 apply (auto simp:tag_str_STAR_def equiv_class_def equiv_str_def) |
|
1840 have "\<And> x y z xstr. xstr \<in> L\<^isub>1\<star> \<Longrightarrow> |
|
1841 xstr = x @ z \<and> tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y \<longrightarrow> y @ z \<in> L\<^isub>1\<star> " |
|
1842 proof (erule Star.induct) |
|
1843 fix x y z xstr |
|
1844 show "[] = x @ z \<and> tag_str_STAR L\<^isub>1 x = tag_str_STAR L\<^isub>1 y \<longrightarrow> y @ z \<in> L\<^isub>1\<star>" |
|
1845 apply (clarsimp simp add:tag_str_STAR_def equiv_str_def equiv_class_def) |
|
1846 apply (blast) |
|
1847 apply (simp add:tag_str_STAR_def equiv_class_def QUOT_def) |
|
1848 apply (simp add:equiv_str_def) |
|
1849 apply (rule allI, rule_tac iffI) |
|
1850 apply (erule_tac star.induct) |
|
1851 apply blast |
|
1852 |
|
1853 sorry |
|
1854 |
|
1855 |
1796 |
1856 lemma quot_star: |
1797 lemma quot_star: |
1857 assumes finite1: "finite (QUOT L\<^isub>1)" |
1798 assumes finite1: "finite (QUOT L\<^isub>1)" |
1858 shows "finite (QUOT (L\<^isub>1\<star>))" |
1799 shows "finite (QUOT (L\<^isub>1\<star>))" |
1859 proof (rule_tac f = "(op `) (tag_str_STAR L\<^isub>1)" in finite_imageD) |
1800 proof (rule_tac f = "(op `) (tag_str_STAR L\<^isub>1)" in finite_imageD) |