Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 153,929 Bytes
4365a98 |
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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 |
(* Title: AF_Stream_Exec.thy
Date: Dec 2006
Author: David Trachtenherz
*)
section \<open>Processing of message streams\<close>
theory AF_Stream_Exec
imports AF_Stream "List-Infinite.ListInf_Prefix" "List-Infinite.SetIntervalStep"
begin
subsection \<open>Executing components with state transition functions\<close>
subsubsection \<open>Basic definitions\<close>
text \<open>
Function type for functions converting
an input value to an input port message for a component\<close>
type_synonym ('a, 'in) Port_Input_Value = "'a \<Rightarrow> 'in message_af"
text \<open>
Function type for functions extracting
the output value of a single output port from
a component value\<close>
type_synonym ('comp, 'out) Port_Output_Value = "'comp \<Rightarrow> 'out message_af"
text \<open>
Function type for functions extracting
the local state of a component from
a component value\<close>
type_synonym ('comp, 'state) Comp_Local_State = "'comp \<Rightarrow> 'state"
text \<open>
Function type for transition functions
computing the component's value after processing
an input for a single time unit\<close>
type_synonym ('comp, 'input) Comp_Trans_Fun = "'input \<Rightarrow> 'comp \<Rightarrow> 'comp"
\<comment> \<open>Execute a component for all inputs in the input stream @{typ "'input list"}\<close>
primrec f_Exec_Comp :: "('comp, 'input) Comp_Trans_Fun \<Rightarrow> 'input list \<Rightarrow> 'comp \<Rightarrow> 'comp"
where
f_Exec_Nil: "f_Exec_Comp trans_fun [] c = c"
| f_Exec_Cons: "f_Exec_Comp trans_fun (x#xs) c = f_Exec_Comp trans_fun xs (trans_fun x c)"
\<comment> \<open>Execute the component for at most n steps\<close>
definition f_Exec_Comp_N :: "('comp, 'input) Comp_Trans_Fun \<Rightarrow> nat \<Rightarrow> 'input list \<Rightarrow> 'comp \<Rightarrow> 'comp"
where "f_Exec_Comp_N trans_fun n xs c \<equiv> f_Exec_Comp trans_fun (xs \<down> n) c"
\<comment> \<open>Produce the component stream for all inputs in the input stream\<close>
primrec f_Exec_Comp_Stream :: "('comp, 'input) Comp_Trans_Fun \<Rightarrow> 'input list \<Rightarrow> 'comp \<Rightarrow> 'comp list"
where
f_Exec_Stream_Nil: "f_Exec_Comp_Stream trans_fun [] c = []"
| f_Exec_Stream_Cons: "f_Exec_Comp_Stream trans_fun (x # xs) c =
(trans_fun x c) # ( f_Exec_Comp_Stream trans_fun xs (trans_fun x c) )"
primrec f_Exec_Comp_Stream_Init ::
"('comp, 'input) Comp_Trans_Fun \<Rightarrow> 'input list \<Rightarrow> 'comp \<Rightarrow> 'comp list"
where
f_Exec_Stream_Init_Nil: "f_Exec_Comp_Stream_Init trans_fun [] c = [c]"
| f_Exec_Stream_Init_Cons: "f_Exec_Comp_Stream_Init trans_fun (x # xs) c =
c # ( f_Exec_Comp_Stream_Init trans_fun xs (trans_fun x c) )"
definition i_Exec_Comp_Stream ::
"('comp, 'input) Comp_Trans_Fun \<Rightarrow> 'input ilist \<Rightarrow> 'comp \<Rightarrow> 'comp ilist"
where "i_Exec_Comp_Stream \<equiv> \<lambda>trans_fun input c n. f_Exec_Comp trans_fun (input \<Down> Suc n) c"
definition i_Exec_Comp_Stream_Init ::
"('comp, 'input) Comp_Trans_Fun \<Rightarrow> 'input ilist \<Rightarrow> 'comp \<Rightarrow> 'comp ilist"
where "i_Exec_Comp_Stream_Init \<equiv> \<lambda>trans_fun input c n. f_Exec_Comp trans_fun (input \<Down> n) c"
subsubsection \<open>Basic results\<close>
lemma f_Exec_one: "f_Exec_Comp trans_fun [m] c = trans_fun m c"
by simp
lemma f_Exec_Stream_length[rule_format, simp]:"
\<forall>c. length (f_Exec_Comp_Stream trans_fun xs c) = length xs"
by (induct xs, simp_all)
lemma f_Exec_Stream_empty_conv:"
(f_Exec_Comp_Stream trans_fun xs c = []) = (xs = [])"
by (simp add: length_0_conv[symmetric] del: length_0_conv)
lemma f_Exec_Stream_not_empty_conv:"
(f_Exec_Comp_Stream trans_fun xs c \<noteq> []) = (xs \<noteq> [])"
by (simp add: f_Exec_Stream_empty_conv)
lemma f_Exec_eq_f_Exec_Stream_last[rule_format]:"
\<forall>c. f_Exec_Comp trans_fun xs c = last (c # (f_Exec_Comp_Stream trans_fun xs c))"
by (induct xs, simp_all)
corollary f_Exec_eq_f_Exec_Stream_last2[rule_format]: "
xs \<noteq> [] \<Longrightarrow>
f_Exec_Comp trans_fun xs c = last (f_Exec_Comp_Stream trans_fun xs c)"
by (simp add: f_Exec_eq_f_Exec_Stream_last f_Exec_Stream_empty_conv[symmetric, of xs trans_fun c])
corollary f_Exec_eq_f_Exec_Stream_last_if: "
f_Exec_Comp trans_fun xs c = (if xs = [] then c else last (f_Exec_Comp_Stream trans_fun xs c))"
by (simp add: f_Exec_eq_f_Exec_Stream_last2)
corollary f_Exec_take_eq_last_f_Exec_Stream_take:"
\<lbrakk> xs \<noteq> []; 0 < n \<rbrakk> \<Longrightarrow>
f_Exec_Comp trans_fun (xs \<down> n) c =
last (f_Exec_Comp_Stream trans_fun (xs \<down> n) c)"
by (simp add: f_Exec_eq_f_Exec_Stream_last2 take_not_empty_conv)
corollary f_Exec_N_eq_last_f_Exec_Stream_take:"
\<lbrakk> xs \<noteq> []; 0 < n \<rbrakk> \<Longrightarrow>
f_Exec_Comp_N trans_fun n xs c =
last (f_Exec_Comp_Stream trans_fun (xs \<down> n) c)"
by (simp add: f_Exec_Comp_N_def f_Exec_take_eq_last_f_Exec_Stream_take)
lemma f_Exec_Stream_nth: "
\<And>n c. n < length xs \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c ! n = f_Exec_Comp trans_fun (xs \<down> Suc n) c"
apply (induct xs, simp)
apply (simp add: nth_Cons')
done
lemma f_Exec_Stream_nth2: "
n \<le> length xs \<Longrightarrow>
(c # f_Exec_Comp_Stream trans_fun xs c) ! n = f_Exec_Comp trans_fun (xs \<down> n) c"
by (simp add: nth_Cons' f_Exec_Stream_nth)
lemma f_Exec_N_all:"
length xs \<le> n \<Longrightarrow>
f_Exec_Comp_N trans_fun n xs c = f_Exec_Comp trans_fun xs c"
by (simp add: f_Exec_Comp_N_def)
lemma f_Exec_Stream_append[rule_format]:"\<forall>c.
f_Exec_Comp_Stream trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream trans_fun xs c) @
(f_Exec_Comp_Stream trans_fun ys (f_Exec_Comp trans_fun xs c))"
by (induct xs, simp_all)
corollary f_Exec_Stream_append_last_Cons[rule_format]:"
f_Exec_Comp_Stream trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream trans_fun xs c) @
(f_Exec_Comp_Stream trans_fun ys (last (c # (f_Exec_Comp_Stream trans_fun xs c))))"
by (simp add: f_Exec_Stream_append f_Exec_eq_f_Exec_Stream_last)
corollary f_Exec_Stream_append_last[rule_format]:"
xs \<noteq> [] \<Longrightarrow>
f_Exec_Comp_Stream trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream trans_fun xs c) @
(f_Exec_Comp_Stream trans_fun ys (last (f_Exec_Comp_Stream trans_fun xs c)))"
by (simp add: f_Exec_Stream_append_last_Cons f_Exec_Stream_empty_conv)
corollary f_Exec_Stream_append_if:"
f_Exec_Comp_Stream trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream trans_fun xs c) @
(f_Exec_Comp_Stream trans_fun ys (
if xs = [] then c else last (f_Exec_Comp_Stream trans_fun xs c)))"
by (simp add: f_Exec_Stream_append f_Exec_eq_f_Exec_Stream_last_if)
corollary f_Exec_append:"
f_Exec_Comp trans_fun (xs @ ys) c =
f_Exec_Comp trans_fun ys (f_Exec_Comp trans_fun xs c)"
by (simp add: f_Exec_eq_f_Exec_Stream_last f_Exec_Stream_append_if f_Exec_Stream_empty_conv)
corollary f_Exec_Stream_Cons_rev: "
xs \<noteq> [] \<Longrightarrow>
(trans_fun (hd xs) c) #
f_Exec_Comp_Stream trans_fun (tl xs) (trans_fun (hd xs) c) =
f_Exec_Comp_Stream trans_fun xs c"
by (subst f_Exec_Stream_Cons[symmetric], simp)
lemma f_Exec_Stream_snoc: "
f_Exec_Comp_Stream trans_fun (xs @ [x]) c =
f_Exec_Comp_Stream trans_fun xs c @
[trans_fun x (f_Exec_Comp trans_fun xs c)]"
by (simp add: f_Exec_Stream_append)
lemma f_Exec_snoc: "
f_Exec_Comp trans_fun (xs @ [x]) c =
trans_fun x (f_Exec_Comp trans_fun xs c)"
by (simp add: f_Exec_append)
lemma f_Exec_N_append[rule_format]:"
f_Exec_Comp_N trans_fun (a + b) xs c =
f_Exec_Comp_N trans_fun b (xs \<up> a) (f_Exec_Comp_N trans_fun a xs c)"
apply (simp add: f_Exec_Comp_N_def f_Exec_append[symmetric])
apply (simp add: take_drop add.commute[of b])
apply (rule subst[of "xs \<down> (a + b) \<down> a" "xs \<down> a" ], simp add: min_eqL)
apply (subst append_take_drop_id, simp)
done
corollary f_Exec_N_Suc[rule_format]:"
f_Exec_Comp_N trans_fun (Suc n) xs c =
f_Exec_Comp_N trans_fun (Suc 0) (xs \<up> n) (f_Exec_Comp_N trans_fun n xs c)"
by (simp add: f_Exec_N_append[symmetric])
corollary f_Exec_N_Suc2[rule_format]:"
n < length xs \<Longrightarrow>
f_Exec_Comp_N trans_fun (Suc n) xs c =
trans_fun (xs ! n) (f_Exec_Comp_N trans_fun n xs c)"
by (simp add: f_Exec_Comp_N_def take_Suc_conv_app_nth f_Exec_append)
theorem f_Exec_Stream_take:"
(f_Exec_Comp_Stream trans_fun xs c) \<down> n =
f_Exec_Comp_Stream trans_fun (xs \<down> n) c"
apply (case_tac "length xs \<le> n", simp)
apply (rule subst[OF append_take_drop_id, of _ n xs])
apply (simp add: f_Exec_Stream_append del: append_take_drop_id)
done
theorem f_Exec_Stream_drop:"
(f_Exec_Comp_Stream trans_fun xs c) \<up> n =
f_Exec_Comp_Stream trans_fun (xs \<up> n)
(f_Exec_Comp trans_fun (xs \<down> n) c)"
apply (case_tac "length xs \<le> n", simp)
apply (rule subst[OF append_take_drop_id, of _ n xs])
apply (simp add: f_Exec_Stream_append del: append_take_drop_id)
done
lemma i_Exec_Stream_nth: "
i_Exec_Comp_Stream trans_fun input c n = f_Exec_Comp trans_fun (input \<Down> Suc n) c"
by (simp add: i_Exec_Comp_Stream_def)
lemma i_Exec_Stream_nth_Suc: "
i_Exec_Comp_Stream trans_fun input c (Suc n) =
trans_fun (input (Suc n)) (i_Exec_Comp_Stream trans_fun input c n)"
by (simp add: i_Exec_Stream_nth i_take_Suc_conv_app_nth f_Exec_append)
lemma i_Exec_Stream_nth_Suc_first: "
i_Exec_Comp_Stream trans_fun input c (Suc n) =
(i_Exec_Comp_Stream trans_fun (input \<Up> Suc 0) (trans_fun (input 0) c) n)"
by (simp add: i_Exec_Stream_nth i_take_Suc)
lemma f_Exec_Stream_nth_eq_i_Exec_Stream_nth: "
n < n' \<Longrightarrow>
f_Exec_Comp_Stream trans_fun (input \<Down> n') c ! n =
i_Exec_Comp_Stream trans_fun input c n"
by (simp add: f_Exec_Stream_nth i_Exec_Stream_nth min_eqR)
lemma i_Exec_Stream_append: "
i_Exec_Comp_Stream trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream trans_fun xs c \<frown>
i_Exec_Comp_Stream trans_fun input (f_Exec_Comp trans_fun xs c)"
by (simp add: ilist_eq_iff i_Exec_Stream_nth f_Exec_Stream_nth f_Exec_append i_append_nth Suc_diff_le)
lemma i_Exec_Stream_append_last_Cons: "
i_Exec_Comp_Stream trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream trans_fun xs c \<frown>
i_Exec_Comp_Stream trans_fun input (
last (c # f_Exec_Comp_Stream trans_fun xs c))"
by (simp add: f_Exec_eq_f_Exec_Stream_last i_Exec_Stream_append)
lemma i_Exec_Stream_append_last: "
xs \<noteq> [] \<Longrightarrow>
i_Exec_Comp_Stream trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream trans_fun xs c \<frown>
i_Exec_Comp_Stream trans_fun input (
last (f_Exec_Comp_Stream trans_fun xs c))"
by (simp add: f_Exec_Stream_empty_conv i_Exec_Stream_append_last_Cons)
lemma i_Exec_Stream_append_if: "
i_Exec_Comp_Stream trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream trans_fun xs c \<frown>
i_Exec_Comp_Stream trans_fun input (
if xs = [] then c
else last (f_Exec_Comp_Stream trans_fun xs c))"
by (simp add: i_Exec_Stream_append_last)
corollary i_Exec_Stream_Cons: "
i_Exec_Comp_Stream trans_fun ([x] \<frown> input) c =
[trans_fun x c] \<frown> i_Exec_Comp_Stream trans_fun input (trans_fun x c)"
by (simp add: i_Exec_Stream_append)
corollary i_Exec_Stream_Cons_rev: "
[trans_fun (input 0) c] \<frown>
i_Exec_Comp_Stream trans_fun (input \<Up> Suc 0) (trans_fun (input 0) c) =
i_Exec_Comp_Stream trans_fun input c"
apply (insert i_Exec_Stream_append[of trans_fun "[input 0]" "input \<Up> Suc 0" c])
apply (simp add: i_drop_Suc_conv_tl)
done
theorem i_Exec_Stream_take:"
(i_Exec_Comp_Stream trans_fun input c) \<Down> n =
f_Exec_Comp_Stream trans_fun (input \<Down> n) c"
by (simp add: list_eq_iff f_Exec_Stream_nth i_Exec_Stream_nth min_eqR)
theorem i_Exec_Stream_drop:"
(i_Exec_Comp_Stream trans_fun input c) \<Up> n =
i_Exec_Comp_Stream trans_fun (input \<Up> n) (f_Exec_Comp trans_fun (input \<Down> n) c)"
apply (rule subst[OF i_append_i_take_i_drop_id, of _ n input])
apply (simp add: i_Exec_Stream_append i_drop_def del: i_append_i_take_i_drop_id)
done
lemma f_Exec_Stream_expand_aggregate_map_take: "
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag \<down> n =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((xs \<down> n) \<odot>\<^sub>f k) c)) k ag"
by (simp add: f_aggregate_take_mult[symmetric] take_map f_Exec_Stream_take f_expand_take_mult)
corollary f_Exec_Stream_expand_aggregate_take: "
f_aggregate (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c) k ag \<down> n =
f_aggregate (f_Exec_Comp_Stream trans_fun ((xs \<down> n) \<odot>\<^sub>f k) c) k ag"
by (insert f_Exec_Stream_expand_aggregate_map_take[of n id trans_fun xs k c ag], simp add: map_id)
lemma i_Exec_Stream_expand_aggregate_map_take: "
0 < k \<Longrightarrow>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) k ag \<Down> n =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c)) k ag"
by (simp add: i_aggregate_i_take_mult[symmetric] i_Exec_Stream_take i_expand_i_take_mult)
corollary i_Exec_Stream_expand_aggregate_take: "
0 < k \<Longrightarrow>
i_aggregate (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c) k ag \<Down> n =
f_aggregate (f_Exec_Comp_Stream trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c) k ag"
by (drule i_Exec_Stream_expand_aggregate_map_take[of k n id trans_fun input c ag], simp add: map_id)
lemma f_Exec_Stream_expand_aggregate_map_drop: "
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag \<up> n =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((xs \<up> n) \<odot>\<^sub>f k) (
f_Exec_Comp trans_fun ((xs \<down> n) \<odot>\<^sub>f k) c))) k ag"
by (simp add: f_aggregate_drop_mult[symmetric] drop_map f_Exec_Stream_drop f_expand_take_mult f_expand_drop_mult)
corollary f_Exec_Stream_expand_aggregate_drop: "
f_aggregate (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c) k ag \<up> n =
f_aggregate (f_Exec_Comp_Stream trans_fun ((xs \<up> n) \<odot>\<^sub>f k) (
f_Exec_Comp trans_fun ((xs \<down> n) \<odot>\<^sub>f k) c)) k ag"
by (insert f_Exec_Stream_expand_aggregate_map_drop[of n id trans_fun xs k c ag], simp add: map_id)
lemma i_Exec_Stream_expand_aggregate_map_drop: "
0 < k \<Longrightarrow>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) k ag \<Up> n =
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun ((input \<Up> n) \<odot>\<^sub>i k) (
f_Exec_Comp trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c))) k ag"
by (simp add: i_aggregate_i_drop_mult[symmetric] i_Exec_Stream_drop i_expand_i_take_mult i_expand_i_drop_mult)
corollary i_Exec_Stream_expand_aggregate_drop: "
0 < k \<Longrightarrow>
i_aggregate (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c) k ag \<Up> n =
i_aggregate (i_Exec_Comp_Stream trans_fun ((input \<Up> n) \<odot>\<^sub>i k) (
f_Exec_Comp trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c)) k ag"
by (drule i_Exec_Stream_expand_aggregate_map_drop[of k n id trans_fun input c ag], simp)
lemma f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth: "
\<lbrakk> 0 < k; n < n' \<rbrakk> \<Longrightarrow>
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (input \<Down> n' \<odot>\<^sub>f k) c)) k ag ! n =
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) k ag n"
apply (simp add: f_aggregate_nth i_aggregate_nth f_Exec_Stream_take f_Exec_Stream_drop i_Exec_Stream_take i_Exec_Stream_drop drop_map take_map)
apply (simp add: f_expand_take_mod i_expand_i_take_mod f_expand_drop_mod i_expand_i_drop_mod i_drop_i_take_1 drop_take_1 min_eqR)
done
corollary f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth': "
0 < k \<Longrightarrow>
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (input \<Down> Suc n \<odot>\<^sub>f k) c)) k ag ! n =
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) k ag n"
by (simp add: f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth)
corollary f_Exec_Stream_expand_aggregate_nth_eq_i_nth: "
\<lbrakk> 0 < k; n < n' \<rbrakk> \<Longrightarrow>
f_aggregate (f_Exec_Comp_Stream trans_fun (input \<Down> n' \<odot>\<^sub>f k) c) k ag ! n =
i_aggregate (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c) k ag n"
by (drule f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth[where f=id], simp_all add: map_id)
corollary f_Exec_Stream_expand_aggregate_nth_eq_i_nth': "
0 < k \<Longrightarrow>
f_aggregate (f_Exec_Comp_Stream trans_fun (input \<Down> Suc n \<odot>\<^sub>f k) c) k ag ! n =
i_aggregate (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c) k ag n"
by (simp add: f_Exec_Stream_expand_aggregate_nth_eq_i_nth)
lemma f_Exec_Stream_expand_shrink_last_map_nth_eq_f_Exec_Comp: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c) \<div>\<^bsub>fl\<^esub> k ! n =
f (f_Exec_Comp trans_fun ((xs \<down> Suc n) \<odot>\<^sub>f k) c)"
apply (simp add: f_shrink_last_map f_shrink_last_length f_shrink_last_nth)
apply (subgoal_tac "n * k + k - Suc 0 < length xs * k")
prefer 2
apply (drule Suc_leI[of n])
apply (drule mult_le_mono1[of _ _ k], simp)
apply (simp add: f_Exec_Stream_nth add.commute[of k] f_expand_take_mult[symmetric])
done
corollary f_Exec_Stream_expand_shrink_last_nth_eq_f_Exec_Comp: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c \<div>\<^bsub>fl\<^esub> k ! n =
f_Exec_Comp trans_fun ((xs \<down> Suc n) \<odot>\<^sub>f k) c"
by (drule f_Exec_Stream_expand_shrink_last_map_nth_eq_f_Exec_Comp[where f=id], simp_all add: map_id)
lemma f_Exec_Stream_expand_aggregate_map_nth: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag ! n =
ag (map f (f_Exec_Comp_Stream trans_fun (xs ! n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c)))"
apply (simp add: f_aggregate_nth take_map drop_map)
apply (simp add: take_map drop_map f_Exec_Stream_drop f_Exec_Stream_take f_expand_take_mod f_expand_drop_mod drop_take_1)
done
corollary f_Exec_Stream_expand_aggregate_nth: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_aggregate (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c) k ag ! n =
ag (f_Exec_Comp_Stream trans_fun (xs ! n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c))"
by (drule f_Exec_Stream_expand_aggregate_map_nth[where f=id], simp_all add: map_id)
corollary f_Exec_Stream_expand_shrink_map_nth: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
(map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) \<div>\<^sub>f k ! n =
last_message (map f (f_Exec_Comp_Stream trans_fun (xs ! n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c)))"
by (simp add: f_shrink_def f_Exec_Stream_expand_aggregate_map_nth)
lemma i_Exec_Stream_expand_aggregate_map_nth: "
0 < k \<Longrightarrow>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) k ag n =
ag (map f (f_Exec_Comp_Stream trans_fun (input n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c)))"
by (simp add: i_aggregate_nth i_Exec_Stream_drop i_Exec_Stream_take i_expand_i_take_mod i_expand_i_drop_mod i_drop_i_take_1)
corollary i_Exec_Stream_expand_aggregate_nth: "
0 < k \<Longrightarrow>
i_aggregate (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c) k ag n =
ag (f_Exec_Comp_Stream trans_fun (input n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun ((input \<Down> n) \<odot>\<^sub>f k) c))"
by (drule i_Exec_Stream_expand_aggregate_map_nth[where f=id], simp add: map_id)
corollary i_Exec_Stream_expand_shrink_map_nth: "
0 < k \<Longrightarrow>
((f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) \<div>\<^sub>i k) n =
last_message (map f (f_Exec_Comp_Stream trans_fun (input n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun (input \<Down> n \<odot>\<^sub>f k) c)))"
by (simp add: i_shrink_def i_Exec_Stream_expand_aggregate_map_nth)
lemma f_Exec_Stream_expand_snoc: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c \<up> (n * k) \<down> k =
f_Exec_Comp_Stream trans_fun (xs ! n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>)
(f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c)"
by (simp add: f_Exec_Stream_drop f_Exec_Stream_take f_expand_take_mod f_expand_drop_mod drop_take_1)
lemma f_Exec_Stream_expand_map_aggregate_append: "
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((xs @ ys) \<odot>\<^sub>f k) c)) k ag =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag @
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (ys \<odot>\<^sub>f k) (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c))) k ag"
by (simp add: f_Exec_Stream_append f_aggregate_append_mod)
lemma i_Exec_Stream_expand_map_aggregate_append: "
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun ((xs \<frown> input) \<odot>\<^sub>i k) c)) k ag =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag \<frown>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c))) k ag"
by (simp add: i_expand_i_append i_Exec_Stream_append i_aggregate_i_append_mod)
lemma f_Exec_Stream_expand_map_aggregate_Cons: "
0 < k \<Longrightarrow>
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((x # xs) \<odot>\<^sub>f k) c)) k ag =
ag (map f (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)) #
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c))) k ag"
apply (subst append_eq_Cons[of x xs, symmetric])
apply (subst f_Exec_Stream_expand_map_aggregate_append)
apply (simp add: f_aggregate_one)
done
lemma f_Exec_Stream_expand_map_aggregate_snoc: "
0 < k \<Longrightarrow>
f_aggregate (map f (f_Exec_Comp_Stream trans_fun ((xs @ [x]) \<odot>\<^sub>f k) c)) k ag =
f_aggregate (map f (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) k ag @
[ag (map f (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)))]"
apply (subst f_Exec_Stream_expand_map_aggregate_append)
apply (simp add: f_aggregate_one)
done
lemma i_Exec_Stream_expand_map_aggregate_Cons: "
0 < k \<Longrightarrow>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (([x] \<frown> input) \<odot>\<^sub>i k) c)) k ag =
[ag (map f (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c))] \<frown>
i_aggregate (f \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c))) k ag"
apply (subst i_Exec_Stream_expand_map_aggregate_append)
apply (simp add: f_aggregate_one)
done
lemma f_Exec_N_eq_f_Exec_Stream_nth:"
n \<le> length xs \<Longrightarrow>
f_Exec_Comp_N trans_fun n xs c = (c # f_Exec_Comp_Stream trans_fun xs c) ! n"
by (simp add: f_Exec_Comp_N_def f_Exec_Stream_nth2)
theorem f_Exec_Stream_causal: "
xs \<down> n = ys \<down> n \<Longrightarrow>
(f_Exec_Comp_Stream trans_fun xs c) \<down> n = (f_Exec_Comp_Stream trans_fun ys c) \<down> n"
by (simp add: f_Exec_Stream_take)
theorem i_Exec_Stream_causal: "
input1 \<Down> n = input2 \<Down> n \<Longrightarrow>
(i_Exec_Comp_Stream trans_fun input1 c) \<Down> n = (i_Exec_Comp_Stream trans_fun input2 c) \<Down> n"
by (simp add: i_Exec_Stream_take)
text \<open>Results for \<open>f_Exec_Comp_Stream_Init\<close>\<close>
text \<open>
\<open>f_Exec_Comp_Stream_Init\<close> computes the execution stream of a component
with the initial value of the component
at the beginning of the result stream.\<close>
lemma f_Exec_Stream_Init_length[rule_format, simp]:"
\<forall>c. length (f_Exec_Comp_Stream_Init trans_fun xs c) = Suc (length xs)"
by (induct xs, simp_all)
lemma f_Exec_Stream_Init_not_empty:"
(f_Exec_Comp_Stream_Init trans_fun xs c \<noteq> [])"
by (simp add: length_0_conv[symmetric] del: length_0_conv)
lemma f_Exec_eq_f_Exec_Stream_Init_last[rule_format]:"
\<forall>c. f_Exec_Comp trans_fun xs c = last (f_Exec_Comp_Stream_Init trans_fun xs c)"
by (induct xs, simp_all add: f_Exec_Stream_Init_not_empty)
lemma f_Exec_Stream_Init_eq_f_Exec_Stream_Cons[rule_format]: "
\<forall>c. f_Exec_Comp_Stream_Init trans_fun xs c = c # f_Exec_Comp_Stream trans_fun xs c"
by (induct xs, simp_all)
corollary f_Exec_Stream_Init_eq_f_Exec_Stream_Cons_output: "
output_fun c = \<NoMsg> \<Longrightarrow>
map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c) =
\<NoMsg> # map output_fun (f_Exec_Comp_Stream trans_fun xs c)"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
corollary f_Exec_Stream_Init_tl_eq_f_Exec_Stream: "
tl (f_Exec_Comp_Stream_Init trans_fun xs c) = f_Exec_Comp_Stream trans_fun xs c"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma f_Exec_N_eq_last_f_Exec_Stream_Init_take:"
f_Exec_Comp_N trans_fun n xs c =
last (f_Exec_Comp_Stream_Init trans_fun (xs \<down> n) c)"
by (simp add: f_Exec_Comp_N_def f_Exec_eq_f_Exec_Stream_Init_last)
lemma f_Exec_Stream_Init_nth: "
n \<le> length xs \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c ! n = f_Exec_Comp trans_fun (xs \<down> n) c"
apply (subst f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
apply (case_tac n, simp)
apply (simp add: f_Exec_Stream_nth)
done
lemma f_Exec_Stream_Init_nth_0: "f_Exec_Comp_Stream_Init trans_fun xs c ! 0 = c"
by (simp add: f_Exec_Stream_Init_nth)
lemma f_Exec_Stream_Init_hd: "hd (f_Exec_Comp_Stream_Init trans_fun xs c) = c"
by (simp add: hd_conv_nth f_Exec_Stream_Init_not_empty f_Exec_Stream_Init_nth_0)
lemma f_Exec_Stream_Init_nth_Suc_eq_f_Exec_Stream_nth: "
f_Exec_Comp_Stream_Init trans_fun xs c ! (Suc n) = f_Exec_Comp_Stream trans_fun xs c ! n"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma f_Exec_Stream_Init_append:"
f_Exec_Comp_Stream_Init trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream_Init trans_fun xs c) @
tl (f_Exec_Comp_Stream_Init trans_fun ys (f_Exec_Comp trans_fun xs c))"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_append)
corollary f_Exec_Stream_Init_append_last:"
f_Exec_Comp_Stream_Init trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream_Init trans_fun xs c) @
tl (f_Exec_Comp_Stream_Init trans_fun ys (last (f_Exec_Comp_Stream_Init trans_fun xs c)))"
by (simp add: f_Exec_Stream_Init_append f_Exec_eq_f_Exec_Stream_Init_last)
lemma f_Exec_Stream_Init_f_Exec_Stream_append:"
f_Exec_Comp_Stream_Init trans_fun (xs @ ys) c =
(f_Exec_Comp_Stream_Init trans_fun xs c) @
(f_Exec_Comp_Stream trans_fun ys (f_Exec_Comp trans_fun xs c))"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_append)
lemma f_Exec_Stream_Init_take:"
(f_Exec_Comp_Stream_Init trans_fun xs c) \<down> Suc n =
f_Exec_Comp_Stream_Init trans_fun (xs \<down> n) c"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_take)
lemma f_Exec_Stream_Init_drop:"
n \<le> length xs \<Longrightarrow>
(f_Exec_Comp_Stream_Init trans_fun xs c) \<up> n =
f_Exec_Comp_Stream_Init trans_fun (xs \<up> n)
(f_Exec_Comp trans_fun (xs \<down> n) c)"
apply (case_tac n, simp)
apply (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_drop)
apply (simp add: take_Suc_conv_app_nth f_Exec_append Cons_nth_drop_Suc[symmetric])
done
lemma f_Exec_Stream_Init_drop_geq_not_valid:"
length xs \<le> n \<Longrightarrow>
(f_Exec_Comp_Stream_Init trans_fun xs c) \<up> Suc n \<noteq>
f_Exec_Comp_Stream_Init trans_fun arbitrary_input arbitrary_comp"
by (simp add: f_Exec_Stream_Init_not_empty[symmetric])
lemma i_Exec_Stream_Init_nth: "
i_Exec_Comp_Stream_Init trans_fun input c n = f_Exec_Comp trans_fun (input \<Down> n) c"
by (simp add: i_Exec_Comp_Stream_Init_def)
lemma i_Exec_Stream_Init_nth_0: "
i_Exec_Comp_Stream_Init trans_fun input c 0 = c"
by (simp add: i_Exec_Stream_Init_nth)
lemma i_Exec_Stream_Init_nth_Suc_eq_i_Exec_Stream_nth: "
i_Exec_Comp_Stream_Init trans_fun input c (Suc n) = i_Exec_Comp_Stream trans_fun input c n"
by (simp add: i_Exec_Stream_Init_nth i_Exec_Stream_nth)
lemma i_Exec_Stream_Init_eq_i_Exec_Stream_Cons: "
i_Exec_Comp_Stream_Init trans_fun input c = [c] \<frown> i_Exec_Comp_Stream trans_fun input c"
by (simp add: ilist_eq_iff i_Exec_Stream_Init_nth i_append_nth i_Exec_Stream_nth)
corollary i_Exec_Stream_Init_eq_i_Exec_Stream_Cons_output: "
output_fun c = \<NoMsg> \<Longrightarrow>
output_fun \<circ> i_Exec_Comp_Stream_Init trans_fun input c =
[\<NoMsg>] \<frown> (output_fun \<circ> i_Exec_Comp_Stream trans_fun input c)"
by (simp add: i_Exec_Stream_Init_eq_i_Exec_Stream_Cons)
lemma i_Exec_Stream_Init_append:"
i_Exec_Comp_Stream_Init trans_fun (input1 \<frown> input2) c =
(f_Exec_Comp_Stream_Init trans_fun input1 c) \<frown>
((i_Exec_Comp_Stream_Init trans_fun input2 (f_Exec_Comp trans_fun input1 c)) \<Up> Suc 0)"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons i_Exec_Stream_Init_eq_i_Exec_Stream_Cons i_Exec_Stream_append)
corollary i_Exec_Stream_Init_append_last:"
i_Exec_Comp_Stream_Init trans_fun (input1 \<frown> input2) c =
(f_Exec_Comp_Stream_Init trans_fun input1 c) \<frown>
((i_Exec_Comp_Stream_Init trans_fun input2 (last (f_Exec_Comp_Stream_Init trans_fun input1 c))) \<Up> Suc 0)"
by (simp add: i_Exec_Stream_Init_append f_Exec_eq_f_Exec_Stream_Init_last)
lemma i_Exec_Stream_Init_i_Exec_Stream_append:"
i_Exec_Comp_Stream_Init trans_fun (input1 \<frown> input2) c =
(f_Exec_Comp_Stream_Init trans_fun input1 c) \<frown>
(i_Exec_Comp_Stream trans_fun input2 (f_Exec_Comp trans_fun input1 c))"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons i_Exec_Stream_Init_eq_i_Exec_Stream_Cons i_Exec_Stream_append)
lemma i_Exec_Stream_Init_take:"
(i_Exec_Comp_Stream_Init trans_fun input c) \<Down> Suc n =
f_Exec_Comp_Stream_Init trans_fun (input \<Down> n) c"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons i_Exec_Stream_Init_eq_i_Exec_Stream_Cons i_Exec_Stream_take)
lemma i_Exec_Stream_Init_drop:"
(i_Exec_Comp_Stream_Init trans_fun input c) \<Up> n =
i_Exec_Comp_Stream_Init trans_fun (input \<Up> n)
(f_Exec_Comp trans_fun (input \<Down> n) c)"
apply (case_tac n, simp)
apply (simp add: i_Exec_Stream_Init_eq_i_Exec_Stream_Cons i_Exec_Stream_drop)
apply (simp add: ilist_eq_iff i_take_Suc_conv_app_nth f_Exec_append i_Exec_Stream_nth i_append_nth i_take_first i_take_drop_eq_map)
apply (simp add: upt_conv_Cons)
done
theorem f_Exec_Stream_Init_strictly_causal: "
xs \<down> n = ys \<down> n \<Longrightarrow>
(f_Exec_Comp_Stream_Init trans_fun xs c) \<down> Suc n = (f_Exec_Comp_Stream_Init trans_fun ys c) \<down> Suc n"
by (simp add: f_Exec_Stream_Init_take)
theorem i_Exec_Stream_Init_strictly_causal: "
input1 \<Down> n = input2 \<Down> n \<Longrightarrow>
(i_Exec_Comp_Stream_Init trans_fun input1 c) \<Down> Suc n = (i_Exec_Comp_Stream_Init trans_fun input2 c) \<Down> Suc n"
by (simp add: i_Exec_Stream_Init_take)
theorem f_Exec_N_eq_f_Exec_Stream_Init_nth:"
n \<le> length xs \<Longrightarrow>
f_Exec_Comp_N trans_fun n xs c = f_Exec_Comp_Stream_Init trans_fun xs c ! n"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_N_eq_f_Exec_Stream_nth)
text \<open>Basic results for previous element functions\<close>
text \<open>
The functions \<open>list_Previous\<close> and \<open>ilist_Previous\<close>
return the previous element of the list relatively to the specified position @{term n}
or the initial element if @{term n} is 0,\<close>
definition list_Previous :: "'value list \<Rightarrow> 'value \<Rightarrow> nat \<Rightarrow> 'value"
where "list_Previous xs init n \<equiv>
case n of
0 \<Rightarrow> init
| Suc n' \<Rightarrow> xs ! n'"
definition ilist_Previous :: "'value ilist \<Rightarrow> 'value \<Rightarrow> nat \<Rightarrow> 'value"
where "ilist_Previous f init n \<equiv>
case n of
0 \<Rightarrow> init
| Suc n' \<Rightarrow> f n'"
abbreviation "list_Previous'" :: "'value list \<Rightarrow> 'value \<Rightarrow> nat \<Rightarrow> 'value"
( "_\<^bsup>\<leftarrow>'' _\<^esup> _" [1000, 10, 100] 100)
where "xs\<^bsup>\<leftarrow>' init\<^esup> n \<equiv> list_Previous xs init n"
abbreviation "ilist_Previous'" :: "'value ilist \<Rightarrow> 'value \<Rightarrow> nat \<Rightarrow> 'value"
( "_\<^bsup>\<leftarrow> _\<^esup> _" [1000, 10, 100] 100)
where "f\<^bsup>\<leftarrow> init\<^esup> n \<equiv> ilist_Previous f init n"
lemma list_Previous_nth: "xs\<^bsup>\<leftarrow>' init\<^esup> n = (case n of 0 \<Rightarrow> init | Suc n' \<Rightarrow> xs ! n')"
by (simp add: list_Previous_def)
lemma ilist_Previous_nth: "f\<^bsup>\<leftarrow> init\<^esup> n = (case n of 0 \<Rightarrow> init | Suc n' \<Rightarrow> f n')"
by (simp add: ilist_Previous_def)
lemma list_Previous_nth_if: "xs\<^bsup>\<leftarrow>' init\<^esup> n = (if n = 0 then init else xs ! (n - Suc 0))"
by (case_tac n, simp_all add: list_Previous_nth)
lemma ilist_Previous_nth_if: "f\<^bsup>\<leftarrow> init\<^esup> n = (if n = 0 then init else f (n - Suc 0))"
by (case_tac n, simp_all add: ilist_Previous_nth)
lemma list_Previous_Cons: "xs\<^bsup>\<leftarrow>' init\<^esup> n = (init # xs) ! n"
by (case_tac n, simp_all add: list_Previous_nth)
lemma ilist_Previous_Cons: "f\<^bsup>\<leftarrow> init\<^esup> n = ([init] \<frown> f) n"
by (case_tac n, simp_all add: ilist_Previous_nth)
lemma list_Previous_0: "xs\<^bsup>\<leftarrow>' init\<^esup> 0 = init"
by (simp add: list_Previous_def)
lemma ilist_Previous_0: "f\<^bsup>\<leftarrow> init\<^esup> 0 = init"
by (simp add: ilist_Previous_def)
lemma list_Previous_gr0: "0 < n \<Longrightarrow> xs\<^bsup>\<leftarrow>' init\<^esup> n = xs ! (n - Suc 0)"
by (case_tac n, simp_all add: list_Previous_nth)
lemma ilist_Previous_gr0: "0 < n \<Longrightarrow> f\<^bsup>\<leftarrow> init\<^esup> n = f (n - Suc 0)"
by (case_tac n, simp_all add: ilist_Previous_nth)
lemma list_Previous_Suc: "xs\<^bsup>\<leftarrow>' init\<^esup> (Suc n) = xs ! n"
by (simp add: list_Previous_def)
lemma ilist_Previous_Suc: "f\<^bsup>\<leftarrow> init\<^esup> (Suc n) = f n"
by (simp add: ilist_Previous_def)
lemma f_Exec_Stream_Previous_f_Exec_Stream_Init: "
f_Exec_Comp_Stream_Init trans_fun xs c ! n =
(f_Exec_Comp_Stream trans_fun xs c)\<^bsup>\<leftarrow>' c\<^esup> n"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons list_Previous_Cons)
lemma i_Exec_Stream_Previous_i_Exec_Stream_Init: "
i_Exec_Comp_Stream_Init trans_fun input c n =
(i_Exec_Comp_Stream trans_fun input c)\<^bsup>\<leftarrow> c\<^esup> n"
by (simp add: i_Exec_Stream_Init_eq_i_Exec_Stream_Cons ilist_Previous_Cons)
lemma f_Exec_Stream_hd: "
0 < length xs \<Longrightarrow> hd (f_Exec_Comp_Stream trans_fun xs c) = trans_fun (hd xs) c"
by (case_tac xs, simp+)
lemma f_Exec_Stream_nth_0: "
0 < length xs \<Longrightarrow> (f_Exec_Comp_Stream trans_fun xs c) ! 0= trans_fun (xs ! 0) c"
by (case_tac xs, simp+)
text \<open>
The calculation of the n-th result stream element
from the previous result stream element and the current input stream element.\<close>
lemma f_Exec_Stream_nth_gr0_calc: "
\<lbrakk> n < length xs; 0 < n \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c ! n =
trans_fun (xs ! n) (f_Exec_Comp_Stream trans_fun xs c ! (n - 1))"
by (simp add: f_Exec_Stream_nth take_Suc_conv_app_nth f_Exec_append)
lemma f_Exec_Stream_nth_calc_Previous: "
n < length xs \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c ! n =
trans_fun (xs ! n) ((f_Exec_Comp_Stream trans_fun xs c)\<^bsup>\<leftarrow>' c\<^esup> n)"
apply (case_tac n)
apply (simp add: list_Previous_0 f_Exec_Stream_nth_0)
apply (simp add: list_Previous_def f_Exec_Stream_nth_gr0_calc)
done
lemma i_Exec_Stream_nth_0: "
(i_Exec_Comp_Stream trans_fun input c) 0 = trans_fun (input 0) c"
by (simp add: i_Exec_Stream_nth i_take_first)
lemma i_Exec_Stream_nth_gr0_calc: "
0 < n \<Longrightarrow>
(i_Exec_Comp_Stream trans_fun input c) n =
trans_fun (input n) ((i_Exec_Comp_Stream trans_fun input c) (n - 1))"
by (simp add: i_Exec_Stream_nth i_take_Suc_conv_app_nth f_Exec_append)
text \<open>
The component state (and thus its output) at time point @{term "n"}
is computed from the previous state
(the state at time @{term "n-1"} for @{term "n > 0"}
or the initial state for @{term "n = 0"})
and the input at time @{term "n"}.\<close>
lemma i_Exec_Stream_nth_calc_Previous: "
i_Exec_Comp_Stream trans_fun input c n =
trans_fun (input n) ((i_Exec_Comp_Stream trans_fun input c)\<^bsup>\<leftarrow> c\<^esup> n)"
by (simp add: i_Exec_Stream_nth ilist_Previous_nth_if i_take_first i_take_Suc_conv_app_nth f_Exec_append)
lemma f_Exec_Stream_Init_nth_Suc_calc: "
n < length xs \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c ! Suc n =
trans_fun (xs ! n) (f_Exec_Comp_Stream_Init trans_fun xs c ! n)"
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_nth nth_Cons' length_greater_0_conv[THEN iffD1, OF gr_implies_gr0] take_Suc_conv_app_nth f_Exec_append)
lemma f_Exec_Stream_Init_nth_Plus1_calc: "
n < length xs \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c ! (n + 1)=
trans_fun (xs ! n) (f_Exec_Comp_Stream_Init trans_fun xs c ! n)"
by (simp add: f_Exec_Stream_Init_nth_Suc_calc)
lemma f_Exec_Stream_Init_nth_gr0_calc: "
\<lbrakk> n \<le> length xs; 0 < n \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c ! n =
trans_fun (xs ! (n - 1)) (f_Exec_Comp_Stream_Init trans_fun xs c ! (n - 1))"
by (clarsimp simp: gr0_conv_Suc f_Exec_Stream_Init_nth_Suc_calc)
text \<open>
At the beginning,
the component state (and thus its output)
for the execution stream with initial state
is represented by the initial state,
contrary to the @{term "i_Exec_Comp_Stream"}
that does not contain the initial state.\<close>
text \<open>
The component state (and thus its output) at time point @{term "n + 1"}
for the execution stream with initial state
is computed from the previous state
(the state at time @{term "n"})
and the previous input
(input at time @{term "n"}),
contrary to the @{term "i_Exec_Comp_Stream"},
where each state at time @{term "n"}
represents the resulting state after processing the input at time @{term "n"}.\<close>
lemma i_Exec_Stream_Init_nth_Suc_calc: "
i_Exec_Comp_Stream_Init trans_fun input c (Suc n) =
trans_fun (input n) (i_Exec_Comp_Stream_Init trans_fun input c n)"
by (simp add: i_Exec_Stream_Init_nth i_take_Suc_conv_app_nth f_Exec_append)
lemma i_Exec_Stream_Init_nth_Plus1_calc: "
i_Exec_Comp_Stream_Init trans_fun input c (n + 1) =
trans_fun (input n) (i_Exec_Comp_Stream_Init trans_fun input c n)"
by (simp add: i_Exec_Stream_Init_nth_Suc_calc)
lemma i_Exec_Stream_Init_nth_gr0_calc: "
0 < n \<Longrightarrow>
i_Exec_Comp_Stream_Init trans_fun input c n =
trans_fun (input (n - 1)) (i_Exec_Comp_Stream_Init trans_fun input c (n - 1))"
by (clarsimp simp: gr0_conv_Suc i_Exec_Stream_Init_nth_Suc_calc)
text \<open>Correlation between Pre/Post-Conditions for
\<open>f_Exec_Comp_Stream\<close> and \<open>f_Exec_Comp_Stream_Init\<close>\<close>
lemma f_Exec_Stream_Pre_Post1: "
\<lbrakk> n < length xs;
c_n = (f_Exec_Comp_Stream trans_fun xs c)\<^bsup>\<leftarrow>' c\<^esup> n; x_n = xs ! n \<rbrakk> \<Longrightarrow>
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (f_Exec_Comp_Stream trans_fun xs c ! n)) =
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: f_Exec_Stream_nth_calc_Previous)
text \<open>Direct relation between input and result after transition\<close>
lemma f_Exec_Stream_Pre_Post2: "
\<lbrakk> n < length xs;
c_n = (f_Exec_Comp_Stream trans_fun xs c)\<^bsup>\<leftarrow>' c\<^esup> n; x_n = xs ! n \<rbrakk> \<Longrightarrow>
(P c_n \<longrightarrow> Q (xs ! n) (f_Exec_Comp_Stream trans_fun xs c ! n)) =
(P c_n \<longrightarrow> Q x_n (trans_fun x_n c_n))"
by (simp add: f_Exec_Stream_nth_calc_Previous)
lemma f_Exec_Stream_Pre_Post2_Suc: "
\<lbrakk> Suc n < length xs;
c_n = f_Exec_Comp_Stream trans_fun xs c ! n; x_n1 = xs ! Suc n \<rbrakk> \<Longrightarrow>
(P c_n \<longrightarrow> Q (xs ! Suc n) (f_Exec_Comp_Stream trans_fun xs c ! Suc n)) =
(P c_n \<longrightarrow> Q x_n1 (trans_fun x_n1 c_n))"
by (simp add: f_Exec_Stream_nth_gr0_calc)
lemma f_Exec_Stream_Init_Pre_Post1: "
\<lbrakk> n < length xs;
c_n = f_Exec_Comp_Stream_Init trans_fun xs c ! n; x_n = xs ! n \<rbrakk> \<Longrightarrow>
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (f_Exec_Comp_Stream_Init trans_fun xs c ! Suc n)) =
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: f_Exec_Stream_Init_nth_Suc_calc)
text \<open>Direct relation between input and state before transition\<close>
lemma f_Exec_Stream_Init_Pre_Post2: "
\<lbrakk> n < length xs;
c_n = f_Exec_Comp_Stream_Init trans_fun xs c ! n; x_n = xs ! n \<rbrakk> \<Longrightarrow>
(P (xs ! n) (f_Exec_Comp_Stream_Init trans_fun xs c ! n) \<longrightarrow>
Q (f_Exec_Comp_Stream_Init trans_fun xs c ! Suc n)) =
(P x_n c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: f_Exec_Stream_Init_nth_Suc_calc)
lemma i_Exec_Stream_Pre_Post1: "
\<lbrakk> c_n = (i_Exec_Comp_Stream trans_fun input c)\<^bsup>\<leftarrow> c\<^esup> n; x_n = input n \<rbrakk> \<Longrightarrow>
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (i_Exec_Comp_Stream trans_fun input c n)) =
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: i_Exec_Stream_nth_calc_Previous)
text \<open>Direct relation between input and result after transition\<close>
lemma i_Exec_Stream_Pre_Post2: "
\<lbrakk> c_n = (i_Exec_Comp_Stream trans_fun input c)\<^bsup>\<leftarrow> c\<^esup> n; x_n = input n \<rbrakk> \<Longrightarrow>
(P c_n \<longrightarrow> Q (input n) (i_Exec_Comp_Stream trans_fun input c n)) =
(P c_n \<longrightarrow> Q x_n (trans_fun x_n c_n))"
by (simp add: i_Exec_Stream_nth_calc_Previous)
lemma i_Exec_Stream_Pre_Post2_Suc: "
\<lbrakk> c_n = i_Exec_Comp_Stream trans_fun input c n; x_n1 = input (Suc n) \<rbrakk> \<Longrightarrow>
(P c_n \<longrightarrow> Q (input (Suc n)) (i_Exec_Comp_Stream trans_fun input c (Suc n))) =
(P c_n \<longrightarrow> Q x_n1 (trans_fun x_n1 c_n))"
by (simp add: i_Exec_Stream_nth_gr0_calc)
lemma i_Exec_Stream_Init_Pre_Post1: "
\<lbrakk> c_n = i_Exec_Comp_Stream_Init trans_fun input c n; x_n = input n \<rbrakk> \<Longrightarrow>
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (i_Exec_Comp_Stream_Init trans_fun input c (Suc n))) =
(P1 x_n \<and> P2 c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: i_Exec_Stream_Init_nth_Suc_calc)
text \<open>Direct relation between input and state before transition\<close>
lemma i_Exec_Stream_Init_Pre_Post2: "
\<lbrakk> c_n = i_Exec_Comp_Stream_Init trans_fun input c n; x_n = input n \<rbrakk> \<Longrightarrow>
(P (input n) (i_Exec_Comp_Stream_Init trans_fun input c n) \<longrightarrow>
Q (i_Exec_Comp_Stream_Init trans_fun input c (Suc n))) =
(P x_n c_n \<longrightarrow> Q (trans_fun x_n c_n))"
by (simp add: i_Exec_Stream_Init_nth_Suc_calc)
text \<open>Basic results for stream prefices\<close>
lemma f_Exec_Stream_prefix: "
prefix xs ys \<Longrightarrow>
prefix (f_Exec_Comp_Stream trans_fun xs c)
(f_Exec_Comp_Stream trans_fun ys c)"
by (clarsimp simp: prefix_def f_Exec_Stream_append)
lemma i_Exec_Stream_prefix: "
xs \<sqsubseteq> input \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c \<sqsubseteq>
i_Exec_Comp_Stream trans_fun input c"
by (simp add: iprefix_eq_iprefix_take i_Exec_Stream_take)
lemma f_Exec_N_prefix: "
\<lbrakk> n \<le> length xs; prefix xs ys \<rbrakk> \<Longrightarrow>
f_Exec_Comp_N trans_fun n xs c =
f_Exec_Comp_N trans_fun n ys c"
by (simp add: f_Exec_Comp_N_def prefix_imp_take_eq)
theorem f_Exec_Stream_prefix_causal[rule_format]:"
n \<le> length (xs \<sqinter> ys) \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c \<down> n =
f_Exec_Comp_Stream trans_fun ys c \<down> n"
by (rule f_Exec_Stream_causal, rule inf_prefix_take_correct)
lemma f_Exec_Stream_Init_prefix:"
prefix xs ys \<Longrightarrow>
prefix (f_Exec_Comp_Stream_Init trans_fun xs c)
(f_Exec_Comp_Stream_Init trans_fun ys c)"
by (clarsimp simp: prefix_def f_Exec_Stream_Init_append)
lemma i_Exec_Stream_Init_prefix: "
xs \<sqsubseteq> input \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c \<sqsubseteq>
i_Exec_Comp_Stream_Init trans_fun input c"
by (simp add: iprefix_eq_iprefix_take i_Exec_Stream_Init_take)
theorem f_Exec_Stream_Init_prefix_strictly_causal[rule_format]:"
n \<le> length (xs \<sqinter> ys) \<Longrightarrow>
f_Exec_Comp_Stream_Init trans_fun xs c \<down> Suc n =
f_Exec_Comp_Stream_Init trans_fun ys c \<down> Suc n"
by (rule f_Exec_Stream_Init_strictly_causal, rule inf_prefix_take_correct)
text \<open>
A predicate indicating
whether a component is deterministically dependent
on the local state extracted by the the given local state function.\<close>
definition Deterministic_Trans_Fun ::
"('comp, 'input) Comp_Trans_Fun \<Rightarrow> ('comp, 'state) Comp_Local_State \<Rightarrow> bool"
where "Deterministic_Trans_Fun trans_fun localState \<equiv>
\<forall>c1 c2 x. localState c1 = localState c2 \<longrightarrow> trans_fun x c1 = trans_fun x c2"
lemma Deterministic_f_Exec: "
\<lbrakk> Deterministic_Trans_Fun trans_fun localState; localState c1 = localState c2; xs \<noteq> [] \<rbrakk> \<Longrightarrow>
f_Exec_Comp trans_fun xs c1 = f_Exec_Comp trans_fun xs c2"
apply (unfold Deterministic_Trans_Fun_def)
apply (case_tac xs, simp)
apply (rename_tac y ys)
apply (drule_tac x=c1 in spec)
apply (drule_tac x=c2 in spec)
apply simp
done
lemma Deterministic_f_Exec_Stream: "
\<lbrakk> Deterministic_Trans_Fun trans_fun localState; localState c1 = localState c2 \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c1 = f_Exec_Comp_Stream trans_fun xs c2"
apply (clarsimp simp: list_eq_iff f_Exec_Stream_nth)
apply (rule Deterministic_f_Exec)
apply (simp add: length_greater_0_conv[THEN iffD1, OF gr_implies_gr0])+
done
lemma Deterministic_i_Exec_Stream: "
\<lbrakk> Deterministic_Trans_Fun trans_fun localState; localState c1 = localState c2 \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream trans_fun input c1 = i_Exec_Comp_Stream trans_fun input c2"
apply (clarsimp simp: ilist_eq_iff i_Exec_Stream_nth)
apply (rule Deterministic_f_Exec)
apply simp+
done
subsubsection \<open>Connected streams\<close>
text \<open>
A predicate indicating for two message streams,
that the ports, they correspond to, are connected.
The predicate implies strict causality.\<close>
definition f_Streams_Connected :: "'a fstream_af \<Rightarrow> 'a fstream_af \<Rightarrow> bool"
where "f_Streams_Connected outS inS \<equiv> inS = \<NoMsg> # outS"
definition i_Streams_Connected :: "'a istream_af \<Rightarrow> 'a istream_af \<Rightarrow> bool"
where "i_Streams_Connected outS inS \<equiv> inS = [\<NoMsg>] \<frown> outS"
lemmas Streams_Connected_defs =
f_Streams_Connected_def
i_Streams_Connected_def
lemma f_Streams_Connected_imp_not_empty: "f_Streams_Connected outS inS \<Longrightarrow> inS \<noteq> []"
by (simp add: f_Streams_Connected_def)
lemma f_Streams_Connected_nth_conv: "
f_Streams_Connected outS inS =
(length inS = Suc (length outS) \<and>
(\<forall>i<length inS. inS ! i = (case i of 0 \<Rightarrow> \<NoMsg> | Suc k \<Rightarrow> outS ! k)))"
by (simp add: f_Streams_Connected_def list_eq_iff nth_Cons)
lemma f_Streams_Connected_nth_conv_if: "
f_Streams_Connected outS inS =
(length inS = Suc (length outS) \<and>
(\<forall>i<length inS. inS ! i = (if i = 0 then \<NoMsg> else outS ! (i - Suc 0))))"
apply (subst f_Streams_Connected_nth_conv)
apply (rule conj_cong, simp)
apply (rule all_imp_eqI, simp)
apply (rename_tac i, case_tac i, simp+)
done
lemma i_Streams_Connected_nth_conv: "
i_Streams_Connected outS inS =
(\<forall>i. inS i = (case i of 0 \<Rightarrow> \<NoMsg> | Suc k \<Rightarrow> outS k))"
by (simp add: i_Streams_Connected_def ilist_eq_iff i_append_nth_Cons)
lemma i_Streams_Connected_nth_conv_if: "
i_Streams_Connected outS inS =
(\<forall>i. inS i = (if i = 0 then \<NoMsg> else outS (i - Suc 0)))"
apply (subst i_Streams_Connected_nth_conv)
apply (rule all_eqI)
apply (rename_tac i, case_tac i, simp+)
done
lemma f_Exec_Stream_Init_eq_output_channel: "
\<lbrakk> output_fun c = \<NoMsg>;
f_Streams_Connected
(map output_fun (f_Exec_Comp_Stream trans_fun xs c))
channel \<rbrakk> \<Longrightarrow>
map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c) = channel"
by (simp add: f_Streams_Connected_def f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma i_Exec_Stream_Init_eq_output_channel: "
\<lbrakk> output_fun c = \<NoMsg>;
i_Streams_Connected
(output_fun \<circ> (i_Exec_Comp_Stream trans_fun input c))
channel \<rbrakk> \<Longrightarrow>
output_fun \<circ> (i_Exec_Comp_Stream_Init trans_fun input c) = channel"
by (simp add: i_Streams_Connected_def i_Exec_Stream_Init_eq_i_Exec_Stream_Cons)
lemma f_Exec_Stream_output_causal: "
\<lbrakk> xs \<down> n = ys \<down> n;
output1 = map output_fun (f_Exec_Comp_Stream trans_fun xs c);
output2 = map output_fun (f_Exec_Comp_Stream trans_fun ys c) \<rbrakk> \<Longrightarrow>
output1 \<down> n = output2 \<down> n"
by (simp add: take_map f_Exec_Stream_causal[of n xs])
lemma f_Exec_Stream_Init_output_strictly_causal: "
\<lbrakk> xs \<down> n = ys \<down> n;
output1 = map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c);
output2 = map output_fun (f_Exec_Comp_Stream_Init trans_fun ys c) \<rbrakk> \<Longrightarrow>
output1 \<down> Suc n = output2 \<down> Suc n"
by (simp add: take_map f_Exec_Stream_Init_strictly_causal[of n xs])
lemma i_Exec_Stream_output_causal: "
\<lbrakk> input1 \<Down> n = input2 \<Down> n;
output1 = output_fun \<circ> i_Exec_Comp_Stream trans_fun input1 c;
output2 = output_fun \<circ> i_Exec_Comp_Stream trans_fun input2 c \<rbrakk> \<Longrightarrow>
output1 \<Down> n = output2 \<Down> n"
by (simp add: i_Exec_Stream_causal[of n input1])
lemma i_Exec_Stream_Init_output_strictly_causal: "
\<lbrakk> input1 \<Down> n = input2 \<Down> n;
output1 = output_fun \<circ> i_Exec_Comp_Stream_Init trans_fun input1 c;
output2 = output_fun \<circ> i_Exec_Comp_Stream_Init trans_fun input2 c \<rbrakk> \<Longrightarrow>
output1 \<Down> Suc n = output2 \<Down> Suc n"
by (simp add: i_Exec_Stream_Init_strictly_causal[of n input1])
lemma f_Exec_Stream_Connected_strictly_causal: "
\<lbrakk> xs \<down> n = ys \<down> n;
f_Streams_Connected
(map output_fun (f_Exec_Comp_Stream trans_fun xs c))
channel1;
f_Streams_Connected
(map output_fun (f_Exec_Comp_Stream trans_fun ys c))
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<down> Suc n = channel2 \<down> Suc n"
by (simp add: f_Streams_Connected_def take_map f_Exec_Stream_take)
lemma i_Exec_Stream_Connected_strictly_causal: "
\<lbrakk> input1 \<Down> n = input2 \<Down> n;
i_Streams_Connected
(portOutput \<circ> (i_Exec_Comp_Stream trans_fun input1 c))
channel1;
i_Streams_Connected
(portOutput \<circ> (i_Exec_Comp_Stream trans_fun input2 c))
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<Down> Suc n = channel2 \<Down> Suc n"
by (simp add: i_Streams_Connected_def i_take_Suc_Cons i_Exec_Stream_take)
text \<open>
A predicate for the semantics with initial state in result stream
indicating for two message streams that the ports, they correspond to, are connected.\<close>
definition f_Streams_Connected_Init :: "'a fstream_af \<Rightarrow> 'a fstream_af \<Rightarrow> bool"
where "f_Streams_Connected_Init outS inS \<equiv> inS = outS"
definition i_Streams_Connected_Init :: "'a istream_af \<Rightarrow> 'a istream_af \<Rightarrow> bool"
where "i_Streams_Connected_Init outS inS \<equiv> inS = outS"
lemmas Streams_Connected_Init_defs =
f_Streams_Connected_Init_def
i_Streams_Connected_Init_def
lemma f_Streams_Connected_Init_nth_conv: "
f_Streams_Connected_Init outS inS =
(length inS = length outS \<and> (\<forall>i<length inS. inS ! i = outS ! i))"
by (simp add: f_Streams_Connected_Init_def list_eq_iff)
lemma i_Streams_Connected_Init_nth_conv: "
i_Streams_Connected_Init outS inS =
(\<forall>i. inS i = outS i)"
by (simp add: i_Streams_Connected_Init_def ilist_eq_iff)
lemma f_Exec_Stream_Init_eq_output_channel2: "
\<lbrakk> output_fun c = \<NoMsg>;
f_Streams_Connected_Init
(map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c))
channel \<rbrakk> \<Longrightarrow>
map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c) = channel"
by (simp add: f_Streams_Connected_Init_def f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma i_Exec_Stream_Init_eq_output_channel2: "
\<lbrakk> output_fun c = \<NoMsg>;
i_Streams_Connected_Init
(output_fun \<circ> (i_Exec_Comp_Stream_Init trans_fun input c))
channel \<rbrakk> \<Longrightarrow>
output_fun \<circ> (i_Exec_Comp_Stream_Init trans_fun input c) = channel"
by (simp add: i_Streams_Connected_Init_def i_Exec_Stream_Init_eq_i_Exec_Stream_Cons)
lemma f_Exec_Stream_Connected_Init_strictly_causal: "
\<lbrakk> xs \<down> n = ys \<down> n;
f_Streams_Connected_Init
(map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c))
channel1;
f_Streams_Connected_Init
(map output_fun (f_Exec_Comp_Stream_Init trans_fun ys c))
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<down> Suc n = channel2 \<down> Suc n"
by (simp add: f_Streams_Connected_Init_def f_Exec_Stream_Init_eq_f_Exec_Stream_Cons take_map f_Exec_Stream_take)
lemma i_Exec_Stream_Connected_Init_strictly_causal: "
\<lbrakk> input1 \<Down> n = input2 \<Down> n;
i_Streams_Connected_Init
(portOutput \<circ> (i_Exec_Comp_Stream_Init trans_fun input1 c))
channel1;
i_Streams_Connected_Init
(portOutput \<circ> (i_Exec_Comp_Stream_Init trans_fun input2 c))
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<Down> Suc n = channel2 \<Down> Suc n"
by (simp add: i_Streams_Connected_Init_def i_Exec_Stream_Init_eq_i_Exec_Stream_Cons i_Exec_Stream_take)
subsubsection \<open>Additional auxiliary results\<close>
text \<open>The following lemma shows that,
if the system state is different at some time points
with respect to a certain predicate @{term P},
then there exists a defined time point between these two,
where the state change has taken place\<close>
lemma f_State_Change_exists_set: "
\<lbrakk> n1 \<le> n2; n1 \<in> I; n2 \<in> I;
\<not> P (f_Exec_Comp trans_fun (input \<down> n1) c);
P (f_Exec_Comp trans_fun (input \<down> n2) c) \<rbrakk> \<Longrightarrow>
\<exists>n\<in>I. n1 \<le> n \<and> n < n2 \<and>
\<not> P (f_Exec_Comp trans_fun (input \<down> n) c) \<and>
P (f_Exec_Comp trans_fun (input \<down> (inext n I)) c)"
by (rule inext_predicate_change_exists)
lemma f_State_Change_exists: "
\<lbrakk> n1 \<le> n2;
\<not> P (f_Exec_Comp trans_fun (input \<down> n1) c);
P (f_Exec_Comp trans_fun (input \<down> n2) c) \<rbrakk> \<Longrightarrow>
\<exists>n\<ge>n1. n < n2 \<and>
\<not> P (f_Exec_Comp trans_fun (input \<down> n) c) \<and>
P (f_Exec_Comp trans_fun (input \<down> (Suc n)) c)"
by (rule nat_Suc_predicate_change_exists)
lemma i_State_Change_exists_set: "
\<lbrakk> n1 \<le> n2; n1 \<in> I; n2 \<in> I;
\<not> P (i_Exec_Comp_Stream trans_fun input c n1);
P (i_Exec_Comp_Stream trans_fun input c n2) \<rbrakk> \<Longrightarrow>
\<exists>n\<in>I. n1 \<le> n \<and> n < n2 \<and>
\<not> P (i_Exec_Comp_Stream trans_fun input c n) \<and>
P (i_Exec_Comp_Stream trans_fun input c (inext n I))"
by (rule inext_predicate_change_exists)
lemma i_State_Change_exists: "
\<lbrakk> n1 \<le> n2;
\<not> P (i_Exec_Comp_Stream trans_fun input c n1);
P (i_Exec_Comp_Stream trans_fun input c n2) \<rbrakk> \<Longrightarrow>
\<exists>n\<ge>n1. n < n2 \<and>
\<not> P (i_Exec_Comp_Stream trans_fun input c n) \<and>
P (i_Exec_Comp_Stream trans_fun input c (Suc n))"
by (rule nat_Suc_predicate_change_exists)
lemma i_State_Change_Init_exists_set: "
\<lbrakk> n1 \<le> n2; n1 \<in> I; n2 \<in> I;
\<not> P (i_Exec_Comp_Stream_Init trans_fun input c n1);
P (i_Exec_Comp_Stream_Init trans_fun input c n2) \<rbrakk> \<Longrightarrow>
\<exists>n\<in>I. n1 \<le> n \<and> n < n2 \<and>
\<not> P (i_Exec_Comp_Stream_Init trans_fun input c n) \<and>
P (i_Exec_Comp_Stream_Init trans_fun input c (inext n I))"
by (rule inext_predicate_change_exists)
lemma i_State_Change_Init_exists: "
\<lbrakk> n1 \<le> n2;
\<not> P (i_Exec_Comp_Stream_Init trans_fun input c n1);
P (i_Exec_Comp_Stream_Init trans_fun input c n2) \<rbrakk> \<Longrightarrow>
\<exists>n\<ge>n1. n < n2 \<and>
\<not> P (i_Exec_Comp_Stream_Init trans_fun input c n) \<and>
P (i_Exec_Comp_Stream_Init trans_fun input c (Suc n))"
by (rule nat_Suc_predicate_change_exists)
subsection \<open>Components with accelerated execution\<close>
text \<open>
This section deals with variable execution speed components.
A component accelerated by a (clocking) factor @{term k}
processes streams expanded by factor @{term k}
and its output streams are compressed by factor @{term k}.\<close>
subsubsection \<open>Equivalence relation for executions\<close>
text \<open>
A predicate indicating for
two components together with transition functions
and a given equivalence predicate for their local states,
that the components exhibit equivalent observable behaviour
after expanding input streams and shrinking output streams
by a constant factor,
given that their local states are equivalent
with respect to the specified equivalence relations.\<close>
definition
Equiv_Exec :: "
'input \<Rightarrow>
('state1 \<Rightarrow> 'state2 \<Rightarrow> bool) \<Rightarrow> \<comment> \<open>Equivalence predicate for local states\<close>
('comp1, 'state1) Comp_Local_State \<Rightarrow>
('comp2, 'state2) Comp_Local_State \<Rightarrow>
('input, 'input1) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for first component\<close>
('input, 'input2) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for second component\<close>
('comp1, 'output) Port_Output_Value \<Rightarrow>
('comp2, 'output) Port_Output_Value \<Rightarrow>
('comp1, 'input1 message_af) Comp_Trans_Fun \<Rightarrow>
('comp2, 'input2 message_af) Comp_Trans_Fun \<Rightarrow>
nat \<Rightarrow> nat \<Rightarrow> 'comp1 \<Rightarrow> 'comp2 \<Rightarrow> bool"
where
"Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<equiv>
equiv_states (localState1 c1) (localState2 c2) \<longrightarrow> (
last_message (map output_fun1 (
f_Exec_Comp_Stream trans_fun1 (input_fun1 m # \<NoMsg>\<^bsup>k1 - Suc 0\<^esup>) c1)) =
last_message (map output_fun2 (
f_Exec_Comp_Stream trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2)) \<and>
equiv_states
(localState1 (f_Exec_Comp trans_fun1 (input_fun1 m # \<NoMsg>\<^bsup>k1 - Suc 0\<^esup>) c1))
(localState2 (f_Exec_Comp trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2)))"
text \<open>
Predicate indicating for
two components together with transition functions
and a given equivalence predicate for their local states,
that the equivalence predicate is stable
with respect to component execution,
i.e., it determines the equivalence
of components' local states
both for the initial states and after the components
have processed an arbitrary input.
The restricting version @{term "Equiv_Exec_stable_set"}
guarantees stability only for inputs from a given restriction set,
the not-restricting version guarantees stability for all inputs.\<close>
definition
Equiv_Exec_stable_set :: "
'input set \<Rightarrow>
('state1 \<Rightarrow> 'state2 \<Rightarrow> bool) \<Rightarrow> \<comment> \<open>Equivalence predicate for local states\<close>
('comp1, 'state1) Comp_Local_State \<Rightarrow>
('comp2, 'state2) Comp_Local_State \<Rightarrow>
('input, 'input1) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for first component\<close>
('input, 'input2) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for second component\<close>
('comp1, 'output) Port_Output_Value \<Rightarrow>
('comp2, 'output) Port_Output_Value \<Rightarrow>
('comp1, 'input1 message_af) Comp_Trans_Fun \<Rightarrow>
('comp2, 'input2 message_af) Comp_Trans_Fun \<Rightarrow>
nat \<Rightarrow> nat \<Rightarrow> 'comp1 \<Rightarrow> 'comp2 \<Rightarrow> bool"
where
"Equiv_Exec_stable_set A
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<equiv>
\<forall>input m. set input \<subseteq> A \<and> m \<in> A \<longrightarrow>
Equiv_Exec m
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)"
definition
Equiv_Exec_stable :: "
('state1 \<Rightarrow> 'state2 \<Rightarrow> bool) \<Rightarrow> \<comment> \<open>Equivalence predicate for local states\<close>
('comp1, 'state1) Comp_Local_State \<Rightarrow>
('comp2, 'state2) Comp_Local_State \<Rightarrow>
('input, 'input1) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for first component\<close>
('input, 'input2) Port_Input_Value \<Rightarrow> \<comment> \<open>Input adaptor for second component\<close>
('comp1, 'output) Port_Output_Value \<Rightarrow>
('comp2, 'output) Port_Output_Value \<Rightarrow>
('comp1, 'input1 message_af) Comp_Trans_Fun \<Rightarrow>
('comp2, 'input2 message_af) Comp_Trans_Fun \<Rightarrow>
nat \<Rightarrow> nat \<Rightarrow> 'comp1 \<Rightarrow> 'comp2 \<Rightarrow> bool"
where
"Equiv_Exec_stable
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<equiv>
\<forall>input m.
Equiv_Exec m
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)"
lemma Equiv_Exec_equiv_statesI: "
\<lbrakk> equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 (f_Exec_Comp trans_fun1 (input_fun1 m # \<NoMsg>\<^bsup>k1 - Suc 0\<^esup>) c1))
(localState2 (f_Exec_Comp trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2))"
by (simp add: Equiv_Exec_def)
lemma Equiv_Exec_output_eqI: "
\<lbrakk> equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
last_message (map output_fun1 (
f_Exec_Comp_Stream trans_fun1 (input_fun1 m # \<NoMsg>\<^bsup>k1 - Suc 0\<^esup>) c1)) =
last_message (map output_fun2 (
f_Exec_Comp_Stream trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2))"
by (simp add: Equiv_Exec_def)
lemma Equiv_Exec_equiv_statesI': "
\<lbrakk> equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 (f_Exec_Comp trans_fun1 NoMsg\<^bsup>k1 - Suc 0\<^esup> (trans_fun1 (input_fun1 m) c1)))
(localState2 (f_Exec_Comp trans_fun2 NoMsg\<^bsup>k2 - Suc 0\<^esup> (trans_fun2 (input_fun2 m) c2)))"
by (simp add: Equiv_Exec_def)
lemma Equiv_Exec_le1: "
\<lbrakk> k1 \<le> Suc 0; k2 \<le> Suc 0;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec m
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
output_fun1 (trans_fun1 (input_fun1 m) c1) =
output_fun2 (trans_fun2 (input_fun2 m) c2) \<and>
equiv_states
(localState1 (trans_fun1 (input_fun1 m) c1))
(localState2 (trans_fun2 (input_fun2 m) c2))"
by (simp add: Equiv_Exec_def)
lemma Equiv_Exec_stable_set_UNIV: "
Equiv_Exec_stable_set
UNIV equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 =
Equiv_Exec_stable
equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2"
by (simp add: Equiv_Exec_stable_set_def Equiv_Exec_stable_def)
lemma Equiv_Exec_stable_setI: "
\<lbrakk> Equiv_Exec_stable_set A
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
set input \<subseteq> A; m \<in> A \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)"
by (simp add: Equiv_Exec_stable_set_def)
lemma Equiv_Exec_stableI: "
Equiv_Exec_stable
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<Longrightarrow>
Equiv_Exec m
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)"
by (simp add: Equiv_Exec_stable_def)
text \<open>Reflexitity, symmetry and transitivity results for @{term "Equiv_Exec"}\<close>
lemma Equiv_Exec_refl: "
\<lbrakk> \<And>c. equiv_states (localState c) (localState c) \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states
localState localState input_fun input_fun output_fun output_fun
trans_fun trans_fun k k c c"
by (simp add: Equiv_Exec_def)
lemma Equiv_Exec_sym[rule_format]: "
\<lbrakk> \<forall>c1 c2.
equiv_states (localState1 c1) (localState2 c2) =
equiv_states (localState2 c2) (localState1 c1) \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 =
Equiv_Exec
m equiv_states
localState2 localState1 input_fun2 input_fun1 output_fun2 output_fun1
trans_fun2 trans_fun1 k2 k1 c2 c1"
by (fastforce simp: Equiv_Exec_def)
lemma Equiv_Exec_sym2: "
\<lbrakk> equiv_states_sym = (\<lambda>s1 s2. equiv_states s2 s1) \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 =
Equiv_Exec
m equiv_states_sym
localState2 localState1 input_fun2 input_fun1 output_fun2 output_fun1
trans_fun2 trans_fun1 k2 k1 c2 c1"
by (fastforce simp: Equiv_Exec_def)
lemma Equiv_Exec_sym2_ex: "
\<exists>equiv_states_sym.
Equiv_Exec
m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 =
Equiv_Exec
m equiv_states_sym
localState2 localState1 input_fun2 input_fun1 output_fun2 output_fun1
trans_fun2 trans_fun1 k2 k1 c2 c1"
by (rule exI, rule Equiv_Exec_sym2, simp)
lemma Equiv_Exec_trans: "
\<lbrakk> Equiv_Exec
m equiv_states12
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
Equiv_Exec
m equiv_states23
localState2 localState3 input_fun2 input_fun3 output_fun2 output_fun3
trans_fun2 trans_fun3 k2 k3 c2 c3;
equiv_states13 = (\<lambda>s1 s3. (
if s1 = localState1 c1 \<and> s3 = localState3 c3 then
equiv_states12 s1 (localState2 c2) \<and>
equiv_states23 (localState2 c2) s3
else
equiv_states12 s1 (
localState2 (f_Exec_Comp trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2))) \<and>
equiv_states23 (
localState2 (f_Exec_Comp trans_fun2 (input_fun2 m # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2)) s3) \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states13
localState1 localState3 input_fun1 input_fun3 output_fun1 output_fun3
trans_fun1 trans_fun3 k1 k3 c1 c3"
by (fastforce simp: Equiv_Exec_def)
lemma Equiv_Exec_trans_ex: "
\<lbrakk> Equiv_Exec
m equiv_states12
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
Equiv_Exec
m equiv_states23
localState2 localState3 input_fun2 input_fun3 output_fun2 output_fun3
trans_fun2 trans_fun3 k2 k3 c2 c3 \<rbrakk> \<Longrightarrow>
\<exists>equiv_states13. Equiv_Exec
m equiv_states13
localState1 localState3 input_fun1 input_fun3 output_fun1 output_fun3
trans_fun1 trans_fun3 k1 k3 c1 c3"
by (blast intro: Equiv_Exec_trans)
text \<open>A predicate indicating for
a given local state extraction function and
a given transition function,
that components, whose states are equal with regard to the
local state extraction function,
are transformed into equal componenents,
when the transition function is applied with the same input.\<close>
definition Exec_Equal_State ::
"('comp, 'state) Comp_Local_State \<Rightarrow> ('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow> bool"
where "Exec_Equal_State localState trans_fun \<equiv>
\<forall>c1 c2 m. localState c1 = localState c2 \<longrightarrow> trans_fun m c1 = trans_fun m c2"
lemma Exec_Equal_StateD: "
\<lbrakk> Exec_Equal_State localState trans_fun;
localState c1 = localState c2 \<rbrakk> \<Longrightarrow>
trans_fun m c1 = trans_fun m c2"
by (unfold Exec_Equal_State_def, blast)
lemma Exec_Equal_StateD': "
Exec_Equal_State localState trans_fun \<Longrightarrow>
\<forall>c1 c2 m. localState c1 = localState c2 \<longrightarrow> trans_fun m c1 = trans_fun m c2"
by (unfold Exec_Equal_State_def, blast)
lemma Exec_Equal_StateI: "
(\<And>c1 c2 m. localState c1 = localState c2 \<Longrightarrow> trans_fun m c1 = trans_fun m c2)
\<Longrightarrow> Exec_Equal_State localState trans_fun"
by (unfold Exec_Equal_State_def, blast)
lemma f_Exec_Equal_State: "\<And>c1 c2.
\<lbrakk> Exec_Equal_State localState trans_fun;
localState c1 = localState c2; xs \<noteq> [] \<rbrakk> \<Longrightarrow>
f_Exec_Comp trans_fun xs c1 = f_Exec_Comp trans_fun xs c2"
apply (induct xs, simp)
apply (case_tac "xs = []")
apply simp
apply (rule Exec_Equal_StateD, assumption+)
apply (drule_tac x="trans_fun a c1" in meta_spec)
apply (drule_tac x="trans_fun a c2" in meta_spec)
apply (drule_tac ?c1.0=c1 and ?c2.0=c2 and m=a in Exec_Equal_StateD, assumption)
apply simp
done
lemma f_Exec_Stream_Equal_State: "
\<lbrakk> Exec_Equal_State localState trans_fun;
localState c1 = localState c2 \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream trans_fun xs c1 =
f_Exec_Comp_Stream trans_fun xs c2"
apply (clarsimp simp: list_eq_iff f_Exec_Stream_nth)
apply (drule gr_implies_gr0)
apply (rule f_Exec_Equal_State)
apply simp+
done
lemma i_Exec_Stream_Equal_State: "
\<lbrakk> Exec_Equal_State localState trans_fun;
localState c1 = localState c2 \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream trans_fun input c1 =
i_Exec_Comp_Stream trans_fun input c2"
apply (clarsimp simp: ilist_eq_iff i_Exec_Stream_nth)
apply (rule f_Exec_Equal_State)
apply simp+
done
subsubsection \<open>Idle states\<close>
definition State_Idle ::
"('comp, 'state) Comp_Local_State \<Rightarrow> ('comp \<Rightarrow> 'output message_af) \<Rightarrow>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow> 'state \<Rightarrow> bool"
where "State_Idle localState output_fun trans_fun state \<equiv>
\<forall>c. localState c = state \<longrightarrow>
localState (trans_fun \<NoMsg> c) = state \<and>
output_fun (trans_fun \<NoMsg> c) = \<NoMsg>"
lemma State_IdleD: "
\<lbrakk> State_Idle localState output_fun trans_fun state;
localState c = state \<rbrakk> \<Longrightarrow>
localState (trans_fun \<NoMsg> c) = state \<and>
output_fun (trans_fun \<NoMsg> c) = \<NoMsg>"
by (unfold State_Idle_def, blast)
lemma State_IdleD': "
State_Idle localState output_fun trans_fun state \<Longrightarrow>
\<forall>c. localState c = state \<longrightarrow>
localState (trans_fun \<NoMsg> c) = state \<and>
output_fun (trans_fun \<NoMsg> c) = \<NoMsg>"
by (unfold State_Idle_def, blast)
lemma State_IdleI: "
\<lbrakk> \<And>c. localState c = state \<Longrightarrow>
localState (trans_fun \<NoMsg> c) = state \<and>
output_fun (trans_fun \<NoMsg> c) = \<NoMsg> \<rbrakk> \<Longrightarrow>
State_Idle localState output_fun trans_fun state"
by (unfold State_Idle_def, blast)
lemma State_Idle_step[rule_format]: "
\<lbrakk> State_Idle localState output_fun trans_fun (localState c) \<rbrakk> \<Longrightarrow>
State_Idle localState output_fun trans_fun (localState (trans_fun \<NoMsg> c))"
apply (frule State_IdleD[OF _ refl], erule conjE)
apply (rule State_IdleI, rename_tac c0)
apply (drule_tac c=c0 in State_IdleD)
apply simp+
done
lemma f_Exec_State_Idle_replicate_NoMsg_state[rule_format]: "
\<And>c. State_Idle localState output_fun trans_fun (localState c) \<Longrightarrow>
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = localState c"
apply (induct n, simp)
apply (frule State_Idle_step)
apply (drule_tac c=c in State_IdleD, rule refl)
apply simp
done
lemma f_Exec_State_Idle_replicate_NoMsg_gr0_output[rule_format]: "\<And>c.
\<lbrakk> State_Idle localState output_fun trans_fun (localState c); 0 < n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = \<NoMsg>"
apply (induct n, simp)
apply (case_tac "n = 0")
apply simp
apply (rule State_IdleD[THEN conjunct2], assumption, simp)
apply (drule State_Idle_step)
apply simp
done
lemma f_Exec_State_Idle_replicate_NoMsg_output[rule_format]: "
\<lbrakk> State_Idle localState output_fun trans_fun (localState c);
output_fun c = \<NoMsg> \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = \<NoMsg>"
apply (case_tac "n = 0", simp)
apply (simp add: f_Exec_State_Idle_replicate_NoMsg_gr0_output)
done
lemma f_Exec_Stream_State_Idle_replicate_NoMsg_output[rule_format]: "
\<lbrakk> State_Idle localState output_fun trans_fun (localState c) \<rbrakk> \<Longrightarrow>
map output_fun (f_Exec_Comp_Stream trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = \<NoMsg>\<^bsup>n\<^esup>"
by (simp add: list_eq_iff f_Exec_Stream_nth min_eqL f_Exec_State_Idle_replicate_NoMsg_gr0_output del: replicate.simps)
corollary f_Exec_State_Idle_append_replicate_NoMsg_state: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c)) \<rbrakk> \<Longrightarrow>
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) =
localState (f_Exec_Comp trans_fun xs c)"
by (simp add: f_Exec_append f_Exec_State_Idle_replicate_NoMsg_state)
corollary f_Exec_State_Idle_append_replicate_NoMsg_ge_state: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>m\<^esup>) c));
m \<le> n \<rbrakk> \<Longrightarrow>
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) =
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>m\<^esup>) c)"
apply (rule_tac t=n and s="m + (n - m)" in subst, simp)
apply (simp only: replicate_add append_assoc[symmetric])
apply (rule f_Exec_State_Idle_append_replicate_NoMsg_state, simp)
done
corollary f_Exec_State_Idle_replicate_NoMsg_ge_state: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>m\<^esup> c));
m \<le> n \<rbrakk> \<Longrightarrow>
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) =
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>m\<^esup> c)"
by (cut_tac f_Exec_State_Idle_append_replicate_NoMsg_ge_state[where xs="[]"], simp+)
corollary f_Exec_State_Idle_append_replicate_NoMsg_gr0_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c));
0 < n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) = \<NoMsg>"
by (simp add: f_Exec_append f_Exec_State_Idle_replicate_NoMsg_gr0_output)
corollary f_Exec_Stream_State_Idle_append_replicate_NoMsg_gr0_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c)) \<rbrakk> \<Longrightarrow>
map output_fun (f_Exec_Comp_Stream trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) =
map output_fun (f_Exec_Comp_Stream trans_fun xs c) @ \<NoMsg>\<^bsup>n\<^esup>"
by (simp add: f_Exec_Stream_append f_Exec_Stream_State_Idle_replicate_NoMsg_output)
corollary f_Exec_State_Idle_append_replicate_NoMsg_gr_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>m\<^esup>) c));
m < n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) = \<NoMsg>"
apply (rule_tac t=n and s="m + (n - m)" in subst, simp)
apply (simp only: replicate_add append_assoc[symmetric])
apply (rule f_Exec_State_Idle_append_replicate_NoMsg_gr0_output, simp+)
done
corollary f_Exec_State_Idle_append_replicate_NoMsg_ge_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>m\<^esup>) c));
output_fun (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>m\<^esup>) c) = \<NoMsg>; m \<le> n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c) = \<NoMsg>"
by (fastforce simp: order_le_less f_Exec_State_Idle_append_replicate_NoMsg_gr_output)
corollary f_Exec_State_Idle_replicate_NoMsg_gr_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>m\<^esup> c));
m < n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = \<NoMsg>"
by (cut_tac xs="[]" in f_Exec_State_Idle_append_replicate_NoMsg_gr_output, simp+)
corollary f_Exec_State_Idle_replicate_NoMsg_ge_output: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>m\<^esup> c));
output_fun (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>m\<^esup> c) = \<NoMsg>; m \<le> n \<rbrakk> \<Longrightarrow>
output_fun (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c) = \<NoMsg>"
by (fastforce simp: order_le_less f_Exec_State_Idle_replicate_NoMsg_gr_output)
lemma State_Idle_append_replicate_NoMsg_output_last_message: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c)) \<rbrakk> \<Longrightarrow>
last_message (map output_fun (f_Exec_Comp_Stream trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c)) =
last_message (map output_fun (f_Exec_Comp_Stream trans_fun xs c))"
by (simp add: f_Exec_Stream_State_Idle_append_replicate_NoMsg_gr0_output last_message_append_replicate_NoMsg)
lemma State_Idle_append_replicate_NoMsg_output_Msg_eq_last_message: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c));
output_fun (f_Exec_Comp trans_fun xs c) \<noteq> \<NoMsg>;
xs \<noteq> [] \<rbrakk> \<Longrightarrow>
last_message (map output_fun (f_Exec_Comp_Stream trans_fun (xs @ \<NoMsg>\<^bsup>n\<^esup>) c)) =
output_fun (f_Exec_Comp trans_fun xs c)"
apply (simp add: State_Idle_append_replicate_NoMsg_output_last_message f_Exec_eq_f_Exec_Stream_last2 )
apply (subst last_message_Msg_eq_last)
apply (simp add: map_last f_Exec_Stream_not_empty_conv)+
done
corollary State_Idle_output_Msg_eq_last_message: "
\<lbrakk> State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun xs c));
output_fun (f_Exec_Comp trans_fun xs c) \<noteq> \<NoMsg>;
xs \<noteq> [] \<rbrakk> \<Longrightarrow>
last_message (map output_fun (f_Exec_Comp_Stream trans_fun xs c)) =
output_fun (f_Exec_Comp trans_fun xs c)"
by (rule_tac n=0 in subst[OF State_Idle_append_replicate_NoMsg_output_Msg_eq_last_message, rule_format], simp+)
lemma State_Idle_imp_exists_state_change: "
\<lbrakk> \<not> State_Idle localState output_fun trans_fun (localState c);
State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c)) \<rbrakk> \<Longrightarrow>
\<exists>i<n. (
\<not> State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>i\<^esup> c)) \<and> (
\<forall>j\<le>n. i < j \<longrightarrow> State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>j\<^esup> c))))"
apply (cut_tac
a=0 and b=n and
P="\<lambda>x. State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun NoMsg\<^bsup>x\<^esup> c))"
in nat_Suc_predicate_change_exists, simp+)
apply (clarify, rename_tac n1)
apply (rule_tac x=n1 in exI)
apply clarsimp
apply (rule_tac t="j" and s="Suc n1 + (j - Suc n1)" in subst, simp)
apply (subst replicate_add)
apply (simp add: replicate_add f_Exec_State_Idle_append_replicate_NoMsg_state)
done
lemma State_Idle_imp_exists_state_change2: "
\<lbrakk> \<not> State_Idle localState output_fun trans_fun (localState c);
State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>n\<^esup> c)) \<rbrakk> \<Longrightarrow>
\<exists>i<n. (
(\<forall>j\<le>i. \<not> State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>i\<^esup> c))) \<and>
(\<forall>j\<le>n. i < j \<longrightarrow> State_Idle localState output_fun trans_fun (localState (f_Exec_Comp trans_fun \<NoMsg>\<^bsup>j\<^esup> c))))"
apply (frule State_Idle_imp_exists_state_change, assumption)
apply (clarify, rename_tac i)
apply (rule_tac x=i in exI)
apply simp
done
subsubsection \<open>Basic definitions for accelerated execution\<close>
text \<open>Stream processing with accelerated components\<close>
definition f_Exec_Comp_Stream_Acc_Output ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'output message_af) \<Rightarrow> \<comment> \<open>Output extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input fstream_af \<Rightarrow> 'comp \<Rightarrow>
'output fstream_af"
where "f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<equiv>
(map output_fun (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) \<div>\<^sub>f k"
definition f_Exec_Comp_Stream_Acc_LocalState ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'state) \<Rightarrow> \<comment> \<open>Local state extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input fstream_af \<Rightarrow> 'comp \<Rightarrow>
'state list"
where "f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c \<equiv>
(map localState (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) \<div>\<^bsub>fl\<^esub> k"
definition i_Exec_Comp_Stream_Acc_Output ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'output message_af) \<Rightarrow> \<comment> \<open>Output extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input istream_af \<Rightarrow> 'comp \<Rightarrow>
'output istream_af"
where "i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c \<equiv>
(output_fun \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) \<div>\<^sub>i k"
definition i_Exec_Comp_Stream_Acc_LocalState ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'state) \<Rightarrow> \<comment> \<open>Local state extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input istream_af \<Rightarrow> 'comp \<Rightarrow>
'state ilist"
where "i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c \<equiv>
(localState \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) \<div>\<^bsub>il\<^esub> k"
definition f_Exec_Comp_Stream_Acc_Output_Init ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'output message_af) \<Rightarrow> \<comment> \<open>Output extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input fstream_af \<Rightarrow> 'comp \<Rightarrow>
'output fstream_af"
where "f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c \<equiv>
(output_fun c) # f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c"
definition f_Exec_Comp_Stream_Acc_LocalState_Init ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'state) \<Rightarrow> \<comment> \<open>Local state extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow> 'input fstream_af \<Rightarrow> 'comp \<Rightarrow>
'state list"
where "f_Exec_Comp_Stream_Acc_LocalState_Init k localState trans_fun xs c \<equiv>
(localState c) # f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c"
definition i_Exec_Comp_Stream_Acc_Output_Init ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'output message_af) \<Rightarrow> \<comment> \<open>Output extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input istream_af \<Rightarrow> 'comp \<Rightarrow>
'output istream_af"
where "i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c \<equiv>
[output_fun c] \<frown> (i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c)"
definition i_Exec_Comp_Stream_Acc_LocalState_Init ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp \<Rightarrow> 'state) \<Rightarrow> \<comment> \<open>Local state extraction function\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
'input istream_af \<Rightarrow> 'comp \<Rightarrow>
'state ilist"
where "i_Exec_Comp_Stream_Acc_LocalState_Init k localState trans_fun input c \<equiv>
[localState c] \<frown> (i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c)"
lemma f_Exec_Stream_Acc_Output_length[simp]: "
0 < k \<Longrightarrow>
length (f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c) = length xs"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def f_shrink_length)
lemma f_Exec_Stream_Acc_LocalState_length[simp]: "
0 < k \<Longrightarrow>
length (f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c) = length xs"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def f_shrink_last_length)
lemmas f_Exec_Stream_Acc_length =
f_Exec_Stream_Acc_LocalState_length
f_Exec_Stream_Acc_Output_length
subsubsection \<open>Basic results for accelerated execution\<close>
lemma f_Exec_Stream_Acc_Output_Nil[simp]: "
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun [] c = []"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def)
lemma f_Exec_Stream_Acc_LocalState_Nil[simp]: "
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun [] c = []"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def)
lemmas f_Exec_Stream_Acc_Nil =
f_Exec_Stream_Acc_LocalState_Nil
f_Exec_Stream_Acc_Output_Nil
lemma f_Exec_Stream_Acc_Output_0[simp]: "
f_Exec_Comp_Stream_Acc_Output 0 output_fun trans_fun xs c = []"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def)
lemma f_Exec_Stream_Acc_LocalState_0[simp]: "
f_Exec_Comp_Stream_Acc_LocalState 0 localState trans_fun xs c = []"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def)
lemmas f_Exec_Stream_Acc_0 =
f_Exec_Stream_Acc_LocalState_0
f_Exec_Stream_Acc_Output_0
lemma f_Exec_Stream_Acc_Output_1[simp]: "
f_Exec_Comp_Stream_Acc_Output (Suc 0) output_fun trans_fun xs c =
map output_fun (f_Exec_Comp_Stream trans_fun xs c)"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def)
lemma f_Exec_Stream_Acc_LocalState_1[simp]: "
f_Exec_Comp_Stream_Acc_LocalState (Suc 0) localState trans_fun xs c =
map localState (f_Exec_Comp_Stream trans_fun xs c)"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def)
lemma i_Exec_Stream_Acc_Output_1[simp]: "
i_Exec_Comp_Stream_Acc_Output (Suc 0) output_fun trans_fun input c =
output_fun \<circ> (i_Exec_Comp_Stream trans_fun input c)"
by (simp add: i_Exec_Comp_Stream_Acc_Output_def)
lemma i_Exec_Stream_Acc_LocalState_1[simp]: "
i_Exec_Comp_Stream_Acc_LocalState (Suc 0) localState trans_fun input c =
localState \<circ> (i_Exec_Comp_Stream trans_fun input c)"
by (simp add: i_Exec_Comp_Stream_Acc_LocalState_def)
lemma f_Exec_Stream_Acc_Output_eq_last_message_hold: "
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c =
(map output_fun (f_Exec_Comp_Stream trans_fun (xs \<odot>\<^sub>f k) c)) \<longmapsto>\<^sub>f k \<div>\<^bsub>fl\<^esub> k"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def f_shrink_eq_f_last_message_hold_shrink_last)
lemma i_Exec_Stream_Acc_Output_eq_last_message_hold: "0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c =
(output_fun \<circ> (i_Exec_Comp_Stream trans_fun (input \<odot>\<^sub>i k) c)) \<longmapsto>\<^sub>i k \<div>\<^bsub>il\<^esub> k"
by (simp add: i_Exec_Comp_Stream_Acc_Output_def i_shrink_eq_i_last_message_hold_shrink_last)
lemma f_Exec_Stream_Acc_Output_take: "
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<down> n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (xs \<down> n) c"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def f_shrink_def f_Exec_Stream_expand_aggregate_map_take)
lemma f_Exec_Stream_Acc_Output_drop: "
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<up> n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (xs \<up> n) (
f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c)"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def f_shrink_def f_Exec_Stream_expand_aggregate_map_drop)
lemma i_Exec_Stream_Acc_Output_take: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c \<Down> n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> n) c"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def i_Exec_Comp_Stream_Acc_Output_def
f_shrink_def i_shrink_def i_Exec_Stream_expand_aggregate_map_take)
lemma i_Exec_Stream_Acc_Output_drop: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c \<Up> n =
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Up> n) (
f_Exec_Comp trans_fun (input \<Down> n \<odot>\<^sub>f k) c)"
by (simp add: i_Exec_Comp_Stream_Acc_Output_def i_shrink_def i_Exec_Stream_expand_aggregate_map_drop)
lemma i_Exec_Stream_Acc_LocalState_take: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c \<Down> n =
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (input \<Down> n) c"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def i_Exec_Comp_Stream_Acc_LocalState_def
f_shrink_last_def i_shrink_last_def i_Exec_Stream_expand_aggregate_map_take)
lemma i_Exec_Stream_Acc_LocalState_drop: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c \<Up> n =
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (input \<Up> n) (
f_Exec_Comp trans_fun (input \<Down> n \<odot>\<^sub>f k) c)"
by (simp add: i_Exec_Comp_Stream_Acc_LocalState_def i_shrink_last_def i_Exec_Stream_expand_aggregate_map_drop)
lemma f_Exec_Stream_Acc_Output_append: "
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (xs @ ys) c =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c @
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun ys (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)"
by (simp only: f_Exec_Comp_Stream_Acc_Output_def f_shrink_def f_Exec_Stream_expand_map_aggregate_append)
lemma f_Exec_Stream_Acc_Output_Cons: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (x # xs) c =
last_message (map output_fun (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)) #
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)"
by (simp only: f_Exec_Comp_Stream_Acc_Output_def f_shrink_def f_Exec_Stream_expand_map_aggregate_Cons)
lemma f_Exec_Stream_Acc_Output_one: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun [x] c =
[last_message (map output_fun (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c))]"
by (simp add: f_Exec_Stream_Acc_Output_Cons)
lemma f_Exec_Stream_Acc_Output_snoc: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (xs @ [x]) c =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c @
[last_message (map output_fun (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)))]"
by (simp add: f_Exec_Stream_Acc_Output_append f_Exec_Stream_Acc_Output_one)
lemma i_Exec_Stream_Acc_Output_append: "
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<frown>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def i_Exec_Comp_Stream_Acc_Output_def f_shrink_def i_shrink_def i_Exec_Stream_expand_map_aggregate_append)
lemma i_Exec_Stream_Acc_Output_Cons: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun ([x] \<frown> input) c =
[last_message (map output_fun (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c))] \<frown>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)"
by (simp add: i_Exec_Stream_Acc_Output_append f_Exec_Stream_Acc_Output_one)
lemma f_Exec_Stream_Acc_LocalState_append: "
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (xs @ ys) c =
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c @
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun ys (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)"
by (simp only: f_Exec_Comp_Stream_Acc_LocalState_def f_shrink_last_def f_Exec_Stream_expand_map_aggregate_append)
lemma f_Exec_Stream_Acc_LocalState_Cons: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (x # xs) c =
localState (f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c) #
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)"
apply (unfold f_Exec_Comp_Stream_Acc_LocalState_def)
apply (simp only: f_shrink_last_map f_expand_Cons append_Cons[symmetric])
apply (simp add: f_Exec_Stream_append replicate_pred_Cons_length f_shrink_last_Cons del: f_Exec_Stream_Cons append_Cons)
apply (simp add: f_Exec_eq_f_Exec_Stream_last2[symmetric] f_Exec_Stream_empty_conv)
done
lemma f_Exec_Stream_Acc_LocalState_one: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun [x] c =
[localState (f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)]"
by (simp add: f_Exec_Stream_Acc_LocalState_Cons)
lemma f_Exec_Stream_Acc_LocalState_snoc: "
0 < k \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (xs @ [x]) c =
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c @
[localState (f_Exec_Comp trans_fun ((xs @ [x]) \<odot>\<^sub>f k) c)]"
by (simp add: f_Exec_Stream_Acc_LocalState_append f_Exec_Stream_Acc_LocalState_Cons f_Exec_append)
lemma i_Exec_Stream_Acc_LocalState_append: "
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (xs \<frown> input) c =
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c \<frown>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input (
f_Exec_Comp trans_fun (xs \<odot>\<^sub>f k) c)"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_def i_Exec_Comp_Stream_Acc_LocalState_def f_shrink_last_def i_shrink_last_def i_Exec_Stream_expand_map_aggregate_append)
lemma i_Exec_Stream_Acc_LocalState_Cons: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun ([x] \<frown> input) c =
[localState (f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)] \<frown>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input (
f_Exec_Comp trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)"
by (simp add: i_Exec_Stream_Acc_LocalState_append f_Exec_Stream_Acc_LocalState_one f_expand_one)
lemma f_Exec_Stream_Acc_Output_nth: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c ! n =
last_message (map output_fun (
f_Exec_Comp_Stream trans_fun (xs ! n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) (
f_Exec_Comp trans_fun (xs \<down> n \<odot>\<^sub>f k) c)))"
by (unfold f_Exec_Comp_Stream_Acc_Output_def f_shrink_def, rule f_Exec_Stream_expand_aggregate_map_nth)
lemma f_Exec_Stream_Acc_Output_nth_eq_i_nth: "
\<lbrakk> 0 < k; n < n' \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> n') c ! n =
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n"
by (unfold f_Exec_Comp_Stream_Acc_Output_def i_Exec_Comp_Stream_Acc_Output_def f_shrink_def i_shrink_def, rule f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth)
lemma i_Exec_Stream_Acc_Output_nth: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n =
last_message (map output_fun (
f_Exec_Comp_Stream trans_fun (input n # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) (
f_Exec_Comp trans_fun (input \<Down> n \<odot>\<^sub>f k) c)))"
by (unfold i_Exec_Comp_Stream_Acc_Output_def i_shrink_def, rule i_Exec_Stream_expand_aggregate_map_nth)
corollary i_Exec_Stream_Acc_Output_nth_f_nth: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> Suc n) c ! n"
by (simp add: f_Exec_Stream_Acc_Output_nth_eq_i_nth)
corollary i_Exec_Stream_Acc_Output_nth_f_last: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n =
last (f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> Suc n) c)"
by (simp add: i_Exec_Stream_Acc_Output_nth_f_nth last_nth length_greater_0_conv[THEN iffD1])
lemma f_Exec_Stream_Acc_LocalState_nth: "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c ! n =
localState (f_Exec_Comp trans_fun (xs \<down> Suc n \<odot>\<^sub>f k) c)"
apply (simp add: f_Exec_Comp_Stream_Acc_LocalState_def f_shrink_last_map)
apply (simp add: f_shrink_last_nth' f_shrink_last_length del: mult_Suc)
apply (simp add: f_Exec_Stream_nth less_imp_Suc_mult_pred_less f_expand_take_mod del: mult_Suc)
done
lemma f_Exec_Stream_Acc_LocalState_nth_eq_i_nth: "
\<lbrakk> 0 < k; n < n' \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (input \<Down> n') c ! n =
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c n"
by (unfold f_Exec_Comp_Stream_Acc_LocalState_def i_Exec_Comp_Stream_Acc_LocalState_def f_shrink_last_def i_shrink_last_def, rule f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth)
corollary i_Exec_Stream_Acc_LocalState_nth_f_nth: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k output_fun trans_fun input c n =
f_Exec_Comp_Stream_Acc_LocalState k output_fun trans_fun (input \<Down> Suc n) c ! n"
by (simp add: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth)
corollary i_Exec_Stream_Acc_LocalState_nth_f_last: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c n =
last (f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (input \<Down> Suc n) c)"
by (simp add: i_Exec_Stream_Acc_LocalState_nth_f_nth last_nth length_greater_0_conv[THEN iffD1])
lemma i_Exec_Stream_Acc_LocalState_nth: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c n =
localState (f_Exec_Comp trans_fun (input \<Down> Suc n \<odot>\<^sub>f k) c)"
by (simp add: i_Exec_Stream_Acc_LocalState_nth_f_nth f_Exec_Stream_Acc_LocalState_nth)
lemma f_Exec_Stream_Acc_Output_causal: "
xs \<down> n = ys \<down> n \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<down> n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun ys c \<down> n"
by (simp add: f_Exec_Stream_Acc_Output_take)
lemma i_Exec_Stream_Acc_Output_causal: "
input1 \<Down> n = input2 \<Down> n \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input1 c \<Down> n =
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input2 c \<Down> n"
apply (case_tac "k = 0")
apply (simp add: i_Exec_Comp_Stream_Acc_Output_def)
apply (simp add: i_Exec_Stream_Acc_Output_take)
done
lemma f_Exec_Stream_Acc_Output_Connected_strictly_causal: "
\<lbrakk> xs \<down> n = ys \<down> n;
f_Streams_Connected
(f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c)
channel1;
f_Streams_Connected
(f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun ys c)
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<down> Suc n = channel2 \<down> Suc n"
by (simp add: f_Streams_Connected_def f_Exec_Stream_Acc_Output_take)
lemma i_Exec_Stream_Acc_Output_Connected_strictly_causal: "
\<lbrakk> input1 \<Down> n = input2 \<Down> n;
i_Streams_Connected
(i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input1 c)
channel1;
i_Streams_Connected
(i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input2 c)
channel2 \<rbrakk> \<Longrightarrow>
channel1 \<Down> Suc n = channel2 \<Down> Suc n"
apply (unfold i_Streams_Connected_def)
apply (case_tac "k = 0")
apply (simp add: i_Exec_Comp_Stream_Acc_Output_def)
apply (simp add: i_Exec_Stream_Acc_Output_take)
done
text \<open>Complete execution cycles/steps of accelrated execution\<close>
definition Acc_Trans_Fun_Step ::
"nat \<Rightarrow> \<comment> \<open>Acceleration factor\<close>
('comp, 'input message_af) Comp_Trans_Fun \<Rightarrow>
('comp list \<Rightarrow> 'comp) \<Rightarrow> \<comment> \<open>Pointwise output shrink function\<close>
'input message_af \<Rightarrow> 'comp \<Rightarrow>
'comp"
where "Acc_Trans_Fun_Step k trans_fun pointwise_shrink x c \<equiv>
pointwise_shrink (f_Exec_Comp_Stream trans_fun (x # \<NoMsg>\<^bsup>k - Suc 0\<^esup>) c)"
definition is_Pointwise_Output_Shrink ::
"('comp list \<Rightarrow> 'comp) \<Rightarrow> \<comment> \<open>Pointwise output shrink function\<close>
('comp \<Rightarrow> 'output message_af) \<Rightarrow> \<comment> \<open>Output extraction function for consideration\<close>
bool"
where "is_Pointwise_Output_Shrink pointwise_shrink output_fun \<equiv>
\<forall>cs. output_fun (pointwise_shrink cs) = last_message (map output_fun cs)"
primrec is_Pointwise_Output_Shrink_list ::
"('comp list \<Rightarrow> 'comp) \<Rightarrow> \<comment> \<open>Pointwise output shrink function\<close>
('comp \<Rightarrow> 'output message_af) list \<Rightarrow> \<comment> \<open>List of output extraction functions for consideration\<close>
bool"
where
"is_Pointwise_Output_Shrink_list pointwise_shrink [] = True"
| "is_Pointwise_Output_Shrink_list pointwise_shrink (f # fs) =
(is_Pointwise_Output_Shrink pointwise_shrink f \<and>
is_Pointwise_Output_Shrink_list pointwise_shrink fs)"
definition is_correct_localState_Pointwise_Output_Shrink ::
"('comp list \<Rightarrow> 'comp) \<Rightarrow> \<comment> \<open>Pointwise output shrink function\<close>
('comp \<Rightarrow> 'state) \<Rightarrow> \<comment> \<open>Local state extraction function\<close>
bool"
where "is_correct_localState_Pointwise_Output_Shrink pointwise_shrink localState \<equiv>
\<forall>cs. cs \<noteq> [] \<longrightarrow> localState (pointwise_shrink cs) = localState (last cs)"
lemma Deterministic_trans_fun_imp_acc_trans_fun:
"Deterministic_Trans_Fun trans_fun localState \<Longrightarrow>
Deterministic_Trans_Fun (Acc_Trans_Fun_Step k trans_fun pointwise_shrink) localState"
apply (simp (no_asm) only: Deterministic_Trans_Fun_def Acc_Trans_Fun_Step_def)
apply clarify
apply (subst Deterministic_f_Exec_Stream, simp+)
done
lemma is_Pointwise_Output_Shrink_list_imp_is_Pointwise_Output_Shrink:
"\<lbrakk> is_Pointwise_Output_Shrink_list pointwise_shrink fs; output_fun \<in> set fs \<rbrakk> \<Longrightarrow>
is_Pointwise_Output_Shrink pointwise_shrink output_fun"
apply (induct fs, simp)
apply fastforce
done
lemma is_Pointwise_Output_Shrink_list_eq_is_Pointwise_Output_Shrink_all:
"(is_Pointwise_Output_Shrink_list pointwise_shrink fs) =
(\<forall>output_fun \<in> set fs. is_Pointwise_Output_Shrink pointwise_shrink output_fun)"
apply (rule iffI)
apply (rule ballI)
apply (rule is_Pointwise_Output_Shrink_list_imp_is_Pointwise_Output_Shrink)
apply (simp add: member_def)+
apply (induct fs, simp)
apply simp
done
lemma is_Pointwise_Output_Shrink_subset:
"\<lbrakk> is_Pointwise_Output_Shrink_list pointwise_shrink fs; set fs' \<subseteq> set fs \<rbrakk> \<Longrightarrow>
is_Pointwise_Output_Shrink_list pointwise_shrink fs'"
by (fastforce simp: is_Pointwise_Output_Shrink_list_eq_is_Pointwise_Output_Shrink_all)
lemma f_Exec_Stream_Acc_LocalState_eq_Acc_Trans_Fun_Step_LocalState: "\<And>c.
\<lbrakk> 0 < k;
Deterministic_Trans_Fun trans_fun localState;
is_correct_localState_Pointwise_Output_Shrink pointwise_shrink localState \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c =
map localState (f_Exec_Comp_Stream (Acc_Trans_Fun_Step k trans_fun pointwise_shrink) xs c)"
apply (drule Deterministic_trans_fun_imp_acc_trans_fun[of trans_fun localState k pointwise_shrink])
apply (clarsimp simp: list_eq_iff)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth f_Exec_Stream_nth)
apply (induct xs, simp)
apply (rename_tac x xs c i)
apply (simp add: Acc_Trans_Fun_Step_def f_expand_Cons f_Exec_append)
apply (case_tac i)
apply simp
apply (simp only: is_correct_localState_Pointwise_Output_Shrink_def)
apply (drule_tac x="f_Exec_Comp_Stream trans_fun (x # NoMsg\<^bsup>k - Suc 0\<^esup>) c" in spec)
apply (simp add: f_Exec_Stream_not_empty_conv f_Exec_eq_f_Exec_Stream_last)
apply (rename_tac i2)
apply (drule_tac x="f_Exec_Comp trans_fun \<NoMsg>\<^bsup>k - Suc 0\<^esup> (trans_fun x c)" in meta_spec)
apply (drule_tac x=i2 in meta_spec)
apply (simp add: is_correct_localState_Pointwise_Output_Shrink_def)
apply (drule_tac x="f_Exec_Comp_Stream trans_fun (x # NoMsg\<^bsup>k - Suc 0\<^esup>) c" in spec)
apply (simp add: f_Exec_Stream_not_empty_conv)
apply (rule arg_cong[where f=localState])
apply (rule Deterministic_f_Exec)
apply assumption
apply (simp add: f_Exec_eq_f_Exec_Stream_last)
apply (simp add: length_greater_0_conv[symmetric] del: length_greater_0_conv)
done
lemma f_Exec_Stream_Acc_Output_eq_Acc_Trans_Fun_Step_Output: "\<And>c.
\<lbrakk> 0 < k;
Deterministic_Trans_Fun trans_fun localState;
is_correct_localState_Pointwise_Output_Shrink pointwise_shrink localState;
is_Pointwise_Output_Shrink pointwise_shrink output_fun \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c =
map output_fun (f_Exec_Comp_Stream (Acc_Trans_Fun_Step k trans_fun pointwise_shrink) xs c)"
apply (drule Deterministic_trans_fun_imp_acc_trans_fun[of trans_fun localState k pointwise_shrink])
apply (clarsimp simp: list_eq_iff)
apply (simp add: f_Exec_Stream_Acc_Output_nth f_Exec_Stream_nth del: f_Exec_Stream_Cons)
apply (induct xs, simp)
apply (rename_tac x xs c i)
apply (simp add: Acc_Trans_Fun_Step_def del: f_Exec_Stream_Cons)
apply (case_tac i)
apply (simp add: is_Pointwise_Output_Shrink_def)
apply (rename_tac i2)
apply (simp add: f_Exec_append)
apply (drule_tac x="f_Exec_Comp trans_fun \<NoMsg>\<^bsup>k - Suc 0\<^esup> (trans_fun x c)" in meta_spec)
apply (drule_tac x=i2 in meta_spec)
apply (simp add: is_correct_localState_Pointwise_Output_Shrink_def)
apply (drule_tac x="f_Exec_Comp_Stream trans_fun (x # NoMsg\<^bsup>k - Suc 0\<^esup>) c" in spec)
apply (simp add: f_Exec_Stream_not_empty_conv)
apply (rule arg_cong[where f=output_fun])
apply (rule Deterministic_f_Exec)
apply assumption
apply (simp add: f_Exec_eq_f_Exec_Stream_last)
apply (simp add: length_greater_0_conv[symmetric] del: length_greater_0_conv)
done
lemma i_Exec_Stream_Acc_LocalState_eq_Acc_Trans_Fun_Step_LocalState: "\<And>c.
\<lbrakk> 0 < k;
Deterministic_Trans_Fun trans_fun localState;
is_correct_localState_Pointwise_Output_Shrink pointwise_shrink localState \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c =
localState \<circ> (i_Exec_Comp_Stream (Acc_Trans_Fun_Step k trans_fun pointwise_shrink) input c)"
apply (rule ilist_i_take_eq_conv[THEN iffD2], rule allI)
apply (simp add: i_Exec_Stream_Acc_LocalState_take i_Exec_Stream_take f_Exec_Stream_Acc_LocalState_eq_Acc_Trans_Fun_Step_LocalState)
done
lemma i_Exec_Stream_Acc_Output_eq_Acc_Trans_Fun_Step_Output: "\<And>c.
\<lbrakk> 0 < k;
Deterministic_Trans_Fun trans_fun localState;
is_correct_localState_Pointwise_Output_Shrink pointwise_shrink localState;
is_Pointwise_Output_Shrink pointwise_shrink output_fun \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c =
output_fun \<circ> (i_Exec_Comp_Stream (Acc_Trans_Fun_Step k trans_fun pointwise_shrink) input c)"
apply (rule ilist_i_take_eq_conv[THEN iffD2], rule allI)
apply (simp add: i_Exec_Stream_Acc_Output_take i_Exec_Stream_take f_Exec_Stream_Acc_Output_eq_Acc_Trans_Fun_Step_Output)
done
subsubsection \<open>Basic results for accelerated execution with initial state in the resulting stream\<close>
lemma f_Exec_Stream_Acc_Output_Init_length: "
0 < k \<Longrightarrow>
length (f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c) = Suc (length xs)"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def)
lemma f_Exec_Stream_Acc_LocalState_Init_length: "
0 < k \<Longrightarrow>
length (f_Exec_Comp_Stream_Acc_LocalState_Init k localState trans_fun xs c) = Suc (length xs)"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_Init_def)
lemma f_Exec_Stream_Acc_Output_Init_Nil: "
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun [] c = [output_fun c]"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def)
lemma f_Exec_Stream_Acc_LocalState_Init_Nil: "
f_Exec_Comp_Stream_Acc_LocalState_Init k localState trans_fun [] c = [localState c]"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_Init_def)
lemma f_Exec_Stream_Acc_Output_Init_1: "
f_Exec_Comp_Stream_Acc_Output_Init (Suc 0) output_fun trans_fun xs c =
map output_fun (f_Exec_Comp_Stream_Init trans_fun xs c)"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma f_Exec_Stream_Acc_LocalState_Init_1: "
f_Exec_Comp_Stream_Acc_LocalState_Init (Suc 0) localState trans_fun xs c =
map localState (f_Exec_Comp_Stream_Init trans_fun xs c)"
by (simp add: f_Exec_Comp_Stream_Acc_LocalState_Init_def f_Exec_Stream_Init_eq_f_Exec_Stream_Cons)
lemma i_Exec_Stream_Acc_Output_Init_1: "
i_Exec_Comp_Stream_Acc_Output_Init (Suc 0) output_fun trans_fun input c =
output_fun \<circ> (i_Exec_Comp_Stream_Init trans_fun input c)"
by (simp add: i_Exec_Comp_Stream_Acc_Output_Init_def i_Exec_Stream_Init_eq_i_Exec_Stream_Cons)
lemma i_Exec_Stream_Acc_LocalState_Init_1: "
i_Exec_Comp_Stream_Acc_LocalState_Init (Suc 0) localState trans_fun input c =
localState \<circ> (i_Exec_Comp_Stream_Init trans_fun input c)"
by (simp add: i_Exec_Comp_Stream_Acc_LocalState_Init_def i_Exec_Stream_Init_eq_i_Exec_Stream_Cons)
lemma f_Exec_Stream_Acc_Output_Init_take: "
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c \<down> (Suc n) =
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun (xs \<down> n) c"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def f_Exec_Stream_Acc_Output_take)
lemma f_Exec_Stream_Acc_Output_Init_drop': "
\<lbrakk> 0 < k; n < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c \<up> Suc n =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<up> n"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def)
lemma i_Exec_Stream_Acc_Output_Init_take: "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c \<Down> (Suc n) =
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun (input \<Down> n) c"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def i_Exec_Comp_Stream_Acc_Output_Init_def i_Exec_Stream_Acc_Output_take)
lemma i_Exec_Stream_Acc_Output_Init_drop': "
0 < k \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c \<Up> Suc n =
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c \<Up> n"
by (simp add: i_Exec_Comp_Stream_Acc_Output_Init_def)
lemma f_Exec_Stream_Acc_Output_Init_strictly_causal: "
xs \<down> n = ys \<down> n \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c \<down> Suc n =
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun ys c \<down> Suc n"
by (simp add: f_Exec_Comp_Stream_Acc_Output_Init_def, rule f_Exec_Stream_Acc_Output_causal)
lemma i_Exec_Stream_Acc_Output_Init_strictly_causal: "
input1 \<Down> n = input2 \<Down> n \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input1 c \<Down> Suc n =
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input2 c \<Down> Suc n"
by (simp add: i_Exec_Comp_Stream_Acc_Output_Init_def, rule i_Exec_Stream_Acc_Output_causal)
lemma f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons: "
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c =
output_fun c # f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c"
by (simp add: f_Exec_Comp_Stream_Acc_Output_def f_Exec_Comp_Stream_Acc_Output_Init_def)
lemma f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons_output: "
output_fun c = \<NoMsg> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c =
\<NoMsg> # f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c"
by (simp add: f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons)
lemma f_Exec_Stream__Acc_OutputInit_tl_eq_f_Exec_Stream_Acc_Output: "
tl (f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c) =
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c"
by (simp add: f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons)
lemma f_Exec_Stream_Previous_f_Exec_Stream_Acc_Output_Init: "
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c ! n =
(f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c)\<^bsup>\<leftarrow>' output_fun c\<^esup> n"
by (simp add: f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons list_Previous_nth_if nth_Cons')
lemma f_Exec_Stream_Acc_Output_Init_eq_output_channel: "
\<lbrakk> output_fun c = \<NoMsg>;
f_Streams_Connected
(f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c)
channel \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun xs c = channel"
by (simp add: f_Streams_Connected_def f_Exec_Stream_Acc_Output_Init_eq_f_Exec_Stream_Acc_Output_Cons_output)
lemma i_Exec_Stream_Acc_Output_Init_eq_i_Exec_Stream_Acc_Output_Cons: "
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c =
[output_fun c] \<frown> i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c"
by (simp add: i_Exec_Comp_Stream_Acc_Output_def i_Exec_Comp_Stream_Acc_Output_Init_def)
lemma i_Exec_Stream_Acc_Output_Init_eq_i_Exec_Stream_Acc_Output_Cons_output: "
output_fun c = \<NoMsg> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c =
[\<NoMsg> ] \<frown> i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c"
by (simp add: i_Exec_Stream_Acc_Output_Init_eq_i_Exec_Stream_Acc_Output_Cons)
lemma i_Exec_Stream_Previous_i_Exec_Stream_Acc_Output_Init: "
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c n =
(i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c)\<^bsup>\<leftarrow> output_fun c\<^esup> n"
by (simp add: i_Exec_Stream_Acc_Output_Init_eq_i_Exec_Stream_Acc_Output_Cons ilist_Previous_nth_if)
lemma i_Exec_Stream_Acc_Output_Init_eq_output_channel: "
\<lbrakk> output_fun c = \<NoMsg>;
i_Streams_Connected
(i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c)
channel \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output_Init k output_fun trans_fun input c = channel"
by (simp add: i_Streams_Connected_def i_Exec_Stream_Acc_Output_Init_eq_i_Exec_Stream_Acc_Output_Cons_output)
subsubsection \<open>Rules for proving execution equivalence\<close>
text \<open>
A required precondition is that the @{term equiv_states} relation,
which indicates whether the local states of @{term c1} and @{term c2}
are equivalent with respect to observable behaviour,
is preserved also after executing an input stream,
because the @{term equiv_states} relation
should deliver valid results not only at the time point @{term 0}
but at every time point.\<close>
lemma f_Equiv_Exec_Stream_expand_shrink_equiv_state_set[rule_format]: "
\<And>c1 c2 i. \<lbrakk>
0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<forall>input0. set input0 \<subseteq> A \<longrightarrow> (\<forall>m\<in>A.
Equiv_Exec m equiv_states
localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2));
\<comment> \<open>\<open>equiv_states\<close> relation implies equivalent executions\<close>
\<comment> \<open>not only at the beginning but also after processing an input\<close>
set input \<subseteq> A; i < length input \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 ((f_Exec_Comp_Stream trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1) \<div>\<^bsub>fl\<^esub> k1 ! i))
(localState2 ((f_Exec_Comp_Stream trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2) \<div>\<^bsub>fl\<^esub> k2 ! i))"
apply (induct input, simp)
apply (clarsimp simp: append_Cons[symmetric] f_Exec_Stream_append_if f_shrink_last_Cons nth_Cons simp del: last.simps f_Exec_Stream_Cons append_Cons)
apply (case_tac i)
apply (drule_tac x="[]" in spec)
apply (drule mp, simp)
apply (drule_tac x=a in bspec, assumption)
apply (simp del: last.simps f_Exec_Stream_Cons)
apply (subst f_Exec_eq_f_Exec_Stream_last2[symmetric], simp)+
apply (rule Equiv_Exec_equiv_statesI[of equiv_states localState1 _ localState2 _ _ input_fun1], assumption+)
apply (rename_tac i')
apply (subst f_Exec_eq_f_Exec_Stream_last2[symmetric], simp)+
apply (drule_tac x="f_Exec_Comp trans_fun1 (input_fun1 a # \<NoMsg>\<^bsup>k1 - Suc 0\<^esup>) c1" in meta_spec)
apply (drule_tac x="f_Exec_Comp trans_fun2 (input_fun2 a # \<NoMsg>\<^bsup>k2 - Suc 0\<^esup>) c2" in meta_spec)
apply (drule_tac x=i' in meta_spec)
apply (drule meta_mp, simp)+
apply (drule_tac x="[]" in spec, simp)
apply (drule_tac x=a in bspec, assumption)
apply (rule Equiv_Exec_equiv_statesI'[of equiv_states localState1 _ localState2 _ _ input_fun1], simp+)
apply clarsimp
apply (drule meta_mp)
apply clarify
apply (drule_tac x="a # input0" in spec)
apply (simp add: f_Exec_append)
apply simp
done
corollary f_Equiv_Exec_Stream_expand_shrink_equiv_state: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m. Equiv_Exec m
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2);
i<length input \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 ((f_Exec_Comp_Stream trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1) \<div>\<^bsub>fl\<^esub> k1 ! i))
(localState2 ((f_Exec_Comp_Stream trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2) \<div>\<^bsub>fl\<^esub> k2 ! i))"
by (rule f_Equiv_Exec_Stream_expand_shrink_equiv_state_set[of k1 k2 equiv_states localState1 c1 localState2 c2 UNIV input_fun1 input_fun2 output_fun1 output_fun2], simp+)
lemma f_Equiv_Exec_expand_shrink_equiv_state_set:"
\<lbrakk> 0 < k1; 0 < k2; equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m. \<lbrakk>set input0 \<subseteq> A; m \<in> A\<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2);
set input \<subseteq> A \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 (f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1))
(localState2 (f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2))"
apply (case_tac "input = []", simp)
apply (subgoal_tac "map input_fun1 input \<odot>\<^sub>f k1 \<noteq> [] \<and> map input_fun2 input \<odot>\<^sub>f k2 \<noteq> []")
prefer 2
apply (simp add: length_greater_0_conv[symmetric] del: length_greater_0_conv)
apply (simp add: f_Exec_eq_f_Exec_Stream_last2 last_nth f_Exec_Stream_not_empty_conv)
apply (insert f_shrink_last_nth[of "length input - Suc 0" "f_Exec_Comp_Stream trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1" k1, symmetric])
apply (insert f_shrink_last_nth[of "length input - Suc 0" "f_Exec_Comp_Stream trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2" k2, symmetric])
apply (simp add: diff_mult_distrib gr0_imp_self_le_mult2)
apply (rule f_Equiv_Exec_Stream_expand_shrink_equiv_state_set[of k1 k2 equiv_states localState1 _ localState2 _ A input_fun1 input_fun2 output_fun1 output_fun2])
apply simp+
done
lemma f_Equiv_Exec_expand_shrink_equiv_state:"
\<lbrakk> 0 < k1; 0 < k2; equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m.
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2) \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 (f_Exec_Comp trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1))
(localState2 (f_Exec_Comp trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2))"
by (rule f_Equiv_Exec_expand_shrink_equiv_state_set[of k1 k2 equiv_states localState1 _ localState2 _ UNIV input_fun1 input_fun2 output_fun1 output_fun2], simp+)
lemma i_Equiv_Exec_Stream_expand_shrink_equiv_state_set[rule_format]: "
\<lbrakk> 0 < k1; 0 < k2; equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m. \<lbrakk>set input0 \<subseteq> A; m \<in> A\<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2);
range input \<subseteq> A \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 ((i_Exec_Comp_Stream trans_fun1 ((input_fun1 \<circ> input) \<odot>\<^sub>i k1) c1 \<div>\<^bsub>il\<^esub> k1) i))
(localState2 ((i_Exec_Comp_Stream trans_fun2 ((input_fun2 \<circ> input) \<odot>\<^sub>i k2) c2 \<div>\<^bsub>il\<^esub> k2) i))"
apply (simp add: i_shrink_last_nth i_Exec_Stream_nth i_expand_i_take_mod)
apply (rule f_Equiv_Exec_expand_shrink_equiv_state_set[of
k1 k2 equiv_states localState1 c1 localState2 c2 A input_fun1 input_fun2 output_fun1 output_fun2])
apply (simp add: subset_trans[OF set_i_take_subset])+
done
lemma i_Equiv_Exec_Stream_expand_shrink_equiv_state: "
\<lbrakk> 0 < k1; 0 < k2; equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m.
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2) \<rbrakk> \<Longrightarrow>
equiv_states
(localState1 ((i_Exec_Comp_Stream trans_fun1 ((input_fun1 \<circ> input) \<odot>\<^sub>i k1) c1 \<div>\<^bsub>il\<^esub> k1) i))
(localState2 ((i_Exec_Comp_Stream trans_fun2 ((input_fun2 \<circ> input) \<odot>\<^sub>i k2) c2 \<div>\<^bsub>il\<^esub> k2) i))"
by (rule i_Equiv_Exec_Stream_expand_shrink_equiv_state_set[of k1 k2 equiv_states localState1 c1 localState2 c2 UNIV input_fun1 input_fun2 output_fun1 output_fun2], simp+)
lemma f_Equiv_Exec_Stream_expand_shrink_output_set_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m. \<lbrakk> set input0 \<subseteq> A; m \<in> A \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2);
set input \<subseteq> A \<rbrakk> \<Longrightarrow>
(map output_fun1 (
f_Exec_Comp_Stream trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)) \<div>\<^sub>f k1 =
(map output_fun2 (
f_Exec_Comp_Stream trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)) \<div>\<^sub>f k2"
apply (subst list_eq_iff)
apply (clarsimp simp: f_shrink_length)
apply (simp del: last.simps f_Exec_Stream_Cons add: f_shrink_nth take_map drop_map f_Exec_Stream_take f_Exec_Stream_drop f_expand_take_mod f_expand_drop_mod take_first)
apply (frule_tac n=i in subset_trans[OF set_take_subset, rule_format])
apply (unfold atomize_all atomize_imp, intro allI impI)
apply (frule_tac x="take i input" in spec)
apply (drule_tac x="input ! i" in spec)
apply (erule impE, assumption)
apply (erule impE)
apply (blast intro: nth_mem)
apply (simp del: last.simps f_Exec_Stream_Cons)
apply (rule Equiv_Exec_output_eqI[of equiv_states localState1 _ localState2 _ _ input_fun1 input_fun2])
apply (case_tac i, simp)
apply (simp add: take_map[symmetric] f_Exec_Stream_expand_shrink_last_nth_eq_f_Exec_Comp[symmetric])
apply (frule Suc_lessD)
apply (simp add: f_Equiv_Exec_Stream_expand_shrink_equiv_state_set[of k1 k2 equiv_states localState1 _ localState2 _ A input_fun1 input_fun2 output_fun1 output_fun2])
apply simp
done
lemma f_Equiv_Exec_Stream_expand_shrink_output_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m.
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2) \<rbrakk> \<Longrightarrow>
(map output_fun1 (
f_Exec_Comp_Stream trans_fun1 (map input_fun1 input \<odot>\<^sub>f k1) c1)) \<div>\<^sub>f k1 =
(map output_fun2 (
f_Exec_Comp_Stream trans_fun2 (map input_fun2 input \<odot>\<^sub>f k2) c2)) \<div>\<^sub>f k2"
by (rule f_Equiv_Exec_Stream_expand_shrink_output_set_eq[of k1 k2 equiv_states localState1 _ localState2 _ UNIV], simp+)
lemma i_Equiv_Exec_Stream_expand_shrink_output_set_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m. \<lbrakk> set input0 \<subseteq> A; m \<in> A \<rbrakk> \<Longrightarrow>
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2);
range input \<subseteq> A \<rbrakk> \<Longrightarrow>
(output_fun1 \<circ>
i_Exec_Comp_Stream trans_fun1 ((input_fun1 \<circ> input) \<odot>\<^sub>i k1) c1) \<div>\<^sub>i k1 =
(output_fun2 \<circ>
i_Exec_Comp_Stream trans_fun2 ((input_fun2 \<circ> input) \<odot>\<^sub>i k2) c2) \<div>\<^sub>i k2"
apply (clarsimp simp: ilist_eq_iff, rename_tac i)
apply (simp del: last.simps f_Exec_Stream_Cons add: i_shrink_nth i_Exec_Stream_take i_Exec_Stream_drop i_expand_i_take_mod i_expand_i_drop_mod i_take_first map_one f_expand_one)
apply (rule Equiv_Exec_output_eqI[of
equiv_states localState1 _ localState2 _ _
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2])
apply (rule f_Equiv_Exec_expand_shrink_equiv_state_set[of
k1 k2 equiv_states localState1 _ localState2 _ A
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2])
apply (simp add: subset_trans[OF set_i_take_subset] subsetD[OF _ rangeI])+
done
lemma i_Equiv_Exec_Stream_expand_shrink_output_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
\<And>input0 m.
Equiv_Exec
m equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2
(f_Exec_Comp trans_fun1 (map input_fun1 input0 \<odot>\<^sub>f k1) c1)
(f_Exec_Comp trans_fun2 (map input_fun2 input0 \<odot>\<^sub>f k2) c2) \<rbrakk> \<Longrightarrow>
(output_fun1 \<circ>
i_Exec_Comp_Stream trans_fun1 ((input_fun1 \<circ> input) \<odot>\<^sub>i k1) c1) \<div>\<^sub>i k1 =
(output_fun2 \<circ>
i_Exec_Comp_Stream trans_fun2 ((input_fun2 \<circ> input) \<odot>\<^sub>i k2) c2) \<div>\<^sub>i k2"
apply (rule i_Equiv_Exec_Stream_expand_shrink_output_set_eq[of
k1 k2 equiv_states localState1 c1 localState2 c2 UNIV
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2])
apply simp+
done
lemma f_Equiv_Exec_Stream_Acc_LocalState_set: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable_set A
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
\<comment> \<open>\<open>equiv_states\<close> relation implies equivalent executions\<close>
\<comment> \<open>not only at the beginning but also after processing an input\<close>
set input \<subseteq> A;
i < length input \<rbrakk> \<Longrightarrow>
equiv_states
(f_Exec_Comp_Stream_Acc_LocalState k1 localState1 trans_fun1 (map input_fun1 input) c1 ! i)
(f_Exec_Comp_Stream_Acc_LocalState k2 localState2 trans_fun2 (map input_fun2 input) c2 ! i)"
apply (unfold f_Exec_Comp_Stream_Acc_LocalState_def Equiv_Exec_stable_set_def)
apply (simp add: f_shrink_last_map f_shrink_last_length)
apply (rule f_Equiv_Exec_Stream_expand_shrink_equiv_state_set[of
k1 k2 equiv_states localState1 c1 localState2 c2 A
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 input, rule_format])
apply simp+
done
lemma f_Equiv_Exec_Stream_Acc_LocalState: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
\<comment> \<open>\<open>equiv_states\<close> relation implies equivalent executions\<close>
\<comment> \<open>not only at the beginning but also after processing an input\<close>
i < length input \<rbrakk> \<Longrightarrow>
equiv_states
(f_Exec_Comp_Stream_Acc_LocalState k1 localState1 trans_fun1 (map input_fun1 input) c1 ! i)
(f_Exec_Comp_Stream_Acc_LocalState k2 localState2 trans_fun2 (map input_fun2 input) c2 ! i)"
apply (rule f_Equiv_Exec_Stream_Acc_LocalState_set[where A=UNIV])
apply (simp add: Equiv_Exec_stable_set_UNIV)+
done
lemma f_Equiv_Exec_Stream_Acc_Output_set_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable_set A
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2 c1 c2;
set input \<subseteq> A \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k1 output_fun1 trans_fun1 (map input_fun1 input) c1 =
f_Exec_Comp_Stream_Acc_Output k2 output_fun2 trans_fun2 (map input_fun2 input) c2"
apply (unfold f_Exec_Comp_Stream_Acc_Output_def Equiv_Exec_stable_set_def)
apply (rule f_Equiv_Exec_Stream_expand_shrink_output_set_eq[of
k1 k2 equiv_states localState1 c1 localState2 c2
A input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 input])
apply simp+
done
lemma f_Equiv_Exec_Stream_Acc_Output_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k1 output_fun1 trans_fun1 (map input_fun1 input) c1 =
f_Exec_Comp_Stream_Acc_Output k2 output_fun2 trans_fun2 (map input_fun2 input) c2"
apply (rule f_Equiv_Exec_Stream_Acc_Output_set_eq[of k1 k2 equiv_states localState1 c1 localState2 c2 UNIV])
apply (simp add: Equiv_Exec_stable_set_UNIV)+
done
lemma i_Equiv_Exec_Stream_Acc_LocalState_set: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable_set A
equiv_states localState1 localState2 input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2;
range input \<subseteq> A \<rbrakk> \<Longrightarrow>
equiv_states
(i_Exec_Comp_Stream_Acc_LocalState k1 localState1 trans_fun1 (input_fun1 \<circ> input) c1 i)
(i_Exec_Comp_Stream_Acc_LocalState k2 localState2 trans_fun2 (input_fun2 \<circ> input) c2 i)"
apply (simp add: i_Exec_Stream_Acc_LocalState_nth_f_nth)
apply (rule f_Equiv_Exec_Stream_Acc_LocalState_set)
apply (simp add: subset_trans[OF set_i_take_subset])+
done
lemma i_Equiv_Exec_Stream_Acc_LocalState: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2
trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
equiv_states
(i_Exec_Comp_Stream_Acc_LocalState k1 localState1 trans_fun1 (input_fun1 \<circ> input) c1 i)
(i_Exec_Comp_Stream_Acc_LocalState k2 localState2 trans_fun2 (input_fun2 \<circ> input) c2 i)"
apply (rule i_Equiv_Exec_Stream_Acc_LocalState_set[where A=UNIV])
apply (simp add: Equiv_Exec_stable_set_UNIV)+
done
lemma i_Equiv_Exec_Stream_Acc_Output_set_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable_set A
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2 c1 c2;
range input \<subseteq> A \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k1 output_fun1 trans_fun1 (input_fun1 \<circ> input) c1 =
i_Exec_Comp_Stream_Acc_Output k2 output_fun2 trans_fun2 (input_fun2 \<circ> input) c2"
apply (clarsimp simp: ilist_eq_iff i_Exec_Stream_Acc_Output_nth_f_nth, rename_tac i)
apply (drule_tac n="Suc i" in subset_trans[OF set_i_take_subset, rule_format])
apply (simp add: f_Equiv_Exec_Stream_Acc_Output_set_eq[where equiv_states=equiv_states])
done
lemma i_Equiv_Exec_Stream_Acc_Output_eq: "
\<lbrakk> 0 < k1; 0 < k2;
equiv_states (localState1 c1) (localState2 c2);
Equiv_Exec_stable
equiv_states localState1 localState2
input_fun1 input_fun2 output_fun1 output_fun2 trans_fun1 trans_fun2 k1 k2 c1 c2 \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k1 output_fun1 trans_fun1 (input_fun1 \<circ> input) c1 =
i_Exec_Comp_Stream_Acc_Output k2 output_fun2 trans_fun2 (input_fun2 \<circ> input) c2"
apply (rule i_Equiv_Exec_Stream_Acc_Output_set_eq[of k1 k2 equiv_states localState1 c1 localState2 c2 UNIV])
apply (simp add: Equiv_Exec_stable_set_UNIV)+
done
subsubsection \<open>Idle states and accelerated execution\<close>
lemma f_Exec_Stream_Acc_LocalState__State_Idle_nth[rule_format]: "
\<And>c i.
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n\<le>i. State_Idle localState output_fun trans_fun (
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c ! n);
i < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c ! i =
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c ! i"
apply (frule length_greater_0_conv[THEN iffD1, OF gr_implies_gr0])
apply (simp only: f_Exec_Stream_Acc_LocalState_nth take_Suc_conv_app_nth)
apply (simp only: f_expand_snoc f_Exec_append)
apply (rule_tac s="\<NoMsg>\<^bsup>l - Suc 0\<^esup> @ \<NoMsg>\<^bsup>k-l\<^esup>" and t="\<NoMsg>\<^bsup>k - Suc 0\<^esup>" in subst)
apply (simp add: replicate_le_diff2)
apply (subst append_Cons[symmetric])
apply (induct xs, simp)
apply (case_tac i)
apply (simp add: f_Exec_Stream_Acc_LocalState_Cons f_Exec_State_Idle_append_replicate_NoMsg_state)
apply (rename_tac n)
apply (drule_tac x="f_Exec_Comp trans_fun (a # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c" in meta_spec)
apply (drule_tac x=n in meta_spec)
apply (simp del: f_Exec_Cons)
apply (frule length_greater_imp_not_empty)
apply (drule meta_mp)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth f_Exec_append)
apply (simp add: append_Cons[symmetric] f_expand_Cons f_Exec_append del: append_Cons)
apply (subgoal_tac "
localState (f_Exec_Comp trans_fun (a # NoMsg\<^bsup>k - Suc 0\<^esup>) c) =
localState (f_Exec_Comp trans_fun (a # NoMsg\<^bsup>l - Suc 0\<^esup>) c)")
prefer 2
apply (drule_tac x=0 in spec)
apply (simp add: f_Exec_Stream_Acc_LocalState_Cons)
apply (subst replicate_le_diff2[OF Suc_leI, symmetric], assumption+)
apply (simp add: append_Cons[symmetric] f_Exec_append del: append_Cons)
apply (rule f_Exec_State_Idle_replicate_NoMsg_state, assumption)
apply (case_tac "n = 0")
apply (frule_tac
?c1.0="f_Exec_Comp trans_fun (a # NoMsg\<^bsup>k - Suc 0\<^esup>) c" and
xs = "xs ! 0 # NoMsg\<^bsup>l - Suc 0\<^esup>" in f_Exec_Equal_State)
apply simp+
apply (frule_tac
?c1.0="f_Exec_Comp trans_fun (a # NoMsg\<^bsup>k - Suc 0\<^esup>) c" and
xs = "xs \<down> n \<odot>\<^sub>f k" in f_Exec_Equal_State)
apply (simp add: f_expand_not_empty_conv)+
done
corollary f_Exec_Stream_Acc_LocalState__State_Idle_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n<length xs. State_Idle localState output_fun trans_fun (
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c ! n) \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c =
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c"
apply (clarsimp simp: list_eq_iff)
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply simp
done
lemma i_Exec_Stream_Acc_LocalState__State_Idle_nth[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n\<le>i. State_Idle localState output_fun trans_fun (
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c i =
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c i"
apply (simp only: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth[of _ _ "Suc i", symmetric])
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth)
done
corollary i_Exec_Stream_Acc_LocalState__State_Idle_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n. State_Idle localState output_fun trans_fun (
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c =
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c"
apply (clarsimp simp: ilist_eq_iff)
apply (rule i_Exec_Stream_Acc_LocalState__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply simp
done
lemma f_Exec_Stream_Acc_Output__State_Idle_nth[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n\<le>i. State_Idle localState output_fun trans_fun (
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c ! n);
i < length xs \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c ! i =
f_Exec_Comp_Stream_Acc_Output l output_fun trans_fun xs c ! i"
apply (drule order_le_less[THEN iffD1], erule disjE)
prefer 2
apply simp
apply (frule zero_less_diff[of k l, THEN iffD2])
apply (frule length_greater_imp_not_empty)
apply (simp add: f_Exec_Stream_Acc_Output_nth del: f_Exec_Stream_Cons)
apply (subst replicate_le_diff2[OF Suc_leI, symmetric])
apply (simp del: f_Exec_Stream_Cons)+
apply (subst append_Cons[symmetric])
apply (case_tac i)
apply (drule_tac x=0 in spec)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth take_first f_expand_one del: last.simps f_Exec_Cons f_Exec_Stream_Cons append_Cons replicate.simps)
apply (simp only: f_Exec_Stream_append map_append last_message_append)
apply (rule if_P')
apply (clarsimp simp: last_message_NoMsg_conv f_Exec_Stream_nth min_eqL simp del: last.simps f_Exec_Comp.simps append_Cons replicate.simps)
apply (rule f_Exec_State_Idle_replicate_NoMsg_gr0_output)
apply (simp del: last.simps f_Exec_Comp_Stream.simps append_Cons)+
apply (rename_tac n)
apply (simp only: f_Exec_Stream_append map_append last_message_append)
apply (subgoal_tac "
localState (f_Exec_Comp trans_fun (xs \<down> Suc n \<odot>\<^sub>f k) c) =
localState (f_Exec_Comp trans_fun (xs \<down> Suc n \<odot>\<^sub>f l) c)")
prefer 2
apply (simp add: f_Exec_Stream_Acc_LocalState_nth[symmetric])
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_nth)
apply simp+
apply (rename_tac n, drule_tac x=n in spec, simp)
apply simp
apply (rule if_P')
apply (simp add: last_message_NoMsg_conv f_Exec_Stream_nth min_eqL del: f_Exec_Comp.simps replicate.simps)
apply (clarify, rename_tac j)
apply (frule_tac x="Suc n" in spec)
apply (simp only: f_Exec_Stream_Acc_LocalState_nth)
apply (rule_tac
?c1.0="f_Exec_Comp trans_fun (xs \<down> Suc n \<odot>\<^sub>f l) c"
and ?c2.0="f_Exec_Comp trans_fun (xs \<down> Suc n \<odot>\<^sub>f k) c"
in subst[OF f_Exec_Equal_State, rule_format])
apply (simp del: f_Exec_Comp.simps replicate.simps)+
apply (simp only: take_Suc_conv_app_nth f_expand_snoc f_Exec_append)
apply (rule f_Exec_State_Idle_replicate_NoMsg_gr0_output, assumption)
apply simp
apply (rule arg_cong[where f="\<lambda>x. last_message (map output_fun x)"])
apply (rule f_Exec_Stream_Equal_State, assumption+)
done
lemma f_Exec_Stream_Acc_Output__State_Idle_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n<length xs. State_Idle localState output_fun trans_fun (
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c ! n) \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c =
f_Exec_Comp_Stream_Acc_Output l output_fun trans_fun xs c"
apply (clarsimp simp: list_eq_iff)
apply (rule f_Exec_Stream_Acc_Output__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply simp
done
lemma i_Exec_Stream_Acc_Output__State_Idle_nth[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n\<le>i. State_Idle localState output_fun trans_fun (
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c i =
i_Exec_Comp_Stream_Acc_Output l output_fun trans_fun input c i"
apply (simp only: i_Exec_Stream_Acc_Output_nth_f_nth)
apply (rule f_Exec_Stream_Acc_Output__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth)
done
lemma i_Exec_Stream_Acc_Output__State_Idle_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
\<forall>n. State_Idle localState output_fun trans_fun (
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c =
i_Exec_Comp_Stream_Acc_Output l output_fun trans_fun input c"
apply (clarsimp simp: ilist_eq_iff)
apply (rule i_Exec_Stream_Acc_Output__State_Idle_nth)
apply simp_all
apply (drule_tac x=n in spec)
apply simp
done
text \<open>
When a certain number @{term l} of steps suffices to reach
an idle state from any other idle state,
than for any acceleration factor @{term "k \<ge> l"}
the accelerated processing of every input message
will be finished in an idle state.\<close>
lemma f_Exec_Stream_Acc_LocalState__State_Idle_all[rule_format]: "
\<And>c xs. \<lbrakk> 0 < l; l \<le> k;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c));
i < length xs \<rbrakk> \<Longrightarrow>
State_Idle localState output_fun trans_fun (
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c ! i)"
apply (frule length_greater_imp_not_empty)
apply (subgoal_tac "
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (hd xs # NoMsg\<^bsup>k - Suc 0\<^esup>) c))")
prefer 2
apply (drule_tac x=c in spec, drule_tac x="hd xs" in spec)
apply (rule subst[OF replicate_le_diff2[OF Suc_leI], of 0 l k], assumption+)
apply (simp add: f_Exec_append f_Exec_State_Idle_replicate_NoMsg_state)
apply (induct i)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth take_first hd_eq_first)
apply (drule_tac x="f_Exec_Comp trans_fun (hd xs # NoMsg\<^bsup>k - Suc 0\<^esup>) c" in meta_spec)
apply (drule_tac x="tl xs" in meta_spec)
apply (subgoal_tac "i < length (tl xs) \<and> tl xs \<noteq> []", elim conjE)
prefer 2
apply (simp add: length_greater_0_conv[symmetric] del: length_greater_0_conv)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth)
apply (rule_tac n="Suc i" in ssubst[OF take_Suc, rule_format], assumption)
apply (simp add: append_Cons[symmetric] f_Exec_append del: append_Cons)
apply (drule meta_mp)
apply (drule_tac x="f_Exec_Comp trans_fun (hd xs # NoMsg\<^bsup>k - Suc 0\<^esup>) c" in spec)
apply (drule mp, simp)
apply (drule_tac x="hd (tl xs)" in spec)
apply (subst replicate_le_diff2[OF Suc_leI, of 0 l k, symmetric], simp+)
apply (simp add: f_Exec_append f_Exec_State_Idle_replicate_NoMsg_state)
apply (simp add: f_Exec_Stream_Acc_LocalState_nth)
done
lemma i_Exec_Stream_Acc_LocalState__State_Idle_all[rule_format]: "
\<lbrakk> 0 < l; l \<le> k;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c)) \<rbrakk> \<Longrightarrow>
State_Idle localState output_fun trans_fun (
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c i)"
apply (simp only: i_Exec_Stream_Acc_LocalState_nth_f_nth)
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_all)
apply simp_all
apply (rename_tac c' m, drule_tac x=c' in spec)
apply simp
done
lemma f_Exec_Stream_Acc_Output__State_Idle_all_imp_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c)) \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun xs c =
f_Exec_Comp_Stream_Acc_Output l output_fun trans_fun xs c"
apply (rule f_Exec_Stream_Acc_Output__State_Idle_eq, assumption+)
apply (simp add: f_Exec_Stream_Acc_LocalState__State_Idle_all)
done
lemma i_Exec_Stream_Acc_Output__State_Idle_all_imp_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c)) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c =
i_Exec_Comp_Stream_Acc_Output l output_fun trans_fun input c"
apply (rule i_Exec_Stream_Acc_Output__State_Idle_eq, assumption+)
apply (simp add: i_Exec_Stream_Acc_LocalState__State_Idle_all)
done
lemma f_Exec_Stream_Acc_LocalState__State_Idle_all_imp_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c)) \<rbrakk> \<Longrightarrow>
f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c =
f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c"
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_eq, assumption+)
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_all)
apply simp+
done
lemma i_Exec_Stream_Acc_LocalState__State_Idle_all_imp_eq[rule_format]: "
\<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
State_Idle localState output_fun trans_fun (localState c);
\<forall>c m. State_Idle localState output_fun trans_fun (localState c) \<longrightarrow>
State_Idle localState output_fun trans_fun (
localState (f_Exec_Comp trans_fun (m # \<NoMsg>\<^bsup>l - Suc 0\<^esup>) c)) \<rbrakk> \<Longrightarrow>
i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun xs c =
i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun xs c"
apply (rule i_Exec_Stream_Acc_LocalState__State_Idle_eq, assumption+)
apply (rule i_Exec_Stream_Acc_LocalState__State_Idle_all)
apply simp+
done
text \<open>Converting inputs\<close>
lemma f_Exec_input_map: "\<And>c.
f_Exec_Comp trans_fun (map f xs) c = f_Exec_Comp (trans_fun \<circ> f) xs c"
by (induct xs, simp+)
lemma f_Exec_Stream_input_map: "
f_Exec_Comp_Stream trans_fun (map f xs) c =
f_Exec_Comp_Stream (trans_fun \<circ> f) xs c"
by (simp add: list_eq_iff f_Exec_Stream_nth take_map f_Exec_input_map)
lemma i_Exec_Stream_input_map: "
i_Exec_Comp_Stream trans_fun (f \<circ> input) c =
i_Exec_Comp_Stream (trans_fun \<circ> f) input c"
by (simp add: ilist_eq_iff i_Exec_Stream_nth f_Exec_input_map)
end
|