entities
listlengths
1
9.05k
max_stars_repo_path
stringlengths
5
154
max_stars_repo_name
stringlengths
6
76
max_stars_count
int64
0
38.8k
content
stringlengths
24
1.03M
id
stringlengths
1
5
new_content
stringlengths
17
1.03M
modified
bool
1 class
references
stringlengths
31
1.03M
[ { "context": " [:title \"your title\"])\n ;;\n (let* ((auth \"d5e61940f461ab9c0c625cb8f2fbc45e\")\n (auth-line (format nil \"Authorization:", "end": 2063, "score": 0.9802767634391785, "start": 2031, "tag": "PASSWORD", "value": "d5e61940f461ab9c0c625cb8f2fbc45e" }, { "context": ":00:32.309Z\\\",\n \\\"private_key\\\":\\\"a7c8783b60a02f392a20b4683d07284b5bd43a2f9872d967597399fb9a0493f3\\\",\n \\\"public_key\\\":\\\"02865be123fa", "end": 6495, "score": 0.9997438192367554, "start": 6431, "tag": "KEY", "value": "a7c8783b60a02f392a20b4683d07284b5bd43a2f9872d967597399fb9a0493f3" }, { "context": "99fb9a0493f3\\\",\n \\\"public_key\\\":\\\"02865be123fa2daf9b2b2ea3f46bd849965c3be094039ce3ab8e2be3003710e3ec\\\",\n \\\"seed\\\":\\\"D633B44BB5ED5C9704", "end": 6599, "score": 0.9997118711471558, "start": 6533, "tag": "KEY", "value": "02865be123fa2daf9b2b2ea3f46bd849965c3be094039ce3ab8e2be3003710e3ec" }, { "context": " 640982b83bc1aa015d8f60b6ed5f0799fa42a51760313decc854a9b91840bbd8\n ", "end": 6955, "score": 0.9959834218025208, "start": 6953, "tag": "KEY", "value": "42" }, { "context": "\":\\\"2015-01-12T04:21:30.983Z\\\",\n\\\"private_key\\\":\\\"0c4709e0e21369cb73ca0ddf97775f2bcdbf7461a2558105ada9086e6069645b\\\",\n\\\"public_key\\\":\\\"030c35ecbf936c8bf6e53fa0fcb78", "end": 11132, "score": 0.9997757077217102, "start": 11068, "tag": "KEY", "value": "0c4709e0e21369cb73ca0ddf97775f2bcdbf7461a2558105ada9086e6069645b" }, { "context": "f7461a2558105ada9086e6069645b\\\",\n\\\"public_key\\\":\\\"030c35ecbf936c8bf6e53fa0fcb7822237158f2ddd096594223cb48b88d35fde12\\\"},\n\n{\\\"tx_hash\\\":\\\"bdc6244b11575e29329ca10a65e6b17", "end": 11221, "score": 0.9997787475585938, "start": 11153, "tag": "KEY", "value": "030c35ecbf936c8bf6e53fa0fcb7822237158f2ddd096594223cb48b88d35fde12\\\"" }, { "context": "\":\\\"2014-11-05T02:01:52.887Z\\\",\n\\\"private_key\\\":\\\"f7d286ec06df0f0b278f7f2976bdcfeb61cb15e9bb8906d7730ffa079c1adf00\\\",\n\\\"public_key\\\":\\\"0495cca1916fc8d4ade304ef1aae5", "end": 11547, "score": 0.9997804164886475, "start": 11483, "tag": "KEY", "value": "f7d286ec06df0f0b278f7f2976bdcfeb61cb15e9bb8906d7730ffa079c1adf00" }, { "context": "b15e9bb8906d7730ffa079c1adf00\\\",\n\\\"public_key\\\":\\\"0495cca1916fc8d4ade304ef1aae5e68809fb3a9d70338a914dd751344830311dc26230a31bf88db1abdc85f2d7e6d489153a9fcf253aa807b23bf1adbd4a94161\\\"},\n\n{\\\"tx_hash\\\":\\\"b65f0530d2b56e1f3", "end": 11686, "score": 0.9987735152244568, "start": 11568, "tag": "KEY", "value": "0495cca1916fc8d4ade304ef1aae5e68809fb3a9d70338a914dd751344830311dc26230a31bf88db1abdc85f2d7e6d489153a9fcf253aa807b23bf" }, { "context": "\":\\\"2014-11-05T02:01:52.906Z\\\",\n\\\"private_key\\\":\\\"69f84c65bb28ec14ce722fb7cec0335820f16dde44b7ea1af251b53054394ab1\\\",\n\\\"public_key\\\":\\\"046b8f836097ee7ce437fe8cbef79", "end": 12027, "score": 0.9996956586837769, "start": 11963, "tag": "KEY", "value": "69f84c65bb28ec14ce722fb7cec0335820f16dde44b7ea1af251b53054394ab1" }, { "context": "16dde44b7ea1af251b53054394ab1\\\",\n\\\"public_key\\\":\\\"046b8f836097ee7ce437fe8cbef79ffd0122c3eff945f3552f19b38539f2677055bcf85c87b0d2692c636d04748715c07cf25403459c887aed63ff72cc64fd3fde\\\"},\n\n{\\\"tx_hash\\\":\\\"a4f4d37ce4ae65b6403bdfb843879", "end": 12178, "score": 0.9992598295211792, "start": 12048, "tag": "KEY", "value": "046b8f836097ee7ce437fe8cbef79ffd0122c3eff945f3552f19b38539f2677055bcf85c87b0d2692c636d04748715c07cf25403459c887aed63ff72cc64fd3fde" }, { "context": "4.377Z\\\",\n\\\"updated_at\\\":\\\"2014-11-05T02:01:52.923Z\\\",\n\\\"private_key\\\":\\\"5818658756094f3e5b32b49039cb", "end": 12421, "score": 0.9996542930603027, "start": 12420, "tag": "KEY", "value": "Z" }, { "context": "\":\\\"2014-11-05T02:01:52.923Z\\\",\n\\\"private_key\\\":\\\"5818658756094f3e5b32b49039cbde329b4e9b59702e1f8766212c5a302363cc\\\",\n\\\"public_key\\\":\\\"04f5c8c43121346d5ceaf82a7765d", "end": 12507, "score": 0.9997057318687439, "start": 12443, "tag": "KEY", "value": "5818658756094f3e5b32b49039cbde329b4e9b59702e1f8766212c5a302363cc" }, { "context": "e9b59702e1f8766212c5a302363cc\\\",\n\\\"public_key\\\":\\\"04f5c8c43121346d5ceaf82a7765da7ce9d53df8e6fdc31e04899ef822c24a8eb957bb23a1123e34a55a2dae6af8f122e074d2c49cf0cc35bd55bd89d262a80392\\\"},\n\n{\\\"tx_hash\\\":\\\"f4ea6b84442ab6b72160f6633b7c43a", "end": 12660, "score": 0.9967544078826904, "start": 12528, "tag": "KEY", "value": "04f5c8c43121346d5ceaf82a7765da7ce9d53df8e6fdc31e04899ef822c24a8eb957bb23a1123e34a55a2dae6af8f122e074d2c49cf0cc35bd55bd89d262a80392\\\"" }, { "context": "\":\\\"2014-11-05T02:01:52.940Z\\\",\n\\\"private_key\\\":\\\"34c4372c4b381a9b56745fe485fc777abf0ab5b17f5b5ef7878f334b23786825\\\",\n\\\"public_key\\\":\\\"04aed6f0e99ae96975066fc0c21f9", "end": 12987, "score": 0.9997482895851135, "start": 12923, "tag": "KEY", "value": "34c4372c4b381a9b56745fe485fc777abf0ab5b17f5b5ef7878f334b23786825" }, { "context": "ab5b17f5b5ef7878f334b23786825\\\",\n\\\"public_key\\\":\\\"04aed6f0e99ae96975066fc0c21f9f1ff42485e5db1e5c6dd3b83532e42ef23c8566f286312e5563cb1ccc8d3f8980aa03b8df1c0cfabef582608c4f399c934e52\\\"},\n\n{\\", "end": 13096, "score": 0.9990739822387695, "start": 13008, "tag": "KEY", "value": "04aed6f0e99ae96975066fc0c21f9f1ff42485e5db1e5c6dd3b83532e42ef23c8566f286312e5563cb1ccc8d" }, { "context": "5db1e5c6dd3b83532e42ef23c8566f286312e5563cb1ccc8d3f8980aa03b8df1c0cfabef582608c4f399c934e52\\\"},\n\n{\\\"tx_hash\\\":", "end": 13107, "score": 0.9756180644035339, "start": 13097, "tag": "KEY", "value": "f8980aa03b" }, { "context": "\":\\\"2014-11-05T02:01:53.516Z\\\",\n\\\"private_key\\\":\\\"1fba92f7a17afe4935dc813e64a7aa3a236929256825fd42d70ad95f3b7c2462\\\",\n\\\"public_key\\\":\\\"04d05babdbd06d8f2f78b68808e92", "end": 13467, "score": 0.999705970287323, "start": 13403, "tag": "KEY", "value": "1fba92f7a17afe4935dc813e64a7aa3a236929256825fd42d70ad95f3b7c2462" }, { "context": "929256825fd42d70ad95f3b7c2462\\\",\n\\\"public_key\\\":\\\"04d05babdbd06d8f2f78b68808e92395af8a49222a1099096fba93c24546042b3f488d5f208bdde3bc53e9ef2e72ee66c775729535bb1162a1ada1445afe8cfe0c\\\"},\n\n{\\\"tx_hash\\\":\\\"ed6a0c5266ef634d3ff70e8edea9eb4", "end": 13620, "score": 0.9997058510780334, "start": 13488, "tag": "KEY", "value": "04d05babdbd06d8f2f78b68808e92395af8a49222a1099096fba93c24546042b3f488d5f208bdde3bc53e9ef2e72ee66c775729535bb1162a1ada1445afe8cfe0c\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.546Z\\\",\n\\\"private_key\\\":\\\"7d7e0cb8a9288dd7d05a06026a4057fd191b62c8d5414161ce4599418142a55e\\\",\n\\\"public_key\\\":\\\"04ab49b94316152af2bcd263756c8", "end": 13947, "score": 0.9997180700302124, "start": 13883, "tag": "KEY", "value": "7d7e0cb8a9288dd7d05a06026a4057fd191b62c8d5414161ce4599418142a55e" }, { "context": "b62c8d5414161ce4599418142a55e\\\",\n\\\"public_key\\\":\\\"04ab49b94316152af2bcd263756c8d972499679dddf4915baff2bfcbfec9a4efe6b87be5a4141666d72be05cdd456239bcee8a1d280db4d01798c2415f95008751\\\"},\n\n{\\\"tx_hash\\\":\\\"b31b5e20c24cdbd9effcaebd5fb2d13", "end": 14100, "score": 0.9997037649154663, "start": 13968, "tag": "KEY", "value": "04ab49b94316152af2bcd263756c8d972499679dddf4915baff2bfcbfec9a4efe6b87be5a4141666d72be05cdd456239bcee8a1d280db4d01798c2415f95008751\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.761Z\\\",\n\\\"private_key\\\":\\\"b58d509caaa3f86bba12e9bf18a9f1ae6bf56315ded5e5c625ace2dc537a341e\\\",\n\\\"public_key\\\":\\\"04413115b0d9117a95ddd3de14e0d", "end": 14427, "score": 0.9997288584709167, "start": 14363, "tag": "KEY", "value": "b58d509caaa3f86bba12e9bf18a9f1ae6bf56315ded5e5c625ace2dc537a341e" }, { "context": "56315ded5e5c625ace2dc537a341e\\\",\n\\\"public_key\\\":\\\"04413115b0d9117a95ddd3de14e0d6718eca167a63b09825390c29c648ce231fd64ffafb72a15b3bbcdbcdf6c5e4ae113bfada24565a9bb74d9415f541dc4274c1\\\"},\n\n{\\\"tx_hash\\\":\\\"9a33b4", "end": 14555, "score": 0.9981672763824463, "start": 14448, "tag": "KEY", "value": "04413115b0d9117a95ddd3de14e0d6718eca167a63b09825390c29c648ce231fd64ffafb72a15b3bbcdbcdf6c5e4ae113bfada24565" }, { "context": "\":\\\"2014-11-05T02:01:53.924Z\\\",\n\\\"private_key\\\":\\\"fb60576b17a5003f245e3d153205ede104c080642a77864039bf44040ca72b08\\\",\n\\\"public_key\\\":\\\"04c2ffd07ec46197e3ade8b1973ae", "end": 14907, "score": 0.9997282028198242, "start": 14843, "tag": "KEY", "value": "fb60576b17a5003f245e3d153205ede104c080642a77864039bf44040ca72b08" }, { "context": "080642a77864039bf44040ca72b08\\\",\n\\\"public_key\\\":\\\"04c2ffd07ec46197e3ade8b1973aebd1d84e50790aebaf7f2d374dbed5b4a97f03970e1470d9132fb18141e07dd68940c2a9923eca6fd87a4bb94992095b869330\\\"},\n\n{\\\"tx_hash\\\":\\\"0c0fcf84d098e9a66c0848e9fc00662", "end": 15060, "score": 0.9996962547302246, "start": 14928, "tag": "KEY", "value": "04c2ffd07ec46197e3ade8b1973aebd1d84e50790aebaf7f2d374dbed5b4a97f03970e1470d9132fb18141e07dd68940c2a9923eca6fd87a4bb94992095b869330\\\"" }, { "context": "\":\\\"2015-01-14T01:21:27.230Z\\\",\n\\\"private_key\\\":\\\"1b3b7b080ed361e3171a9e04c586568ebe0067e1b4fdbedf669afb8a330be7c4\\\",\n\\\"public_key\\\":\\\"0255d5ed6953f267c13d8cbde8e9f", "end": 15387, "score": 0.9997478127479553, "start": 15323, "tag": "KEY", "value": "1b3b7b080ed361e3171a9e04c586568ebe0067e1b4fdbedf669afb8a330be7c4" }, { "context": "067e1b4fdbedf669afb8a330be7c4\\\",\n\\\"public_key\\\":\\\"0255d5ed6953f267c13d8cbde8e9fbb74746462f4384954cdfef5ba9d7a3a05e95\\\"},\n\n{\\\"tx_hash\\\":\\\"5633980ac2a46f7ade29eb20da90307", "end": 15476, "score": 0.9997521638870239, "start": 15408, "tag": "KEY", "value": "0255d5ed6953f267c13d8cbde8e9fbb74746462f4384954cdfef5ba9d7a3a05e95\\\"" }, { "context": "\":\\\"2015-03-23T03:41:45.110Z\\\",\n\\\"private_key\\\":\\\"c74c71353f05b968b22dcfbceebc72faf106eaa4006aaa116a9765deb37ff061\\\",\n\\\"public_key\\\":\\\"027fbbaabe8a9e808acb0b12c9c3a", "end": 15803, "score": 0.9997751116752625, "start": 15739, "tag": "KEY", "value": "c74c71353f05b968b22dcfbceebc72faf106eaa4006aaa116a9765deb37ff061" }, { "context": "6eaa4006aaa116a9765deb37ff061\\\",\n\\\"public_key\\\":\\\"027fbbaabe8a9e808acb0b12c9c3a3a5ec040515afe6660c9f4620b76947afbd5f\\\"},\n\n{\\\"tx_hash\\\":\\\"d6e8a78c75cbae895ce35cac701e722", "end": 15892, "score": 0.9997660517692566, "start": 15824, "tag": "KEY", "value": "027fbbaabe8a9e808acb0b12c9c3a3a5ec040515afe6660c9f4620b76947afbd5f\\\"" }, { "context": "\":\\\"2015-01-15T02:21:43.280Z\\\",\n\\\"private_key\\\":\\\"b1e62f87f8620a8c854d6c498a3140984f0f9150bfa11eb6f6f2a671ce292560\\\",\n\\\"public_key\\\":\\\"034c92ab3ce98a5bfaf5d2f51f020", "end": 16219, "score": 0.9997590780258179, "start": 16155, "tag": "KEY", "value": "b1e62f87f8620a8c854d6c498a3140984f0f9150bfa11eb6f6f2a671ce292560" }, { "context": "f9150bfa11eb6f6f2a671ce292560\\\",\n\\\"public_key\\\":\\\"034c92ab3ce98a5bfaf5d2f51f020de0606c42584f093564b665cb0fdaf776da76\\\"},\n\n{\\\"tx_hash\\\":\\\"a82e164dc639f8c2427b6585135da31", "end": 16308, "score": 0.9997571110725403, "start": 16240, "tag": "KEY", "value": "034c92ab3ce98a5bfaf5d2f51f020de0606c42584f093564b665cb0fdaf776da76\\\"" }, { "context": "\":\\\"2015-05-06T06:11:57.254Z\\\",\n\\\"private_key\\\":\\\"fed68abd80d2a328c462434422dab297c8dd80f4a47c961b83e9d4730843f5e2\\\",\n\\\"public_key\\\":\\\"02817b4adcb21ea9c0be130dbbe4c", "end": 16635, "score": 0.9997151494026184, "start": 16571, "tag": "KEY", "value": "fed68abd80d2a328c462434422dab297c8dd80f4a47c961b83e9d4730843f5e2" }, { "context": "d80f4a47c961b83e9d4730843f5e2\\\",\n\\\"public_key\\\":\\\"02817b4adcb21ea9c0be130dbbe4c4562276c603db180d65fa6828585f08943650\\\"},\n\n{\\\"tx_hash\\\":\\\"d6568ebd966d2cef00885e3460ca202", "end": 16724, "score": 0.9997352361679077, "start": 16656, "tag": "KEY", "value": "02817b4adcb21ea9c0be130dbbe4c4562276c603db180d65fa6828585f08943650\\\"" }, { "context": "\":\\\"2014-11-05T02:01:52.951Z\\\",\n\\\"private_key\\\":\\\"10ed3e980e62d373e5ee300d51ef954aa049b615ea5d597323285cfaba4b9c29\\\",\n\\\"public_key\\\":\\\"04be695f8af1fa9b7de536759df508b6", "end": 17054, "score": 0.997887372970581, "start": 16987, "tag": "KEY", "value": "10ed3e980e62d373e5ee300d51ef954aa049b615ea5d597323285cfaba4b9c29\\\"," }, { "context": "9b615ea5d597323285cfaba4b9c29\\\",\n\\\"public_key\\\":\\\"04be695f8af1fa9b7de536759df508b623a166e9bc96adad560c577af16b29ae6a0268a3805c7840a30573e4fbb6af5bc9895ac0fe4f04e0bb4e206e181056b7bd\\\"},\n\n{\\\"tx_hash\\\":\\\"2831a771337e431791d1281992e20be", "end": 17204, "score": 0.9995961785316467, "start": 17072, "tag": "KEY", "value": "04be695f8af1fa9b7de536759df508b623a166e9bc96adad560c577af16b29ae6a0268a3805c7840a30573e4fbb6af5bc9895ac0fe4f04e0bb4e206e181056b7bd\\\"" }, { "context": "\":\\\"2014-11-05T02:01:52.961Z\\\",\n\\\"private_key\\\":\\\"7d01ce525f9b8df8de5599e41891c44dcc1e2b337891bd0904c44a4b465bc67d\\\",\n\\\"public_key\\\":\\\"049cdba1d356124cd20782ebb470f", "end": 17531, "score": 0.9996919631958008, "start": 17467, "tag": "KEY", "value": "7d01ce525f9b8df8de5599e41891c44dcc1e2b337891bd0904c44a4b465bc67d" }, { "context": "e2b337891bd0904c44a4b465bc67d\\\",\n\\\"public_key\\\":\\\"049cdba1d356124cd20782ebb470fb259b7fd5273aaa4b7ad694407165cdcd8effa6c29ea3121b22d84bba6a1150708c44f94d9f1c3c63d81a585cfa68c893946d\\\"},\n\n{\\\"tx_hash\\\":\\\"85f5a8e7319a1ddc28fbf58e7f7f67b", "end": 17684, "score": 0.9997601509094238, "start": 17552, "tag": "KEY", "value": "049cdba1d356124cd20782ebb470fb259b7fd5273aaa4b7ad694407165cdcd8effa6c29ea3121b22d84bba6a1150708c44f94d9f1c3c63d81a585cfa68c893946d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:52.974Z\\\",\n\\\"private_key\\\":\\\"c20381615d5974d93c866023c4763f219dc704906f7043f587722144ccbf98cc\\\",\n\\\"public_key\\\":\\\"04dd10cb063a0fafc0aea92e6d39a", "end": 18011, "score": 0.9997746348381042, "start": 17947, "tag": "KEY", "value": "c20381615d5974d93c866023c4763f219dc704906f7043f587722144ccbf98cc" }, { "context": "704906f7043f587722144ccbf98cc\\\",\n\\\"public_key\\\":\\\"04dd10cb063a0fafc0aea92e6d39aa870dffb7b3d2a87f95a81b5ae0089c34febe867f18b1ef2c14699077e2825b977d44ecbbfb53d7e10be6683bdb08ee9b63aa\\\"},\n\n{\\\"tx_hash\\\":\\\"9a33c1b174a8cad687e2081383c94db", "end": 18164, "score": 0.9997714757919312, "start": 18032, "tag": "KEY", "value": "04dd10cb063a0fafc0aea92e6d39aa870dffb7b3d2a87f95a81b5ae0089c34febe867f18b1ef2c14699077e2825b977d44ecbbfb53d7e10be6683bdb08ee9b63aa\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.167Z\\\",\n\\\"private_key\\\":\\\"fb9a0bd7c86af880aed682ead260dd211d35a8160b18fc7f6fa14eefd9c670fb\\\",\n\\\"public_key\\\":\\\"04e57203fa268ef54c93c083f8646", "end": 18491, "score": 0.99972003698349, "start": 18427, "tag": "KEY", "value": "fb9a0bd7c86af880aed682ead260dd211d35a8160b18fc7f6fa14eefd9c670fb" }, { "context": "5a8160b18fc7f6fa14eefd9c670fb\\\",\n\\\"public_key\\\":\\\"04e57203fa268ef54c93c083f86464408b2fe1bd3183be67e6c6cdffaba3f877d6c0994fc41ab35c82c67c73a9e8a000a5a7a5295d40a7b35a9d3f901613724dd9\\\"},\n\n{\\\"tx_hash\\\":\\\"3bd108eff5534cbaf85747376118f5e", "end": 18644, "score": 0.9997124671936035, "start": 18512, "tag": "KEY", "value": "04e57203fa268ef54c93c083f86464408b2fe1bd3183be67e6c6cdffaba3f877d6c0994fc41ab35c82c67c73a9e8a000a5a7a5295d40a7b35a9d3f901613724dd9\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.193Z\\\",\n\\\"private_key\\\":\\\"3865d08058c9c9f8524eff9adef8c3771daa85153ab5366c0368b2ef17d5ae97\\\",\n\\\"public_key\\\":\\\"04c896167494c4f5e6501c24950b9", "end": 18971, "score": 0.9993913769721985, "start": 18907, "tag": "KEY", "value": "3865d08058c9c9f8524eff9adef8c3771daa85153ab5366c0368b2ef17d5ae97" }, { "context": "a85153ab5366c0368b2ef17d5ae97\\\",\n\\\"public_key\\\":\\\"04c896167494c4f5e6501c24950b94ab8ccbf26cec0ada292961cca5fedea403b2dcfd2f948353091c8257592937c9415d7c63d59c89066adb2780bf9326377773\\\"},\n\n{\\\"tx_hash\\\":\\\"76846c2a77902e57ab1e75b33133945", "end": 19124, "score": 0.9997706413269043, "start": 18992, "tag": "KEY", "value": "04c896167494c4f5e6501c24950b94ab8ccbf26cec0ada292961cca5fedea403b2dcfd2f948353091c8257592937c9415d7c63d59c89066adb2780bf9326377773\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.384Z\\\",\n\\\"private_key\\\":\\\"737521d94b6e4f37e6c5fea71e244b47ed043c45c8952a77a36c1afa2ebbce72\\\",\n\\\"public_key\\\":\\\"04e254bf5f65374d3d4b857f621f9", "end": 19450, "score": 0.99976646900177, "start": 19386, "tag": "KEY", "value": "737521d94b6e4f37e6c5fea71e244b47ed043c45c8952a77a36c1afa2ebbce72" }, { "context": "43c45c8952a77a36c1afa2ebbce72\\\",\n\\\"public_key\\\":\\\"04e254bf5f65374d3d4b857f621f9fc6d3b621dc60c6b4080d131456db835aae03ec5b77e319393090589d789d083b53f9f91f970a22c9ef974ff3b05e99ce9f14\\\"},\n\n{\\\"tx_hash\\\":\\\"6262b99f22bcce8bacad6c4621121", "end": 19601, "score": 0.9997759461402893, "start": 19471, "tag": "KEY", "value": "04e254bf5f65374d3d4b857f621f9fc6d3b621dc60c6b4080d131456db835aae03ec5b77e319393090589d789d083b53f9f91f970a22c9ef974ff3b05e99ce9f14" }, { "context": "\":\\\"2014-11-05T02:01:54.510Z\\\",\n\\\"private_key\\\":\\\"bee478f7e8c85f24d58edf4bef616235968b290ae5308d0ef2259fbacf02a267\\\",\n\\\"public_key\\\":\\\"04728fbea6cac2bfcce4e573faa46", "end": 19930, "score": 0.999686062335968, "start": 19866, "tag": "KEY", "value": "bee478f7e8c85f24d58edf4bef616235968b290ae5308d0ef2259fbacf02a267" }, { "context": "b290ae5308d0ef2259fbacf02a267\\\",\n\\\"public_key\\\":\\\"04728fbea6cac2bfcce4e573faa46f9dfba09965ac285b0687a6cd39fc8670384e53e9804b687e30d5955c3deccdc429732f012c0fd69db318b9196e5746fe06f3\\\"},\n\n{\\\"tx_hash\\\":\\\"daf0600d1a28ae86882adc03b8f5834", "end": 20083, "score": 0.9992523789405823, "start": 19951, "tag": "KEY", "value": "04728fbea6cac2bfcce4e573faa46f9dfba09965ac285b0687a6cd39fc8670384e53e9804b687e30d5955c3deccdc429732f012c0fd69db318b9196e5746fe06f3\\\"" }, { "context": "\":\\\"2015-02-12T07:41:56.531Z\\\",\n\\\"private_key\\\":\\\"b591ee7c5a64a36d2258873d28f2845477b357dfce709fa2dfe04ba76d419dec\\\",\n\\\"public_key\\\":\\\"0397711cdb60fbd551a162a029956", "end": 20410, "score": 0.9992750883102417, "start": 20346, "tag": "KEY", "value": "b591ee7c5a64a36d2258873d28f2845477b357dfce709fa2dfe04ba76d419dec" }, { "context": "357dfce709fa2dfe04ba76d419dec\\\",\n\\\"public_key\\\":\\\"0397711cdb60fbd551a162a029956980524a87ab26251badac92fe34cd1e7b472e\\\"},\n\n{\\\"tx_hash\\\":\\\"052aab2bd27b31b81ac39bad164cd38", "end": 20499, "score": 0.9996932744979858, "start": 20431, "tag": "KEY", "value": "0397711cdb60fbd551a162a029956980524a87ab26251badac92fe34cd1e7b472e\\\"" }, { "context": "\":\\\"2015-05-14T03:03:00.807Z\\\",\n\\\"private_key\\\":\\\"13eb60184656f64032076b4ec173aa49e0a60008e5427b29f44702fb8f615fa0\\\",\n\\\"public_key\\\":\\\"02a3c5a2e07a891888bbb5a3b31a0", "end": 20826, "score": 0.9997721314430237, "start": 20762, "tag": "KEY", "value": "13eb60184656f64032076b4ec173aa49e0a60008e5427b29f44702fb8f615fa0" }, { "context": "60008e5427b29f44702fb8f615fa0\\\",\n\\\"public_key\\\":\\\"02a3c5a2e07a891888bbb5a3b31a07ef81d792a0c2a940c94bae6e18229b7d7a43\\\"},\n\n{\\\"tx_hash\\\":\\\"b9d3496573b5d1e867d77315a2fd917", "end": 20915, "score": 0.999756395816803, "start": 20847, "tag": "KEY", "value": "02a3c5a2e07a891888bbb5a3b31a07ef81d792a0c2a940c94bae6e18229b7d7a43\\\"" }, { "context": "\":\\\"2014-11-14T00:21:40.358Z\\\",\n\\\"private_key\\\":\\\"a7e451c7455d3f06db42ed5f169b4cba8e57923048bc091ba7753280f2284790\\\",\n\\\"public_key\\\":\\\"0364ce196c16aacebb3a2e0f5840a", "end": 21242, "score": 0.9997409582138062, "start": 21178, "tag": "KEY", "value": "a7e451c7455d3f06db42ed5f169b4cba8e57923048bc091ba7753280f2284790" }, { "context": "7923048bc091ba7753280f2284790\\\",\n\\\"public_key\\\":\\\"0364ce196c16aacebb3a2e0f5840ab9113fa1b9824063251fc61ab9c603fc429ba\\\"},\n\n{\\\"tx_hash\\\":\\\"21e08bd07f30d6cd503e4ce64a0fdb7", "end": 21331, "score": 0.9996962547302246, "start": 21263, "tag": "KEY", "value": "0364ce196c16aacebb3a2e0f5840ab9113fa1b9824063251fc61ab9c603fc429ba\\\"" }, { "context": "\":\\\"2015-03-17T09:03:29.537Z\\\",\n\\\"private_key\\\":\\\"238943026621dcb27e1a2e905da0e4df60b09d690c34460ca5a826f52342913d\\\",\n\\\"public_key\\\":\\\"02d5feec473fa8f83ee52478fce24", "end": 21658, "score": 0.9997610449790955, "start": 21594, "tag": "KEY", "value": "238943026621dcb27e1a2e905da0e4df60b09d690c34460ca5a826f52342913d" }, { "context": "09d690c34460ca5a826f52342913d\\\",\n\\\"public_key\\\":\\\"02d5feec473fa8f83ee52478fce24512a8fdab9ba03525bfa760040d341526bce3\\\"},\n\n{\\\"tx_hash\\\":\\\"7561a3bf4a53fadca684639e877af39", "end": 21747, "score": 0.9997490644454956, "start": 21679, "tag": "KEY", "value": "02d5feec473fa8f83ee52478fce24512a8fdab9ba03525bfa760040d341526bce3\\\"" }, { "context": "x_hash\\\":\\\"7561a3bf4a53fadca684639e877af39abdb1c77e04ba1f856476ba56ae72cb94\\\",\n\\\"recipient\\\":\\\"1G9RXz", "end": 21806, "score": 0.9813790917396545, "start": 21805, "tag": "KEY", "value": "e" }, { "context": "\":\\\"2014-11-05T02:01:52.991Z\\\",\n\\\"private_key\\\":\\\"9046f1d856de34d7e5762d71f39cc972a210c9194be83fdd1dacf30479bd550f\\\",\n\\\"public_key\\\":\\\"04d02a28ae18aaf266075fc973c09", "end": 22074, "score": 0.9996805191040039, "start": 22010, "tag": "KEY", "value": "9046f1d856de34d7e5762d71f39cc972a210c9194be83fdd1dacf30479bd550f" }, { "context": "0c9194be83fdd1dacf30479bd550f\\\",\n\\\"public_key\\\":\\\"04d02a28ae18aaf266075fc973c09621d76a11ea64a944111d20d7c16f9964c5d008bfe4a926d8568cfe2a74f18a08cce521b648b714434a78c503084231198a66\\\"},\n\n{\\\"tx_hash\\\":\\\"", "end": 22196, "score": 0.998803973197937, "start": 22095, "tag": "KEY", "value": "04d02a28ae18aaf266075fc973c09621d76a11ea64a944111d20d7c16f9964c5d008bfe4a926d8568cfe2a74f18a08cce521b" }, { "context": "7c16f9964c5d008bfe4a926d8568cfe2a74f18a08cce521b648b714434a78c503084231198a66\\\"},\n\n{\\\"tx_hash\\\":\\\"274b0e7143eee9a23d166f6d60c9f8d", "end": 22227, "score": 0.9969580769538879, "start": 22198, "tag": "KEY", "value": "8b714434a78c503084231198a66\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.001Z\\\",\n\\\"private_key\\\":\\\"09dc9cf9b4e563a9ec1486fba581008fffd2cca484f9e8cd1b3cdcd4bb888a44\\\",\n\\\"public_key\\\":\\\"0483eeae686580b32c2d7d7c6fd5b", "end": 22554, "score": 0.9996877312660217, "start": 22490, "tag": "KEY", "value": "09dc9cf9b4e563a9ec1486fba581008fffd2cca484f9e8cd1b3cdcd4bb888a44" }, { "context": "2cca484f9e8cd1b3cdcd4bb888a44\\\",\n\\\"public_key\\\":\\\"0483eeae686580b32c2d7d7c6fd5b39adda777203931c96841dc92cd97c2c55df7a57941561c2885fd8851ab2a5f50a921436b368cd9ab9eeb709e9ca481d89c21\\\"},\n\n{\\\"tx_hash\\\":\\\"0c28e0f4ebe036df09ded5ee33323d9", "end": 22707, "score": 0.9997500777244568, "start": 22575, "tag": "KEY", "value": "0483eeae686580b32c2d7d7c6fd5b39adda777203931c96841dc92cd97c2c55df7a57941561c2885fd8851ab2a5f50a921436b368cd9ab9eeb709e9ca481d89c21\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.536Z\\\",\n\\\"private_key\\\":\\\"923f93bf3d6d13aad34c198e4f9f205f39e41f12eb456c3f395880fc0a27a7ff\\\",\n\\\"public_key\\\":\\\"04be9536046b77db1e5ac7b59bfad", "end": 23034, "score": 0.9997743368148804, "start": 22970, "tag": "KEY", "value": "923f93bf3d6d13aad34c198e4f9f205f39e41f12eb456c3f395880fc0a27a7ff" }, { "context": "41f12eb456c3f395880fc0a27a7ff\\\",\n\\\"public_key\\\":\\\"04be9536046b77db1e5ac7b59bfad5302453ffbdc357c8ed82242d1baf5431c3a24e46959339e9dd9ddd292bb18de91b8b864ed9b40cc89a5cc036e8b88244b1dd\\\"},\n\n{\\\"tx_hash\\\":\\\"7334c1369680e4f999e97b3bd9315e3", "end": 23187, "score": 0.9997590184211731, "start": 23055, "tag": "KEY", "value": "04be9536046b77db1e5ac7b59bfad5302453ffbdc357c8ed82242d1baf5431c3a24e46959339e9dd9ddd292bb18de91b8b864ed9b40cc89a5cc036e8b88244b1dd\\\"" }, { "context": ",\n\n{\\\"tx_hash\\\":\\\"7334c1369680e4f999e97b3bd9315e3d0a521cf50587c582de50ab0f72f201b6\\\",\n\\\"recipient\\\":\\\"14R", "end": 23243, "score": 0.9787613153457642, "start": 23238, "tag": "KEY", "value": "0a521" }, { "context": "x_hash\\\":\\\"7334c1369680e4f999e97b3bd9315e3d0a521cf50587c582de50ab0f72f201b6\\\",\n\\\"recipient\\\":\\\"14RWr2qjHC", "end": 23250, "score": 0.97880619764328, "start": 23245, "tag": "KEY", "value": "50587" }, { "context": "\\\":\\\"7334c1369680e4f999e97b3bd9315e3d0a521cf50587c582de50ab0f72f201b6\\\",\n\\\"recipient\\\":\\\"14RWr2qjHCgmP", "end": 23253, "score": 0.7075994610786438, "start": 23251, "tag": "KEY", "value": "58" }, { "context": "\\\"7334c1369680e4f999e97b3bd9315e3d0a521cf50587c582de50ab0f72f201b6\\\",\n\\\"recipient\\\":\\\"14RWr2qjHCgmPtet2BCeqRqTfnA9Lf", "end": 23270, "score": 0.9049623608589172, "start": 23254, "tag": "KEY", "value": "de50ab0f72f201b6" }, { "context": "\":\\\"2014-11-05T02:01:54.615Z\\\",\n\\\"private_key\\\":\\\"06737cee30c6ad8831de0a6621c9bd7b1fdd64540c2142293b5b35f30bb0c14c\\\",\n\\\"public_key\\\":\\\"04a4fa83e35142c7b1b94a041fe65", "end": 23514, "score": 0.999710202217102, "start": 23450, "tag": "KEY", "value": "06737cee30c6ad8831de0a6621c9bd7b1fdd64540c2142293b5b35f30bb0c14c" }, { "context": "d64540c2142293b5b35f30bb0c14c\\\",\n\\\"public_key\\\":\\\"04a4fa83e35142c7b1b94a041fe651e5eccfd25acc1ec61ed817c853adf8de5fee4faab80664ae95864b67b493e56917069df084dc23026f051e1ed1026d6b75c8\\\"},\n\n{\\\"tx_hash\\\":\\\"15872e495968e5f68893d13a75c3101", "end": 23667, "score": 0.9995774030685425, "start": 23535, "tag": "KEY", "value": "04a4fa83e35142c7b1b94a041fe651e5eccfd25acc1ec61ed817c853adf8de5fee4faab80664ae95864b67b493e56917069df084dc23026f051e1ed1026d6b75c8\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.625Z\\\",\n\\\"private_key\\\":\\\"22a2f43caa5414f6d64c3d28e1fc824a75bb173ab750dfc0ca45fbaeb1e21e3b\\\",\n\\\"public_key\\\":\\\"043e2c6cab8285bb47455687e1189", "end": 23994, "score": 0.9996485710144043, "start": 23930, "tag": "KEY", "value": "22a2f43caa5414f6d64c3d28e1fc824a75bb173ab750dfc0ca45fbaeb1e21e3b" }, { "context": "b173ab750dfc0ca45fbaeb1e21e3b\\\",\n\\\"public_key\\\":\\\"043e2c6cab8285bb47455687e11898ba3bbddf943ccbdc8d517a10a98ad5e9783dc53dd18ec46de21c8613e8225c11ac810ca5b039bb947369af0d2bd8c9bacfc4\\\"},\n\n{\\\"tx_hash\\\":\\\"551131e5f5fc48b7816ff07acfeedc5", "end": 24147, "score": 0.9997332096099854, "start": 24015, "tag": "KEY", "value": "043e2c6cab8285bb47455687e11898ba3bbddf943ccbdc8d517a10a98ad5e9783dc53dd18ec46de21c8613e8225c11ac810ca5b039bb947369af0d2bd8c9bacfc4\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.645Z\\\",\n\\\"private_key\\\":\\\"a5814d9dc878bc744ca7988352d2f0e5f15e9d995c315bad747ae7a85961144f\\\",\n\\\"public_key\\\":\\\"040732ecd23426eb99741c2707dbb", "end": 24474, "score": 0.9997637271881104, "start": 24410, "tag": "KEY", "value": "a5814d9dc878bc744ca7988352d2f0e5f15e9d995c315bad747ae7a85961144f" }, { "context": "e9d995c315bad747ae7a85961144f\\\",\n\\\"public_key\\\":\\\"040732ecd23426eb99741c2707dbbcb74bcaf94d4d95d7f06bf2ede7403e11b1d0f0e1c50e0f6526500a7404c2906b5af0cd678c7cb971530fbfea93a946f2995c\\\"},\n\n{\\\"tx_hash\\\":\\\"4747e4c8524c82fc737caf89f9ad666", "end": 24627, "score": 0.9997690320014954, "start": 24495, "tag": "KEY", "value": "040732ecd23426eb99741c2707dbbcb74bcaf94d4d95d7f06bf2ede7403e11b1d0f0e1c50e0f6526500a7404c2906b5af0cd678c7cb971530fbfea93a946f2995c\\\"" }, { "context": "},\n\n{\\\"tx_hash\\\":\\\"4747e4c8524c82fc737caf89f9ad666abad4715cf4f99dd796c4c2d002ff22dc\\\",\n\\\"recipient\\\":\\\"1K", "end": 24682, "score": 0.8706064224243164, "start": 24677, "tag": "KEY", "value": "abad4" }, { "context": "hash\\\":\\\"4747e4c8524c82fc737caf89f9ad666abad4715cf4f99dd796c4c2d002ff22dc\\\",\n\\\"recipient\\\":\\\"1Kiwqx8Rrw8", "end": 24691, "score": 0.9104795455932617, "start": 24687, "tag": "KEY", "value": "4f99" }, { "context": "747e4c8524c82fc737caf89f9ad666abad4715cf4f99dd796c4c2d002ff22dc\\\",\n\\\"recipient\\\":\\\"1Kiwqx8Rrw8XafDNBnsrUX1j", "end": 24704, "score": 0.9488958716392517, "start": 24697, "tag": "KEY", "value": "4c2d002" }, { "context": "4c82fc737caf89f9ad666abad4715cf4f99dd796c4c2d002ff22dc\\\",\n\\\"recipient\\\":\\\"1Kiwqx8Rrw8XafDNBnsrUX1j5ohy1Y", "end": 24710, "score": 0.917381763458252, "start": 24706, "tag": "KEY", "value": "22dc" }, { "context": "\":\\\"2014-11-14T14:51:47.987Z\\\",\n\\\"private_key\\\":\\\"5cdd1269eaffeca5340ffceb6be10fc362747d5a6a366ffd3ca40e9f983f146e\\\",\n\\\"public_key\\\":\\\"028e0ee7aa13e67f343f2a6ab4618", "end": 24954, "score": 0.9996916055679321, "start": 24890, "tag": "KEY", "value": "5cdd1269eaffeca5340ffceb6be10fc362747d5a6a366ffd3ca40e9f983f146e" }, { "context": "47d5a6a366ffd3ca40e9f983f146e\\\",\n\\\"public_key\\\":\\\"028e0ee7aa13e67f343f2a6ab46185c9de95419495e48b914414989c55254c65f5\\\"},\n\n{\\\"tx_hash\\\":\\\"4d10a835b5e9a974596755f95407c82", "end": 25043, "score": 0.9997291564941406, "start": 24975, "tag": "KEY", "value": "028e0ee7aa13e67f343f2a6ab46185c9de95419495e48b914414989c55254c65f5\\\"" }, { "context": "\":\\\"2014-11-15T08:32:36.799Z\\\",\n\\\"private_key\\\":\\\"a73f0ca8defa94d5edee84b6331cb16a2dac88a45b12cca89c1077ee4af400eb\\\",\n\\\"public_key\\\":\\\"02ecd34d7caa9f2045db74eee0505", "end": 25370, "score": 0.9997420907020569, "start": 25306, "tag": "KEY", "value": "a73f0ca8defa94d5edee84b6331cb16a2dac88a45b12cca89c1077ee4af400eb" }, { "context": "c88a45b12cca89c1077ee4af400eb\\\",\n\\\"public_key\\\":\\\"02ecd34d7caa9f2045db74eee05053caff1a4aa83c893495a8eb51df1373e0ca8c\\\"},\n\n{\\\"tx_hash\\\":\\\"b03", "end": 25431, "score": 0.9997230768203735, "start": 25391, "tag": "KEY", "value": "02ecd34d7caa9f2045db74eee05053caff1a4aa8" }, { "context": "\":\\\"2015-05-06T06:11:57.704Z\\\",\n\\\"private_key\\\":\\\"d6af2f3f662ef00992ac6e7c75b2a3ad78bff16ab852efe24115b43bf22eaf03\\\",\n\\\"public_key\\\":\\\"03bc60554a4cb229feb85c4c39077", "end": 25786, "score": 0.9997166395187378, "start": 25722, "tag": "KEY", "value": "d6af2f3f662ef00992ac6e7c75b2a3ad78bff16ab852efe24115b43bf22eaf03" }, { "context": "ff16ab852efe24115b43bf22eaf03\\\",\n\\\"public_key\\\":\\\"03bc60554a4cb229feb85c4c3907785a8532263bb392b5d790ae7f81e201809695\\\"},\n\n{\\\"tx_hash\\\":\\\"d33c092e34a89d60dc718f22903735d", "end": 25875, "score": 0.9997231960296631, "start": 25807, "tag": "KEY", "value": "03bc60554a4cb229feb85c4c3907785a8532263bb392b5d790ae7f81e201809695\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.011Z\\\",\n\\\"private_key\\\":\\\"a2c4ad08c4ba5e04d6e8558f5b5c964dc99d2a0792dad153dd06465a34cb62f5\\\",\n\\\"public_key\\\":\\\"04249c03a55ae8fb404295391d3a3", "end": 26202, "score": 0.9996834993362427, "start": 26138, "tag": "KEY", "value": "a2c4ad08c4ba5e04d6e8558f5b5c964dc99d2a0792dad153dd06465a34cb62f5" }, { "context": "d2a0792dad153dd06465a34cb62f5\\\",\n\\\"public_key\\\":\\\"04249c03a55ae8fb404295391d3a326de5e7960bbd9e194c2e2010e09d8a3b5cc7dbf8fa7bf07b8f07e631281f027ea78e743d67fd6bf4a13d94e4bcadc35c9393\\\"},\n\n{\\\"tx_hash\\\":\\\"50d46c1696c07d2e4aed3f0f6b8ec36", "end": 26355, "score": 0.9997212886810303, "start": 26223, "tag": "KEY", "value": "04249c03a55ae8fb404295391d3a326de5e7960bbd9e194c2e2010e09d8a3b5cc7dbf8fa7bf07b8f07e631281f027ea78e743d67fd6bf4a13d94e4bcadc35c9393\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.022Z\\\",\n\\\"private_key\\\":\\\"c916ea8d7207898958439efad7b0faa753425dad9cb9a1a4256820876892931c\\\",\n\\\"public_key\\\":\\\"0452a147585174d85f326df0875a1", "end": 26682, "score": 0.9997485876083374, "start": 26618, "tag": "KEY", "value": "c916ea8d7207898958439efad7b0faa753425dad9cb9a1a4256820876892931c" }, { "context": "25dad9cb9a1a4256820876892931c\\\",\n\\\"public_key\\\":\\\"0452a147585174d85f326df0875a19669943ec5e5336d0e1029b80eaf17564268036de4b522e590847aec38f1895d73978dd9d2b3151418acad19ece2cf14cd706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd2", "end": 26835, "score": 0.9996693134307861, "start": 26703, "tag": "KEY", "value": "0452a147585174d85f326df0875a19669943ec5e5336d0e1029b80eaf17564268036de4b522e590847aec38f1895d73978dd9d2b3151418acad19ece2cf14cd706\\\"" }, { "context": "2b3151418acad19ece2cf14cd706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a82926", "end": 26856, "score": 0.9086513519287109, "start": 26855, "tag": "KEY", "value": "9" }, { "context": "ad19ece2cf14cd706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c", "end": 26868, "score": 0.7094855904579163, "start": 26866, "tag": "KEY", "value": "77" }, { "context": "cf14cd706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"re", "end": 26876, "score": 0.7376222610473633, "start": 26874, "tag": "KEY", "value": "80" }, { "context": "4cd706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"reci", "end": 26878, "score": 0.7298364043235779, "start": 26877, "tag": "KEY", "value": "5" }, { "context": "706\\\"},\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient", "end": 26883, "score": 0.7647997736930847, "start": 26880, "tag": "KEY", "value": "aac" }, { "context": ",\n\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient\\\":\\", "end": 26887, "score": 0.5688124299049377, "start": 26886, "tag": "KEY", "value": "c" }, { "context": "\n{\\\"tx_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient\\\":\\\"14gc", "end": 26892, "score": 0.6889739036560059, "start": 26888, "tag": "KEY", "value": "8a28" }, { "context": "_hash\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient\\\":\\\"14gcu52", "end": 26895, "score": 0.5148069262504578, "start": 26894, "tag": "KEY", "value": "6" }, { "context": "sh\\\":\\\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient\\\":\\\"14gcu52GekwuQBwwto6", "end": 26907, "score": 0.7269567251205444, "start": 26897, "tag": "KEY", "value": "b74a829260" }, { "context": "fdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\\\",\n\\\"recipient\\\":\\\"14gcu52GekwuQBwwto6RpbWQDgv3Jh", "end": 26918, "score": 0.8528444170951843, "start": 26909, "tag": "KEY", "value": "54eea083c" }, { "context": "\":\\\"2014-11-05T02:01:53.046Z\\\",\n\\\"private_key\\\":\\\"0ce1cc475772c535bd0053b5c3e43ab415bf26903642d7737168ff1cea1a558d\\\",\n\\\"public_key\\\":\\\"04ed86fe2649cec4b835224e62d45", "end": 27162, "score": 0.9997026324272156, "start": 27098, "tag": "KEY", "value": "0ce1cc475772c535bd0053b5c3e43ab415bf26903642d7737168ff1cea1a558d" }, { "context": "f26903642d7737168ff1cea1a558d\\\",\n\\\"public_key\\\":\\\"04ed86fe2649cec4b835224e62d45c3676f1e3fbd8a9c079ac7278994f7bfb3a8e6990abc97dc05774163317417509c22e4e69593eec6194fa15d86f90bf7705cd\\\"},\n\n{\\\"tx_hash\\\":\\\"04642f3f029eda2b48640642ca970", "end": 27313, "score": 0.9996798634529114, "start": 27183, "tag": "KEY", "value": "04ed86fe2649cec4b835224e62d45c3676f1e3fbd8a9c079ac7278994f7bfb3a8e6990abc97dc05774163317417509c22e4e69593eec6194fa15d86f90bf7705cd" }, { "context": "\":\\\"2014-11-05T02:01:54.730Z\\\",\n\\\"private_key\\\":\\\"d138ed28d4dcc7c678bb6562a7250b9ca71ac3b528ef6b9a5d9c31d365f1cffe\\\",\n\\\"public_key\\\":\\\"04d3f31a343168d54ee2c37075e86", "end": 27642, "score": 0.9995666742324829, "start": 27578, "tag": "KEY", "value": "d138ed28d4dcc7c678bb6562a7250b9ca71ac3b528ef6b9a5d9c31d365f1cffe" }, { "context": "ac3b528ef6b9a5d9c31d365f1cffe\\\",\n\\\"public_key\\\":\\\"04d3f31a343168d54ee2c37075e86873c88b1c2ac7fc0225a309ab7af30b85e3ac8e8eac52da965d377b20561bd4667923f8188003c27a6ce62296d8be78dbf6e0\\\"},\n\n{\\\"tx_hash\\\":\\\"d1d7623456bfe389152c7e5d7075728", "end": 27795, "score": 0.99969482421875, "start": 27663, "tag": "KEY", "value": "04d3f31a343168d54ee2c37075e86873c88b1c2ac7fc0225a309ab7af30b85e3ac8e8eac52da965d377b20561bd4667923f8188003c27a6ce62296d8be78dbf6e0\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.979Z\\\",\n\\\"private_key\\\":\\\"6b6542584866076598b63cb6adbad08d0fdd9f250f1c71b782d586f0b914272f\\\",\n\\\"public_key\\\":\\\"048438e4fa2b9e38e3248eae495d2", "end": 28122, "score": 0.9997622966766357, "start": 28058, "tag": "KEY", "value": "6b6542584866076598b63cb6adbad08d0fdd9f250f1c71b782d586f0b914272f" }, { "context": "d9f250f1c71b782d586f0b914272f\\\",\n\\\"public_key\\\":\\\"048438e4fa2b9e38e3248eae495d2240eb0ffab485d0119c1921251e084ebb90c4a1bcdd0a7758e6fe76ef5adbce6711c92ba28fe35ff72e236218d36b160743ab\\\"},\n\n{\\\"tx_hash\\\":\\\"b5175cd928c898cf", "end": 28260, "score": 0.9983701109886169, "start": 28143, "tag": "KEY", "value": "048438e4fa2b9e38e3248eae495d2240eb0ffab485d0119c1921251e084ebb90c4a1bcdd0a7758e6fe76ef5adbce6711c92ba28fe35ff72e23621" }, { "context": "cdd0a7758e6fe76ef5adbce6711c92ba28fe35ff72e236218d36b160743ab\\\"},\n\n{\\\"tx_hash\\\":\\\"b5175cd928c898cf3a9f3", "end": 28265, "score": 0.8337599635124207, "start": 28262, "tag": "KEY", "value": "36b" }, { "context": "\":\\\"2014-11-05T02:01:55.102Z\\\",\n\\\"private_key\\\":\\\"b9200b1a5fbd360b8039c3f10f48388b76408361c46e8d32610b7e1fc2cfdef5\\\",\n\\\"public_key\\\":\\\"04a640490f6c04e0c305f86361e12", "end": 28602, "score": 0.9997589588165283, "start": 28538, "tag": "KEY", "value": "b9200b1a5fbd360b8039c3f10f48388b76408361c46e8d32610b7e1fc2cfdef5" }, { "context": "08361c46e8d32610b7e1fc2cfdef5\\\",\n\\\"public_key\\\":\\\"04a640490f6c04e0c305f86361e122d731356a7c93f90409f7ebfa6d891cfa6dbd0f22b772b67eeaf3551898029e884bac8f4e6aa3366f6d006defa673f95a2a44\\\"},\n\n{\\\"tx_hash\\\":\\\"44f2cf8058d4d5c1f7aaa019ba404c0", "end": 28755, "score": 0.999733030796051, "start": 28623, "tag": "KEY", "value": "04a640490f6c04e0c305f86361e122d731356a7c93f90409f7ebfa6d891cfa6dbd0f22b772b67eeaf3551898029e884bac8f4e6aa3366f6d006defa673f95a2a44\\\"" }, { "context": "\":\\\"2014-11-16T03:51:50.052Z\\\",\n\\\"private_key\\\":\\\"831b92d1aa41dcd9c0e85c21edf40bfd595c7c2b6cb8c603b24e9e8fc39ee1cd\\\",\n\\\"public_key\\\":\\\"033ff5321b1d617fda82d1f6bebbe", "end": 29081, "score": 0.9997642636299133, "start": 29017, "tag": "KEY", "value": "831b92d1aa41dcd9c0e85c21edf40bfd595c7c2b6cb8c603b24e9e8fc39ee1cd" }, { "context": "c7c2b6cb8c603b24e9e8fc39ee1cd\\\",\n\\\"public_key\\\":\\\"033ff5321b1d617fda82d1f6bebbea8b26ff0f3216bb3ebcbae25500725594b858\\\"},\n\n{\\\"tx_hash\\\":\\\"eb5f0cef8a03ff68980d045e2c27689", "end": 29170, "score": 0.999748945236206, "start": 29102, "tag": "KEY", "value": "033ff5321b1d617fda82d1f6bebbea8b26ff0f3216bb3ebcbae25500725594b858\\\"" }, { "context": "\":\\\"2015-01-17T04:11:33.558Z\\\",\n\\\"private_key\\\":\\\"43c0502453a232da29e30359a8492137c87fcd4c8b9e17cbc40f3521f8e30ff7\\\",\n\\\"public_key\\\":\\\"029f99da5354afde84d03f16af423", "end": 29497, "score": 0.9997623562812805, "start": 29433, "tag": "KEY", "value": "43c0502453a232da29e30359a8492137c87fcd4c8b9e17cbc40f3521f8e30ff7" }, { "context": "fcd4c8b9e17cbc40f3521f8e30ff7\\\",\n\\\"public_key\\\":\\\"029f99da5354afde84d03f16af423485812d29c1109bd3fe84d00c81586ab2ed44\\\"},\n\n{\\\"tx_hash\\\":\\\"c205529af8313c48102dfa8cc78e309", "end": 29586, "score": 0.9997559189796448, "start": 29518, "tag": "KEY", "value": "029f99da5354afde84d03f16af423485812d29c1109bd3fe84d00c81586ab2ed44\\\"" }, { "context": "\":\\\"2015-02-13T05:32:20.428Z\\\",\n\\\"private_key\\\":\\\"cb458daeea219ac9bf4562992266e28959b228f9a2316cbca7e36abb9c79b952\\\",\n\\\"public_key\\\":\\\"029405bb9a4cc52435525b906bddb", "end": 29913, "score": 0.999775230884552, "start": 29849, "tag": "KEY", "value": "cb458daeea219ac9bf4562992266e28959b228f9a2316cbca7e36abb9c79b952" }, { "context": "228f9a2316cbca7e36abb9c79b952\\\",\n\\\"public_key\\\":\\\"029405bb9a4cc52435525b906bddbf12214afd1e28a5664d86624daf16c1363da4\\\"},\n\n{\\\"tx_hash\\\":\\\"15baee9509fa0e591634d5da7e3d540", "end": 30002, "score": 0.9997748732566833, "start": 29934, "tag": "KEY", "value": "029405bb9a4cc52435525b906bddbf12214afd1e28a5664d86624daf16c1363da4\\\"" }, { "context": "\":\\\"2015-05-07T04:21:52.571Z\\\",\n\\\"private_key\\\":\\\"3186ac813cc3867407f70571a1b1d3fe88a0cf246af0c8853312608aededd717\\\",\n\\\"public_key\\\":\\\"0233e8be7ac425bffa9678597339a", "end": 30329, "score": 0.9997739195823669, "start": 30265, "tag": "KEY", "value": "3186ac813cc3867407f70571a1b1d3fe88a0cf246af0c8853312608aededd717" }, { "context": "0cf246af0c8853312608aededd717\\\",\n\\\"public_key\\\":\\\"0233e8be7ac425bffa9678597339a4fac60b722cdabbe5bdf3f26d6c11087dce33\\\"},\n\n{\\\"tx_hash\\\":\\\"cb4cda0073b401d796e0f2c96e8f5a8", "end": 30418, "score": 0.9997684955596924, "start": 30350, "tag": "KEY", "value": "0233e8be7ac425bffa9678597339a4fac60b722cdabbe5bdf3f26d6c11087dce33\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.058Z\\\",\n\\\"private_key\\\":\\\"f37d79877dfe29ea694ceea88d2c1f3221b8907c68fe980082071ce9ff815c06\\\",\n\\\"public_key\\\":\\\"048d7c6dfa1d1136a28407496c53b", "end": 30745, "score": 0.999660313129425, "start": 30681, "tag": "KEY", "value": "f37d79877dfe29ea694ceea88d2c1f3221b8907c68fe980082071ce9ff815c06" }, { "context": "8907c68fe980082071ce9ff815c06\\\",\n\\\"public_key\\\":\\\"048d7c6dfa1d1136a28407496c53b715b51c0f5bd6253e755213c0a65965245abd7505dfae8b135d72259dde7e6e279cb2e64171fbbdbf3585a6548191440fac31\\\"},\n\n{\\\"tx_hash\\\":\\\"f0dbb6df8156cc81cafa247814664d3", "end": 30898, "score": 0.9996510148048401, "start": 30766, "tag": "KEY", "value": "048d7c6dfa1d1136a28407496c53b715b51c0f5bd6253e755213c0a65965245abd7505dfae8b135d72259dde7e6e279cb2e64171fbbdbf3585a6548191440fac31\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.109Z\\\",\n\\\"private_key\\\":\\\"a18e2e283a58d6f6a1cbcdff920d4e92c9b86378f3fcc4f40f1e0d92b7a9cd7b\\\",\n\\\"public_key\\\":\\\"0483d1d9ba63793fc10fa73daca41", "end": 31225, "score": 0.9996910691261292, "start": 31161, "tag": "KEY", "value": "a18e2e283a58d6f6a1cbcdff920d4e92c9b86378f3fcc4f40f1e0d92b7a9cd7b" }, { "context": "86378f3fcc4f40f1e0d92b7a9cd7b\\\",\n\\\"public_key\\\":\\\"0483d1d9ba63793fc10fa73daca41de8be2b992eba1c3aa49f8fb559b858af19e1c25064e04bde8e119355a96106263d9632ba57b0f24d2dd401a8b26ac2820a05\\\"},\n\n{\\\"tx_hash\\\":\\\"886b51655b0695ac6f1b8ea08847c5c", "end": 31378, "score": 0.9997141361236572, "start": 31246, "tag": "KEY", "value": "0483d1d9ba63793fc10fa73daca41de8be2b992eba1c3aa49f8fb559b858af19e1c25064e04bde8e119355a96106263d9632ba57b0f24d2dd401a8b26ac2820a05\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.119Z\\\",\n\\\"private_key\\\":\\\"8a158d968a8c020f6f1dccc51b35cdcb457aaf3238301a2a17ce10a3817c8883\\\",\n\\\"public_key\\\":\\\"04bb31ba65bb934f4e4f3247f2706", "end": 31705, "score": 0.9997644424438477, "start": 31641, "tag": "KEY", "value": "8a158d968a8c020f6f1dccc51b35cdcb457aaf3238301a2a17ce10a3817c8883" }, { "context": "aaf3238301a2a17ce10a3817c8883\\\",\n\\\"public_key\\\":\\\"04bb31ba65bb934f4e4f3247f27060910ff136ff9320240bdfe437f3e61eeed4c8972aff6758b74bb1ce075042aa6d8814507f3f0f9c265f9204ccd821d733dadd\\\"},\n\n{\\\"tx_hash\\\":\\\"66a5d6bd7f492a5ccfd86eba7f9e945", "end": 31858, "score": 0.9997533559799194, "start": 31726, "tag": "KEY", "value": "04bb31ba65bb934f4e4f3247f27060910ff136ff9320240bdfe437f3e61eeed4c8972aff6758b74bb1ce075042aa6d8814507f3f0f9c265f9204ccd821d733dadd\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.258Z\\\",\n\\\"private_key\\\":\\\"71bb534e70b39726f89060e23fbe5996b00bd7f3de454f6eb14462f423a4fba1\\\",\n\\\"public_key\\\":\\\"0400e6755f589eeb2a0202fa7efce", "end": 32185, "score": 0.9997112154960632, "start": 32121, "tag": "KEY", "value": "71bb534e70b39726f89060e23fbe5996b00bd7f3de454f6eb14462f423a4fba1" }, { "context": "bd7f3de454f6eb14462f423a4fba1\\\",\n\\\"public_key\\\":\\\"0400e6755f589eeb2a0202fa7efce84b5b1cedcab50a4501d4739a19808ae95d2c32cf0ba4a1f63caa1bab11244402614b8d908200a5ff18a57044b2d36c73010f\\\"},\n\n{\\\"tx_hash\\\":\\\"576e4dd53fbab59178efb1bba3b9659", "end": 32338, "score": 0.9995957016944885, "start": 32206, "tag": "KEY", "value": "0400e6755f589eeb2a0202fa7efce84b5b1cedcab50a4501d4739a19808ae95d2c32cf0ba4a1f63caa1bab11244402614b8d908200a5ff18a57044b2d36c73010f\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.445Z\\\",\n\\\"private_key\\\":\\\"3318c71742e4e6286ed2a2afb154b522c10b2306966b554f99caf99a382945ad\\\",\n\\\"public_key\\\":\\\"0499ae0087b0929d075ebab2c134d", "end": 32665, "score": 0.9996987581253052, "start": 32601, "tag": "KEY", "value": "3318c71742e4e6286ed2a2afb154b522c10b2306966b554f99caf99a382945ad" }, { "context": "b2306966b554f99caf99a382945ad\\\",\n\\\"public_key\\\":\\\"0499ae0087b0929d075ebab2c134d2f9a20857da83b0ac2b402dbf9b24d2361f5a62ec2bbb47ac1f2d51af263c91163c8adb994c2aada3a6779ccb20ec61c818a4\\\"},\n\n{\\\"tx_hash\\\":\\\"43b51534677a771d3ef3236280cee09", "end": 32818, "score": 0.9997555613517761, "start": 32686, "tag": "KEY", "value": "0499ae0087b0929d075ebab2c134d2f9a20857da83b0ac2b402dbf9b24d2361f5a62ec2bbb47ac1f2d51af263c91163c8adb994c2aada3a6779ccb20ec61c818a4\\\"" }, { "context": "\":\\\"2014-11-17T14:21:47.075Z\\\",\n\\\"private_key\\\":\\\"5a8659e78d26e1cf4c3555a205e699b088e7506b8b896b70de946228e81b4b65\\\",\n\\\"public_key\\\":\\\"03a09315d53cf5729f804ae263429", "end": 33145, "score": 0.9997807145118713, "start": 33081, "tag": "KEY", "value": "5a8659e78d26e1cf4c3555a205e699b088e7506b8b896b70de946228e81b4b65" }, { "context": "7506b8b896b70de946228e81b4b65\\\",\n\\\"public_key\\\":\\\"03a09315d53cf5729f804ae263429567c1f218d42027bcec139acd2991952a173c\\\"},\n\n{\\\"tx_hash\\\":\\\"1f59e364b4fc3eaf62b77d458c2ce94", "end": 33234, "score": 0.9997730851173401, "start": 33166, "tag": "KEY", "value": "03a09315d53cf5729f804ae263429567c1f218d42027bcec139acd2991952a173c\\\"" }, { "context": "\":\\\"2015-04-08T06:32:03.752Z\\\",\n\\\"private_key\\\":\\\"a43d6467d9eb951f23e6ee556f3a45fae1706237d40b007edeefde2a7a8e7604\\\",\n\\\"public_key\\\":\\\"037806957b24003910b4485ac0c13", "end": 33561, "score": 0.999535858631134, "start": 33497, "tag": "KEY", "value": "a43d6467d9eb951f23e6ee556f3a45fae1706237d40b007edeefde2a7a8e7604" }, { "context": "06237d40b007edeefde2a7a8e7604\\\",\n\\\"public_key\\\":\\\"037806957b24003910b4485ac0c13e7a5158ffdad323d4ebeef45c2de1637a3648\\\"},\n\n{\\\"tx_hash\\\":\\\"2c813acaadd48e6552fa291aa72a01d", "end": 33650, "score": 0.9997007250785828, "start": 33582, "tag": "KEY", "value": "037806957b24003910b4485ac0c13e7a5158ffdad323d4ebeef45c2de1637a3648\\\"" }, { "context": "\":\\\"2014-11-18T00:41:49.817Z\\\",\n\\\"private_key\\\":\\\"5686bc1699e94233c63ffb0d05934bf83342dff09ab65b9d0485cf6066a50c4f\\\",\n\\\"public_key\\\":\\\"022a8231d4364c7605e81e1cb3b0f", "end": 33977, "score": 0.9997609853744507, "start": 33913, "tag": "KEY", "value": "5686bc1699e94233c63ffb0d05934bf83342dff09ab65b9d0485cf6066a50c4f" }, { "context": "2dff09ab65b9d0485cf6066a50c4f\\\",\n\\\"public_key\\\":\\\"022a8231d4364c7605e81e1cb3b0f792c96a330685f99d50c3b7cb220e5741bb56\\\"},\n\n{\\\"tx_hash\\\":\\\"3bbff16458b", "end": 34046, "score": 0.9997357130050659, "start": 33998, "tag": "KEY", "value": "022a8231d4364c7605e81e1cb3b0f792c96a330685f99d50" }, { "context": "\":\\\"2014-11-19T01:32:58.124Z\\\",\n\\\"private_key\\\":\\\"0f9beffa195fa20d67c3a18ca8e05f8deaff0904b6bc72beebe5f8bcd27d6666\\\",\n\\\"public_key\\\":\\\"024d639bc9805b3dfe0d5af18a4a8", "end": 34393, "score": 0.999742329120636, "start": 34329, "tag": "KEY", "value": "0f9beffa195fa20d67c3a18ca8e05f8deaff0904b6bc72beebe5f8bcd27d6666" }, { "context": "f0904b6bc72beebe5f8bcd27d6666\\\",\n\\\"public_key\\\":\\\"024d639bc9805b3dfe0d5af18a4a82fdf8c378bbabb502c4c1f0a58d631e0dfb78\\\"},\n\n{\\\"tx_hash\\\":\\\"8ebe0d670073ba67c736f2920ee082c", "end": 34482, "score": 0.9997416138648987, "start": 34414, "tag": "KEY", "value": "024d639bc9805b3dfe0d5af18a4a82fdf8c378bbabb502c4c1f0a58d631e0dfb78\\\"" }, { "context": "\":\\\"2014-11-20T02:04:37.604Z\\\",\n\\\"private_key\\\":\\\"f102939e5f29777ae44968ef1a73ce68382b32b6d63eb54f8726543dd3b77d73\\\",\n\\\"public_key\\\":\\\"020e6360e67b85a40729a5ff8e441", "end": 34809, "score": 0.9996500611305237, "start": 34745, "tag": "KEY", "value": "f102939e5f29777ae44968ef1a73ce68382b32b6d63eb54f8726543dd3b77d73" }, { "context": "b32b6d63eb54f8726543dd3b77d73\\\",\n\\\"public_key\\\":\\\"020e6360e67b85a40729a5ff8e441e57419ad4d4dacd4de9519f5621af30c3f3d4\\\"},\n\n{\\\"tx_hash\\\":\\\"946f2b211b6741f2699f6c8f029caab", "end": 34898, "score": 0.9996657371520996, "start": 34830, "tag": "KEY", "value": "020e6360e67b85a40729a5ff8e441e57419ad4d4dacd4de9519f5621af30c3f3d4\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.129Z\\\",\n\\\"private_key\\\":\\\"f731a1ee280e63ef70a49997a4419a39c2f3ff0c80348cfde7ab73a493078770\\\",\n\\\"public_key\\\":\\\"0468939836d53bcb615a33dad8b1d", "end": 35225, "score": 0.9997475743293762, "start": 35161, "tag": "KEY", "value": "f731a1ee280e63ef70a49997a4419a39c2f3ff0c80348cfde7ab73a493078770" }, { "context": "3ff0c80348cfde7ab73a493078770\\\",\n\\\"public_key\\\":\\\"0468939836d53bcb615a33dad8b1d868efa620dd6a258e477ef2c5de213afd2925775a7f80dfe625c591f3ae4398416c87e1d481dc70d739c553772b0e051f775b\\\"},\n\n{\\\"tx_hash\\\":\\\"19c42ab5ec36db0d5127f82c5ae7ac9", "end": 35378, "score": 0.9997379779815674, "start": 35246, "tag": "KEY", "value": "0468939836d53bcb615a33dad8b1d868efa620dd6a258e477ef2c5de213afd2925775a7f80dfe625c591f3ae4398416c87e1d481dc70d739c553772b0e051f775b\\\"" }, { "context": "\":\\\"2014-11-21T02:03:45.847Z\\\",\n\\\"private_key\\\":\\\"4bf7ba2605d314574146a74b422986eea2886193308cf7eda252f8b507e129aa\\\",\n\\\"public_key\\\":\\\"021058ced7248273debd77d0dc0b5", "end": 35705, "score": 0.9997655153274536, "start": 35641, "tag": "KEY", "value": "4bf7ba2605d314574146a74b422986eea2886193308cf7eda252f8b507e129aa" }, { "context": "86193308cf7eda252f8b507e129aa\\\",\n\\\"public_key\\\":\\\"021058ced7248273debd77d0dc0b5bea82eedbcba940884742f47becf933e42a69\\\"},\n\n{\\\"tx_hash\\\":\\\"9466a3c8c7d333ffc72dfc16e1992cf", "end": 35794, "score": 0.9997180104255676, "start": 35726, "tag": "KEY", "value": "021058ced7248273debd77d0dc0b5bea82eedbcba940884742f47becf933e42a69\\\"" }, { "context": "\":\\\"2015-01-27T09:39:31.697Z\\\",\n\\\"private_key\\\":\\\"5df7c58923cff0c3e6f483b669d665b9ba942f46732f7a25ad4bbf0877a3efa1\\\",\n\\\"public_key\\\":\\\"023a2dc2fc7dbc6db344aa5cf522c", "end": 36121, "score": 0.9997756481170654, "start": 36057, "tag": "KEY", "value": "5df7c58923cff0c3e6f483b669d665b9ba942f46732f7a25ad4bbf0877a3efa1" }, { "context": "42f46732f7a25ad4bbf0877a3efa1\\\",\n\\\"public_key\\\":\\\"023a2dc2fc7dbc6db344aa5cf522c8d795ad5f192b91ed7a487026ea92862e7f83\\\"},\n\n{\\\"tx_hash\\\":\\\"440321c778c38f3c821a0664b3a5209", "end": 36210, "score": 0.9997478127479553, "start": 36142, "tag": "KEY", "value": "023a2dc2fc7dbc6db344aa5cf522c8d795ad5f192b91ed7a487026ea92862e7f83\\\"" }, { "context": "\":\\\"2015-02-14T03:32:33.451Z\\\",\n\\\"private_key\\\":\\\"cf8d2d406a5e5c6b98da1c02bac23cbfce7402db593e1c3fbeac735e5172199c\\\",\n\\\"public_key\\\":\\\"02ac79b78d3b079394ae76978fcdc", "end": 36537, "score": 0.9997610449790955, "start": 36473, "tag": "KEY", "value": "cf8d2d406a5e5c6b98da1c02bac23cbfce7402db593e1c3fbeac735e5172199c" }, { "context": "402db593e1c3fbeac735e5172199c\\\",\n\\\"public_key\\\":\\\"02ac79b78d3b079394ae76978fcdced9ebb088b082f22f089b60c1a253fee134c2\\\"},\n\n{\\\"tx_hash\\\":\\\"6553bf0bdf60ae8cd779ccf35e40a73", "end": 36626, "score": 0.9997521638870239, "start": 36558, "tag": "KEY", "value": "02ac79b78d3b079394ae76978fcdced9ebb088b082f22f089b60c1a253fee134c2\\\"" }, { "context": "\":\\\"2015-03-06T02:12:06.336Z\\\",\n\\\"private_key\\\":\\\"120591da350a83cc8c4824d4287b60336752ffbc04b6f41a134845726ba211f4\\\",\n\\\"public_key\\\":\\\"02aa64879afcca357c31846e2883f", "end": 36953, "score": 0.9997630715370178, "start": 36889, "tag": "KEY", "value": "120591da350a83cc8c4824d4287b60336752ffbc04b6f41a134845726ba211f4" }, { "context": "2ffbc04b6f41a134845726ba211f4\\\",\n\\\"public_key\\\":\\\"02aa64879afcca357c31846e2883f62a68a42e754d43645429d18223936ca19589\\\"},\n\n{", "end": 36997, "score": 0.9997278451919556, "start": 36974, "tag": "KEY", "value": "02aa64879afcca357c31846" }, { "context": "\":\\\"2015-03-16T01:51:28.986Z\\\",\n\\\"private_key\\\":\\\"00382b3411f96713a3219ec51d9d1c00f7674fff8723fc0a69c40a1261bf3b17\\\",\n\\\"public_key\\\":\\\"027fdc523bf14900aa4de123b8d66", "end": 37369, "score": 0.9997673630714417, "start": 37305, "tag": "KEY", "value": "00382b3411f96713a3219ec51d9d1c00f7674fff8723fc0a69c40a1261bf3b17" }, { "context": "74fff8723fc0a69c40a1261bf3b17\\\",\n\\\"public_key\\\":\\\"027fdc523bf14900aa4de123b8d6627fae97f40e103fd5d3a294aa5acd12c24683\\\"},\n\n{\\\"tx_hash\\\":\\\"99f5c46372957b146e5f644874c3359", "end": 37458, "score": 0.9997616410255432, "start": 37390, "tag": "KEY", "value": "027fdc523bf14900aa4de123b8d6627fae97f40e103fd5d3a294aa5acd12c24683\\\"" }, { "context": "\":\\\"2015-05-18T09:51:29.803Z\\\",\n\\\"private_key\\\":\\\"6efee64827ef07699e4047347384dcf1fe318562f616874d9ca29911db2893c1\\\",\n\\\"public_key\\\":\\\"0221ee36be7dd9660af80a45e7966", "end": 37785, "score": 0.9994788765907288, "start": 37721, "tag": "KEY", "value": "6efee64827ef07699e4047347384dcf1fe318562f616874d9ca29911db2893c1" }, { "context": "18562f616874d9ca29911db2893c1\\\",\n\\\"public_key\\\":\\\"0221ee36be7dd9660af80a45e7966705736775a60674012c2fba0252ea05faa93f\\\"},\n\n{\\\"tx_hash\\\":\\\"e55d281e60d25023cb07adacc376c8f", "end": 37874, "score": 0.9996592402458191, "start": 37806, "tag": "KEY", "value": "0221ee36be7dd9660af80a45e7966705736775a60674012c2fba0252ea05faa93f\\\"" }, { "context": "\":\\\"2015-05-08T08:12:20.765Z\\\",\n\\\"private_key\\\":\\\"723806784434266cb6a9e9701bbec4c0e76753a09fb503f6151d148191a2c748\\\",\n\\\"public_key\\\":\\\"03ba4fd62f94886febc36265e3cb7", "end": 38201, "score": 0.9997580051422119, "start": 38137, "tag": "KEY", "value": "723806784434266cb6a9e9701bbec4c0e76753a09fb503f6151d148191a2c748" }, { "context": "753a09fb503f6151d148191a2c748\\\",\n\\\"public_key\\\":\\\"03ba4fd62f94886febc36265e3cb77af197c738be30d6170e932769a7348586355\\\"},\n\n{\\\"tx_hash\\\":\\\"10417bfe88b10ca116cba61fca45788", "end": 38290, "score": 0.9997466206550598, "start": 38222, "tag": "KEY", "value": "03ba4fd62f94886febc36265e3cb77af197c738be30d6170e932769a7348586355\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.152Z\\\",\n\\\"private_key\\\":\\\"e650256c4b2909eca53b1ff7c42025263a224448af880c7c24b6bd1854f70143\\\",\n\\\"public_key\\\":\\\"04a079f3de5d55377f46583bb57c4", "end": 38617, "score": 0.9997643828392029, "start": 38553, "tag": "KEY", "value": "e650256c4b2909eca53b1ff7c42025263a224448af880c7c24b6bd1854f70143" }, { "context": "24448af880c7c24b6bd1854f70143\\\",\n\\\"public_key\\\":\\\"04a079f3de5d55377f46583bb57c4b678079226cdf95b9042bd535e629c427f59d39d456f6aafaba762399081914fd0daf6d1aa789694bfe93d57c42de37c58b21\\\"},\n\n{\\\"tx_hash\\\":\\\"5f8768b7abd0cc28643c1aafaa691e0", "end": 38770, "score": 0.9997431635856628, "start": 38638, "tag": "KEY", "value": "04a079f3de5d55377f46583bb57c4b678079226cdf95b9042bd535e629c427f59d39d456f6aafaba762399081914fd0daf6d1aa789694bfe93d57c42de37c58b21\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.162Z\\\",\n\\\"private_key\\\":\\\"ec2b3258941a80c3e478eee326e781fd3809375054214f319fc749e6ad8670e8\\\",\n\\\"public_key\\\":\\\"0412c7f7bc3312c0127248936206c", "end": 39097, "score": 0.9997279644012451, "start": 39033, "tag": "KEY", "value": "ec2b3258941a80c3e478eee326e781fd3809375054214f319fc749e6ad8670e8" }, { "context": "9375054214f319fc749e6ad8670e8\\\",\n\\\"public_key\\\":\\\"0412c7f7bc3312c0127248936206c7cd721a223193fe6635ea4c581965279bbcc8954c8c8c6b405234c83", "end": 39153, "score": 0.9997428059577942, "start": 39118, "tag": "KEY", "value": "0412c7f7bc3312c0127248936206c7cd721" }, { "context": "\":\\\"2014-11-05T02:01:53.172Z\\\",\n\\\"private_key\\\":\\\"8ba148ef7f9caba5b0985031484270ef9848d5bd2e52545eab75c4c0244a7205\\\",\n\\\"public_key\\\":\\\"04b894e099684e1908d552e232022", "end": 39577, "score": 0.9997550845146179, "start": 39513, "tag": "KEY", "value": "8ba148ef7f9caba5b0985031484270ef9848d5bd2e52545eab75c4c0244a7205" }, { "context": "8d5bd2e52545eab75c4c0244a7205\\\",\n\\\"public_key\\\":\\\"04b894e099684e1908d552e232022aaa60955f25ef60e3d938b58e7d84e953668c22215558d724a304b1428508b8b755c70bff2a0ee9d1d81f2351ec59dc5e5c79\\\"},\n\n{\\\"tx_hash\\\":\\\"446a6b8f158e8755806b6672bf6acbc", "end": 39730, "score": 0.9997571110725403, "start": 39598, "tag": "KEY", "value": "04b894e099684e1908d552e232022aaa60955f25ef60e3d938b58e7d84e953668c22215558d724a304b1428508b8b755c70bff2a0ee9d1d81f2351ec59dc5e5c79\\\"" }, { "context": "\":\\\"2015-05-13T16:02:38.947Z\\\",\n\\\"private_key\\\":\\\"1cc6e2cf7a830bcaca0c2c714aa4ffb4d00a2deea5383f5c241b98cb1acef803\\\",\n\\\"public_key\\\":\\\"02964b9f3684c002168802552ec30", "end": 40057, "score": 0.9997626543045044, "start": 39993, "tag": "KEY", "value": "1cc6e2cf7a830bcaca0c2c714aa4ffb4d00a2deea5383f5c241b98cb1acef803" }, { "context": "a2deea5383f5c241b98cb1acef803\\\",\n\\\"public_key\\\":\\\"02964b9f3684c002168802552ec3069e168ba04c5b857ea05e100750394f15bf38\\\"},\n\n{\\\"tx_hash\\\":\\\"e37f0a9c8f1b52fd8883cae81f41892", "end": 40146, "score": 0.9997574687004089, "start": 40078, "tag": "KEY", "value": "02964b9f3684c002168802552ec3069e168ba04c5b857ea05e100750394f15bf38\\\"" }, { "context": "\":\\\"2015-05-09T02:22:06.134Z\\\",\n\\\"private_key\\\":\\\"02d444a239779ae0183e84f8ff75590e8fc9efd28b765e1c716cc924c33c9124\\\",\n\\\"public_key\\\":\\\"02a6f14075e09a122083e38f03384", "end": 40473, "score": 0.9997581839561462, "start": 40409, "tag": "KEY", "value": "02d444a239779ae0183e84f8ff75590e8fc9efd28b765e1c716cc924c33c9124" }, { "context": "9efd28b765e1c716cc924c33c9124\\\",\n\\\"public_key\\\":\\\"02a6f14075e09a122083e38f033847d39845c81bdfa3358e089ec71845ea79a3c4\\\"},\n\n{\\\"tx_hash\\\":\\\"2e088f04c5dc0324f16771a491", "end": 40557, "score": 0.9997138381004333, "start": 40494, "tag": "KEY", "value": "02a6f14075e09a122083e38f033847d39845c81bdfa3358e089ec71845ea79a" }, { "context": "\":\\\"2014-11-22T01:21:28.008Z\\\",\n\\\"private_key\\\":\\\"cd7679280b720d0de41abbec3e4b4e8577685b6037e20dd261ec879160bfb414\\\",\n\\\"public_key\\\":\\\"0335bf0f6a43e0f394caf882e175c", "end": 40889, "score": 0.9997529983520508, "start": 40825, "tag": "KEY", "value": "cd7679280b720d0de41abbec3e4b4e8577685b6037e20dd261ec879160bfb414" }, { "context": "85b6037e20dd261ec879160bfb414\\\",\n\\\"public_key\\\":\\\"0335bf0f6a43e0f394caf882e175cae58f21c88852823aeb41d59bdbe6cd23941f\\\"},\n\n{\\\"tx_hash\\\":\\\"7a97fbfe87a98cffe1a832a3244b1ac", "end": 40978, "score": 0.9997515082359314, "start": 40910, "tag": "KEY", "value": "0335bf0f6a43e0f394caf882e175cae58f21c88852823aeb41d59bdbe6cd23941f\\\"" }, { "context": "\":\\\"2014-11-23T01:03:36.035Z\\\",\n\\\"private_key\\\":\\\"95b4d298f8eba04b26d4adb144e068e41624ee4dc0a4e529f7e8f0e7faaf0eca\\\",\n\\\"public_key\\\":\\\"03095199780c60cc22f7193efb1bb", "end": 41305, "score": 0.9992873072624207, "start": 41241, "tag": "KEY", "value": "95b4d298f8eba04b26d4adb144e068e41624ee4dc0a4e529f7e8f0e7faaf0eca" }, { "context": "4ee4dc0a4e529f7e8f0e7faaf0eca\\\",\n\\\"public_key\\\":\\\"03095199780c60cc22f7193efb1bbe1c5836c7e643f872b579d89bcb4d68d83560\\\"},\n\n{\\\"tx_hash\\\":\\\"d3419d432015929785e88d5dfc9f3e6", "end": 41394, "score": 0.9997655749320984, "start": 41326, "tag": "KEY", "value": "03095199780c60cc22f7193efb1bbe1c5836c7e643f872b579d89bcb4d68d83560\\\"" }, { "context": "\":\\\"2015-05-10T15:31:57.006Z\\\",\n\\\"private_key\\\":\\\"dbea14764191f7393b6c0faac87580879d2c0e4bc20a18a010088333b4393db1\\\",\n\\\"public_key\\\":\\\"0234c35a455cd7897091b8d1778f3", "end": 41721, "score": 0.9997649192810059, "start": 41657, "tag": "KEY", "value": "dbea14764191f7393b6c0faac87580879d2c0e4bc20a18a010088333b4393db1" }, { "context": "c0e4bc20a18a010088333b4393db1\\\",\n\\\"public_key\\\":\\\"0234c35a455cd7897091b8d1778f3d48781245d92950c69f4f878c23a37741e92c\\\"},\n\n{\\\"tx_hash\\\":\\\"2d9cdc612ed78cc0a0c02d4ab5df99a", "end": 41810, "score": 0.9997653365135193, "start": 41742, "tag": "KEY", "value": "0234c35a455cd7897091b8d1778f3d48781245d92950c69f4f878c23a37741e92c\\\"" }, { "context": "\":\\\"2015-02-15T02:41:53.066Z\\\",\n\\\"private_key\\\":\\\"2f7a2370bb0b28ad6c8f3e3d07b2d704359434ebbeacdc8d9a15431426b18fcd\\\",\n\\\"public_key\\\":\\\"034db30b146f09ae6f95bfcff4548", "end": 42137, "score": 0.9997663497924805, "start": 42073, "tag": "KEY", "value": "2f7a2370bb0b28ad6c8f3e3d07b2d704359434ebbeacdc8d9a15431426b18fcd" }, { "context": "434ebbeacdc8d9a15431426b18fcd\\\",\n\\\"public_key\\\":\\\"034db30b146f09ae6f95bfcff45486f41024be68cee7c2d181ddff85b6057bd6c9\\\"},\n\n{\\\"tx_hash\\\":\\\"b06394a816cf500167defc419064187", "end": 42226, "score": 0.9997666478157043, "start": 42158, "tag": "KEY", "value": "034db30b146f09ae6f95bfcff45486f41024be68cee7c2d181ddff85b6057bd6c9\\\"" }, { "context": "\":\\\"2015-02-16T13:03:24.902Z\\\",\n\\\"private_key\\\":\\\"c138b470742e4edb0c06bd2dcd9f869ba37170f4bf095910d899d0df4971e598\\\",\n\\\"public_key\\\":\\\"0281bd2813fc67cbbc6183e50f0a7", "end": 42553, "score": 0.9997767210006714, "start": 42489, "tag": "KEY", "value": "c138b470742e4edb0c06bd2dcd9f869ba37170f4bf095910d899d0df4971e598" }, { "context": "170f4bf095910d899d0df4971e598\\\",\n\\\"public_key\\\":\\\"0281bd2813fc67cbbc6183e50f0a7ef5e7b4c2cbc3f937e3f9a95edd8d04c2325d\\\"},\n\n{\\\"tx_hash\\\":\\\"5df96fbce787ad35836a2eb7c0b3ab0", "end": 42642, "score": 0.999768078327179, "start": 42574, "tag": "KEY", "value": "0281bd2813fc67cbbc6183e50f0a7ef5e7b4c2cbc3f937e3f9a95edd8d04c2325d\\\"" }, { "context": "\":\\\"2015-02-17T09:32:14.650Z\\\",\n\\\"private_key\\\":\\\"80c9c1acf4761eba2f860f7319276e5e7291e6edc4105c17ee80afa74b800f53\\\",\n\\\"public_key\\\":\\\"03aba50cba1b95e66b6bc90f4b2e5", "end": 42969, "score": 0.9997530579566956, "start": 42905, "tag": "KEY", "value": "80c9c1acf4761eba2f860f7319276e5e7291e6edc4105c17ee80afa74b800f53" }, { "context": "1e6edc4105c17ee80afa74b800f53\\\",\n\\\"public_key\\\":\\\"03aba50cba1b95e66b6bc90f4b2e57611a7ac107e440e6ceb0b2abf631713a318c\\\"},\n\n{\\\"tx_hash\\\":\\\"80d790815a6ae2b4982989af7285562", "end": 43058, "score": 0.9997695684432983, "start": 42990, "tag": "KEY", "value": "03aba50cba1b95e66b6bc90f4b2e57611a7ac107e440e6ceb0b2abf631713a318c\\\"" }, { "context": "\":\\\"2015-02-19T02:41:52.068Z\\\",\n\\\"private_key\\\":\\\"43e872a53ef104fedb7c17df6bae8c63343e5535083f08dcfeb56c544da58484\\\",\n\\\"public_key\\\":\\\"027f122d03e7d9441003f63690857", "end": 43385, "score": 0.9997482895851135, "start": 43321, "tag": "KEY", "value": "43e872a53ef104fedb7c17df6bae8c63343e5535083f08dcfeb56c544da58484" }, { "context": "e5535083f08dcfeb56c544da58484\\\",\n\\\"public_key\\\":\\\"027f122d03e7d9441003f63690857f9bb7bff092bdddc6c275b72528ce7856bccc\\\"},\n\n{\\\"tx_hash\\\":\\\"ef50c29dccfa428d99a26d404acc7a8", "end": 43474, "score": 0.9997678399085999, "start": 43406, "tag": "KEY", "value": "027f122d03e7d9441003f63690857f9bb7bff092bdddc6c275b72528ce7856bccc\\\"" }, { "context": "\":\\\"2015-02-18T14:03:27.288Z\\\",\n\\\"private_key\\\":\\\"6cbd1b28112cda0d50969ef3929e2b13d7e1fa806bb6728d31a30a7f3f1ea67f\\\",\n\\\"public_key\\\":\\\"036ef7ae3f8fa2b2e54756bb86324", "end": 43801, "score": 0.9997554421424866, "start": 43737, "tag": "KEY", "value": "6cbd1b28112cda0d50969ef3929e2b13d7e1fa806bb6728d31a30a7f3f1ea67f" }, { "context": "1fa806bb6728d31a30a7f3f1ea67f\\\",\n\\\"public_key\\\":\\\"036ef7ae3f8fa2b2e54756bb8632425f394d4addc206a0a735fea3b1a3f702db41\\\"},\n\n{\\\"tx_hash\\\":\\\"263d31cd4eb2d684dc0ab311112f5dc", "end": 43890, "score": 0.9997515678405762, "start": 43822, "tag": "KEY", "value": "036ef7ae3f8fa2b2e54756bb8632425f394d4addc206a0a735fea3b1a3f702db41\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.187Z\\\",\n\\\"private_key\\\":\\\"795491021f09a66cd93056e985f4a02d31be5aee06df95ef425ce7366f981b1c\\\",\n\\\"public_key\\\":\\\"045541edc137a245a65cc2f07d6d4", "end": 44217, "score": 0.999722421169281, "start": 44153, "tag": "KEY", "value": "795491021f09a66cd93056e985f4a02d31be5aee06df95ef425ce7366f981b1c" }, { "context": "e5aee06df95ef425ce7366f981b1c\\\",\n\\\"public_key\\\":\\\"045541edc137a245a65cc2f07d6d4ef1829bb5130d3a22ed3de04486", "end": 44244, "score": 0.9996872544288635, "start": 44238, "tag": "KEY", "value": "045541" }, { "context": "1ac476e314b6380d515c300250bf66fb4983b23728d9a38d26eb0d7f80f1e1f2cdbb4ee3\\\"},\n\n{\\\"tx_hash\\\":\\\"c636d3b28f960236325d4c263", "end": 44364, "score": 0.9837833046913147, "start": 44346, "tag": "KEY", "value": "eb0d7f80f1e1f2cdbb" }, { "context": "c300250bf66fb4983b23728d9a38d26eb0d7f80f1e1f2cdbb4ee3\\\"},\n\n{\\\"tx_hash\\\":\\\"c636d3b28f960236325d4c2638f8", "end": 44367, "score": 0.9992673397064209, "start": 44365, "tag": "KEY", "value": "ee" }, { "context": "\":\\\"2014-11-05T02:01:53.198Z\\\",\n\\\"private_key\\\":\\\"91c36b1aac2c23d1e041afc9f068b9d4df2511c93b002822e49ff9d4bbfb1720\\\",\n\\\"public_key\\\":\\\"044ae0d9dab46ff1d5f7f06db8bee", "end": 44697, "score": 0.9997735619544983, "start": 44633, "tag": "KEY", "value": "91c36b1aac2c23d1e041afc9f068b9d4df2511c93b002822e49ff9d4bbfb1720" }, { "context": "511c93b002822e49ff9d4bbfb1720\\\",\n\\\"public_key\\\":\\\"044ae0d9dab46ff1d5f7f06db8bee30e9f6399c95c566ec54921316c861b1148802858fc2229be5cebf1783089e8b93baf28283dbe3a6d9401671b0629f4879939\\\"},\n\n{\\\"tx_hash\\\":\\\"ef9e6c1c337661b22ef1b508b917d0b", "end": 44850, "score": 0.9997569918632507, "start": 44718, "tag": "KEY", "value": "044ae0d9dab46ff1d5f7f06db8bee30e9f6399c95c566ec54921316c861b1148802858fc2229be5cebf1783089e8b93baf28283dbe3a6d9401671b0629f4879939\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.208Z\\\",\n\\\"private_key\\\":\\\"71749262eb0b78b8f9410917de640e1ecb1be625e0da66e0cfc64f45e3ba0035\\\",\n\\\"public_key\\\":\\\"044a0fa820d8fedf98b19305cc783", "end": 45177, "score": 0.9996252655982971, "start": 45113, "tag": "KEY", "value": "71749262eb0b78b8f9410917de640e1ecb1be625e0da66e0cfc64f45e3ba0035" }, { "context": "be625e0da66e0cfc64f45e3ba0035\\\",\n\\\"public_key\\\":\\\"044a0fa820d8fedf98b19305cc7838ff92f1dbd8842bca27502e4e32f9930914b21770d544301661f05d9abce8033d12fc3e537f8b0b90ab1249647ae649ca9608\\\"},\n\n{\\\"tx_hash\\\"", "end": 45296, "score": 0.9946731925010681, "start": 45198, "tag": "KEY", "value": "044a0fa820d8fedf98b19305cc7838ff92f1dbd8842bca27502e4e32f9930914b21770d544301661f05d9abce8033d12fc" }, { "context": "4e32f9930914b21770d544301661f05d9abce8033d12fc3e537f8b0b90ab1249647ae649ca9608\\\"},\n\n{\\\"tx_hash\\\":\\\"cf81", "end": 45303, "score": 0.8780038952827454, "start": 45300, "tag": "KEY", "value": "7f8" }, { "context": "f9930914b21770d544301661f05d9abce8033d12fc3e537f8b0b90ab1249647ae649ca9608\\\"},\n\n{\\\"tx_hash\\\":\\\"cf815a", "end": 45305, "score": 0.8205915689468384, "start": 45304, "tag": "KEY", "value": "0" }, { "context": "930914b21770d544301661f05d9abce8033d12fc3e537f8b0b90ab1249647ae649ca9608\\\"},\n\n{\\\"tx_hash\\\":\\\"cf815a603fb0d2348c786f219fc71a7", "end": 45330, "score": 0.9497931599617004, "start": 45306, "tag": "KEY", "value": "90ab1249647ae649ca9608\\\"" }, { "context": "\":\\\"2014-11-24T02:32:17.019Z\\\",\n\\\"private_key\\\":\\\"5de6bf0f97ec7c608effa8246d5fa6080e93a229ab4529e596c72e4c38aec933\\\",\n\\\"public_key\\\":\\\"03e4dd506e68752ab16d89c80827d", "end": 45657, "score": 0.9995707273483276, "start": 45593, "tag": "KEY", "value": "5de6bf0f97ec7c608effa8246d5fa6080e93a229ab4529e596c72e4c38aec933" }, { "context": "3a229ab4529e596c72e4c38aec933\\\",\n\\\"public_key\\\":\\\"03e4dd506e68752ab16d89c80827dbc12478e5414eb19c726a726fbbbfd1544671\\\"},\n\n{\\\"tx_hash\\\":\\\"4d8dfb4699b0d1ac7e438c1182a0cc4", "end": 45746, "score": 0.9997498393058777, "start": 45678, "tag": "KEY", "value": "03e4dd506e68752ab16d89c80827dbc12478e5414eb19c726a726fbbbfd1544671\\\"" }, { "context": "\":\\\"2015-03-22T21:51:31.967Z\\\",\n\\\"private_key\\\":\\\"a03b8153a2264d45d19ff39f9e055cf70fce9fa19affaa854a81abcdcbfe8f0c\\\",\n\\\"public_key\\\":\\\"03a440e08d803daef868ffeed9bbb", "end": 46073, "score": 0.9997543692588806, "start": 46009, "tag": "KEY", "value": "a03b8153a2264d45d19ff39f9e055cf70fce9fa19affaa854a81abcdcbfe8f0c" }, { "context": "e9fa19affaa854a81abcdcbfe8f0c\\\",\n\\\"public_key\\\":\\\"03a440e08d803daef868ffeed9bbb914edd8a57fe1ea8272969593968655a52e53\\\"},\n\n{\\\"tx_hash\\\":\\\"2f4d1c4640b86d094bb2d225a8a414e", "end": 46162, "score": 0.9997137784957886, "start": 46094, "tag": "KEY", "value": "03a440e08d803daef868ffeed9bbb914edd8a57fe1ea8272969593968655a52e53\\\"" }, { "context": "\":\\\"2015-02-20T02:03:39.623Z\\\",\n\\\"private_key\\\":\\\"9430d7f562abd8b7ce88c7a6bea45dca913d79b57081639d2ac0981443ae3d80\\\",\n\\\"public_key\\\":\\\"033517a9a2010d08d982f6b9b64db", "end": 46489, "score": 0.9997565746307373, "start": 46425, "tag": "KEY", "value": "9430d7f562abd8b7ce88c7a6bea45dca913d79b57081639d2ac0981443ae3d80" }, { "context": "d79b57081639d2ac0981443ae3d80\\\",\n\\\"public_key\\\":\\\"033517a9a2010d08d982f6b9b64db580719b43d458ff9b0e254fa383b64a6c2588\\\"},\n\n{\\\"tx_hash\\\":\\\"cc610efdac09b0dd95d0801eb589d66", "end": 46578, "score": 0.9997571110725403, "start": 46510, "tag": "KEY", "value": "033517a9a2010d08d982f6b9b64db580719b43d458ff9b0e254fa383b64a6c2588\\\"" }, { "context": "\":\\\"2015-03-08T17:03:36.014Z\\\",\n\\\"private_key\\\":\\\"bd4443dc91f7995a11fcea24eecb02abdf6143a9f78748e6e74b210772b0526e\\\",\n\\\"public_key\\\":\\\"03262cc8dbee43147a2edc7285338", "end": 46905, "score": 0.9997586011886597, "start": 46841, "tag": "KEY", "value": "bd4443dc91f7995a11fcea24eecb02abdf6143a9f78748e6e74b210772b0526e" }, { "context": "143a9f78748e6e74b210772b0526e\\\",\n\\\"public_key\\\":\\\"03262cc8dbee43147a2edc7285338e145461557cd7424be7f8dbfc492159088467\\\"},\n\n{\\\"tx_hash\\\":\\\"97fd31ba4defc8344e4cfbb8df10c5a", "end": 46994, "score": 0.9997535943984985, "start": 46926, "tag": "KEY", "value": "03262cc8dbee43147a2edc7285338e145461557cd7424be7f8dbfc492159088467\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.218Z\\\",\n\\\"private_key\\\":\\\"20f7ee1e3ab18ec7a413344e314b0ee4639b39f44008b6309d0eceee175dbae5\\\",\n\\\"public_key\\\":\\\"04cd82d871496a996961a62e3d5fc", "end": 47321, "score": 0.9996874928474426, "start": 47257, "tag": "KEY", "value": "20f7ee1e3ab18ec7a413344e314b0ee4639b39f44008b6309d0eceee175dbae5" }, { "context": "b39f44008b6309d0eceee175dbae5\\\",\n\\\"public_key\\\":\\\"04cd82d871496a996961a62e3d5fcd7d36711cf7d88269ca598391ece912af978b5221cb0e41f5f1d90134b1ac72dd7e24a9e7f19c365b248f88490bf1806c2758\\\"},\n\n{\\\"tx_hash\\\":\\\"a2d14ba75d34d95002f2d94acecf579", "end": 47474, "score": 0.9996854066848755, "start": 47342, "tag": "KEY", "value": "04cd82d871496a996961a62e3d5fcd7d36711cf7d88269ca598391ece912af978b5221cb0e41f5f1d90134b1ac72dd7e24a9e7f19c365b248f88490bf1806c2758\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.228Z\\\",\n\\\"private_key\\\":\\\"54cd91fceaac4795244354d97acc9df6e105f2c67c89ce0dc5d425280e66c199\\\",\n\\\"public_key\\\":\\\"046ce8b9bb09ace0bb9800eba5d50", "end": 47801, "score": 0.9997333288192749, "start": 47737, "tag": "KEY", "value": "54cd91fceaac4795244354d97acc9df6e105f2c67c89ce0dc5d425280e66c199" }, { "context": "5f2c67c89ce0dc5d425280e66c199\\\",\n\\\"public_key\\\":\\\"046ce8b9bb09ace0bb9800eba5d50227c3fbe3c3285754882a4476beaf64e3ba1c883a17e9d907be20f12a2748", "end": 47862, "score": 0.9997151494026184, "start": 47822, "tag": "KEY", "value": "046ce8b9bb09ace0bb9800eba5d50227c3fbe3c3" }, { "context": "\":\\\"2014-11-05T02:01:53.242Z\\\",\n\\\"private_key\\\":\\\"b0b25e7777cbecb4bfd4ccdfb25f1c43c74d0f2c206a924f5fbcdbe07f8d9596\\\",\n\\\"public_key\\\":\\\"049916dc85897aae622d7988fe3b3", "end": 48280, "score": 0.9997630715370178, "start": 48216, "tag": "KEY", "value": "b0b25e7777cbecb4bfd4ccdfb25f1c43c74d0f2c206a924f5fbcdbe07f8d9596" }, { "context": "d0f2c206a924f5fbcdbe07f8d9596\\\",\n\\\"public_key\\\":\\\"049916dc85897aae622d7988fe3b33397aed6183f06863dbe25ee3d64c4a086eb18bc4e2b439fad16cb7e02e4caa1d7a6d48df86085df7dc847155c488c361ffea\\\"},\n\n{\\\"tx_hash\\\":\\\"3b2b6ef09ee244411e9383ac42d82cf", "end": 48433, "score": 0.9997020959854126, "start": 48301, "tag": "KEY", "value": "049916dc85897aae622d7988fe3b33397aed6183f06863dbe25ee3d64c4a086eb18bc4e2b439fad16cb7e02e4caa1d7a6d48df86085df7dc847155c488c361ffea\\\"" }, { "context": "\":\\\"2014-11-25T02:31:49.377Z\\\",\n\\\"private_key\\\":\\\"dcdfddf513bd1cdac4a662a0b48e6400104248f688c065aa3db7089984f94214\\\",\n\\\"public_key\\\":\\\"023d6b3a566192d7868ecc87b66c4", "end": 48760, "score": 0.9997743964195251, "start": 48696, "tag": "KEY", "value": "dcdfddf513bd1cdac4a662a0b48e6400104248f688c065aa3db7089984f94214" }, { "context": "248f688c065aa3db7089984f94214\\\",\n\\\"public_key\\\":\\\"023d6b3a566192d7868ecc87b66c422b718f8eaf0954ab2489502864f5cd7c7411\\\"},\n\n{\\\"tx_hash\\\":\\\"36741940f0a73484912a4b2aca38fb7", "end": 48849, "score": 0.9997706413269043, "start": 48781, "tag": "KEY", "value": "023d6b3a566192d7868ecc87b66c422b718f8eaf0954ab2489502864f5cd7c7411\\\"" }, { "context": "\":\\\"2015-01-27T09:39:32.317Z\\\",\n\\\"private_key\\\":\\\"8ea2c187876178abc0446df68b5ce1b29eb6e6cff3edee681cc8d373b12ef103\\\",\n\\\"public_key\\\":\\\"030e1953e7af164480c142e3f5b3d", "end": 49176, "score": 0.9997398853302002, "start": 49112, "tag": "KEY", "value": "8ea2c187876178abc0446df68b5ce1b29eb6e6cff3edee681cc8d373b12ef103" }, { "context": "6e6cff3edee681cc8d373b12ef103\\\",\n\\\"public_key\\\":\\\"030e1953e7af164480c142e3f5b3dd8629b1ad05f36cc463014f236c13d322b7b0\\\"},\n\n{\\\"tx_hash\\\":\\\"24a8242ea0aabb23ffe395035ed0fbd", "end": 49265, "score": 0.9997626543045044, "start": 49197, "tag": "KEY", "value": "030e1953e7af164480c142e3f5b3dd8629b1ad05f36cc463014f236c13d322b7b0\\\"" }, { "context": "\":\\\"2015-01-27T09:39:32.791Z\\\",\n\\\"private_key\\\":\\\"fe6c2fd627f009b4c5f496a329ecd4335ee2dd7d793b6870645f575369afa3c6\\\",\n\\\"public_key\\\":\\\"032462e0eaf5da9b2a29a28e4d2e5", "end": 49592, "score": 0.9997181296348572, "start": 49528, "tag": "KEY", "value": "fe6c2fd627f009b4c5f496a329ecd4335ee2dd7d793b6870645f575369afa3c6" }, { "context": "2dd7d793b6870645f575369afa3c6\\\",\n\\\"public_key\\\":\\\"032462e0eaf5da9b2a29a28e4d2e5e320a8070980a28d4514ecec8533b76ffb876\\\"},\n\n{\\\"tx_hash\\\":\\\"d23151f82e9b92e559a8092f79a57e6", "end": 49681, "score": 0.9996606707572937, "start": 49613, "tag": "KEY", "value": "032462e0eaf5da9b2a29a28e4d2e5e320a8070980a28d4514ecec8533b76ffb876\\\"" }, { "context": "\":\\\"2015-01-29T02:21:48.672Z\\\",\n\\\"private_key\\\":\\\"6e00610ded1ba5f5dac66347d0c86dd7a86b3cccfd603401788f3684835d8ca9\\\",\n\\\"public_key\\\":\\\"027769a94092aa5197ec0ef60d3e4", "end": 50008, "score": 0.9997449517250061, "start": 49944, "tag": "KEY", "value": "6e00610ded1ba5f5dac66347d0c86dd7a86b3cccfd603401788f3684835d8ca9" }, { "context": "b3cccfd603401788f3684835d8ca9\\\",\n\\\"public_key\\\":\\\"027769a94092aa5197ec0ef60d3e408df38f265cb020cfabf06c7e9e0f1c2944d2\\\"", "end": 50047, "score": 0.9996708035469055, "start": 50029, "tag": "KEY", "value": "027769a94092aa5197" }, { "context": "\":\\\"2015-02-20T08:32:18.258Z\\\",\n\\\"private_key\\\":\\\"d266f45f04660dd22ca83986b98a84b231838718a88de7d7a0c5a75c19506310\\\",\n\\\"public_key\\\":\\\"02ebfce9e76876ff2294b076f10c0", "end": 50424, "score": 0.9997352361679077, "start": 50360, "tag": "KEY", "value": "d266f45f04660dd22ca83986b98a84b231838718a88de7d7a0c5a75c19506310" }, { "context": "38718a88de7d7a0c5a75c19506310\\\",\n\\\"public_key\\\":\\\"02ebfce9e76876ff2294b076f10c07ede6642ac034c3df1a8491ded8b9ae2263b9\\\"},\n\n{\\\"tx_hash\\\":\\\"820810819ca30b3ba0b42509e64ee6a", "end": 50513, "score": 0.9996998906135559, "start": 50445, "tag": "KEY", "value": "02ebfce9e76876ff2294b076f10c07ede6642ac034c3df1a8491ded8b9ae2263b9\\\"" }, { "context": "\":\\\"2015-02-01T09:11:38.062Z\\\",\n\\\"private_key\\\":\\\"94d2d50522380d7843a8dfa3051d6c5122a7833dddab31d16c51939d5530af27\\\",\n\\\"public_key\\\":\\\"03c639be124a29bca750120e58cff", "end": 50840, "score": 0.9987531304359436, "start": 50776, "tag": "KEY", "value": "94d2d50522380d7843a8dfa3051d6c5122a7833dddab31d16c51939d5530af27" }, { "context": "7833dddab31d16c51939d5530af27\\\",\n\\\"public_key\\\":\\\"03c639be124a29bca750120e58cff390027f843895dbdb4f8768c09e93634ecc31\\\"},\n\n{\\\"tx_hash\\\":\\\"f1844287d3de2fb8e5ba2524f0d543e", "end": 50929, "score": 0.999752402305603, "start": 50861, "tag": "KEY", "value": "03c639be124a29bca750120e58cff390027f843895dbdb4f8768c09e93634ecc31\\\"" }, { "context": "\":\\\"2015-02-22T06:41:36.344Z\\\",\n\\\"private_key\\\":\\\"5e5072744b016a579ab24ae6811995748f32a6a75ab8798138b45f3c7c29ee21\\\",\n\\\"public_key\\\":\\\"0362f244fbcd7948608f761d1b373", "end": 51256, "score": 0.9997707605361938, "start": 51192, "tag": "KEY", "value": "5e5072744b016a579ab24ae6811995748f32a6a75ab8798138b45f3c7c29ee21" }, { "context": "2a6a75ab8798138b45f3c7c29ee21\\\",\n\\\"public_key\\\":\\\"0362f244fbcd7948608f761d1b37351ca422ceb52e5d0560986373e8b44a27cd1f\\\"},\n\n{\\\"tx_hash\\\":\\\"119f044d51c887a18bc0aa6bc31dff7", "end": 51345, "score": 0.9997682571411133, "start": 51277, "tag": "KEY", "value": "0362f244fbcd7948608f761d1b37351ca422ceb52e5d0560986373e8b44a27cd1f\\\"" }, { "context": "\":\\\"2015-03-08T17:03:36.683Z\\\",\n\\\"private_key\\\":\\\"1e69ca8d0c865e7465c5033c4af7913bda2306fd3a3b53550660d50e8e460e0d\\\",\n\\\"public_key\\\":\\\"03958851b51dc568cc7ddd75be429", "end": 51672, "score": 0.9997645616531372, "start": 51608, "tag": "KEY", "value": "1e69ca8d0c865e7465c5033c4af7913bda2306fd3a3b53550660d50e8e460e0d" }, { "context": "306fd3a3b53550660d50e8e460e0d\\\",\n\\\"public_key\\\":\\\"03958851b51dc568cc7ddd75be4291af797e80acb97f262924c08a18d75b498729\\\"},\n\n{\\\"tx_hash\\\":\\\"d1b8c561fb07e6bc0162e1a35c090e9", "end": 51761, "score": 0.9997692704200745, "start": 51693, "tag": "KEY", "value": "03958851b51dc568cc7ddd75be4291af797e80acb97f262924c08a18d75b498729\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.252Z\\\",\n\\\"private_key\\\":\\\"e2548d886cba076d6a2152714d7499b79e55fba38d87e3fdcd3cd06b950e072d\\\",\n\\\"public_key\\\":\\\"040d13312e2bff9514a2036672d69", "end": 52088, "score": 0.9997718930244446, "start": 52024, "tag": "KEY", "value": "e2548d886cba076d6a2152714d7499b79e55fba38d87e3fdcd3cd06b950e072d" }, { "context": "5fba38d87e3fdcd3cd06b950e072d\\\",\n\\\"public_key\\\":\\\"040d13312e2bff9514a2036672d69955b38915c710263ef0cfe6855b11014d9c0f1fb23cd8339d69275005cb5d9dfbc8410447280a6eb7838a38d6e9704bd58fbe\\", "end": 52190, "score": 0.9997533559799194, "start": 52109, "tag": "KEY", "value": "040d13312e2bff9514a2036672d69955b38915c710263ef0cfe6855b11014d9c0f1fb23cd8339d692" }, { "context": "38915c710263ef0cfe6855b11014d9c0f1fb23cd8339d69275005cb5d9dfbc8410447280a6eb7838a38d6e9704bd58fbe\\\"},\n", "end": 52194, "score": 0.6211680173873901, "start": 52192, "tag": "KEY", "value": "00" }, { "context": "15c710263ef0cfe6855b11014d9c0f1fb23cd8339d69275005cb5d9dfbc8410447280a6eb7838a38d6e9704bd58fbe\\\"},\n\n{\\", "end": 52197, "score": 0.9997062683105469, "start": 52195, "tag": "KEY", "value": "cb" }, { "context": "63ef0cfe6855b11014d9c0f1fb23cd8339d69275005cb5d9dfbc8410447280a6eb7838a38d6e9704bd58fbe\\\"},\n\n{\\\"tx_has", "end": 52204, "score": 0.5883875489234924, "start": 52202, "tag": "KEY", "value": "bc" }, { "context": "\":\\\"2014-11-05T02:01:53.261Z\\\",\n\\\"private_key\\\":\\\"126b5ba1b5b41d31dc84f7312c7f1f6986dfa80580104cab749c79eb34fb5491\\\",\n\\\"public_key\\\":\\\"040e28c86b7c867dd02f172e5bde2", "end": 52568, "score": 0.9997339248657227, "start": 52504, "tag": "KEY", "value": "126b5ba1b5b41d31dc84f7312c7f1f6986dfa80580104cab749c79eb34fb5491" }, { "context": "fa80580104cab749c79eb34fb5491\\\",\n\\\"public_key\\\":\\\"040e28c86b7c867dd02f172e5bde21bbe55f8a53c2208a476faaa629b0f2f9cdaed16c0dd252bc87d4ed21f18eb97dbe196ea5efb8bdb158fb963a08f946fdddff\\\"},\n\n{\\\"tx_hash\\\":\\\"e96df52be3a2b2560dcf8967a629fa2", "end": 52721, "score": 0.9997138977050781, "start": 52589, "tag": "KEY", "value": "040e28c86b7c867dd02f172e5bde21bbe55f8a53c2208a476faaa629b0f2f9cdaed16c0dd252bc87d4ed21f18eb97dbe196ea5efb8bdb158fb963a08f946fdddff\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.271Z\\\",\n\\\"private_key\\\":\\\"79ef921fc6e588bfbd10aa055d12a23d505118b2f061040063b8329d43710cd6\\\",\n\\\"public_key\\\":\\\"04663f8f570a8c53f72fef0032476", "end": 53048, "score": 0.9997578859329224, "start": 52984, "tag": "KEY", "value": "79ef921fc6e588bfbd10aa055d12a23d505118b2f061040063b8329d43710cd6" }, { "context": "118b2f061040063b8329d43710cd6\\\",\n\\\"public_key\\\":\\\"04663f8f570a8c53f72fef0032476665b5665f61729ce3492813ffc0199191edca5fb3d95be1a08dc96cd3963c8af85cbe1679f7789123ab7f8cb025b64227f3e9\\\"},\n\n{\\\"tx_hash\\\":\\\"3fba2e0fe527f85fa90da49fef62471", "end": 53201, "score": 0.9997288584709167, "start": 53069, "tag": "KEY", "value": "04663f8f570a8c53f72fef0032476665b5665f61729ce3492813ffc0199191edca5fb3d95be1a08dc96cd3963c8af85cbe1679f7789123ab7f8cb025b64227f3e9\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.280Z\\\",\n\\\"private_key\\\":\\\"976f1c678e1d5574e0bfa9ba51776c6487efe0690b56cb189f972aea225e12d1\\\",\n\\\"public_key\\\":\\\"04f95ce975aabe43b27442360ff3d", "end": 53528, "score": 0.9997597336769104, "start": 53464, "tag": "KEY", "value": "976f1c678e1d5574e0bfa9ba51776c6487efe0690b56cb189f972aea225e12d1" }, { "context": "fe0690b56cb189f972aea225e12d1\\\",\n\\\"public_key\\\":\\\"04f95ce975aabe43b27442360ff3dce14d864a22f8c420490a40ebad553399b9299f3c542a4b328f4d53ffc1a13bcf016754cc350f65d813825a4804597d811e9d\\\"},\n\n{\\", "end": 53637, "score": 0.9988788962364197, "start": 53549, "tag": "KEY", "value": "04f95ce975aabe43b27442360ff3dce14d864a22f8c420490a40ebad553399b9299f3c542a4b328f4d53ffc1" }, { "context": "2f8c420490a40ebad553399b9299f3c542a4b328f4d53ffc1a13bcf016754cc350f65d813825a4804597d811e9d\\\"},\n\n{\\\"t", "end": 53639, "score": 0.5819522738456726, "start": 53638, "tag": "KEY", "value": "1" }, { "context": "20490a40ebad553399b9299f3c542a4b328f4d53ffc1a13bcf016754cc350f65d813825a4804597d811e9d\\\"},\n\n{\\\"tx_has", "end": 53644, "score": 0.9487165808677673, "start": 53643, "tag": "KEY", "value": "0" }, { "context": "\":\\\"2014-11-05T02:01:53.289Z\\\",\n\\\"private_key\\\":\\\"796b2de388963e2237f77d599fcfee235a457eace3f58f9ba9a7c4d0f78e4436\\\",\n\\\"public_key\\\":\\\"04f21243ddf8b008b80f0ff3422bb", "end": 54008, "score": 0.9997276663780212, "start": 53944, "tag": "KEY", "value": "796b2de388963e2237f77d599fcfee235a457eace3f58f9ba9a7c4d0f78e4436" }, { "context": "57eace3f58f9ba9a7c4d0f78e4436\\\",\n\\\"public_key\\\":\\\"04f21243ddf8b008b80f0ff3422bb618cdad8b14bbe4ca32af195c92abb8453d9328f86b5cbfcdd78783d190b009a6265c59f28c1bc5f3c5f2877f2d09a5588753\\\"},\n\n{\\\"tx_hash\\\":\\\"4e9c565741cdc89df91406b17605ff0", "end": 54161, "score": 0.9997602105140686, "start": 54029, "tag": "KEY", "value": "04f21243ddf8b008b80f0ff3422bb618cdad8b14bbe4ca32af195c92abb8453d9328f86b5cbfcdd78783d190b009a6265c59f28c1bc5f3c5f2877f2d09a5588753\\\"" }, { "context": "atus\\\":1,\n\\\"created_at\\\":\\\"2014-06-08T00:00:28.939Z\\\",\n\\\"updated_at\\\":\\\"2014-11-05T02:01:53.299Z\\\",\n\\", "end": 54357, "score": 0.5581176280975342, "start": 54356, "tag": "KEY", "value": "Z" }, { "context": "\":\\\"2014-11-05T02:01:53.299Z\\\",\n\\\"private_key\\\":\\\"7cb60258698d66e661da2b273e44684703904e10a9c71849bdcb653ba753932a\\\",\n\\\"public_key\\\":\\\"04493a19ddf04b447c12487cc2bc5", "end": 54488, "score": 0.9997076392173767, "start": 54424, "tag": "KEY", "value": "7cb60258698d66e661da2b273e44684703904e10a9c71849bdcb653ba753932a" }, { "context": "04e10a9c71849bdcb653ba753932a\\\",\n\\\"public_key\\\":\\\"04493a19ddf04b447c12487cc2bc546987f71f73ee463adfd19b7bce17a3b363e4a9bee8ea6f1adefe11660b05f8980113e56eb55ed2752b1e62615128000143ef\\\"},\n\n{\\\"tx_hash\\\":\\\"638825d12cecdcd45100de8364da6cd", "end": 54641, "score": 0.9995113611221313, "start": 54509, "tag": "KEY", "value": "04493a19ddf04b447c12487cc2bc546987f71f73ee463adfd19b7bce17a3b363e4a9bee8ea6f1adefe11660b05f8980113e56eb55ed2752b1e62615128000143ef\\\"" }, { "context": "\":\\\"2014-11-26T02:41:13.596Z\\\",\n\\\"private_key\\\":\\\"33d1e1df02da9f31f4b35ec47cf26ecc9347394a742adb1d15eabfa47d79d037\\\",\n\\\"public_key\\\":\\\"03e2db6702cd38282b89e67d7be89", "end": 54968, "score": 0.9997477531433105, "start": 54904, "tag": "KEY", "value": "33d1e1df02da9f31f4b35ec47cf26ecc9347394a742adb1d15eabfa47d79d037" }, { "context": "7394a742adb1d15eabfa47d79d037\\\",\n\\\"public_key\\\":\\\"03e2db6702cd38282b89e67d7be890417f67e486a47701084b99054d1bf374c3b9\\\"},\n\n{\\\"tx_hash\\\":\\\"af1370ba00198de53709e1db13245a2", "end": 55057, "score": 0.9997263550758362, "start": 54989, "tag": "KEY", "value": "03e2db6702cd38282b89e67d7be890417f67e486a47701084b99054d1bf374c3b9\\\"" }, { "context": "\":\\\"2015-02-01T08:32:00.780Z\\\",\n\\\"private_key\\\":\\\"42fcadb4edc199886dda943fe200c31212fc8c0b4131b9ecdf95afd66416c370\\\",\n\\\"public_key\\\":\\\"02296cf861cfcaf3d855070557d21", "end": 55384, "score": 0.9997503757476807, "start": 55320, "tag": "KEY", "value": "42fcadb4edc199886dda943fe200c31212fc8c0b4131b9ecdf95afd66416c370" }, { "context": "c8c0b4131b9ecdf95afd66416c370\\\",\n\\\"public_key\\\":\\\"02296cf861cfcaf3d855070557d211fdbd7933d24eb48870613e53d5abcb86c79d\\\"},\n\n{\\\"tx_hash\\\":\\\"4e0e85de3430e92744c5db1bd8424f6", "end": 55473, "score": 0.9997527599334717, "start": 55405, "tag": "KEY", "value": "02296cf861cfcaf3d855070557d211fdbd7933d24eb48870613e53d5abcb86c79d\\\"" }, { "context": "\":\\\"2015-02-01T09:11:38.573Z\\\",\n\\\"private_key\\\":\\\"0f56eaa06c1542ca75fd02c97ea821585387927d4cd75976ba133ec3801b32c3\\\",\n\\\"public_key\\\":\\\"022df77e586f361f7a54865839ce2", "end": 55800, "score": 0.9997340440750122, "start": 55736, "tag": "KEY", "value": "0f56eaa06c1542ca75fd02c97ea821585387927d4cd75976ba133ec3801b32c3" }, { "context": "7927d4cd75976ba133ec3801b32c3\\\",\n\\\"public_key\\\":\\\"022df77e586f361f7a54865839ce2a27fc7790b4c508d16670956ef516517d58bc\\\"},\n\n{\\\"tx_hash\\\":\\\"a38fdad21e38e56dafbf2c12da1552d", "end": 55889, "score": 0.9997466206550598, "start": 55821, "tag": "KEY", "value": "022df77e586f361f7a54865839ce2a27fc7790b4c508d16670956ef516517d58bc\\\"" }, { "context": "\":\\\"2015-02-01T09:11:39.068Z\\\",\n\\\"private_key\\\":\\\"b79b2db92019f243906a8fa2eab5f095bb001bc1a74898a156473a16eb45d61e\\\",\n\\\"public_key\\\":\\\"026d4a7b644587bd693d121186959", "end": 56216, "score": 0.9997627139091492, "start": 56152, "tag": "KEY", "value": "b79b2db92019f243906a8fa2eab5f095bb001bc1a74898a156473a16eb45d61e" }, { "context": "01bc1a74898a156473a16eb45d61e\\\",\n\\\"public_key\\\":\\\"026d4a7b644587bd693d121186959dd6b8b0d2ed154cef639b76823e17b1ed9a22\\\"},\n\n{\\\"tx_hash\\\":\\\"f155d9e6f0e63848112fdd4ee56b0b3", "end": 56305, "score": 0.9997613430023193, "start": 56237, "tag": "KEY", "value": "026d4a7b644587bd693d121186959dd6b8b0d2ed154cef639b76823e17b1ed9a22\\\"" }, { "context": "\":\\\"2015-04-13T03:32:15.143Z\\\",\n\\\"private_key\\\":\\\"188aaa96d8328b22af02d91662ec604a20805e87168965d884d2bce7c413acdf\\\",\n\\\"public_key\\\":\\\"02689751bb700089f15ef28559095", "end": 56632, "score": 0.9997519254684448, "start": 56568, "tag": "KEY", "value": "188aaa96d8328b22af02d91662ec604a20805e87168965d884d2bce7c413acdf" }, { "context": "05e87168965d884d2bce7c413acdf\\\",\n\\\"public_key\\\":\\\"02689751bb700089f15ef285590959ce44ae2ef07721ce812dbc4531158a040845\\\"},\n\n{\\\"tx_hash\\\":\\\"940b1c299bc80d09db22878e96589f8", "end": 56721, "score": 0.9997293949127197, "start": 56653, "tag": "KEY", "value": "02689751bb700089f15ef285590959ce44ae2ef07721ce812dbc4531158a040845\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.308Z\\\",\n\\\"private_key\\\":\\\"08c7cc51ff329c9980e2a4d7638bb15458ffd81ab8b9808016b9da2bead06c06\\\",\n\\\"public_key\\\":\\\"04f70ea95a1660abd8d2384d40d0a", "end": 57048, "score": 0.999760091304779, "start": 56984, "tag": "KEY", "value": "08c7cc51ff329c9980e2a4d7638bb15458ffd81ab8b9808016b9da2bead06c06" }, { "context": "fd81ab8b9808016b9da2bead06c06\\\",\n\\\"public_key\\\":\\\"04f70ea95a1660abd8d2384d40d0a454c4b04d4636f839edf27390a7fec6ef1f993703683a778e708ffb83ddbead1baad60f9a2df3a546115c578e0d3607ec3bf8\\\"},\n\n{\\\"tx_hash\\\":\\\"3bda48eaa0d8a65b722dc323e8403a0", "end": 57201, "score": 0.9997283220291138, "start": 57069, "tag": "KEY", "value": "04f70ea95a1660abd8d2384d40d0a454c4b04d4636f839edf27390a7fec6ef1f993703683a778e708ffb83ddbead1baad60f9a2df3a546115c578e0d3607ec3bf8\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.318Z\\\",\n\\\"private_key\\\":\\\"7574f25f69ef2e027b9557bf7b494101694e5d5ec6f8f7a066aac83b0351d507\\\",\n\\\"public_key\\\":\\\"041156822502cd2063e5e86270899", "end": 57527, "score": 0.9997076392173767, "start": 57463, "tag": "KEY", "value": "7574f25f69ef2e027b9557bf7b494101694e5d5ec6f8f7a066aac83b0351d507" }, { "context": "e5d5ec6f8f7a066aac83b0351d507\\\",\n\\\"public_key\\\":\\\"041156822502cd2063e5e862708998d0cf63e148243ab5a8411f7c133acc729adc399eadb6f418bb5ec3ee43b3a8d0f0874683bddd5a9007de2f5c7710b2a6247b\\\"},\n\n{\\\"tx_hash\\\":\\\"006d98d7cc04610e99e26064ca341f8", "end": 57680, "score": 0.9996323585510254, "start": 57548, "tag": "KEY", "value": "041156822502cd2063e5e862708998d0cf63e148243ab5a8411f7c133acc729adc399eadb6f418bb5ec3ee43b3a8d0f0874683bddd5a9007de2f5c7710b2a6247b\\\"" }, { "context": "\":\\\"2014-11-27T08:31:38.423Z\\\",\n\\\"private_key\\\":\\\"3ce403a65a7c24f0dd5f18fb9c9dc8959fb28284cb81da950fed82ce11dcb021\\\",\n\\\"public_key\\\":\\\"03dfa606b650b7133a3cc08ef048c", "end": 58007, "score": 0.9996925592422485, "start": 57943, "tag": "KEY", "value": "3ce403a65a7c24f0dd5f18fb9c9dc8959fb28284cb81da950fed82ce11dcb021" }, { "context": "28284cb81da950fed82ce11dcb021\\\",\n\\\"public_key\\\":\\\"03dfa606b650b7133a3cc08ef048c3a7c3fcfbd4ad18a618f365b6e9958fd877d0\\\"},\n\n{\\\"tx_hash\\\":\\\"6ac17d327a1af6d4c23d4df61e6c8ec", "end": 58096, "score": 0.9997465014457703, "start": 58028, "tag": "KEY", "value": "03dfa606b650b7133a3cc08ef048c3a7c3fcfbd4ad18a618f365b6e9958fd877d0\\\"" }, { "context": "\":\\\"2014-11-28T01:31:35.785Z\\\",\n\\\"private_key\\\":\\\"d201e07ee63f7a40c5f44a236c69ac1ced101ee9ae36c11d98b46e1d0d89cb03\\\",\n\\\"public_key\\\":\\\"032c60ea10aa61e8e98f201403028", "end": 58423, "score": 0.9997342824935913, "start": 58359, "tag": "KEY", "value": "d201e07ee63f7a40c5f44a236c69ac1ced101ee9ae36c11d98b46e1d0d89cb03" }, { "context": "01ee9ae36c11d98b46e1d0d89cb03\\\",\n\\\"public_key\\\":\\\"032c60ea10aa61e8e98f201403028a2eb90476ca8c07be634986a57fdc910b1aa0\\\"},\n\n{\\\"tx_hash\\\":\\\"9d5fbf9b2a08ab1fa138e4e186c9ebd", "end": 58512, "score": 0.9997553825378418, "start": 58444, "tag": "KEY", "value": "032c60ea10aa61e8e98f201403028a2eb90476ca8c07be634986a57fdc910b1aa0\\\"" }, { "context": "\":\\\"2014-11-29T14:02:32.236Z\\\",\n\\\"private_key\\\":\\\"1479e1faea25aeb35cf85707f7cde30e1722806b8e2e22bf240e2b67c810d4af\\\",\n\\\"public_key\\\":\\\"024436581d5f1edee56dbf6c976e6", "end": 58839, "score": 0.9997543096542358, "start": 58775, "tag": "KEY", "value": "1479e1faea25aeb35cf85707f7cde30e1722806b8e2e22bf240e2b67c810d4af" }, { "context": "2806b8e2e22bf240e2b67c810d4af\\\",\n\\\"public_key\\\":\\\"024436581d5f1edee56dbf6c976e620305f423d9bedab81d7a3634dc7f8ae7f30a\\\"},\n\n{\\\"tx_hash\\\":\\\"a0565e9c65c5e6521fc808edd311456", "end": 58928, "score": 0.999746561050415, "start": 58860, "tag": "KEY", "value": "024436581d5f1edee56dbf6c976e620305f423d9bedab81d7a3634dc7f8ae7f30a\\\"" }, { "context": "\":\\\"2014-11-30T03:41:26.418Z\\\",\n\\\"private_key\\\":\\\"f45668263a977a60c0111a93f2070f7bc20558f26840dd007c4d3083a90b1a95\\\",\n\\\"public_key\\\":\\\"03647e5790930f67ada5dede83ff7", "end": 59255, "score": 0.9997680187225342, "start": 59191, "tag": "KEY", "value": "f45668263a977a60c0111a93f2070f7bc20558f26840dd007c4d3083a90b1a95" }, { "context": "558f26840dd007c4d3083a90b1a95\\\",\n\\\"public_key\\\":\\\"03647e5790930f67ada5dede83ff7c7f6cf6b3076d3a6c98348fa8635853a753d5\\\"},\n\n{\\\"tx_hash\\\":\\\"788901fe347df34bbba5b0b811b7dcb", "end": 59344, "score": 0.9997576475143433, "start": 59276, "tag": "KEY", "value": "03647e5790930f67ada5dede83ff7c7f6cf6b3076d3a6c98348fa8635853a753d5\\\"" }, { "context": "\":\\\"2014-12-01T01:02:20.176Z\\\",\n\\\"private_key\\\":\\\"6f1a59678b01764f1eb415a53cf135de56e8bbafc36d18924f6b3c7c1fade191\\\",\n\\\"public_key\\\":\\\"029e1d34b7bb8b8bbcf7e8861131c", "end": 59671, "score": 0.9997618198394775, "start": 59607, "tag": "KEY", "value": "6f1a59678b01764f1eb415a53cf135de56e8bbafc36d18924f6b3c7c1fade191" }, { "context": "8bbafc36d18924f6b3c7c1fade191\\\",\n\\\"public_key\\\":\\\"029e1d34b7bb8b8bbcf7e8861131caaf5a4fd7c985043706dd6e967c8a4bf1f933\\\"},\n\n{\\\"tx_hash\\\":\\\"62e612858a11f764d6de72da806540d", "end": 59760, "score": 0.9997578859329224, "start": 59692, "tag": "KEY", "value": "029e1d34b7bb8b8bbcf7e8861131caaf5a4fd7c985043706dd6e967c8a4bf1f933\\\"" }, { "context": "\":\\\"2014-12-02T10:31:40.609Z\\\",\n\\\"private_key\\\":\\\"3ee1911f540e78be0ede946c0fff0749d6e2736a0450a293bbca2d1cfff7a9b8\\\",\n\\\"public_key\\\":\\\"020fac513f0c6494fe31fe73ba078", "end": 60087, "score": 0.9997557401657104, "start": 60023, "tag": "KEY", "value": "3ee1911f540e78be0ede946c0fff0749d6e2736a0450a293bbca2d1cfff7a9b8" }, { "context": "2736a0450a293bbca2d1cfff7a9b8\\\",\n\\\"public_key\\\":\\\"020fac513f0c6494fe31fe73ba07868aca1efede5f2ffbcc3a13bba44d879737d3\\\"},\n\n{\\\"tx_hash\\\":\\\"a740c53413f576cc6774c5e0e5e577e", "end": 60176, "score": 0.9994797110557556, "start": 60108, "tag": "KEY", "value": "020fac513f0c6494fe31fe73ba07868aca1efede5f2ffbcc3a13bba44d879737d3\\\"" }, { "context": "\":\\\"2014-12-04T05:21:26.521Z\\\",\n\\\"private_key\\\":\\\"e254e813d967d45239dafedaa459a62dbb241a5b428f0e20fad82cc4e89f909b\\\",\n\\\"public_key\\\":\\\"0326aa95f31beadd0d92dc2de14063c4", "end": 60506, "score": 0.9947667121887207, "start": 60439, "tag": "KEY", "value": "e254e813d967d45239dafedaa459a62dbb241a5b428f0e20fad82cc4e89f909b\\\"," }, { "context": "41a5b428f0e20fad82cc4e89f909b\\\",\n\\\"public_key\\\":\\\"0326aa95f31beadd0d92dc2de14063c4f02c1dca6a623956f19799977b795af52b\\\"},\n\n{\\\"tx_hash\\\":\\\"1596943406db888462b84b833319044", "end": 60592, "score": 0.9997285008430481, "start": 60524, "tag": "KEY", "value": "0326aa95f31beadd0d92dc2de14063c4f02c1dca6a623956f19799977b795af52b\\\"" }, { "context": "\":\\\"2014-12-05T04:41:18.769Z\\\",\n\\\"private_key\\\":\\\"e7974b349795db137054c9810ea68d56f715c3b4775af4f0820da5b33899355e\\\",\n\\\"public_key\\\":\\\"035d76821c1133b8243558742444d", "end": 60919, "score": 0.9997095465660095, "start": 60855, "tag": "KEY", "value": "e7974b349795db137054c9810ea68d56f715c3b4775af4f0820da5b33899355e" }, { "context": "5c3b4775af4f0820da5b33899355e\\\",\n\\\"public_key\\\":\\\"035d76821c1133b8243558742444d47597969ca8fe27c4d5388f3e068f675fd975\\\"},\n\n{\\\"tx_hash\\\":\\\"8fd29553b5dcbbee3f9f2348cc44fdd", "end": 61008, "score": 0.9997587203979492, "start": 60940, "tag": "KEY", "value": "035d76821c1133b8243558742444d47597969ca8fe27c4d5388f3e068f675fd975\\\"" }, { "context": "\":\\\"2014-12-06T03:31:32.361Z\\\",\n\\\"private_key\\\":\\\"84d66e22396612964d9cf18381fea09cbc0650db00eb8f8fbf1c842b9c474534\\\",\n\\\"public_key\\\":\\\"030edff4a25438aaa67e2275bb51f", "end": 61335, "score": 0.9997710585594177, "start": 61271, "tag": "KEY", "value": "84d66e22396612964d9cf18381fea09cbc0650db00eb8f8fbf1c842b9c474534" }, { "context": "650db00eb8f8fbf1c842b9c474534\\\",\n\\\"public_key\\\":\\\"030edff4a25438aaa67e2275bb51f0e1eb68771979dc304106d9552237a739bf4c\\\"},\n\n{\\\"tx_hash\\\":\\\"32240fc3fdbd0584dbe3cfd219c8991", "end": 61424, "score": 0.9997629523277283, "start": 61356, "tag": "KEY", "value": "030edff4a25438aaa67e2275bb51f0e1eb68771979dc304106d9552237a739bf4c\\\"" }, { "context": "\":\\\"2014-12-07T01:03:04.602Z\\\",\n\\\"private_key\\\":\\\"f266f6c53b2c4c11e6cbeee0ddc5dc1451424cd7841b09e572bbcf5154fde925\\\",\n\\\"public_key\\\":\\\"03e8c9ad12b7442bbf49883036171", "end": 61751, "score": 0.9997649192810059, "start": 61687, "tag": "KEY", "value": "f266f6c53b2c4c11e6cbeee0ddc5dc1451424cd7841b09e572bbcf5154fde925" }, { "context": "24cd7841b09e572bbcf5154fde925\\\",\n\\\"public_key\\\":\\\"03e8c9ad12b7442bbf49883036171343bbbd00a3870161f27efe22236fa89e7d95\\\"},\n\n{\\\"tx_hash\\\":\\\"cc6fb0bda4f2e417df47924453e28a6", "end": 61840, "score": 0.999756932258606, "start": 61772, "tag": "KEY", "value": "03e8c9ad12b7442bbf49883036171343bbbd00a3870161f27efe22236fa89e7d95\\\"" }, { "context": "\":\\\"2014-12-08T06:21:25.426Z\\\",\n\\\"private_key\\\":\\\"bce19c2f3d86b90fa19c978b8ff9fbf0b34a68d2cf6dd8f5ae98b2272724da07\\\",\n\\\"public_key\\\":\\\"031b3e0e39024099ef6748c4ff0d3", "end": 62167, "score": 0.9997668266296387, "start": 62103, "tag": "KEY", "value": "bce19c2f3d86b90fa19c978b8ff9fbf0b34a68d2cf6dd8f5ae98b2272724da07" }, { "context": "a68d2cf6dd8f5ae98b2272724da07\\\",\n\\\"public_key\\\":\\\"031b3e0e39024099ef6748c4ff0d35b97b1c32d9c9b3d55603d96ca89031e93167\\\"},\n\n{\\\"tx_hash\\\":\\\"ff889c510fb6c7f3f3461b29d8ed4e0", "end": 62256, "score": 0.9997689723968506, "start": 62188, "tag": "KEY", "value": "031b3e0e39024099ef6748c4ff0d35b97b1c32d9c9b3d55603d96ca89031e93167\\\"" }, { "context": "\":\\\"2014-12-09T21:31:35.358Z\\\",\n\\\"private_key\\\":\\\"afb2eec5f7efb84d778ed975576f4957ed9e49f0c461030ce57fbd84904e191e\\\",\n\\\"public_key\\\":\\\"02c8ec7261d2fd7d924e2479123f2", "end": 62583, "score": 0.9997383952140808, "start": 62519, "tag": "KEY", "value": "afb2eec5f7efb84d778ed975576f4957ed9e49f0c461030ce57fbd84904e191e" }, { "context": "e49f0c461030ce57fbd84904e191e\\\",\n\\\"public_key\\\":\\\"02c8ec7261d2fd7d924e2479123f22a0e569e763d263ac8bc40f18faf85706c51f\\\"},\n\n{\\\"tx_hash\\\":\\\"d2c9f2e2744e13456bf403d6e7ee88e", "end": 62672, "score": 0.9997634291648865, "start": 62604, "tag": "KEY", "value": "02c8ec7261d2fd7d924e2479123f22a0e569e763d263ac8bc40f18faf85706c51f\\\"" }, { "context": "\":\\\"2014-12-10T01:11:25.531Z\\\",\n\\\"private_key\\\":\\\"cf09274f0eb16994b76b9633502161e4751d1ad67dfdbce86fce1c8878f51d32\\\",\n\\\"public_key\\\":\\\"02f04e4f61e7d11e465ab36200c25", "end": 62999, "score": 0.9997682571411133, "start": 62935, "tag": "KEY", "value": "cf09274f0eb16994b76b9633502161e4751d1ad67dfdbce86fce1c8878f51d32" }, { "context": "d1ad67dfdbce86fce1c8878f51d32\\\",\n\\\"public_key\\\":\\\"02f04e4f61e7d11e465ab36200c25a565dec69d058cb5df6071cd718bd86c259f9\\\"},\n\n{\\\"tx_hash\\\":\\\"e82455ed01cda5baf84d93790701f8e", "end": 63088, "score": 0.9997626543045044, "start": 63020, "tag": "KEY", "value": "02f04e4f61e7d11e465ab36200c25a565dec69d058cb5df6071cd718bd86c259f9\\\"" }, { "context": "df6071cd718bd86c259f9\\\"},\n\n{\\\"tx_hash\\\":\\\"e82455ed01cda5baf84d93790701f8ecb7f08cbad38c69cc4d2941d891c8", "end": 63117, "score": 0.5969021320343018, "start": 63115, "tag": "KEY", "value": "01" }, { "context": "8bd86c259f9\\\"},\n\n{\\\"tx_hash\\\":\\\"e82455ed01cda5baf84d93790701f8ecb7f08cbad38c69cc4d2941d891c8f25f\\\",\n\\\"r", "end": 63128, "score": 0.662194550037384, "start": 63125, "tag": "KEY", "value": "4d9" }, { "context": "\":\\\"2014-12-15T07:11:58.195Z\\\",\n\\\"private_key\\\":\\\"c1f20b6079403baac1f3853624b938f46c875fa713d1f53c6b889a26c8b7bb6a\\\",\n\\\"public_key\\\":\\\"034e989f1c70b44ce005bc281f69b", "end": 63415, "score": 0.9997537136077881, "start": 63351, "tag": "KEY", "value": "c1f20b6079403baac1f3853624b938f46c875fa713d1f53c6b889a26c8b7bb6a" }, { "context": "75fa713d1f53c6b889a26c8b7bb6a\\\",\n\\\"public_key\\\":\\\"034e989f1c70b44ce005bc281f69b920325e65bc96d5aa445da0ee617e4d0888f8\\\"},\n\n{\\\"tx_hash\\\":\\\"9bc74c1389e34c836e4b66b8106bb1f", "end": 63504, "score": 0.9997324347496033, "start": 63436, "tag": "KEY", "value": "034e989f1c70b44ce005bc281f69b920325e65bc96d5aa445da0ee617e4d0888f8\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.328Z\\\",\n\\\"private_key\\\":\\\"edb624a48a7717a7a081f1a7926c98923ced522e99152336d07c2b5ee0e838af\\\",\n\\\"public_key\\\":\\\"040c0182d8e79c33479c5510411a8", "end": 63831, "score": 0.9984737038612366, "start": 63767, "tag": "KEY", "value": "edb624a48a7717a7a081f1a7926c98923ced522e99152336d07c2b5ee0e838af" }, { "context": "d522e99152336d07c2b5ee0e838af\\\",\n\\\"public_key\\\":\\\"040c0182d8e79c33479c5510411a888efff992c8d218be3ec5a72", "end": 63855, "score": 0.9995837807655334, "start": 63852, "tag": "KEY", "value": "040" }, { "context": "e4707992afe8e4099e2b2b2e45b6daca8f09ac5690c9110589c5a64c71a64aa463\\\"},\n\n{\\\"tx_hash\\\":\\\"4e3f39c404deeee", "end": 63968, "score": 0.792438268661499, "start": 63966, "tag": "KEY", "value": "c5" }, { "context": "\":\\\"2014-11-05T02:01:53.344Z\\\",\n\\\"private_key\\\":\\\"9f95ec49696d9e0057329178bd58792aa4d2e651d1690e1b07949feacbecdc19\\\",\n\\\"public_key\\\":\\\"0441c7e5617b0d2f513012e1ea64a", "end": 64311, "score": 0.9997584223747253, "start": 64247, "tag": "KEY", "value": "9f95ec49696d9e0057329178bd58792aa4d2e651d1690e1b07949feacbecdc19" }, { "context": "2e651d1690e1b07949feacbecdc19\\\",\n\\\"public_key\\\":\\\"0441c7e5617b0d2f513012e1ea64ac69cb8d4bfb6ed29ab4e468081086a153c98ab0e8e40051039f451ee5a59c88b339d062f0ce54cb01411d41265bc39fee1a6d\\\"},\n\n{\\\"tx_hash\\\":\\\"7729867b65e959d3ca78eb27428b8a9", "end": 64464, "score": 0.9997559189796448, "start": 64332, "tag": "KEY", "value": "0441c7e5617b0d2f513012e1ea64ac69cb8d4bfb6ed29ab4e468081086a153c98ab0e8e40051039f451ee5a59c88b339d062f0ce54cb01411d41265bc39fee1a6d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.353Z\\\",\n\\\"private_key\\\":\\\"c8a23de81df036e1b5bec6dabfed2c2701a7b2d9b2611256ad8e806d729b44db\\\",\n\\\"public_key\\\":\\\"041a35b00541e6b810caf24968968", "end": 64791, "score": 0.9996572136878967, "start": 64727, "tag": "KEY", "value": "c8a23de81df036e1b5bec6dabfed2c2701a7b2d9b2611256ad8e806d729b44db" }, { "context": "7b2d9b2611256ad8e806d729b44db\\\",\n\\\"public_key\\\":\\\"041a35b00541e6b810caf249689686f2affd58246be1bf64da4a12640db39b1b92890a994bad3104db5df3ecc39648a8b8eefa1059ba081816358a54d8c0fc2af2\\\"},\n\n{\\\"tx_hash", "end": 64908, "score": 0.9981493353843689, "start": 64812, "tag": "KEY", "value": "041a35b00541e6b810caf249689686f2affd58246be1bf64da4a12640db39b1b92890a994bad3104db5df3ecc39648a8" }, { "context": "4da4a12640db39b1b92890a994bad3104db5df3ecc39648a8b8eefa1059ba081816358a54d8c0fc2af2\\\"},\n\n{\\\"tx_hash\\\"", "end": 64910, "score": 0.9553058743476868, "start": 64909, "tag": "KEY", "value": "8" }, { "context": "4a12640db39b1b92890a994bad3104db5df3ecc39648a8b8eefa1059ba081816358a54d8c0fc2af2\\\"},\n\n{\\\"tx_hash\\\":\\\"c62c201342aa9f5bdc0bf22e075dac5", "end": 64944, "score": 0.9885405898094177, "start": 64912, "tag": "KEY", "value": "fa1059ba081816358a54d8c0fc2af2\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.363Z\\\",\n\\\"private_key\\\":\\\"bcf1c80da32d0c487acf7b48951a4aee69143bcc037c3d956af3fffb1ec87aaa\\\",\n\\\"public_key\\\":\\\"045a9b42a576814b61e393e02789f", "end": 65271, "score": 0.9996976852416992, "start": 65207, "tag": "KEY", "value": "bcf1c80da32d0c487acf7b48951a4aee69143bcc037c3d956af3fffb1ec87aaa" }, { "context": "43bcc037c3d956af3fffb1ec87aaa\\\",\n\\\"public_key\\\":\\\"045a9b42a576814b61e393e02789fa4bd29316f4dac6b63ffa50c4dc23e6bc50f16b1a7d96c5a5116393cce68c2eea162b3f3f89e04c63fa6616709fc873fa73f0\\\"},\n\n{\\\"tx_hash\\\":\\\"d14350bae9ebfd6d5fd1d1a14260725", "end": 65424, "score": 0.9997259974479675, "start": 65292, "tag": "KEY", "value": "045a9b42a576814b61e393e02789fa4bd29316f4dac6b63ffa50c4dc23e6bc50f16b1a7d96c5a5116393cce68c2eea162b3f3f89e04c63fa6616709fc873fa73f0\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.372Z\\\",\n\\\"private_key\\\":\\\"109a48b8319280016e2a2febdffc05e08455cc50528aa004548b495f20472577\\\",\n\\\"public_key\\\":\\\"04120fbee840958337a8d0278cf49", "end": 65751, "score": 0.9997510313987732, "start": 65687, "tag": "KEY", "value": "109a48b8319280016e2a2febdffc05e08455cc50528aa004548b495f20472577" }, { "context": "5cc50528aa004548b495f20472577\\\",\n\\\"public_key\\\":\\\"04120fbee840958337a8d0278cf491d8145a36b8d93def9e9f6a9742cdb4080d97e0a0d187021686ccfed63c083ed2312aa7cf91e018627f677d306b205fa7f432\\\"},\n\n{\\\"tx_hash\\\":\\\"f19de2eda6ceb4465f0f2f6e51699b7", "end": 65904, "score": 0.9997365474700928, "start": 65772, "tag": "KEY", "value": "04120fbee840958337a8d0278cf491d8145a36b8d93def9e9f6a9742cdb4080d97e0a0d187021686ccfed63c083ed2312aa7cf91e018627f677d306b205fa7f432\\\"" }, { "context": "_hash\\\":\\\"f19de2eda6ceb4465f0f2f6e51699b7e34d374c8bc7c8ca0d952c41aa2ab190a\\\",\n\\\"recipient\\\":\\\"15DA5aCRy12vvMZ7MYsd8y6UmXBvxF", "end": 65987, "score": 0.8945242166519165, "start": 65963, "tag": "KEY", "value": "bc7c8ca0d952c41aa2ab190a" }, { "context": "\":\\\"2014-11-05T02:01:53.382Z\\\",\n\\\"private_key\\\":\\\"0a125f1aef09d73afac6bc8d9e7afc231d0352cd47139d7a2c9e9df222c0bd0c\\\",\n\\\"public_key\\\":\\\"040e82d92ea3d273d4393b4e98553", "end": 66231, "score": 0.9997528195381165, "start": 66167, "tag": "KEY", "value": "0a125f1aef09d73afac6bc8d9e7afc231d0352cd47139d7a2c9e9df222c0bd0c" }, { "context": "352cd47139d7a2c9e9df222c0bd0c\\\",\n\\\"public_key\\\":\\\"040e82d92ea3d273d4393b4e9855365e511c416dc40779036d203b9e59008fff5bcd1d5565e366077cb77d025c23afc31c701fb49f71b7acdfcc7a884f2d106d65\\\"},\n\n{\\\"tx_hash\\\":\\\"955fce669b8e39ae8019c252d8b87fd", "end": 66384, "score": 0.9997461438179016, "start": 66252, "tag": "KEY", "value": "040e82d92ea3d273d4393b4e9855365e511c416dc40779036d203b9e59008fff5bcd1d5565e366077cb77d025c23afc31c701fb49f71b7acdfcc7a884f2d106d65\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.410Z\\\",\n\\\"private_key\\\":\\\"9749fcfe0f6694fb835c5435120def7abb95cbb1cdbd796f588c34ce66b104ca\\\",\n\\\"public_key\\\":\\\"04862a88984b896d2d00ee3ba509e", "end": 66711, "score": 0.9997220635414124, "start": 66647, "tag": "KEY", "value": "9749fcfe0f6694fb835c5435120def7abb95cbb1cdbd796f588c34ce66b104ca" }, { "context": "5cbb1cdbd796f588c34ce66b104ca\\\",\n\\\"public_key\\\":\\\"04862a88984b896d2d00ee3ba509eb57a4d9874264c5d6c7c0882c24aa18418fd73eb8ce9277bc1f8a14402f5fcc214889ab3031bd322a0711e8b9a8bcca91fbc1\\\"},\n\n{\\\"tx_hash\\\":\\\"eb2f56a706f8695c21866542c6fee70", "end": 66864, "score": 0.9996659755706787, "start": 66732, "tag": "KEY", "value": "04862a88984b896d2d00ee3ba509eb57a4d9874264c5d6c7c0882c24aa18418fd73eb8ce9277bc1f8a14402f5fcc214889ab3031bd322a0711e8b9a8bcca91fbc1\\\"" }, { "context": "\":\\\"2015-02-21T23:51:38.171Z\\\",\n\\\"private_key\\\":\\\"625554c1f90ef6414fba91bc927d98d1e16f52db45992a625dd6cc0a04946d01\\\",\n\\\"public_key\\\":\\\"0278d0cbe6364776067cf1df6ab21", "end": 67191, "score": 0.9997625946998596, "start": 67127, "tag": "KEY", "value": "625554c1f90ef6414fba91bc927d98d1e16f52db45992a625dd6cc0a04946d01" }, { "context": "f52db45992a625dd6cc0a04946d01\\\",\n\\\"public_key\\\":\\\"0278d0cbe6364776067cf1df6ab21b49116f1cfd129ac19808c51fa64efe02a327\\\"},\n\n{\\\"tx_hash\\\":\\\"7f8d7ef78b392baa65b3564ca4c2af9", "end": 67280, "score": 0.9997538924217224, "start": 67212, "tag": "KEY", "value": "0278d0cbe6364776067cf1df6ab21b49116f1cfd129ac19808c51fa64efe02a327\\\"" }, { "context": "\":\\\"2014-12-03T03:21:12.903Z\\\",\n\\\"private_key\\\":\\\"fac10a76fc58cb4db63f271333e8427224b635fcb213a98a7021b90ba9c9e0c5\\\",\n\\\"public_key\\\":\\\"025a26f6dd247d4f9087dcaf2fedf", "end": 67607, "score": 0.9997588992118835, "start": 67543, "tag": "KEY", "value": "fac10a76fc58cb4db63f271333e8427224b635fcb213a98a7021b90ba9c9e0c5" }, { "context": "635fcb213a98a7021b90ba9c9e0c5\\\",\n\\\"public_key\\\":\\\"025a26f6dd247d4f9087dcaf2fedf296441d6a533cdf2d4504146d7cabf4962fe1\\\"},\n\n{\\\"tx_hash\\\":\\\"ac053b59823bb9fc4f466ccebad61c1", "end": 67696, "score": 0.9997414946556091, "start": 67628, "tag": "KEY", "value": "025a26f6dd247d4f9087dcaf2fedf296441d6a533cdf2d4504146d7cabf4962fe1\\\"" }, { "context": "\":\\\"2014-12-12T03:03:00.623Z\\\",\n\\\"private_key\\\":\\\"dd7ca9be82ac43b4617c0303890cd7d3dcab9a0734d70112e7f042686155da23\\\",\n\\\"public_key\\\":\\\"030af256d3a126058f4cca78d046f", "end": 68023, "score": 0.9997433423995972, "start": 67959, "tag": "KEY", "value": "dd7ca9be82ac43b4617c0303890cd7d3dcab9a0734d70112e7f042686155da23" }, { "context": "b9a0734d70112e7f042686155da23\\\",\n\\\"public_key\\\":\\\"030af256d3a126058f4cca78d046ff333fe50575be5fdccbf96276611f9ef652ed\\\"},\n\n{\\\"tx_hash\\\":\\\"6d61fbd4c7c7cb957ba9bad778f6884", "end": 68112, "score": 0.9997158050537109, "start": 68044, "tag": "KEY", "value": "030af256d3a126058f4cca78d046ff333fe50575be5fdccbf96276611f9ef652ed\\\"" }, { "context": "\"},\n\n{\\\"tx_hash\\\":\\\"6d61fbd4c7c7cb957ba9bad778f6884f7a4b6fa586c2b49ce860ade584ced4bf\\\",\n\\\"recipient\\\"", "end": 68162, "score": 0.9949776530265808, "start": 68161, "tag": "KEY", "value": "4" }, { "context": ":\\\"6d61fbd4c7c7cb957ba9bad778f6884f7a4b6fa586c2b49ce860ade584ced4bf\\\",\n\\\"recipient\\\":\\\"1DruqemSaF2WiaU", "end": 68180, "score": 0.9857940077781677, "start": 68178, "tag": "KEY", "value": "ce" }, { "context": "\":\\\"2015-03-09T02:51:37.961Z\\\",\n\\\"private_key\\\":\\\"981aae545566e6e14a0e5986a26529cf23f750abad23fd1202426a1904fb5907\\\",\n\\\"public_key\\\":\\\"02d73978621fc8bcf09bb1b05600a", "end": 68439, "score": 0.999743640422821, "start": 68375, "tag": "KEY", "value": "981aae545566e6e14a0e5986a26529cf23f750abad23fd1202426a1904fb5907" }, { "context": "750abad23fd1202426a1904fb5907\\\",\n\\\"public_key\\\":\\\"02d73978621fc8bcf09bb1b05600a405561ec83004524e71c9f7438a04fa3e138e\\\"},\n\n{\\\"tx_hash\\\":\\\"110f9cc7eed95cdab83a75159dc80ce", "end": 68528, "score": 0.9997506737709045, "start": 68460, "tag": "KEY", "value": "02d73978621fc8bcf09bb1b05600a405561ec83004524e71c9f7438a04fa3e138e\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.420Z\\\",\n\\\"private_key\\\":\\\"ed6586801c0a49b773cb9d9f67e89bd22a2b4c9f5a8bb999e973661fd7b4a184\\\",\n\\\"public_key\\\":\\\"047982be2498f3ed5fe2b32a65f28", "end": 68855, "score": 0.9997543096542358, "start": 68791, "tag": "KEY", "value": "ed6586801c0a49b773cb9d9f67e89bd22a2b4c9f5a8bb999e973661fd7b4a184" }, { "context": "b4c9f5a8bb999e973661fd7b4a184\\\",\n\\\"public_key\\\":\\\"047982be2498f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1", "end": 68912, "score": 0.9997161030769348, "start": 68876, "tag": "KEY", "value": "047982be2498f3ed5fe2b32a65f28bf86e96" }, { "context": "ey\\\":\\\"047982be2498f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd903", "end": 68920, "score": 0.9455786347389221, "start": 68919, "tag": "KEY", "value": "5" }, { "context": "\\\":\\\"047982be2498f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd90306", "end": 68922, "score": 0.9406227469444275, "start": 68921, "tag": "KEY", "value": "3" }, { "context": "7982be2498f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497a", "end": 68932, "score": 0.6982213854789734, "start": 68928, "tag": "KEY", "value": "06fa" }, { "context": "f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497ab2a01d082af67", "end": 68945, "score": 0.8422446250915527, "start": 68938, "tag": "KEY", "value": "6b55aa1" }, { "context": "a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497ab2a01d082af67a18bb3", "end": 68951, "score": 0.8220227956771851, "start": 68949, "tag": "KEY", "value": "8b" }, { "context": "f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497ab2a01d082af67a18bb327", "end": 68953, "score": 0.9007006287574768, "start": 68952, "tag": "KEY", "value": "9" }, { "context": "960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497ab2a01d082af67a18bb3273d0\\\"},\n\n{", "end": 68963, "score": 0.6495518088340759, "start": 68960, "tag": "KEY", "value": "f15" }, { "context": "\":\\\"2014-11-05T02:01:53.430Z\\\",\n\\\"private_key\\\":\\\"71a81201529ee34a4658112f9012ad880b61512f276b1b0272aeb77c98bc9a1d\\\",\n\\\"public_key\\\":\\\"04491d08744b45eb9d296ebebc87e", "end": 69335, "score": 0.9997472167015076, "start": 69271, "tag": "KEY", "value": "71a81201529ee34a4658112f9012ad880b61512f276b1b0272aeb77c98bc9a1d" }, { "context": "1512f276b1b0272aeb77c98bc9a1d\\\",\n\\\"public_key\\\":\\\"04491d08744b45eb9d296ebebc87e5332ba79e57cab78b9f8fb3700cb5146d436303ef1190fe72dfebe7d1d831d69039bfdc6654e2f32a0a0e426fa4dc61235e92\\\"},\n\n{\\\"tx_hash\\\":\\\"0cdee6fec1e8fcfeef6877a3eb3755c", "end": 69488, "score": 0.9997366666793823, "start": 69356, "tag": "KEY", "value": "04491d08744b45eb9d296ebebc87e5332ba79e57cab78b9f8fb3700cb5146d436303ef1190fe72dfebe7d1d831d69039bfdc6654e2f32a0a0e426fa4dc61235e92\\\"" }, { "context": "041fb0d824507d\\\",\n\\\"recipient\\\":\\\"1Q6EwC7CpCMa9wfevktBXWhPZVicLzxpik\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2014-10-10T00:0", "end": 69625, "score": 0.997982382774353, "start": 69607, "tag": "KEY", "value": "vktBXWhPZVicLzxpik" }, { "context": "\":\\\"2014-11-05T02:01:53.447Z\\\",\n\\\"private_key\\\":\\\"6218934b21bace8094be87d7ce42a46079d3903da78c02f8c93e7c53fa14c8d1\\\",\n\\\"public_key\\\":\\\"048676e0ce04a0c9aad3e045ae422", "end": 69815, "score": 0.9997596740722656, "start": 69751, "tag": "KEY", "value": "6218934b21bace8094be87d7ce42a46079d3903da78c02f8c93e7c53fa14c8d1" }, { "context": "3903da78c02f8c93e7c53fa14c8d1\\\",\n\\\"public_key\\\":\\\"048676e0ce04a0c9aad3e045ae422f1d45ef4a50e6e856c4e77b52777e4b2e99d0d42c2aa16e4d77bc38493654338386185f8ec442747a75709f80dc2eb02abf27\\\"},\n\n{\\\"tx_hash\\\":\\\"e5f2600d775cce0ffaad0d49e17268d", "end": 69968, "score": 0.9997368454933167, "start": 69836, "tag": "KEY", "value": "048676e0ce04a0c9aad3e045ae422f1d45ef4a50e6e856c4e77b52777e4b2e99d0d42c2aa16e4d77bc38493654338386185f8ec442747a75709f80dc2eb02abf27\\\"" }, { "context": "\":\\\"2014-12-16T02:11:47.375Z\\\",\n\\\"private_key\\\":\\\"e88e69bc79b710e8cbd9dd7f58ab73ad95cb6a6ec6d6c147e5dca42df1c6b2b8\\\",\n\\\"public_key\\\":\\\"03dc0e265fcd2b2cb22b928cbf949", "end": 70295, "score": 0.9997721314430237, "start": 70231, "tag": "KEY", "value": "e88e69bc79b710e8cbd9dd7f58ab73ad95cb6a6ec6d6c147e5dca42df1c6b2b8" }, { "context": "b6a6ec6d6c147e5dca42df1c6b2b8\\\",\n\\\"public_key\\\":\\\"03dc0e265fcd2b2cb22b928cbf949d311c399fff1d5434ab698a047b5c17bf5a45\\\"},\n\n{\\\"tx", "end": 70343, "score": 0.9997442960739136, "start": 70316, "tag": "KEY", "value": "03dc0e265fcd2b2cb22b928cbf9" }, { "context": "\":\\\"2014-12-13T01:51:27.991Z\\\",\n\\\"private_key\\\":\\\"3e2570e93a41342806e8b905ea90f8f763219d2facf5a5f675c6a131b0a373cc\\\",\n\\\"public_key\\\":\\\"02daefafe4740ecef42e88f2aab26", "end": 70711, "score": 0.9997380971908569, "start": 70647, "tag": "KEY", "value": "3e2570e93a41342806e8b905ea90f8f763219d2facf5a5f675c6a131b0a373cc" }, { "context": "19d2facf5a5f675c6a131b0a373cc\\\",\n\\\"public_key\\\":\\\"02daefafe4740ecef42e88f2aab2649c7c1f5b89b33c81e9ac4149568888d7d48e\\\"},\n\n{\\\"tx_hash\\\":\\\"da504ee3868a3b33a17c1046107b374", "end": 70800, "score": 0.9997328519821167, "start": 70732, "tag": "KEY", "value": "02daefafe4740ecef42e88f2aab2649c7c1f5b89b33c81e9ac4149568888d7d48e\\\"" }, { "context": "\":\\\"2015-05-18T09:51:31.248Z\\\",\n\\\"private_key\\\":\\\"0c64b79aafc4462cbd17a430970301fe4c86913e8a5d83a17a593d460f72f5a0\\\",\n\\\"public_key\\\":\\\"03062379ab208353f751ec71e6910", "end": 71127, "score": 0.9996309876441956, "start": 71063, "tag": "KEY", "value": "0c64b79aafc4462cbd17a430970301fe4c86913e8a5d83a17a593d460f72f5a0" }, { "context": "6913e8a5d83a17a593d460f72f5a0\\\",\n\\\"public_key\\\":\\\"03062379ab208353f751ec71e69103c814c426692efc5dccbd07d62cc7966e34cf\\\"},\n\n{\\\"tx_hash\\\":\\\"2b60edaf17da94fd876eb298ec76cfc", "end": 71216, "score": 0.9997323155403137, "start": 71148, "tag": "KEY", "value": "03062379ab208353f751ec71e69103c814c426692efc5dccbd07d62cc7966e34cf\\\"" }, { "context": "\":\\\"2014-12-14T01:21:22.291Z\\\",\n\\\"private_key\\\":\\\"6790ffba71c9f400e6ce3af8489e15319c5c41cb26aceaf4b9988922ca261bf4\\\",\n\\\"public_key\\\":\\\"025735f9e278fe9b9907d5511d045", "end": 71543, "score": 0.9997616410255432, "start": 71479, "tag": "KEY", "value": "6790ffba71c9f400e6ce3af8489e15319c5c41cb26aceaf4b9988922ca261bf4" }, { "context": "c41cb26aceaf4b9988922ca261bf4\\\",\n\\\"public_key\\\":\\\"025735f9e278fe9b9907d5511d04563fa9bbaef327defb5ae7b39df28da13c359b\\\"},\n\n{\\\"tx_hash\\\":\\\"ad9d0483ef79b303615d1a78d09846a", "end": 71632, "score": 0.9997598528862, "start": 71564, "tag": "KEY", "value": "025735f9e278fe9b9907d5511d04563fa9bbaef327defb5ae7b39df28da13c359b\\\"" }, { "context": "\":\\\"2014-12-15T01:41:27.818Z\\\",\n\\\"private_key\\\":\\\"206746ed43049a8caea32e1b52187ea20e6c7a67d72d06320beb39ce36db0c6f\\\",\n\\\"public_key\\\":\\\"02bf0f95ab91596eecbb76815723b", "end": 71959, "score": 0.9997396469116211, "start": 71895, "tag": "KEY", "value": "206746ed43049a8caea32e1b52187ea20e6c7a67d72d06320beb39ce36db0c6f" }, { "context": "c7a67d72d06320beb39ce36db0c6f\\\",\n\\\"public_key\\\":\\\"02bf0f95ab91596eecbb76815723b03153d53a56ffee6d624324e4f396c70a5a53\\\"},\n\n{\\\"tx_hash\\\":\\\"257f8e66371e728160d020a90299c5a", "end": 72048, "score": 0.9997529983520508, "start": 71980, "tag": "KEY", "value": "02bf0f95ab91596eecbb76815723b03153d53a56ffee6d624324e4f396c70a5a53\\\"" }, { "context": "\":\\\"2015-02-03T18:11:44.812Z\\\",\n\\\"private_key\\\":\\\"83233700bc835942c37ed5fb080620df09b6bb67b0bb87574116eae33ade315f\\\",\n\\\"public_key\\\":\\\"0282e6119a830419786b352121498", "end": 72375, "score": 0.999763011932373, "start": 72311, "tag": "KEY", "value": "83233700bc835942c37ed5fb080620df09b6bb67b0bb87574116eae33ade315f" }, { "context": "6bb67b0bb87574116eae33ade315f\\\",\n\\\"public_key\\\":\\\"0282e6119a830419786b3521214980c3399e47399dca45c1a08c68c9ff9196f631\\\"},\n\n{\\\"tx_hash\\\":\\\"14c9813897febd3ce406717b010bb2e", "end": 72464, "score": 0.9997673034667969, "start": 72396, "tag": "KEY", "value": "0282e6119a830419786b3521214980c3399e47399dca45c1a08c68c9ff9196f631\\\"" }, { "context": "\":\\\"2014-12-17T08:04:36.447Z\\\",\n\\\"private_key\\\":\\\"61e794e782442742efbf20c935884be7ec3a7ba6174960c544bc20ba12ebc6c7\\\",\n\\\"public_key\\\":\\\"0279782892ef5bb40a03edbe76504", "end": 72791, "score": 0.9997481107711792, "start": 72727, "tag": "KEY", "value": "61e794e782442742efbf20c935884be7ec3a7ba6174960c544bc20ba12ebc6c7" }, { "context": "a7ba6174960c544bc20ba12ebc6c7\\\",\n\\\"public_key\\\":\\\"0279782892ef5bb40a03edbe76504dc58999e1632feec82c5415af8dbaabb25d5f\\\"},\n\n{\\\"tx_hash\\\":\\\"4ea030d2b5f63ac3a4fb39b4cd14e90", "end": 72880, "score": 0.9997072219848633, "start": 72812, "tag": "KEY", "value": "0279782892ef5bb40a03edbe76504dc58999e1632feec82c5415af8dbaabb25d5f\\\"" }, { "context": "\":\\\"2015-02-24T04:21:53.109Z\\\",\n\\\"private_key\\\":\\\"b825479f9c2dc020624c2ddf675c539b03dbd9ddd465195fd96e2a2d1b056cc2\\\",\n\\\"public_key\\\":\\\"03097a78d1fbe986d1ac36d3808e7", "end": 73207, "score": 0.9997749328613281, "start": 73143, "tag": "KEY", "value": "b825479f9c2dc020624c2ddf675c539b03dbd9ddd465195fd96e2a2d1b056cc2" }, { "context": "bd9ddd465195fd96e2a2d1b056cc2\\\",\n\\\"public_key\\\":\\\"03097a78d1fbe986d1ac36d3808e7c67eb09b5f6ee33f0771f8f739f48cda369d8\\\"},\n\n{\\\"tx_hash\\\":\\\"85d6f06fabb72", "end": 73278, "score": 0.9996753334999084, "start": 73228, "tag": "KEY", "value": "03097a78d1fbe986d1ac36d3808e7c67eb09b5f6ee33f0771f" }, { "context": "\":\\\"2015-04-19T05:51:45.524Z\\\",\n\\\"private_key\\\":\\\"ce9757eb478c339989e8096a45428bbc5e9be86ade59c00fab55f396fb933b98\\\",\n\\\"public_key\\\":\\\"02adb69a0a109a9446c3abb3f8e0f", "end": 73623, "score": 0.9997069239616394, "start": 73559, "tag": "KEY", "value": "ce9757eb478c339989e8096a45428bbc5e9be86ade59c00fab55f396fb933b98" }, { "context": "be86ade59c00fab55f396fb933b98\\\",\n\\\"public_key\\\":\\\"02adb69a0a109a9446c3abb3f8e0f104143d267be25d1450f17fdce32f7959ff6d\\\"},\n\n{\\\"tx_hash\\\":\\\"fc3282c0ba4c0858091ba7ac8486cd9", "end": 73712, "score": 0.9997062087059021, "start": 73644, "tag": "KEY", "value": "02adb69a0a109a9446c3abb3f8e0f104143d267be25d1450f17fdce32f7959ff6d\\\"" }, { "context": "\":\\\"2014-12-26T15:02:35.179Z\\\",\n\\\"private_key\\\":\\\"a5cafcef1f74c0ab747ed4a6f8503a6fa23950dd3b69bedb899928470172c227\\\",\n\\\"public_key\\\":\\\"036ca7e0f4428373d02726ee7ccf8", "end": 74039, "score": 0.999626100063324, "start": 73975, "tag": "KEY", "value": "a5cafcef1f74c0ab747ed4a6f8503a6fa23950dd3b69bedb899928470172c227" }, { "context": "950dd3b69bedb899928470172c227\\\",\n\\\"public_key\\\":\\\"036ca7e0f4428373d02726ee7ccf8d58b90bc3626dcbd205cb4a667aedca6b6833\\\"},\n\n{\\\"tx_hash\\\":\\\"5ef24006465b48e339ce3d7ae5af6da", "end": 74128, "score": 0.9997550249099731, "start": 74060, "tag": "KEY", "value": "036ca7e0f4428373d02726ee7ccf8d58b90bc3626dcbd205cb4a667aedca6b6833\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.456Z\\\",\n\\\"private_key\\\":\\\"c733bbf50970fd41f161210ccbde3aac5abce22e0edea024776a0b054c19f95d\\\",\n\\\"public_key\\\":\\\"04b553fd93c35c185bb68f62e6262", "end": 74455, "score": 0.9997637867927551, "start": 74391, "tag": "KEY", "value": "c733bbf50970fd41f161210ccbde3aac5abce22e0edea024776a0b054c19f95d" }, { "context": "ce22e0edea024776a0b054c19f95d\\\",\n\\\"public_key\\\":\\\"04b553fd93c35c185bb68f62e6262b2165cd95567d124da7716e81a95efd0cecaa189b596f078f973f65ba8d1bc02a55cee7fd52aec3adb136840dbf57677f3dde\\\"},\n\n{\\\"tx_hash\\\":\\\"ba88a190f4c65b3a069e74b04580c32", "end": 74608, "score": 0.9997634291648865, "start": 74476, "tag": "KEY", "value": "04b553fd93c35c185bb68f62e6262b2165cd95567d124da7716e81a95efd0cecaa189b596f078f973f65ba8d1bc02a55cee7fd52aec3adb136840dbf57677f3dde\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.466Z\\\",\n\\\"private_key\\\":\\\"a3eb11993e80e7ac5fc5f544fccb853a96e23c2636dbc027fbc35bf5f4f93ecc\\\",\n\\\"public_key\\\":\\\"04bb1ae921f50ca0dedf3e4bb9003", "end": 74935, "score": 0.9997336864471436, "start": 74871, "tag": "KEY", "value": "a3eb11993e80e7ac5fc5f544fccb853a96e23c2636dbc027fbc35bf5f4f93ecc" }, { "context": "23c2636dbc027fbc35bf5f4f93ecc\\\",\n\\\"public_key\\\":\\\"04bb1ae921f50ca0dedf3e4bb9003ac154677f17eba6b8e3807d88291a67d98821e0366000c540b98bfa4d9e21c3aa20ff7c110452beb44f83e85435b8705c3065\\\"},\n\n{\\\"tx_hash\\\":\\\"09088155124078b04884d8dea35fa26", "end": 75088, "score": 0.999534547328949, "start": 74956, "tag": "KEY", "value": "04bb1ae921f50ca0dedf3e4bb9003ac154677f17eba6b8e3807d88291a67d98821e0366000c540b98bfa4d9e21c3aa20ff7c110452beb44f83e85435b8705c3065\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.485Z\\\",\n\\\"private_key\\\":\\\"b49779f36c83debe6304824ea4afb9cb2b79867184810ab3dbccaac9f69d9db9\\\",\n\\\"public_key\\\":\\\"04a739be91d22750758be75ec4cfd", "end": 75415, "score": 0.999756395816803, "start": 75351, "tag": "KEY", "value": "b49779f36c83debe6304824ea4afb9cb2b79867184810ab3dbccaac9f69d9db9" }, { "context": "9867184810ab3dbccaac9f69d9db9\\\",\n\\\"public_key\\\":\\\"04a739be91d22750758be75ec4cfdf5422a02439ab791fa183934addd5590470dd9c473c8c8cfe1cfb07b01746dfaed83745f00283f63791d527", "end": 75502, "score": 0.999553382396698, "start": 75436, "tag": "KEY", "value": "04a739be91d22750758be75ec4cfdf5422a02439ab791fa183934addd5590470dd" }, { "context": "\":\\\"2014-11-05T02:01:53.494Z\\\",\n\\\"private_key\\\":\\\"3392c859559b0ec1007f31092bf2b13725f18166547d41c95e4626704409a6a6\\\",\n\\\"public_key\\\":\\\"0442bca53944607234a4ccbf6d3be", "end": 75895, "score": 0.999762237071991, "start": 75831, "tag": "KEY", "value": "3392c859559b0ec1007f31092bf2b13725f18166547d41c95e4626704409a6a6" }, { "context": "18166547d41c95e4626704409a6a6\\\",\n\\\"public_key\\\":\\\"0442bca53944607234a4ccbf6d3beaee114f7cdd45d8a14716bbafa578e64a525a9ed89b43d5d1d55ec03b7cc6be0b1cb0a6da4338bcd05957bfca2de1b5b6492e\\\"},\n\n{\\\"tx_hash\\\":\\\"708f1c7125cfc80ae6f5504f349d02d", "end": 76048, "score": 0.9997639060020447, "start": 75916, "tag": "KEY", "value": "0442bca53944607234a4ccbf6d3beaee114f7cdd45d8a14716bbafa578e64a525a9ed89b43d5d1d55ec03b7cc6be0b1cb0a6da4338bcd05957bfca2de1b5b6492e\\\"" }, { "context": "\":\\\"2015-02-04T02:02:40.718Z\\\",\n\\\"private_key\\\":\\\"6e7054cb82549bd83662c9b95ae930a5feec13331385d91b7f3e87607ccaf601\\\",\n\\\"public_key\\\":\\\"0340709adb58a5cdab904b4067015", "end": 76375, "score": 0.9997415542602539, "start": 76311, "tag": "KEY", "value": "6e7054cb82549bd83662c9b95ae930a5feec13331385d91b7f3e87607ccaf601" }, { "context": "c13331385d91b7f3e87607ccaf601\\\",\n\\\"public_key\\\":\\\"0340709adb58a5cdab904b40670154afdaabf98b7ae83e99e3ce5e3180754d19ca\\\"},\n\n{\\\"tx_hash\\\":\\\"6c81aee4f3a1c06a98dd7be17d08435", "end": 76464, "score": 0.9997119903564453, "start": 76396, "tag": "KEY", "value": "0340709adb58a5cdab904b40670154afdaabf98b7ae83e99e3ce5e3180754d19ca\\\"" }, { "context": "\":\\\"2014-12-26T08:20:35.137Z\\\",\n\\\"private_key\\\":\\\"9bf6ad1633b6ba059c68ffacb2fe4014842ccedd82e7d40f5beddce45cbdc2c9\\\",\n\\\"public_key\\\":\\\"02c0aff585590ade02636575024ce", "end": 76791, "score": 0.9997604489326477, "start": 76727, "tag": "KEY", "value": "9bf6ad1633b6ba059c68ffacb2fe4014842ccedd82e7d40f5beddce45cbdc2c9" }, { "context": "ccedd82e7d40f5beddce45cbdc2c9\\\",\n\\\"public_key\\\":\\\"02c0aff585590ade02636575024ce4e2c890d3092cacdfa41e7c1efd97e6207fcc\\\"},\n\n{\\\"tx_hash\\\":\\\"c169fbead005637c6506e47c6298334", "end": 76880, "score": 0.9997169375419617, "start": 76812, "tag": "KEY", "value": "02c0aff585590ade02636575024ce4e2c890d3092cacdfa41e7c1efd97e6207fcc\\\"" }, { "context": "005637c6506e47c6298334e86943c711d9cf7672d45f9ba4ce46c24\\\",\n\\\"recipient\\\":\\\"13WcphmngCvPaG5hrp622DH9iKXZzp", "end": 76963, "score": 0.9924660921096802, "start": 76958, "tag": "KEY", "value": "46c24" }, { "context": "\":\\\"2015-02-23T09:03:46.995Z\\\",\n\\\"private_key\\\":\\\"e459d34b4a03cb833e193350c47e062658c8bb2040e897c8702b9609aa1bd955\\\",\n\\\"public_key\\\":\\\"02561adbc8c85267a509b9d22820f", "end": 77207, "score": 0.9997657537460327, "start": 77143, "tag": "KEY", "value": "e459d34b4a03cb833e193350c47e062658c8bb2040e897c8702b9609aa1bd955" }, { "context": "8bb2040e897c8702b9609aa1bd955\\\",\n\\\"public_key\\\":\\\"02561adbc8c85267a509b9d22820fe93d4599f0d9c879b5399d7bc9ba4e762a90c\\\"},\n\n{\\\"tx_hash\\\":\\\"04fd971aff7716594dad0dd659e76b0", "end": 77296, "score": 0.9997640252113342, "start": 77228, "tag": "KEY", "value": "02561adbc8c85267a509b9d22820fe93d4599f0d9c879b5399d7bc9ba4e762a90c\\\"" }, { "context": "\":\\\"2015-02-25T02:32:01.536Z\\\",\n\\\"private_key\\\":\\\"835855fb248dc3af3f2a4c62f09c38d637d48df2e262235dc3e0bee285693658\\\",\n\\\"public_key\\\":\\\"0260655dff2e586a4df6fab49dfe2", "end": 77623, "score": 0.9997667670249939, "start": 77559, "tag": "KEY", "value": "835855fb248dc3af3f2a4c62f09c38d637d48df2e262235dc3e0bee285693658" }, { "context": "48df2e262235dc3e0bee285693658\\\",\n\\\"public_key\\\":\\\"0260655dff2e586a4df6fab49dfe2e851753cf18b68b145824c79315f197c087c7\\\"},\n\n{\\\"tx_hash\\\":\\\"acd740897db33b8fe5f", "end": 77700, "score": 0.9997506141662598, "start": 77644, "tag": "KEY", "value": "0260655dff2e586a4df6fab49dfe2e851753cf18b68b145824c79315" }, { "context": "a4df6fab49dfe2e851753cf18b68b145824c79315f197c087c7\\\"},\n\n{\\\"tx_hash\\\":\\\"acd740897db33b8fe5f136c0e7bb6", "end": 77710, "score": 0.7678937911987305, "start": 77709, "tag": "KEY", "value": "7" }, { "context": "\":\\\"2015-05-17T18:02:55.407Z\\\",\n\\\"private_key\\\":\\\"d26eab1116317315d6141a95f5a887a875681e9a51e4258afbbacd68bd2d200a\\\",\n\\\"public_key\\\":\\\"03c4eb3585c965a017f83a5690de9", "end": 78039, "score": 0.9997423887252808, "start": 77975, "tag": "KEY", "value": "d26eab1116317315d6141a95f5a887a875681e9a51e4258afbbacd68bd2d200a" }, { "context": "81e9a51e4258afbbacd68bd2d200a\\\",\n\\\"public_key\\\":\\\"03c4eb3585c965a017f83a5690de95315245a7a7216c4e66318c09095325a95477\\\"},\n\n{\\\"tx_hash\\\":\\\"ffba72b4b4ad75be9f99d70d7400137", "end": 78128, "score": 0.9997225403785706, "start": 78060, "tag": "KEY", "value": "03c4eb3585c965a017f83a5690de95315245a7a7216c4e66318c09095325a95477\\\"" }, { "context": "\":\\\"2014-12-26T08:20:35.902Z\\\",\n\\\"private_key\\\":\\\"73e7a80d839c5640f5243d7d5690b9423c0b7765b15b76e6128bf58deeffef75\\\",\n\\\"public_key\\\":\\\"027b8d8fb51f859cd896a3b529eed", "end": 78455, "score": 0.9997217059135437, "start": 78391, "tag": "KEY", "value": "73e7a80d839c5640f5243d7d5690b9423c0b7765b15b76e6128bf58deeffef75" }, { "context": "b7765b15b76e6128bf58deeffef75\\\",\n\\\"public_key\\\":\\\"027b8d8fb51f859cd896a3b529eeda8bb890abdb0ceb322b554086254d6a3a9e7c\\\"},\n\n{\\\"tx_hash\\\":\\\"02bb58e93fad82be2181a9df61e0c6b", "end": 78544, "score": 0.999732255935669, "start": 78476, "tag": "KEY", "value": "027b8d8fb51f859cd896a3b529eeda8bb890abdb0ceb322b554086254d6a3a9e7c\\\"" }, { "context": "\":\\\"2014-12-26T08:20:36.257Z\\\",\n\\\"private_key\\\":\\\"a945659753cd101eee0d639e4395d7f9764a6b5900ecbabfeee5d2f26daeec9d\\\",\n\\\"public_key\\\":\\\"02584ece2f48a8af47fd31aa74408", "end": 78871, "score": 0.9997392892837524, "start": 78807, "tag": "KEY", "value": "a945659753cd101eee0d639e4395d7f9764a6b5900ecbabfeee5d2f26daeec9d" }, { "context": "a6b5900ecbabfeee5d2f26daeec9d\\\",\n\\\"public_key\\\":\\\"02584ece2f48a8af47fd31aa74408fdb5028b73ac9167654269f1b97da06e5ae80\\\"},\n\n{\\\"tx_hash\\\":\\\"61ce589b5c7bf41a7faa951fc61ae33", "end": 78960, "score": 0.9997416138648987, "start": 78892, "tag": "KEY", "value": "02584ece2f48a8af47fd31aa74408fdb5028b73ac9167654269f1b97da06e5ae80\\\"" }, { "context": "\":\\\"2014-12-26T08:20:36.599Z\\\",\n\\\"private_key\\\":\\\"4113e3d64b5feb74c350673fbcd6836c9bdb481ef6ff44717c3cd18df980c5fc\\\",\n\\\"public_key\\\":\\\"03df74e5f553464382b71fc81829a", "end": 79287, "score": 0.9997727274894714, "start": 79223, "tag": "KEY", "value": "4113e3d64b5feb74c350673fbcd6836c9bdb481ef6ff44717c3cd18df980c5fc" }, { "context": "b481ef6ff44717c3cd18df980c5fc\\\",\n\\\"public_key\\\":\\\"03df74e5f553464382b71fc81829a9c36016ff7401a3326722b1002ea6bb6112ce\\\"},\n\n{\\\"tx_hash\\\":\\\"0db2399293136f4269af3365e5abe3b", "end": 79376, "score": 0.9997689723968506, "start": 79308, "tag": "KEY", "value": "03df74e5f553464382b71fc81829a9c36016ff7401a3326722b1002ea6bb6112ce\\\"" }, { "context": "\":\\\"2015-02-23T11:32:12.414Z\\\",\n\\\"private_key\\\":\\\"ca4bcd86b45bace84fc21f880c49c34e2032be17cec7406654f68465bb399f7d\\\",\n\\\"public_key\\\":\\\"0243dc90a6432aa95d936b1d17e4c", "end": 79703, "score": 0.9997639060020447, "start": 79639, "tag": "KEY", "value": "ca4bcd86b45bace84fc21f880c49c34e2032be17cec7406654f68465bb399f7d" }, { "context": "2be17cec7406654f68465bb399f7d\\\",\n\\\"public_key\\\":\\\"0243dc90a6432aa95d936b1d17e4c2540bdcadaf203fc31aa2ccd3a62fd7399240\\\"},\n\n{\\\"tx_hash\\\":\\\"0269c5bfa1a3772836a48fc03f6f9c2", "end": 79792, "score": 0.9997711181640625, "start": 79724, "tag": "KEY", "value": "0243dc90a6432aa95d936b1d17e4c2540bdcadaf203fc31aa2ccd3a62fd7399240\\\"" }, { "context": "\":\\\"2014-12-26T08:20:36.999Z\\\",\n\\\"private_key\\\":\\\"754f6658ab6810dbb18a526945d34cb7827f0720acfabb613deb3ee47b1b43c7\\\",\n\\\"public_key\\\":\\\"0218f1e15f5f42116d34e56f761d0", "end": 80119, "score": 0.9997738003730774, "start": 80055, "tag": "KEY", "value": "754f6658ab6810dbb18a526945d34cb7827f0720acfabb613deb3ee47b1b43c7" }, { "context": "f0720acfabb613deb3ee47b1b43c7\\\",\n\\\"public_key\\\":\\\"0218f1e15f5f42116d34e56f761d0c2199e02b73d8db91b76b69a9d4868dc6df4b\\\"},\n\n{\\\"tx_hash\\\":\\\"7e0724c204189970d7597b4d54b6f4e", "end": 80208, "score": 0.9997718930244446, "start": 80140, "tag": "KEY", "value": "0218f1e15f5f42116d34e56f761d0c2199e02b73d8db91b76b69a9d4868dc6df4b\\\"" }, { "context": "\":\\\"2014-12-26T08:20:37.294Z\\\",\n\\\"private_key\\\":\\\"844b37f6c440f724d4b9163e023a36f6dc04736948444d4c8bc635ccc96fe6b7\\\",\n\\\"public_key\\\":\\\"023af3f861557559cc4e691609506", "end": 80535, "score": 0.999774158000946, "start": 80471, "tag": "KEY", "value": "844b37f6c440f724d4b9163e023a36f6dc04736948444d4c8bc635ccc96fe6b7" }, { "context": "4736948444d4c8bc635ccc96fe6b7\\\",\n\\\"public_key\\\":\\\"023af3f861557559cc4e691609506f5cd71007940d88683d3dffa575261293be9c\\\"},\n\n{\\\"tx_hash\\\":\\\"a0330747df03510406923c21bfeb097", "end": 80624, "score": 0.9997367858886719, "start": 80556, "tag": "KEY", "value": "023af3f861557559cc4e691609506f5cd71007940d88683d3dffa575261293be9c\\\"" }, { "context": "\":\\\"2014-12-26T15:02:35.691Z\\\",\n\\\"private_key\\\":\\\"51f09ac7bc7be80ce451281b0b91d23506e0aa45b5f356c0fc1f351f5d2b7613\\\",\n\\\"public_key\\\":\\\"0379352e0901010c38e0f7f96e27a", "end": 80951, "score": 0.9997376203536987, "start": 80887, "tag": "KEY", "value": "51f09ac7bc7be80ce451281b0b91d23506e0aa45b5f356c0fc1f351f5d2b7613" }, { "context": "0aa45b5f356c0fc1f351f5d2b7613\\\",\n\\\"public_key\\\":\\\"0379352e0901010c38e0f7f96e27a9cdce9659957fca201b6489041b1ea5e865ab\\\"},\n\n{\\\"tx_hash\\\":\\\"7e31fb18377e5799a96b1c973eebc9c", "end": 81040, "score": 0.9997161030769348, "start": 80972, "tag": "KEY", "value": "0379352e0901010c38e0f7f96e27a9cdce9659957fca201b6489041b1ea5e865ab\\\"" }, { "context": "\":\\\"2014-12-26T15:02:36.335Z\\\",\n\\\"private_key\\\":\\\"9f254d835921c3365b200b423936f792182d8b508ef8cb3274cb81a4f33f0043\\\",\n\\\"public_key\\\":\\\"023b1ee98c3966e94223250278771", "end": 81367, "score": 0.9997447729110718, "start": 81303, "tag": "KEY", "value": "9f254d835921c3365b200b423936f792182d8b508ef8cb3274cb81a4f33f0043" }, { "context": "d8b508ef8cb3274cb81a4f33f0043\\\",\n\\\"public_key\\\":\\\"023b1ee98c3966e94223250278771f8fee37e9fce9fba118275ed9ba69319320d3\\\"},\n\n{\\\"tx_hash\\\":\\\"2e9f04c056b71a8c1a1aa6fbb193822", "end": 81456, "score": 0.9996713399887085, "start": 81388, "tag": "KEY", "value": "023b1ee98c3966e94223250278771f8fee37e9fce9fba118275ed9ba69319320d3\\\"" }, { "context": "\":\\\"2014-12-27T01:11:40.472Z\\\",\n\\\"private_key\\\":\\\"fa1bd8837a20ea190f725ccec69054387e230f0e340afef943d8632b4560d74d\\\",\n\\\"public_key\\\":\\\"030bdb5e755cb477387cdea2896ed", "end": 81783, "score": 0.9997184872627258, "start": 81719, "tag": "KEY", "value": "fa1bd8837a20ea190f725ccec69054387e230f0e340afef943d8632b4560d74d" }, { "context": "30f0e340afef943d8632b4560d74d\\\",\n\\\"public_key\\\":\\\"030bdb5e755cb477387cdea2896ed9d90d2a4428f7599ece54ad1c19b33eef4f90\\\"},\n\n{\\\"tx_hash\\\":\\\"bf8334fd848413ff2e5de56a7ab2fd0", "end": 81872, "score": 0.9996758699417114, "start": 81804, "tag": "KEY", "value": "030bdb5e755cb477387cdea2896ed9d90d2a4428f7599ece54ad1c19b33eef4f90\\\"" }, { "context": ":08.816Z\\\",\n\\\"updated_at\\\":\\\"2014-12-28T03:02:55.126Z\\\",\n\\\"private_key\\\":\\\"d4bbd1a11ecdc0c24f07c920d9fe", "end": 82113, "score": 0.9997127652168274, "start": 82110, "tag": "KEY", "value": "26Z" }, { "context": "\":\\\"2014-12-28T03:02:55.126Z\\\",\n\\\"private_key\\\":\\\"d4bbd1a11ecdc0c24f07c920d9fe2ed6162aa36bcffb8b2c3643195da9f5152b\\\",\n\\\"public_key\\\":\\\"0201f802ff6415a41d11464e62e3f", "end": 82199, "score": 0.9997552633285522, "start": 82135, "tag": "KEY", "value": "d4bbd1a11ecdc0c24f07c920d9fe2ed6162aa36bcffb8b2c3643195da9f5152b" }, { "context": "aa36bcffb8b2c3643195da9f5152b\\\",\n\\\"public_key\\\":\\\"0201f802ff6415a41d11464e62e3f5ad12e4f39f5c5626737d8a0dc51385aef5c0\\\"},\n\n{\\\"tx_hash\\\":\\\"ffa5713c36e3323697503c224f9162d", "end": 82288, "score": 0.9997231364250183, "start": 82220, "tag": "KEY", "value": "0201f802ff6415a41d11464e62e3f5ad12e4f39f5c5626737d8a0dc51385aef5c0\\\"" }, { "context": "\":\\\"2014-12-29T01:02:54.033Z\\\",\n\\\"private_key\\\":\\\"f185ebbf67f2b4810d4562b586a3ce5658cae4d0adc95eae84a8aceba3d7c9b9\\\",\n\\\"public_key\\\":\\\"022d456138ee179503b5874bc6dfa", "end": 82615, "score": 0.9997360706329346, "start": 82551, "tag": "KEY", "value": "f185ebbf67f2b4810d4562b586a3ce5658cae4d0adc95eae84a8aceba3d7c9b9" }, { "context": "ae4d0adc95eae84a8aceba3d7c9b9\\\",\n\\\"public_key\\\":\\\"022d456138ee179503b5874bc6dfa9a1d4d2f0c6c60b24eef0df5dc5143c6c0ca0\\\"},\n\n{\\\"tx_hash\\\":\\\"3fee60b09cc02aa7b6bbc7c4dd4118e", "end": 82704, "score": 0.9997571706771851, "start": 82636, "tag": "KEY", "value": "022d456138ee179503b5874bc6dfa9a1d4d2f0c6c60b24eef0df5dc5143c6c0ca0\\\"" }, { "context": "\":\\\"2014-12-30T13:31:37.244Z\\\",\n\\\"private_key\\\":\\\"d32df6f49f395c348fe7825cb89d76fc0985608c86f00fe39ff373a10a4c0d67\\\",\n\\\"public_key\\\":\\\"02fb6b22ce3b43640de47dcb971374c4", "end": 83034, "score": 0.9941558837890625, "start": 82967, "tag": "KEY", "value": "d32df6f49f395c348fe7825cb89d76fc0985608c86f00fe39ff373a10a4c0d67\\\"," }, { "context": "5608c86f00fe39ff373a10a4c0d67\\\",\n\\\"public_key\\\":\\\"02fb6b22ce3b43640de47dcb971374c4648c330b119a07c98edbd81994904953f0\\\"},\n\n{\\\"tx_hash\\\":\\\"f464b79ade56edc9d7f8bbb6c3d63f8", "end": 83120, "score": 0.9997751712799072, "start": 83052, "tag": "KEY", "value": "02fb6b22ce3b43640de47dcb971374c4648c330b119a07c98edbd81994904953f0\\\"" }, { "context": "\":\\\"2015-02-05T12:12:12.061Z\\\",\n\\\"private_key\\\":\\\"466496deb7bafa68a40048b05fb82c80d96a9adf385d21b574850a0d463d2544\\\",\n\\\"public_key\\\":\\\"038803862a23108439f69ae049d6f", "end": 83447, "score": 0.9997760057449341, "start": 83383, "tag": "KEY", "value": "466496deb7bafa68a40048b05fb82c80d96a9adf385d21b574850a0d463d2544" }, { "context": "a9adf385d21b574850a0d463d2544\\\",\n\\\"public_key\\\":\\\"038803862a23108439f69ae049d6f5a2b9befc75115f57fcc29ba8d8b3283b33c9\\\"},\n\n{\\\"tx_hash\\\":\\\"77509145bed99546b2182b5d587bd00", "end": 83536, "score": 0.9997742176055908, "start": 83468, "tag": "KEY", "value": "038803862a23108439f69ae049d6f5a2b9befc75115f57fcc29ba8d8b3283b33c9\\\"" }, { "context": "\":\\\"2015-02-26T05:42:36.352Z\\\",\n\\\"private_key\\\":\\\"767aff12e7937a91ac7d99e69f22dbe5466f7daede8241577fa7999ccb90518e\\\",\n\\\"public_key\\\":\\\"029c4fff483310f5f3c1807d73dfd", "end": 83863, "score": 0.9997232556343079, "start": 83799, "tag": "KEY", "value": "767aff12e7937a91ac7d99e69f22dbe5466f7daede8241577fa7999ccb90518e" }, { "context": "f7daede8241577fa7999ccb90518e\\\",\n\\\"public_key\\\":\\\"029c4fff483310f5f3c1807d73dfd01fa764d6351cf53a5794897bfc8852e0cdde\\\"},\n\n{\\\"tx_hash\\\":\\\"16b023d73816bf57d476ada2ed857e9", "end": 83952, "score": 0.9997462034225464, "start": 83884, "tag": "KEY", "value": "029c4fff483310f5f3c1807d73dfd01fa764d6351cf53a5794897bfc8852e0cdde\\\"" }, { "context": "\":\\\"2015-04-06T03:21:37.565Z\\\",\n\\\"private_key\\\":\\\"afca8ff5d01f9659c0caa0e30cc91084381c837b4a2244b0a184d4facc4bd44d\\\",\n\\\"public_key\\\":\\\"021410de0c2b8ede64f03150c8699", "end": 84279, "score": 0.9997578263282776, "start": 84215, "tag": "KEY", "value": "afca8ff5d01f9659c0caa0e30cc91084381c837b4a2244b0a184d4facc4bd44d" }, { "context": "c837b4a2244b0a184d4facc4bd44d\\\",\n\\\"public_key\\\":\\\"021410de0c2b8ede64f03150c86995b6b4b787bacc1d3f4eff6827d9aaf95a6be5\\\"},\n\n{", "end": 84323, "score": 0.9997156262397766, "start": 84300, "tag": "KEY", "value": "021410de0c2b8ede64f0315" }, { "context": "\":\\\"2015-04-05T10:12:02.208Z\\\",\n\\\"private_key\\\":\\\"8768eb5427eb4eb8bcc3c3edabf6f3b6db97613280081734bcd2e02d5c52eaaf\\\",\n\\\"public_key\\\":\\\"03016f946c412f82569453b9ad6dc", "end": 84695, "score": 0.9997276067733765, "start": 84631, "tag": "KEY", "value": "8768eb5427eb4eb8bcc3c3edabf6f3b6db97613280081734bcd2e02d5c52eaaf" }, { "context": "7613280081734bcd2e02d5c52eaaf\\\",\n\\\"public_key\\\":\\\"03016f946c412f82569453b9ad6dca5a490fd875656e8487e72a8b2418a7e01757\\\"},\n\n{\\\"tx_hash\\\":\\\"47389bb2838241eca93235f00211b75", "end": 84784, "score": 0.9997034668922424, "start": 84716, "tag": "KEY", "value": "03016f946c412f82569453b9ad6dca5a490fd875656e8487e72a8b2418a7e01757\\\"" }, { "context": "\":\\\"2015-04-07T13:03:15.670Z\\\",\n\\\"private_key\\\":\\\"259c9b16c170b0d30f33f1be53c8f2c55c7af88dab5ca38dd6ca248ab063f0e9\\\",\n\\\"public_key\\\":\\\"03adb93ed21fcfe713eeab1b4f9fc", "end": 85111, "score": 0.9995737075805664, "start": 85047, "tag": "KEY", "value": "259c9b16c170b0d30f33f1be53c8f2c55c7af88dab5ca38dd6ca248ab063f0e9" }, { "context": "af88dab5ca38dd6ca248ab063f0e9\\\",\n\\\"public_key\\\":\\\"03adb93ed21fcfe713eeab1b4f9fcc0c3a0637de52d061ed321281f1c5ea5624c5\\\"},\n\n{\\\"tx_hash\\\":\\\"1780f4b7edc3ceffb85cf853d864461", "end": 85200, "score": 0.9995402693748474, "start": 85132, "tag": "KEY", "value": "03adb93ed21fcfe713eeab1b4f9fcc0c3a0637de52d061ed321281f1c5ea5624c5\\\"" }, { "context": "\":\\\"2015-04-13T03:32:15.501Z\\\",\n\\\"private_key\\\":\\\"c66a51344e5b55f1e287e9ff543f897e6d550c3ed1c8882e54be4e40b21bb08f\\\",\n\\\"public_key\\\":\\\"029ae96cd96d46bf7570eab945a9d", "end": 85527, "score": 0.9997434020042419, "start": 85463, "tag": "KEY", "value": "c66a51344e5b55f1e287e9ff543f897e6d550c3ed1c8882e54be4e40b21bb08f" }, { "context": "50c3ed1c8882e54be4e40b21bb08f\\\",\n\\\"public_key\\\":\\\"029ae96cd96d46bf7570eab945a9dc5cdbc88c7b581cef5c99329da5d94eb84566\\\"},\n\n{\\\"tx_hash\\\":\\\"d3eb9cd216da609b9cc29258aab0cea", "end": 85616, "score": 0.9997579455375671, "start": 85548, "tag": "KEY", "value": "029ae96cd96d46bf7570eab945a9dc5cdbc88c7b581cef5c99329da5d94eb84566\\\"" }, { "context": "\":\\\"2015-04-18T08:41:32.039Z\\\",\n\\\"private_key\\\":\\\"9f5e3eca85febeff1f86263dd9ba58dd22a8fc6bbb74cff9f0aa1587601c9260\\\",\n\\\"public_key\\\":\\\"03f8b1602d5326e69146441f5b8d6", "end": 85943, "score": 0.9997544288635254, "start": 85879, "tag": "KEY", "value": "9f5e3eca85febeff1f86263dd9ba58dd22a8fc6bbb74cff9f0aa1587601c9260" }, { "context": "8fc6bbb74cff9f0aa1587601c9260\\\",\n\\\"public_key\\\":\\\"03f8b1602d5326e69146441f5b8d610447d7788bd241f289c5d1dbff7f9ee42039\\\"},\n\n{\\\"tx_hash\\\":\\\"7b00e00558dbe54e07687e966fbf767", "end": 86032, "score": 0.9997578859329224, "start": 85964, "tag": "KEY", "value": "03f8b1602d5326e69146441f5b8d610447d7788bd241f289c5d1dbff7f9ee42039\\\"" }, { "context": "\":\\\"2015-04-18T19:11:52.573Z\\\",\n\\\"private_key\\\":\\\"ca260864e63cfbab7fdd707838f9ea5ffcc3b754eccfabcc3d13db3d1dd89ea3\\\",\n\\\"public_key\\\":\\\"029f5ad8d4d4db41f9e28ab7d0a3c", "end": 86359, "score": 0.9997696876525879, "start": 86295, "tag": "KEY", "value": "ca260864e63cfbab7fdd707838f9ea5ffcc3b754eccfabcc3d13db3d1dd89ea3" }, { "context": "3b754eccfabcc3d13db3d1dd89ea3\\\",\n\\\"public_key\\\":\\\"029f5ad8d4d4db41f9e28ab7d0a3ccff5fb30005b941b09b8e97be6272ff64410a\\\"},\n\n{\\\"tx_hash\\\":\\\"bda2605ebd825142d4e78dc58522aad", "end": 86448, "score": 0.9997562766075134, "start": 86380, "tag": "KEY", "value": "029f5ad8d4d4db41f9e28ab7d0a3ccff5fb30005b941b09b8e97be6272ff64410a\\\"" }, { "context": "\":\\\"2015-04-21T08:51:37.763Z\\\",\n\\\"private_key\\\":\\\"df7d27f7a1b565a4a5679aa1d70d34228a9703d8b6a62f1c541d957e5c90d437\\\",\n\\\"public_key\\\":\\\"02991e931baa3b740b81070b696d5", "end": 86774, "score": 0.9997774362564087, "start": 86710, "tag": "KEY", "value": "df7d27f7a1b565a4a5679aa1d70d34228a9703d8b6a62f1c541d957e5c90d437" }, { "context": "703d8b6a62f1c541d957e5c90d437\\\",\n\\\"public_key\\\":\\\"02991e931baa3b740b81070b696d5518bae44dc06114040fc46cf6b4930f31a8dd\\\"},\n\n{\\\"tx_hash\\\":\\\"cb18d149f57c62f5cdd9e74937df1c2", "end": 86863, "score": 0.9997766017913818, "start": 86795, "tag": "KEY", "value": "02991e931baa3b740b81070b696d5518bae44dc06114040fc46cf6b4930f31a8dd\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.507Z\\\",\n\\\"private_key\\\":\\\"d3ba3bbe82aeb9079afc79f68cc84f57eff10fa43ea3bcb4d135e05cc47f2cd4\\\",\n\\\"public_key\\\":\\\"045590e8a114878a699f8fc269cd7", "end": 87190, "score": 0.9997766017913818, "start": 87126, "tag": "KEY", "value": "d3ba3bbe82aeb9079afc79f68cc84f57eff10fa43ea3bcb4d135e05cc47f2cd4" }, { "context": "10fa43ea3bcb4d135e05cc47f2cd4\\\",\n\\\"public_key\\\":\\\"045590e8a114878a699f8fc269cd768637b3a77d0d91fa40cdf56c09a0267d6f8a63102ecc67a87c7d22910e3ecd42e07b5bc82f14b2be2f6dbe6624", "end": 87281, "score": 0.9997673630714417, "start": 87211, "tag": "KEY", "value": "045590e8a114878a699f8fc269cd768637b3a77d0d91fa40cdf56c09a0267d6f8a6310" }, { "context": "fc269cd768637b3a77d0d91fa40cdf56c09a0267d6f8a63102ecc67a87c7d22910e3ecd42e07b5bc82f14b2be2f6dbe66247422", "end": 87285, "score": 0.9997046589851379, "start": 87282, "tag": "KEY", "value": "ecc" }, { "context": "cd768637b3a77d0d91fa40cdf56c09a0267d6f8a63102ecc67a87c7d22910e3ecd42e07b5bc82f14b2be2f6dbe662474229f5", "end": 87288, "score": 0.969277560710907, "start": 87287, "tag": "KEY", "value": "a" }, { "context": "6f8a63102ecc67a87c7d22910e3ecd42e07b5bc82f14b2be2f6dbe662474229f5ea7\\\"},\n\n{\\\"tx_hash\\\":\\\"b4d902789d21", "end": 87324, "score": 0.9869011044502258, "start": 87323, "tag": "KEY", "value": "6" }, { "context": "\":\\\"2015-01-03T19:02:35.343Z\\\",\n\\\"private_key\\\":\\\"43d97b5938931031897a39d7aa03c24d1986a3a633dc3c71a360cb4db242af22\\\",\n\\\"public_key\\\":\\\"038ec24f461d7cbb94f22043f08c9", "end": 87670, "score": 0.9997503161430359, "start": 87606, "tag": "KEY", "value": "43d97b5938931031897a39d7aa03c24d1986a3a633dc3c71a360cb4db242af22" }, { "context": "6a3a633dc3c71a360cb4db242af22\\\",\n\\\"public_key\\\":\\\"038ec24f461d7cbb94f22043f08c9aaa511dcab32986fc303b3eed9b4290c1edf3\\\"},\n\n{\\\"tx_hash\\\":\\\"4a6851a492d1e56b9b1b9ba4fa277aa", "end": 87759, "score": 0.9997380375862122, "start": 87691, "tag": "KEY", "value": "038ec24f461d7cbb94f22043f08c9aaa511dcab32986fc303b3eed9b4290c1edf3\\\"" }, { "context": "\":\\\"2014-12-31T15:21:27.404Z\\\",\n\\\"private_key\\\":\\\"21ee4b99b1e2b73b934375d0b166287641c9318270cf3b810fdcb68bc85e63d1\\\",\n\\\"public_key\\\":\\\"039041ed3d38df7b33154deee0f0e", "end": 88086, "score": 0.9997283220291138, "start": 88022, "tag": "KEY", "value": "21ee4b99b1e2b73b934375d0b166287641c9318270cf3b810fdcb68bc85e63d1" }, { "context": "9318270cf3b810fdcb68bc85e63d1\\\",\n\\\"public_key\\\":\\\"039041ed3d38df7b33154deee0f0e7f00d1406d71b7924e987ab14f40205f1fb6a\\\"},\n\n{\\\"tx_hash\\\":\\\"182ab2e142833d58a844be450b0f480", "end": 88175, "score": 0.9997171759605408, "start": 88107, "tag": "KEY", "value": "039041ed3d38df7b33154deee0f0e7f00d1406d71b7924e987ab14f40205f1fb6a\\\"" }, { "context": "\":\\\"2015-01-01T04:31:34.367Z\\\",\n\\\"private_key\\\":\\\"2baca669f0f370009e2a3c460b09c310fd3ad979558b58bceac19b1c8bcb144d\\\",\n\\\"public_key\\\":\\\"037f8bf4b48a8476578e0aed93afa", "end": 88502, "score": 0.9997642636299133, "start": 88438, "tag": "KEY", "value": "2baca669f0f370009e2a3c460b09c310fd3ad979558b58bceac19b1c8bcb144d" }, { "context": "ad979558b58bceac19b1c8bcb144d\\\",\n\\\"public_key\\\":\\\"037f8bf4b48a8476578e0aed93afa26005a8a1bd796df88b3548b46b78fd182126\\\"},\n\n{\\\"tx_hash\\\":\\\"0412d45d4e794d781a326a606a48240", "end": 88591, "score": 0.9997544288635254, "start": 88523, "tag": "KEY", "value": "037f8bf4b48a8476578e0aed93afa26005a8a1bd796df88b3548b46b78fd182126\\\"" }, { "context": "\":\\\"2015-01-02T11:41:39.408Z\\\",\n\\\"private_key\\\":\\\"cf067495c0eb4d4f8e1dad6a6d05195a4b4ead71a08143d37625acddefd8971f\\\",\n\\\"public_key\\\":\\\"02f51f59952447048709c032ae8f1", "end": 88918, "score": 0.9997501373291016, "start": 88854, "tag": "KEY", "value": "cf067495c0eb4d4f8e1dad6a6d05195a4b4ead71a08143d37625acddefd8971f" }, { "context": "ead71a08143d37625acddefd8971f\\\",\n\\\"public_key\\\":\\\"02f51f59952447048709c032ae8f112b84a057a32f11827b2aa2ae57513070d4f6\\\"},\n\n{\\\"tx_hash\\\":\\\"1a0fc9688bd38866c7f3abb5b35bd85", "end": 89007, "score": 0.9997567534446716, "start": 88939, "tag": "KEY", "value": "02f51f59952447048709c032ae8f112b84a057a32f11827b2aa2ae57513070d4f6\\\"" }, { "context": "\":\\\"2015-01-04T09:51:38.685Z\\\",\n\\\"private_key\\\":\\\"61763ccd8e7d42ea1a1a3c8828c9e7d29aa486752c8401a9b96ff4e2761b11c0\\\",\n\\\"public_key\\\":\\\"033a97a1d3704f37145895eb08e23", "end": 89334, "score": 0.9997727870941162, "start": 89270, "tag": "KEY", "value": "61763ccd8e7d42ea1a1a3c8828c9e7d29aa486752c8401a9b96ff4e2761b11c0" }, { "context": "486752c8401a9b96ff4e2761b11c0\\\",\n\\\"public_key\\\":\\\"033a97a1d3704f37145895eb08e2362b2962a5ced7a478cfb4bfdd99ad833bac42\\\"},\n\n{\\\"tx_hash\\\":\\\"0bc8b895e90f140900914892e656dd7", "end": 89423, "score": 0.999748945236206, "start": 89355, "tag": "KEY", "value": "033a97a1d3704f37145895eb08e2362b2962a5ced7a478cfb4bfdd99ad833bac42\\\"" }, { "context": "\":\\\"2015-01-07T06:11:30.856Z\\\",\n\\\"private_key\\\":\\\"de6bbfd326fc08dba35e02eef97a78462290c67a2ef25e30c52cd4afc0757625\\\",\n\\\"public_key\\\":\\\"03650de7cc5310ec99b67f7d4fd40", "end": 89750, "score": 0.9997183680534363, "start": 89686, "tag": "KEY", "value": "de6bbfd326fc08dba35e02eef97a78462290c67a2ef25e30c52cd4afc0757625" }, { "context": "0c67a2ef25e30c52cd4afc0757625\\\",\n\\\"public_key\\\":\\\"03650de7cc5310ec99b67f7d4fd4005d59fe08ce0eff8d6c29fef2809547f2de78\\\"},\n\n{\\\"tx_hash\\\":\\\"51d5ab218951cd8ad36c22c90e9b2ad", "end": 89839, "score": 0.9996975064277649, "start": 89771, "tag": "KEY", "value": "03650de7cc5310ec99b67f7d4fd4005d59fe08ce0eff8d6c29fef2809547f2de78\\\"" }, { "context": "\":\\\"2015-01-05T07:02:51.195Z\\\",\n\\\"private_key\\\":\\\"3c3d120a144d42f8ed27b90daec96e5eb6b80159e5c8d458780c1fcaa8024021\\\",\n\\\"public_key\\\":\\\"0397728d3f5c9f6b36046255f7923", "end": 90166, "score": 0.9997419714927673, "start": 90102, "tag": "KEY", "value": "3c3d120a144d42f8ed27b90daec96e5eb6b80159e5c8d458780c1fcaa8024021" }, { "context": "80159e5c8d458780c1fcaa8024021\\\",\n\\\"public_key\\\":\\\"0397728d3f5c9f6b36046255f7923f2ebcce85083ea8ba4bc306ae0bf955fdbd9c\\\"},\n\n{\\", "end": 90211, "score": 0.9996976852416992, "start": 90187, "tag": "KEY", "value": "0397728d3f5c9f6b36046255" }, { "context": "\":\\\"2015-01-06T05:21:35.194Z\\\",\n\\\"private_key\\\":\\\"b21a062bbd36b1f1f631e92ff90c72b9edeeb94dbf573cf42fb45fc036da2b3e\\\",\n\\\"public_key\\\":\\\"03218b89814e87159a3b247c88f1e", "end": 90582, "score": 0.9997573494911194, "start": 90518, "tag": "KEY", "value": "b21a062bbd36b1f1f631e92ff90c72b9edeeb94dbf573cf42fb45fc036da2b3e" }, { "context": "eb94dbf573cf42fb45fc036da2b3e\\\",\n\\\"public_key\\\":\\\"03218b89814e87159a3b247c88f1e06bf2b78a436e4b5b798810d7d3f592f20d00\\\"},\n\n{\\\"tx_hash\\\":\\\"fc77ed3cc859b6ea0d52444492203c9", "end": 90671, "score": 0.9997532963752747, "start": 90603, "tag": "KEY", "value": "03218b89814e87159a3b247c88f1e06bf2b78a436e4b5b798810d7d3f592f20d00\\\"" }, { "context": "\":\\\"2015-01-09T02:31:37.362Z\\\",\n\\\"private_key\\\":\\\"abfcc6d49011e81b8935682aa8bc64a67835d3b7c27a626a1bd96ae70e4e8d08\\\",\n\\\"public_key\\\":\\\"03c06de354b0b7d6e7d7b79e35a39", "end": 90998, "score": 0.9997286200523376, "start": 90934, "tag": "KEY", "value": "abfcc6d49011e81b8935682aa8bc64a67835d3b7c27a626a1bd96ae70e4e8d08" }, { "context": "5d3b7c27a626a1bd96ae70e4e8d08\\\",\n\\\"public_key\\\":\\\"03c06de354b0b7d6e7d7b79e35a39de9df1c7f272f4cb0c8066c67c1ba2e48d37d\\\"},\n\n{\\\"tx_hash\\\":\\\"d948f615c9c8ac456573839b7a7e911", "end": 91087, "score": 0.9997538328170776, "start": 91019, "tag": "KEY", "value": "03c06de354b0b7d6e7d7b79e35a39de9df1c7f272f4cb0c8066c67c1ba2e48d37d\\\"" }, { "context": "\":\\\"2015-01-08T02:21:36.417Z\\\",\n\\\"private_key\\\":\\\"d8b2f7185c8c78e2cf04f7ad796f71a46984c4daa11f2f17c1b66f5b26d04d19\\\",\n\\\"public_key\\\":\\\"0214393b2180e16b93fc3d9de9766", "end": 91414, "score": 0.9997762441635132, "start": 91350, "tag": "KEY", "value": "d8b2f7185c8c78e2cf04f7ad796f71a46984c4daa11f2f17c1b66f5b26d04d19" }, { "context": "4c4daa11f2f17c1b66f5b26d04d19\\\",\n\\\"public_key\\\":\\\"0214393b2180e16b93fc3d9de97669b947313115b42efd87e084a744a5d221bfe6\\\"},\n\n{\\\"tx_hash\\\":\\\"269b902c36787deb2541e1596d7a701", "end": 91503, "score": 0.999768078327179, "start": 91435, "tag": "KEY", "value": "0214393b2180e16b93fc3d9de97669b947313115b42efd87e084a744a5d221bfe6\\\"" }, { "context": "\":\\\"2015-01-10T08:11:48.324Z\\\",\n\\\"private_key\\\":\\\"2db85f4b75babbeeea41995b8a7be5e3d2da0ddb367a565f762e79e8064ac428\\\",\n\\\"public_key\\\":\\\"0287a415bf817acf4e8383ba53298", "end": 91830, "score": 0.9997599720954895, "start": 91766, "tag": "KEY", "value": "2db85f4b75babbeeea41995b8a7be5e3d2da0ddb367a565f762e79e8064ac428" }, { "context": "a0ddb367a565f762e79e8064ac428\\\",\n\\\"public_key\\\":\\\"0287a415bf817acf4e8383ba532987796664805d90a25335d056efbff73ce07b80\\\"},\n\n{\\\"tx_hash\\\":\\\"cfeec1dcec94c588483a0f25a63aa6e", "end": 91919, "score": 0.9997377395629883, "start": 91851, "tag": "KEY", "value": "0287a415bf817acf4e8383ba532987796664805d90a25335d056efbff73ce07b80\\\"" }, { "context": "\":\\\"2015-01-11T09:02:32.880Z\\\",\n\\\"private_key\\\":\\\"21a81d189c3350349b62b9f8bab9232163538b229544e9af6cffdbf8eb11a15b\\\",\n\\\"public_key\\\":\\\"025d82924ccaae2ff2ab6b75d90cf", "end": 92246, "score": 0.9997746348381042, "start": 92182, "tag": "KEY", "value": "21a81d189c3350349b62b9f8bab9232163538b229544e9af6cffdbf8eb11a15b" }, { "context": "38b229544e9af6cffdbf8eb11a15b\\\",\n\\\"public_key\\\":\\\"025d82924ccaae2ff2ab6b75d90cf48c19a15c549d1f5e4a7be54d3e17f1d0eaeb\\\"},\n\n{\\\"tx_hash\\\":\\\"9e412776afc88a91f0dc0921b2d0533", "end": 92335, "score": 0.9997546076774597, "start": 92267, "tag": "KEY", "value": "025d82924ccaae2ff2ab6b75d90cf48c19a15c549d1f5e4a7be54d3e17f1d0eaeb\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.527Z\\\",\n\\\"private_key\\\":\\\"39b1809ca5cd73f5fb1233cbc4504122b475dad4df2adaeb460e5b0ec0ebbb08\\\",\n\\\"public_key\\\":\\\"043cf118f77d82750a4852f39fa18", "end": 92662, "score": 0.9997465014457703, "start": 92598, "tag": "KEY", "value": "39b1809ca5cd73f5fb1233cbc4504122b475dad4df2adaeb460e5b0ec0ebbb08" }, { "context": "5dad4df2adaeb460e5b0ec0ebbb08\\\",\n\\\"public_key\\\":\\\"043cf118f77d82750a4852f39fa18f1d4533628efa5fcb1e3a1d2d49585c0de7d9f224877ee78a755aeeb7c13f434a5d03d09344380b39caf75af4944ed6e3b7f1\\\"},\n\n{", "end": 92770, "score": 0.9996486306190491, "start": 92683, "tag": "KEY", "value": "043cf118f77d82750a4852f39fa18f1d4533628efa5fcb1e3a1d2d49585c0de7d9f224877ee78a755aeeb7c" }, { "context": "8efa5fcb1e3a1d2d49585c0de7d9f224877ee78a755aeeb7c13f434a5d03d09344380b39caf75af4944ed6e3b7f1\\\"},\n\n{\\\"tx_h", "end": 92776, "score": 0.9574921727180481, "start": 92771, "tag": "KEY", "value": "3f434" }, { "context": "1d2d49585c0de7d9f224877ee78a755aeeb7c13f434a5d03d09344380b39caf75af4944ed6e3b7f1\\\"},\n\n{\\\"tx_hash\\\":\\\"", "end": 92784, "score": 0.9883200526237488, "start": 92783, "tag": "KEY", "value": "9" }, { "context": "c0de7d9f224877ee78a755aeeb7c13f434a5d03d09344380b39caf75af4944ed6e3b7f1\\\"},\n\n{\\\"tx_hash\\\":\\\"959730b5fd7ff6df09f8e971c80806b", "end": 92815, "score": 0.9903441667556763, "start": 92792, "tag": "KEY", "value": "9caf75af4944ed6e3b7f1\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.537Z\\\",\n\\\"private_key\\\":\\\"87bcdbfbbf7410bd1cae2598eabdf35f4a00ed0a92e1299fce458b587ccbc30f\\\",\n\\\"public_key\\\":\\\"04951ea0640fa8047f48041931035", "end": 93142, "score": 0.9996585249900818, "start": 93078, "tag": "KEY", "value": "87bcdbfbbf7410bd1cae2598eabdf35f4a00ed0a92e1299fce458b587ccbc30f" }, { "context": "0ed0a92e1299fce458b587ccbc30f\\\",\n\\\"public_key\\\":\\\"04951ea0640fa8047f480419310356f9612da0168670684662c13ba4e4c3e6900232d9ef74614dbaf3b9cbbc4ff6364664928fa7d8ae7c489f92d2c9d868644c46\\\"},\n\n{\\\"tx_hash\\\":\\\"c00940fe6d0976db9e53a5f41505cce", "end": 93295, "score": 0.9997530579566956, "start": 93163, "tag": "KEY", "value": "04951ea0640fa8047f480419310356f9612da0168670684662c13ba4e4c3e6900232d9ef74614dbaf3b9cbbc4ff6364664928fa7d8ae7c489f92d2c9d868644c46\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.556Z\\\",\n\\\"private_key\\\":\\\"994ccde9c55ad5f8e1b1942db448f1287195d2e2afcaffde8248ef1c1d2cc017\\\",\n\\\"public_key\\\":\\\"04e4bfaf6afd9303b4b83370ac7ea", "end": 93622, "score": 0.9996944069862366, "start": 93558, "tag": "KEY", "value": "994ccde9c55ad5f8e1b1942db448f1287195d2e2afcaffde8248ef1c1d2cc017" }, { "context": "5d2e2afcaffde8248ef1c1d2cc017\\\",\n\\\"public_key\\\":\\\"04e4bfaf6afd9303b4b83370ac7ea7bfddea1a921c6615ea0064905eeb5c618b4999f96f6470dfa3f8389a55c095a8350bfa5a218de9d2bbcd0b903be16780a446\\\"},\n\n{\\\"tx_hash\\\":\\\"3b42e20f69db1ad6f00ca56a0b2ae7c", "end": 93775, "score": 0.9997552633285522, "start": 93643, "tag": "KEY", "value": "04e4bfaf6afd9303b4b83370ac7ea7bfddea1a921c6615ea0064905eeb5c618b4999f96f6470dfa3f8389a55c095a8350bfa5a218de9d2bbcd0b903be16780a446\\\"" }, { "context": "1ad6f00ca56a0b2ae7c483c4f2733be759bdbc69b49feb318703\\\",\n\\\"recipient\\\":\\\"1QKkr49YoLFo6Z6inHiPhfhAYFxWj9", "end": 93858, "score": 0.7598598003387451, "start": 93856, "tag": "KEY", "value": "03" }, { "context": "\":\\\"2014-11-05T02:01:53.565Z\\\",\n\\\"private_key\\\":\\\"efff3139a5216f7e80a9b5d4d71ab6d1324a697ba20daaa4dd975348923ee84c\\\",\n\\\"public_key\\\":\\\"046cc59df6b9c4cc5197328eb1949", "end": 94102, "score": 0.99968421459198, "start": 94038, "tag": "KEY", "value": "efff3139a5216f7e80a9b5d4d71ab6d1324a697ba20daaa4dd975348923ee84c" }, { "context": "a697ba20daaa4dd975348923ee84c\\\",\n\\\"public_key\\\":\\\"046cc59df6b9c4cc5197328eb1949231c88966a44ba380b2c47b7fd65546aff536df9bfab0a0d816d9a4016fd62d399f95e71b0cb9645a219e9ab9c9acb0d8e046\\\"},\n\n{\\\"tx_hash\\\":\\\"36330ecb94f53ef7502618885e4ee1e", "end": 94255, "score": 0.9896663427352905, "start": 94123, "tag": "KEY", "value": "046cc59df6b9c4cc5197328eb1949231c88966a44ba380b2c47b7fd65546aff536df9bfab0a0d816d9a4016fd62d399f95e71b0cb9645a219e9ab9c9acb0d8e046\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.590Z\\\",\n\\\"private_key\\\":\\\"175e36efc5178d85438e83752e413dfba939fcf13600687923eba2c518a9b6fc\\\",\n\\\"public_key\\\":\\\"04ae1bfdbc34d4786104d5816e9d1", "end": 94582, "score": 0.9996252059936523, "start": 94518, "tag": "KEY", "value": "175e36efc5178d85438e83752e413dfba939fcf13600687923eba2c518a9b6fc" }, { "context": "9fcf13600687923eba2c518a9b6fc\\\",\n\\\"public_key\\\":\\\"04ae1bfdbc34d4786104d5816e9d1339044d1c6f7673b9b4cad09a990da3a65ffb830254d72ef6c2ff8070a5bb84956fc7c770d60dcc53c2eaf0cddbf0f6cdf976\\\"},\n\n{\\\"tx_hash\\\":\\\"b83800314a4c8bd79393fac714eea04", "end": 94735, "score": 0.9997573494911194, "start": 94603, "tag": "KEY", "value": "04ae1bfdbc34d4786104d5816e9d1339044d1c6f7673b9b4cad09a990da3a65ffb830254d72ef6c2ff8070a5bb84956fc7c770d60dcc53c2eaf0cddbf0f6cdf976\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.601Z\\\",\n\\\"private_key\\\":\\\"2297aee3e474ef00241adeba64fb5f7aab2091c38f8a398a7aa8f93c86f356b3\\\",\n\\\"public_key\\\":\\\"04bce5843da8e8879197a965940ed", "end": 95062, "score": 0.9997351169586182, "start": 94998, "tag": "KEY", "value": "2297aee3e474ef00241adeba64fb5f7aab2091c38f8a398a7aa8f93c86f356b3" }, { "context": "091c38f8a398a7aa8f93c86f356b3\\\",\n\\\"public_key\\\":\\\"04bce5843da8e8879197a965940ed51c396b14e692451023b2f489cf623de203acf51200ee85dcb4529cd98e4612f9566645757f9eb5c1834912037fb3afcb37fe\\\"},\n\n{\\\"tx_hash\\\":\\\"23d03659209b3c6fa8ea08cee15e4bb", "end": 95215, "score": 0.9997527003288269, "start": 95083, "tag": "KEY", "value": "04bce5843da8e8879197a965940ed51c396b14e692451023b2f489cf623de203acf51200ee85dcb4529cd98e4612f9566645757f9eb5c1834912037fb3afcb37fe\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.619Z\\\",\n\\\"private_key\\\":\\\"db8b86008429a08cd35368dfcd253c9090d8e8f536b60d603f584cc6fa543e59\\\",\n\\\"public_key\\\":\\\"041fc9291757e74416f1bcaf00f19", "end": 95542, "score": 0.9997440576553345, "start": 95478, "tag": "KEY", "value": "db8b86008429a08cd35368dfcd253c9090d8e8f536b60d603f584cc6fa543e59" }, { "context": "8e8f536b60d603f584cc6fa543e59\\\",\n\\\"public_key\\\":\\\"041fc9291757e74416f1bcaf00f19cc1d8695f0aad1303d2725549babf66362793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\\\"},\n\n{\\\"tx_hash", "end": 95659, "score": 0.999619722366333, "start": 95563, "tag": "KEY", "value": "041fc9291757e74416f1bcaf00f19cc1d8695f0aad1303d2725549babf66362793673cda21a4472e1551add4437824ed" }, { "context": "2725549babf66362793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\\\"},\n\n{\\\"tx_hash\\\":\\\"", "end": 95664, "score": 0.8455473184585571, "start": 95660, "tag": "KEY", "value": "ccdc" }, { "context": "49babf66362793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\\\"},\n\n{\\\"tx_hash\\\":\\\"36", "end": 95666, "score": 0.9946067929267883, "start": 95665, "tag": "KEY", "value": "4" }, { "context": "abf66362793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\\\"},\n\n{\\\"tx_hash\\\":\\\"3661ef8a", "end": 95672, "score": 0.9511594772338867, "start": 95668, "tag": "KEY", "value": "8264" }, { "context": "62793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\\\"},\n\n{\\\"tx_hash\\\":\\\"3661ef8aa0cdabf903e6ff9ea240b48", "end": 95695, "score": 0.9937844276428223, "start": 95674, "tag": "KEY", "value": "1989a21f483d69e4878\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.628Z\\\",\n\\\"private_key\\\":\\\"f2cbf3f7eb3a70165ac0cda36757bd781c985defea4c70a55c02cac662f50061\\\",\n\\\"public_key\\\":\\\"04713383422a965b2a5fbb9189451", "end": 96021, "score": 0.9996866583824158, "start": 95957, "tag": "KEY", "value": "f2cbf3f7eb3a70165ac0cda36757bd781c985defea4c70a55c02cac662f50061" }, { "context": "85defea4c70a55c02cac662f50061\\\",\n\\\"public_key\\\":\\\"04713383422a965b2a5fbb918945104f4f39f66a4102c3c8321af963e25fef736859884f708303049dde9496af30cf17f8abf3b80620ed597f545c112e628eaffa\\\"},\n\n{\\\"tx_hash\\\":\\\"8bc4889e0134508b4cdec5cd972fcfc", "end": 96174, "score": 0.9997182488441467, "start": 96042, "tag": "KEY", "value": "04713383422a965b2a5fbb918945104f4f39f66a4102c3c8321af963e25fef736859884f708303049dde9496af30cf17f8abf3b80620ed597f545c112e628eaffa\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.638Z\\\",\n\\\"private_key\\\":\\\"2608f83789fdeda48aa274b0ab3b9594a081cb7255bf52f6fefdf55d713248f7\\\",\n\\\"public_key\\\":\\\"04048d6062354ede32b1c4e275d1f", "end": 96501, "score": 0.9997535943984985, "start": 96437, "tag": "KEY", "value": "2608f83789fdeda48aa274b0ab3b9594a081cb7255bf52f6fefdf55d713248f7" }, { "context": "1cb7255bf52f6fefdf55d713248f7\\\",\n\\\"public_key\\\":\\\"04048d6062354ede32b1c4e275d1f588502fd5e9301c5fc2bca698634eae2e9bac26f169f46e8ca459a250f36c70e2ba882149d4900d8ffb68b2d7216c2500f4b2\\\"},\n\n{\\\"tx_hash\\\":\\\"ffcdf1aae1acb22d9c81641e545ba20", "end": 96654, "score": 0.9997524619102478, "start": 96522, "tag": "KEY", "value": "04048d6062354ede32b1c4e275d1f588502fd5e9301c5fc2bca698634eae2e9bac26f169f46e8ca459a250f36c70e2ba882149d4900d8ffb68b2d7216c2500f4b2\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.647Z\\\",\n\\\"private_key\\\":\\\"0c5685176d7b0594f6fe6182403f6f79a1ebe9daeb0c1405825eb99bb5ad4daf\\\",\n\\\"public_key\\\":\\\"045a01281da061850238e9704f2c1", "end": 96981, "score": 0.9997383952140808, "start": 96917, "tag": "KEY", "value": "0c5685176d7b0594f6fe6182403f6f79a1ebe9daeb0c1405825eb99bb5ad4daf" }, { "context": "be9daeb0c1405825eb99bb5ad4daf\\\",\n\\\"public_key\\\":\\\"045a01281da061850238e9704f2c1cbb3b3f16f5d88d8579f598bdab2ffefc616aa8ae19e74b46061025e741785d19eb91d371a9b2b276da821655378184543bfd\\\"},\n\n{\\\"tx_hash\\", "end": 97099, "score": 0.9978426694869995, "start": 97002, "tag": "KEY", "value": "045a01281da061850238e9704f2c1cbb3b3f16f5d88d8579f598bdab2ffefc616aa8ae19e74b46061025e741785d19eb9" }, { "context": "dab2ffefc616aa8ae19e74b46061025e741785d19eb91d371a9b2b276da821655378184543bfd\\\"},\n\n{\\\"tx_hash\\\":\\\"e4b", "end": 97106, "score": 0.8756207227706909, "start": 97105, "tag": "KEY", "value": "9" }, { "context": "fc616aa8ae19e74b46061025e741785d19eb91d371a9b2b276da821655378184543bfd\\\"},\n\n{\\\"tx_hash\\\":\\\"e4b2966b3f9c99ba188d3667cbc32b4", "end": 97134, "score": 0.9751837253570557, "start": 97112, "tag": "KEY", "value": "da821655378184543bfd\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.656Z\\\",\n\\\"private_key\\\":\\\"88c3918c7f7c873bb3b00b79865ba5c9464031c0f98651ffb1558f226e9ddf65\\\",\n\\\"public_key\\\":\\\"04aab3e693017d7137e3fab17a348", "end": 97461, "score": 0.9997197985649109, "start": 97397, "tag": "KEY", "value": "88c3918c7f7c873bb3b00b79865ba5c9464031c0f98651ffb1558f226e9ddf65" }, { "context": "031c0f98651ffb1558f226e9ddf65\\\",\n\\\"public_key\\\":\\\"04aab3e693017d7137e3fab17a3488473968dda14bab60ae574df3fed29f61963b2a322dfc4d05b32cb6998d3ea11a6c0f207379af2bbc5ae8259bba8cd8e1c5fb\\\"},\n\n{\\\"tx_hash\\\":\\\"025e34722395211a0f05847679334a6", "end": 97614, "score": 0.999733030796051, "start": 97482, "tag": "KEY", "value": "04aab3e693017d7137e3fab17a3488473968dda14bab60ae574df3fed29f61963b2a322dfc4d05b32cb6998d3ea11a6c0f207379af2bbc5ae8259bba8cd8e1c5fb\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.675Z\\\",\n\\\"private_key\\\":\\\"ece17df0425227fa2f4d764b17f8f10123f38d72713b3faccc2e3e1159d74e9b\\\",\n\\\"public_key\\\":\\\"040c7d98252c3aa9f13dac550f6a6", "end": 97941, "score": 0.999718964099884, "start": 97877, "tag": "KEY", "value": "ece17df0425227fa2f4d764b17f8f10123f38d72713b3faccc2e3e1159d74e9b" }, { "context": "38d72713b3faccc2e3e1159d74e9b\\\",\n\\\"public_key\\\":\\\"040c7d98252c3aa9f13dac550f6a6a987de4ce7bf457c2e02be45408304fec6f85c36a92bd431c54fee3de9b5131b2c4730198396fd34b95cd247c362a49701279\\\"},\n\n{\\\"tx_hash\\\":\\\"51f87059c234fb2ff758895c8e7c990", "end": 98094, "score": 0.9997381567955017, "start": 97962, "tag": "KEY", "value": "040c7d98252c3aa9f13dac550f6a6a987de4ce7bf457c2e02be45408304fec6f85c36a92bd431c54fee3de9b5131b2c4730198396fd34b95cd247c362a49701279\\\"" }, { "context": "b2ff758895c8e7c990059bf46a5d54a1aa31c32f27641b20a24\\\",\n\\\"recipient\\\":\\\"1F1M4K4KfGq5qtzB4CsXBjdHriYufu", "end": 98177, "score": 0.8422595262527466, "start": 98176, "tag": "KEY", "value": "4" }, { "context": "\":\\\"2014-11-05T02:01:53.685Z\\\",\n\\\"private_key\\\":\\\"270decfd0d142ff9442efc67985b41b133e827ddc4393a19d04fd3c73fdec210\\\",\n\\\"public_key\\\":\\\"04c605891c4b90ad3fe70ff7b8aff", "end": 98421, "score": 0.9996992945671082, "start": 98357, "tag": "KEY", "value": "270decfd0d142ff9442efc67985b41b133e827ddc4393a19d04fd3c73fdec210" }, { "context": "827ddc4393a19d04fd3c73fdec210\\\",\n\\\"public_key\\\":\\\"04c605891c4b90ad3fe70ff7b8affb34a6a579618e3c304a874b38dbce59c6e141a668aac3a85d248806154cec01f5e400679bff0b3de88f430a14853facead2f4\\\"},\n\n{\\\"tx_hash\\\":\\\"4e468ff7adbb480a6020188ed6c5103", "end": 98574, "score": 0.9991570115089417, "start": 98442, "tag": "KEY", "value": "04c605891c4b90ad3fe70ff7b8affb34a6a579618e3c304a874b38dbce59c6e141a668aac3a85d248806154cec01f5e400679bff0b3de88f430a14853facead2f4\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.703Z\\\",\n\\\"private_key\\\":\\\"9bd6799aadfd8c2b2c511c089c7f905eb831189b6b49ceff454ebfa9c69c4bb1\\\",\n\\\"public_key\\\":\\\"04c13fcdc487ce7d6ea2b8e50f591", "end": 98901, "score": 0.9996352791786194, "start": 98837, "tag": "KEY", "value": "9bd6799aadfd8c2b2c511c089c7f905eb831189b6b49ceff454ebfa9c69c4bb1" }, { "context": "1189b6b49ceff454ebfa9c69c4bb1\\\",\n\\\"public_key\\\":\\\"04c13fcdc487ce7d6ea2b8e50f591c66bc20d3d019900a58f2ed98a4d3a9864e57b4ea0e3de9ad6c6d085ac8b0319d68ec8445cb1e1a7a13fef7988855d0d0a21e\\\"},\n\n{\\\"tx_hash\\\":\\\"ee1b6b5b44cc6926aa7c4a76a82fed0", "end": 99054, "score": 0.9997042417526245, "start": 98922, "tag": "KEY", "value": "04c13fcdc487ce7d6ea2b8e50f591c66bc20d3d019900a58f2ed98a4d3a9864e57b4ea0e3de9ad6c6d085ac8b0319d68ec8445cb1e1a7a13fef7988855d0d0a21e\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.724Z\\\",\n\\\"private_key\\\":\\\"baffb965fad45a248fd883e33e46cd66366986151462988fb797454702d1cbf0\\\",\n\\\"public_key\\\":\\\"049d16c0b1259152996dfeca5fcce", "end": 99381, "score": 0.9997588992118835, "start": 99317, "tag": "KEY", "value": "baffb965fad45a248fd883e33e46cd66366986151462988fb797454702d1cbf0" }, { "context": "986151462988fb797454702d1cbf0\\\",\n\\\"public_key\\\":\\\"049d16c0b1259152996dfeca5fcce6981ad96408589163e195ab2b742b7bc731ac6c9148f19033fed57712a0eecb5b8d18131c52d539683985f8b5adfa95818e9f\\\"},\n\n{\\\"tx_hash\\\":\\\"4ec4374f1caa4646199806f21645052", "end": 99534, "score": 0.9997274875640869, "start": 99402, "tag": "KEY", "value": "049d16c0b1259152996dfeca5fcce6981ad96408589163e195ab2b742b7bc731ac6c9148f19033fed57712a0eecb5b8d18131c52d539683985f8b5adfa95818e9f\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.735Z\\\",\n\\\"private_key\\\":\\\"dbb97e30e5cbd2eb901aab5087d6ce037df426412c59ad1f992d603f594e3fa9\\\",\n\\\"public_key\\\":\\\"04414b1e0319b226719f916f46c57", "end": 99861, "score": 0.9996664524078369, "start": 99797, "tag": "KEY", "value": "dbb97e30e5cbd2eb901aab5087d6ce037df426412c59ad1f992d603f594e3fa9" }, { "context": "426412c59ad1f992d603f594e3fa9\\\",\n\\\"public_key\\\":\\\"04414b1e0319b226719f916f46c576411623a100e7eda826ededdd80598a4e847960314b5b49394a89f42c3576faf552d667f33f8d1160106333b18f965304399c\\\"},\n\n{\\\"tx_hash\\\":\\\"10fcab160176e81e8df317706742da9", "end": 100014, "score": 0.9996200203895569, "start": 99882, "tag": "KEY", "value": "04414b1e0319b226719f916f46c576411623a100e7eda826ededdd80598a4e847960314b5b49394a89f42c3576faf552d667f33f8d1160106333b18f965304399c\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.745Z\\\",\n\\\"private_key\\\":\\\"8994bc15af244dc4e77635710e29e7e7b0d98b1a1efc8171178f9bb2d14cdd03\\\",\n\\\"public_key\\\":\\\"0453b2cd3ab247ba10c87829c3a7c", "end": 100341, "score": 0.9997199177742004, "start": 100277, "tag": "KEY", "value": "8994bc15af244dc4e77635710e29e7e7b0d98b1a1efc8171178f9bb2d14cdd03" }, { "context": "98b1a1efc8171178f9bb2d14cdd03\\\",\n\\\"public_key\\\":\\\"0453b2cd3ab247ba10c87829c3a7c742964877ddb00490bb62f8f502e08de992ea8b10b81345d9eac99631b91aa9035bc887991248951ac460e9f7d2033a9bd921\\\"},\n\n{\\\"tx_hash\\\":\\\"0684e3a180763c820330628a2173f54", "end": 100494, "score": 0.9997645616531372, "start": 100362, "tag": "KEY", "value": "0453b2cd3ab247ba10c87829c3a7c742964877ddb00490bb62f8f502e08de992ea8b10b81345d9eac99631b91aa9035bc887991248951ac460e9f7d2033a9bd921\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.784Z\\\",\n\\\"private_key\\\":\\\"56804c90e29b45bad78b53392cd3c1ed19087acc388df3ffe350453c1cb902ae\\\",\n\\\"public_key\\\":\\\"0450318588b0c03d10b8ad1c960eb", "end": 100821, "score": 0.9997714757919312, "start": 100757, "tag": "KEY", "value": "56804c90e29b45bad78b53392cd3c1ed19087acc388df3ffe350453c1cb902ae" }, { "context": "87acc388df3ffe350453c1cb902ae\\\",\n\\\"public_key\\\":\\\"0450318588b0c03d10b8ad1c960eb9e1376b2079ac9dfdbd03e76206d22d83e77fe8167d84a8d0f9bbe928cc6f1cc46efac99f92b2da1aa61977b5cfd28a79032b\\\"},\n\n{\\\"tx_hash\\\":\\\"98cfc06713213692a745a3d10e992da", "end": 100974, "score": 0.9997698068618774, "start": 100842, "tag": "KEY", "value": "0450318588b0c03d10b8ad1c960eb9e1376b2079ac9dfdbd03e76206d22d83e77fe8167d84a8d0f9bbe928cc6f1cc46efac99f92b2da1aa61977b5cfd28a79032b\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.800Z\\\",\n\\\"private_key\\\":\\\"e5c2af1bad0022a21a19d6ee10f1cdb8436c3882c1432f9fd8f08814d0116697\\\",\n\\\"public_key\\\":\\\"04f2b299732876a4cf3070966c861", "end": 101301, "score": 0.9997130036354065, "start": 101237, "tag": "KEY", "value": "e5c2af1bad0022a21a19d6ee10f1cdb8436c3882c1432f9fd8f08814d0116697" }, { "context": "c3882c1432f9fd8f08814d0116697\\\",\n\\\"public_key\\\":\\\"04f2b299732876a4cf3070966c861e93a9c799f6e2274a3a172d61e457bb69b4e8e6b6a9ecc85d385c1d13d9227f1a331b67f40b3806fd94fc302fd4be13fe7bae\\\"},\n\n{\\\"tx_hash\\\":\\\"155411ca3c5dac0298dff2ace9e3b", "end": 101452, "score": 0.9996888041496277, "start": 101322, "tag": "KEY", "value": "04f2b299732876a4cf3070966c861e93a9c799f6e2274a3a172d61e457bb69b4e8e6b6a9ecc85d385c1d13d9227f1a331b67f40b3806fd94fc302fd4be13fe7bae" }, { "context": "3dca050820f8ce234ecdf81f97946\\\",\n\\\"public_key\\\":\\\"04ed1200c3650061f4f68eb4279b67f3b92e56bb178260787489584cf31b86871b0d923a76d9aa3d6e2d2fb2eadb8ba9dd2c4f76856f2ddeb286f72f6b0c310876\\\"},\n\n{\\\"tx_hash\\\":\\\"7b8ba249ca64b3900aa6c08d929a94c", "end": 101934, "score": 0.9997618198394775, "start": 101802, "tag": "KEY", "value": "04ed1200c3650061f4f68eb4279b67f3b92e56bb178260787489584cf31b86871b0d923a76d9aa3d6e2d2fb2eadb8ba9dd2c4f76856f2ddeb286f72f6b0c310876\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.828Z\\\",\n\\\"private_key\\\":\\\"df359afc7ccd771eeb5c19162ff2c4592327ea4abf42138ec1c96484e0277b36\\\",\n\\\"public_key\\\":\\\"04e3f8706dd54219469f6ffb1457c", "end": 102261, "score": 0.9997645616531372, "start": 102197, "tag": "KEY", "value": "df359afc7ccd771eeb5c19162ff2c4592327ea4abf42138ec1c96484e0277b36" }, { "context": "7ea4abf42138ec1c96484e0277b36\\\",\n\\\"public_key\\\":\\\"04e3f8706dd54219469f6ffb1457c75406ba6b972fde6b8c2b6eebf26d7d99b18f55d70f3184a5cab9ed4316478123a4b871858965739bff28ef30182d222efacc\\\"},\n\n{\\\"tx_hash\\\":\\\"a578adb058de", "end": 102395, "score": 0.9966484308242798, "start": 102282, "tag": "KEY", "value": "04e3f8706dd54219469f6ffb1457c75406ba6b972fde6b8c2b6eebf26d7d99b18f55d70f3184a5cab9ed4316478123a4b871858965739bff2" }, { "context": "8f55d70f3184a5cab9ed4316478123a4b871858965739bff28ef30182d222efacc\\\"},\n\n{\\\"tx_hash\\\":\\\"a578adb058de0aa8a", "end": 102400, "score": 0.9996626973152161, "start": 102396, "tag": "KEY", "value": "ef30" }, { "context": "\":\\\"2014-11-05T02:01:53.844Z\\\",\n\\\"private_key\\\":\\\"bfc3803e981f7744555de7c2486cef53e6a2e509cc62a284bac283c13533c911\\\",\n\\\"public_key\\\":\\\"04199dc8ae2fdf302c64cf9fbc52c", "end": 102741, "score": 0.9996806979179382, "start": 102677, "tag": "KEY", "value": "bfc3803e981f7744555de7c2486cef53e6a2e509cc62a284bac283c13533c911" }, { "context": "2e509cc62a284bac283c13533c911\\\",\n\\\"public_key\\\":\\\"04199dc8ae2fdf302c64cf9fbc52c4b8296eebd13d2cef5e18596885181ba4c57fa1889c341d5e833771d23c40e2cd5fa3c305ae7fc1c8591a739bc2b375187e9b\\\"},\n\n{\\\"tx_hash\\\":\\\"f111ee1d4f16fddf35a5634a2fe5fa6", "end": 102894, "score": 0.9980209469795227, "start": 102762, "tag": "KEY", "value": "04199dc8ae2fdf302c64cf9fbc52c4b8296eebd13d2cef5e18596885181ba4c57fa1889c341d5e833771d23c40e2cd5fa3c305ae7fc1c8591a739bc2b375187e9b\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.853Z\\\",\n\\\"private_key\\\":\\\"2fe4bd1ecec9acb4f704edf91793ad28435ba548d5e45e4a458231cf03cd7739\\\",\n\\\"public_key\\\":\\\"04ad25e291f53426c4213362b48b4", "end": 103221, "score": 0.9997133612632751, "start": 103157, "tag": "KEY", "value": "2fe4bd1ecec9acb4f704edf91793ad28435ba548d5e45e4a458231cf03cd7739" }, { "context": "ba548d5e45e4a458231cf03cd7739\\\",\n\\\"public_key\\\":\\\"04ad25e291f53426c4213362b48b4fa22b727da11cd9262fecfdb4f92490bf6cf3f148e4eae41dc6fbba690b6c68880418d928aaf5d9b3cb8077619c1e332ad584\\\"},\n\n{\\\"tx_hash\\\":\\\"9181cd4434d9bb2ba6a840b4161334c", "end": 103374, "score": 0.99974524974823, "start": 103242, "tag": "KEY", "value": "04ad25e291f53426c4213362b48b4fa22b727da11cd9262fecfdb4f92490bf6cf3f148e4eae41dc6fbba690b6c68880418d928aaf5d9b3cb8077619c1e332ad584\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.863Z\\\",\n\\\"private_key\\\":\\\"ab0a7f5bc77e68a4abd04e1e1d239aaffa659dd5ca7d29f74848541b6454cb40\\\",\n\\\"public_key\\\":\\\"04e099ef0ddc6111f67c284139edf", "end": 103701, "score": 0.9997643232345581, "start": 103637, "tag": "KEY", "value": "ab0a7f5bc77e68a4abd04e1e1d239aaffa659dd5ca7d29f74848541b6454cb40" }, { "context": "59dd5ca7d29f74848541b6454cb40\\\",\n\\\"public_key\\\":\\\"04e099ef0ddc6111f67c284139edfea15c182033af36ce50b1f184c79e360c16764b427b8f6e8c55dbd5c9656763429f550d52c59fcfc12e971936cbdb722f98df\\\"},\n\n{\\\"tx_hash\\\":\\\"3d0e2a091327adf9843", "end": 103842, "score": 0.9997527003288269, "start": 103722, "tag": "KEY", "value": "04e099ef0ddc6111f67c284139edfea15c182033af36ce50b1f184c79e360c16764b427b8f6e8c55dbd5c9656763429f550d52c59fcfc12e971936cb" }, { "context": "\":\\\"2014-11-05T02:01:53.879Z\\\",\n\\\"private_key\\\":\\\"18145fb74d418eecd1159aa1ba52bbfe0916dc8fc399432bdfed854dafe9663e\\\",\n\\\"public_key\\\":\\\"0408d7cd00d97c6905a78019dd9d6", "end": 104181, "score": 0.999756932258606, "start": 104117, "tag": "KEY", "value": "18145fb74d418eecd1159aa1ba52bbfe0916dc8fc399432bdfed854dafe9663e" }, { "context": "6dc8fc399432bdfed854dafe9663e\\\",\n\\\"public_key\\\":\\\"0408d7cd00d97c6905a78019dd9d6ac1c4333ea7fa44613aaeb70a0379f9040cf4a57de0c078b52278d40e9232662427fb2b4ae51b69ee5437c9429d128b22c5e6\\\"},\n\n{\\\"tx_hash\\\":\\\"76a88d221e6c8748027642db86c76a6", "end": 104334, "score": 0.9991109371185303, "start": 104202, "tag": "KEY", "value": "0408d7cd00d97c6905a78019dd9d6ac1c4333ea7fa44613aaeb70a0379f9040cf4a57de0c078b52278d40e9232662427fb2b4ae51b69ee5437c9429d128b22c5e6\\\"" }, { "context": "5:10.444Z\\\",\n\\\"updated_at\\\":\\\"2014-11-05T02:01:53.889Z\\\",\n\\\"private_key\\\":\\\"6baa1fb4fbfbec054d5e80566b39", "end": 104575, "score": 0.9997318387031555, "start": 104571, "tag": "KEY", "value": "889Z" }, { "context": "\":\\\"2014-11-05T02:01:53.889Z\\\",\n\\\"private_key\\\":\\\"6baa1fb4fbfbec054d5e80566b39cc3c5e1ff5423e934bc0d7433e8a6d7e5538\\\",\n\\\"public_key\\\":\\\"047d83130cb4054032bb870365a38", "end": 104661, "score": 0.9997555613517761, "start": 104597, "tag": "KEY", "value": "6baa1fb4fbfbec054d5e80566b39cc3c5e1ff5423e934bc0d7433e8a6d7e5538" }, { "context": "ff5423e934bc0d7433e8a6d7e5538\\\",\n\\\"public_key\\\":\\\"047d83130cb4054032bb870365a388f63bbce0938ce3da508aefb91d88c14ecc56d2700bbdcbf99d392d60e7e9f2f263000e1aa91def214c1b76f8cb82af53d17a\\\"},\n\n{\\\"tx_hash\\\":\\\"00558a6bf42975bc24ad0c46951ac4d", "end": 104814, "score": 0.999745786190033, "start": 104682, "tag": "KEY", "value": "047d83130cb4054032bb870365a388f63bbce0938ce3da508aefb91d88c14ecc56d2700bbdcbf99d392d60e7e9f2f263000e1aa91def214c1b76f8cb82af53d17a\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.905Z\\\",\n\\\"private_key\\\":\\\"160a6318a034567f223f2dc2d89487b404f9849f5c065b0dff520c8f5e17279c\\\",\n\\\"public_key\\\":\\\"0439bf418a409b41c677ffd2bd907", "end": 105141, "score": 0.9997712969779968, "start": 105077, "tag": "KEY", "value": "160a6318a034567f223f2dc2d89487b404f9849f5c065b0dff520c8f5e17279c" }, { "context": "9849f5c065b0dff520c8f5e17279c\\\",\n\\\"public_key\\\":\\\"0439bf418a409b41c677ffd2bd907ce77d06a73bdbda1d3ca90a6b87e55d9d2287419c98dba37d0e17c9a62dda9df786c7657f45b25608400917abba92b2827af6\\\"},\n\n{\\\"tx_h", "end": 105255, "score": 0.9996658563613892, "start": 105162, "tag": "KEY", "value": "0439bf418a409b41c677ffd2bd907ce77d06a73bdbda1d3ca90a6b87e55d9d2287419c98dba37d0e17c9a62dda9df" }, { "context": "1d3ca90a6b87e55d9d2287419c98dba37d0e17c9a62dda9df786c7657f45b25608400917abba92b2827af6\\\"},\n\n{\\\"tx_hash\\\":\\\"", "end": 105263, "score": 0.9831716418266296, "start": 105256, "tag": "KEY", "value": "86c7657" }, { "context": "\":\\\"2014-11-05T02:01:53.915Z\\\",\n\\\"private_key\\\":\\\"45c6e1b0b331a84c61e53d8bfaec0fcb7c9fa3a6ad99309b14a1a34e638de629\\\",\n\\\"public_key\\\":\\\"04c090f10dbfd1352ea678a801929", "end": 105621, "score": 0.9997416138648987, "start": 105557, "tag": "KEY", "value": "45c6e1b0b331a84c61e53d8bfaec0fcb7c9fa3a6ad99309b14a1a34e638de629" }, { "context": "fa3a6ad99309b14a1a34e638de629\\\",\n\\\"public_key\\\":\\\"04c090f10dbfd1352ea678a80192983693e28ea287a5d05a886e6ed71d24f3f45673b9336b43f82e87ed5dbe0f09e78357bbf4716f2e96b7080afc354abf8e919a\\\"},\n\n{\\\"tx_hash\\\":\\\"4c7994c370b0b7a58f3df65e0fcc522", "end": 105774, "score": 0.9997282028198242, "start": 105642, "tag": "KEY", "value": "04c090f10dbfd1352ea678a80192983693e28ea287a5d05a886e6ed71d24f3f45673b9336b43f82e87ed5dbe0f09e78357bbf4716f2e96b7080afc354abf8e919a\\\"" }, { "context": "\":\\\"2015-05-18T09:51:31.657Z\\\",\n\\\"private_key\\\":\\\"e8722be7b40bbf2f32329f69187819a3ddf61577121ceb056803542e4350dc01\\\",\n\\\"public_key\\\":\\\"039c056d3fa372c77b869bf13b864", "end": 106101, "score": 0.9997707009315491, "start": 106037, "tag": "KEY", "value": "e8722be7b40bbf2f32329f69187819a3ddf61577121ceb056803542e4350dc01" }, { "context": "61577121ceb056803542e4350dc01\\\",\n\\\"public_key\\\":\\\"039c056d3fa372c77b869bf13b8646df501b68b76009cb45ad7782d42fc1519677\\\"},\n\n{\\\"tx_hash\\\":\\\"b1b35b093ffb7ba24155cbbb2110413", "end": 106190, "score": 0.9997713565826416, "start": 106122, "tag": "KEY", "value": "039c056d3fa372c77b869bf13b8646df501b68b76009cb45ad7782d42fc1519677\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.934Z\\\",\n\\\"private_key\\\":\\\"3f67d33e84fc9735a611651dccfbff8994124b80a93dd5d4793febd56193d8a6\\\",\n\\\"public_key\\\":\\\"0437f4d9adeb3495729cce1cefe2f", "end": 106517, "score": 0.9997801780700684, "start": 106453, "tag": "KEY", "value": "3f67d33e84fc9735a611651dccfbff8994124b80a93dd5d4793febd56193d8a6" }, { "context": "24b80a93dd5d4793febd56193d8a6\\\",\n\\\"public_key\\\":\\\"0437f4d9adeb3495729cce1cefe2f5cb16aba99ab4df9bd7f080bf3f453853dad131474c7af9801c6bee23b19d9ccc51faddfaec8be907227f0dc637f7838a4b20\\\"},\n\n{\\\"tx_hash\\\":\\\"1552390c50242cddb935f58c88f3c12", "end": 106670, "score": 0.9997739791870117, "start": 106538, "tag": "KEY", "value": "0437f4d9adeb3495729cce1cefe2f5cb16aba99ab4df9bd7f080bf3f453853dad131474c7af9801c6bee23b19d9ccc51faddfaec8be907227f0dc637f7838a4b20\\\"" }, { "context": "\":\\\"2014-11-05T02:01:53.946Z\\\",\n\\\"private_key\\\":\\\"59acf5d4d66a837402f653052f6c94b972ae1ae90e6ece7476e04a93ecfef1ea\\\",\n\\\"public_key\\\":\\\"0487c8d374455accc2b1030f49b7c", "end": 106997, "score": 0.9997380375862122, "start": 106933, "tag": "KEY", "value": "59acf5d4d66a837402f653052f6c94b972ae1ae90e6ece7476e04a93ecfef1ea" }, { "context": "e1ae90e6ece7476e04a93ecfef1ea\\\",\n\\\"public_key\\\":\\\"0487c8d374455accc2b1030f49b7c85d92c67d913bf193afec2a3431173df7803c9524cf294f66f65a0f2dfc320c55ab2b770cca4a30764aa5392124fb53b08a22\\\"},\n\n{\\\"tx_hash\\\":\\\"364cfa51f9dd1a3f66d1997d3dfc140", "end": 107150, "score": 0.999607503414154, "start": 107018, "tag": "KEY", "value": "0487c8d374455accc2b1030f49b7c85d92c67d913bf193afec2a3431173df7803c9524cf294f66f65a0f2dfc320c55ab2b770cca4a30764aa5392124fb53b08a22\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.054Z\\\",\n\\\"private_key\\\":\\\"6d7af705888d011c072defb9d091e694d3e8b82e5d546b5a46c4c99c80bc3b99\\\",\n\\\"public_key\\\":\\\"04fd0e350898e63ce0f846fe8f4dc", "end": 107477, "score": 0.9997177720069885, "start": 107413, "tag": "KEY", "value": "6d7af705888d011c072defb9d091e694d3e8b82e5d546b5a46c4c99c80bc3b99" }, { "context": "8b82e5d546b5a46c4c99c80bc3b99\\\",\n\\\"public_key\\\":\\\"04fd0e350898e63ce0f846fe8f4dc3c8bb7c7b3a148e38ee297d91b815bc35e9d541a4c2fd6fdbc12c75c7ca10f238d780c6dfb4af13b3b302fddc8eee4d39351c\\\"},\n\n{\\\"tx_hash\\\":\\\"e7380c96301a7c5644f6064cc1000db", "end": 107630, "score": 0.9997665882110596, "start": 107498, "tag": "KEY", "value": "04fd0e350898e63ce0f846fe8f4dc3c8bb7c7b3a148e38ee297d91b815bc35e9d541a4c2fd6fdbc12c75c7ca10f238d780c6dfb4af13b3b302fddc8eee4d39351c\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.084Z\\\",\n\\\"private_key\\\":\\\"f59914901f476c84a435f5be13f9a11729859e266c91b91abe7b2359228da6ce\\\",\n\\\"public_key\\\":\\\"042ed0b725a1acc0a63af5190c8af", "end": 107957, "score": 0.9997407793998718, "start": 107893, "tag": "KEY", "value": "f59914901f476c84a435f5be13f9a11729859e266c91b91abe7b2359228da6ce" }, { "context": "59e266c91b91abe7b2359228da6ce\\\",\n\\\"public_key\\\":\\\"042ed0b725a1acc0a63af5190c8af892a081f253a7b1037961c69b532808ce0dc5f82eab2aabcbcf5e619d72b721801fbff8bbfd0440597ef70f8095e7c3c9f17d\\\"},\n\n{\\\"tx_hash\\\":\\\"e4aad1c75c097eac80e68c2df0db187", "end": 108110, "score": 0.9997631907463074, "start": 107978, "tag": "KEY", "value": "042ed0b725a1acc0a63af5190c8af892a081f253a7b1037961c69b532808ce0dc5f82eab2aabcbcf5e619d72b721801fbff8bbfd0440597ef70f8095e7c3c9f17d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.095Z\\\",\n\\\"private_key\\\":\\\"447c1674b23336c9140c15dc989a1da98735d83a8e63cf7da8d64ac2b2d310df\\\",\n\\\"public_key\\\":\\\"046637bf2d3b33493380c250c170a", "end": 108437, "score": 0.99974524974823, "start": 108373, "tag": "KEY", "value": "447c1674b23336c9140c15dc989a1da98735d83a8e63cf7da8d64ac2b2d310df" }, { "context": "5d83a8e63cf7da8d64ac2b2d310df\\\",\n\\\"public_key\\\":\\\"046637bf2d3b33493380c250c170a8df0d7a9260330d42af477d3ff4153190fa1f71bb9a3b46beabcc37097c12bd1dfc547bff7ba4578aa963952219659b1919e1\\\"},\n\n{\\\"tx_hash\\\":\\\"c533d2f3b74b6e53fd69e0d28477915", "end": 108590, "score": 0.9997041821479797, "start": 108458, "tag": "KEY", "value": "046637bf2d3b33493380c250c170a8df0d7a9260330d42af477d3ff4153190fa1f71bb9a3b46beabcc37097c12bd1dfc547bff7ba4578aa963952219659b1919e1\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.110Z\\\",\n\\\"private_key\\\":\\\"8a64d171816ad307cf608563d481c58298f8d6f1f94b8608dd61797432bdf641\\\",\n\\\"public_key\\\":\\\"0458e765cf40ed67aeb3af2176598", "end": 108917, "score": 0.9996697902679443, "start": 108853, "tag": "KEY", "value": "8a64d171816ad307cf608563d481c58298f8d6f1f94b8608dd61797432bdf641" }, { "context": "8d6f1f94b8608dd61797432bdf641\\\",\n\\\"public_key\\\":\\\"0458e765cf40ed67aeb3af21765983c5dd42fa7f61fafb4404b3a62a401d093374a62f8a59a32454bee4bdbf6014eb3de6f87747f23b6b7f17413fea783f21cd9f\\\"},\n\n{\\\"tx_hash\\\":\\\"c5735f619ea9450afba8a3c39654f5a", "end": 109070, "score": 0.999706506729126, "start": 108938, "tag": "KEY", "value": "0458e765cf40ed67aeb3af21765983c5dd42fa7f61fafb4404b3a62a401d093374a62f8a59a32454bee4bdbf6014eb3de6f87747f23b6b7f17413fea783f21cd9f\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.120Z\\\",\n\\\"private_key\\\":\\\"4c09fd2fbcd7bfe60d925bd91f55869645e3bc7f3d8c4708f83fe440d1f2e1c8\\\",\n\\\"public_key\\\":\\\"0416c275f2ee2eb68334d20d03368", "end": 109397, "score": 0.9997677206993103, "start": 109333, "tag": "KEY", "value": "4c09fd2fbcd7bfe60d925bd91f55869645e3bc7f3d8c4708f83fe440d1f2e1c8" }, { "context": "3bc7f3d8c4708f83fe440d1f2e1c8\\\",\n\\\"public_key\\\":\\\"0416c275f2ee2eb68334d20d03368bd0fa6f66dd28c4a2a51383715b72cdc53363f95dbfd14e26946cb1081f911ed4b0656eb0a8b926fa33bceeb0cf6488843909\\\"},\n\n{\\\"tx_hash\\\":\\\"daf1a9dd37cfa364750a", "end": 109539, "score": 0.9997630715370178, "start": 109418, "tag": "KEY", "value": "0416c275f2ee2eb68334d20d03368bd0fa6f66dd28c4a2a51383715b72cdc53363f95dbfd14e26946cb1081f911ed4b0656eb0a8b926fa33bceeb0cf6" }, { "context": "\":\\\"2014-11-05T02:01:54.130Z\\\",\n\\\"private_key\\\":\\\"7b034cdd763b812c60772cf8e9e62676f667a3f1afe21ecbd0576a7718132abf\\\",\n\\\"public_key\\\":\\\"04e91f82b069b5d08bc511d4eee35", "end": 109877, "score": 0.9997496008872986, "start": 109813, "tag": "KEY", "value": "7b034cdd763b812c60772cf8e9e62676f667a3f1afe21ecbd0576a7718132abf" }, { "context": "7a3f1afe21ecbd0576a7718132abf\\\",\n\\\"public_key\\\":\\\"04e91f82b069b5d08bc511d4eee35ee35de80d8bdd126e19e2cc503b7b878da5238772657585bc597aaaef4f821ef80570aeb56daae5a80f4ce39afaccb70e1580\\\"},\n\n{\\\"tx_hash\\\":\\\"918f4636b7da99f39ef93395e618fb8", "end": 110030, "score": 0.9996115565299988, "start": 109898, "tag": "KEY", "value": "04e91f82b069b5d08bc511d4eee35ee35de80d8bdd126e19e2cc503b7b878da5238772657585bc597aaaef4f821ef80570aeb56daae5a80f4ce39afaccb70e1580\\\"" }, { "context": "3.364Z\\\",\n\\\"updated_at\\\":\\\"2014-11-05T02:01:54.147Z\\\",\n\\\"private_key\\\":\\\"f66bb383dc12dad84b8d5e9ac24d", "end": 110271, "score": 0.9997069239616394, "start": 110270, "tag": "KEY", "value": "Z" }, { "context": "\":\\\"2014-11-05T02:01:54.147Z\\\",\n\\\"private_key\\\":\\\"f66bb383dc12dad84b8d5e9ac24d63938e159d316326bc12f327e3274e5ee7a4\\\",\n\\\"public_key\\\":\\\"04d17fa40097c04facfe7a8b0fe00", "end": 110357, "score": 0.9997601509094238, "start": 110293, "tag": "KEY", "value": "f66bb383dc12dad84b8d5e9ac24d63938e159d316326bc12f327e3274e5ee7a4" }, { "context": "59d316326bc12f327e3274e5ee7a4\\\",\n\\\"public_key\\\":\\\"04d17fa40097c04facfe7a8b0fe000720de1221ccf6668ed3b48120110530192d8b9488519af7d39a57b8f3958447f72bc9c286bf6c94c17d87074f3e91a8c67cb\\\"},\n\n{\\\"tx_hash\\\":\\\"f3bcd428858081ff82f64a583c347aa", "end": 110510, "score": 0.9997527003288269, "start": 110378, "tag": "KEY", "value": "04d17fa40097c04facfe7a8b0fe000720de1221ccf6668ed3b48120110530192d8b9488519af7d39a57b8f3958447f72bc9c286bf6c94c17d87074f3e91a8c67cb\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.157Z\\\",\n\\\"private_key\\\":\\\"ab860b998d496dff1ade01bf32314508ddf9d09959ddc64f574ad5d265e23f61\\\",\n\\\"public_key\\\":\\\"04af6109210fa42f605ce48c17784", "end": 110837, "score": 0.9997609257698059, "start": 110773, "tag": "KEY", "value": "ab860b998d496dff1ade01bf32314508ddf9d09959ddc64f574ad5d265e23f61" }, { "context": "9d09959ddc64f574ad5d265e23f61\\\",\n\\\"public_key\\\":\\\"04af6109210fa42f605ce48c177842c9e6c10825b30cfa48e8ef081a906de7329a78b052ea4874fd8e40e1522c33b3a527927d036813c922cbc5388c152cc6627b\\\"},\n\n{\\", "end": 110946, "score": 0.9996102452278137, "start": 110858, "tag": "KEY", "value": "04af6109210fa42f605ce48c177842c9e6c10825b30cfa48e8ef081a906de7329a78b052ea4874fd8e40e152" }, { "context": "5b30cfa48e8ef081a906de7329a78b052ea4874fd8e40e1522c33b3a527927d036813c922cbc5388c152cc6627b\\\"},\n\n{\\\"tx_hash", "end": 110954, "score": 0.9959708452224731, "start": 110947, "tag": "KEY", "value": "c33b3a5" }, { "context": "e8ef081a906de7329a78b052ea4874fd8e40e1522c33b3a527927d036813c922cbc5388c152cc6627b\\\"},\n\n{\\\"tx_hash\\\":", "end": 110957, "score": 0.995049238204956, "start": 110956, "tag": "KEY", "value": "9" }, { "context": "\":\\\"2014-11-05T02:01:54.179Z\\\",\n\\\"private_key\\\":\\\"d7d02307eefe5368ec4b17bbc6de453099ed0e0f81ff1d5d27dc1728555316aa\\\",\n\\\"public_key\\\":\\\"043c83d03181c16b087e0cb4eb6bd", "end": 111317, "score": 0.9997519850730896, "start": 111253, "tag": "KEY", "value": "d7d02307eefe5368ec4b17bbc6de453099ed0e0f81ff1d5d27dc1728555316aa" }, { "context": "d0e0f81ff1d5d27dc1728555316aa\\\",\n\\\"public_key\\\":\\\"043c83d03181c16b087e0cb4eb6bdd24f8435c05fa36880dfd2c1a93bca94f06737df4eae0ef00cd9f7ca5abc88104b9c4dd5286b2a742a4b30bb7b3c70ddddb3d\\\"},\n\n{\\\"tx_hash\\\":\\\"adf352f73e98f56ed55e1c4fe9f46d4", "end": 111470, "score": 0.9997634887695312, "start": 111338, "tag": "KEY", "value": "043c83d03181c16b087e0cb4eb6bdd24f8435c05fa36880dfd2c1a93bca94f06737df4eae0ef00cd9f7ca5abc88104b9c4dd5286b2a742a4b30bb7b3c70ddddb3d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.211Z\\\",\n\\\"private_key\\\":\\\"c4857f0d4b74caca9c511c342c9c49508e113e5adbe5972de7a180d9566659c2\\\",\n\\\"public_key\\\":\\\"0441190cdfdee4ce9ac98ada810a6", "end": 111797, "score": 0.9995862245559692, "start": 111733, "tag": "KEY", "value": "c4857f0d4b74caca9c511c342c9c49508e113e5adbe5972de7a180d9566659c2" }, { "context": "13e5adbe5972de7a180d9566659c2\\\",\n\\\"public_key\\\":\\\"0441190cdfdee4ce9ac98ada810a6d3cc657cafd72ee4aa3817f21b48ee477ef34efcba82f586ea5ccd8aefd1f74cbe47c1aca6c7ee8c3a2dee06261429c99da3e\\\"},\n\n{\\\"tx_hash\\\":\\\"6ea75d536848f9a1dc8d0e04510767d", "end": 111950, "score": 0.9980613589286804, "start": 111818, "tag": "KEY", "value": "0441190cdfdee4ce9ac98ada810a6d3cc657cafd72ee4aa3817f21b48ee477ef34efcba82f586ea5ccd8aefd1f74cbe47c1aca6c7ee8c3a2dee06261429c99da3e\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.313Z\\\",\n\\\"private_key\\\":\\\"746748b2f43dae2deb1e441c29ee7ed455ec5a4ecddc135b14f5779a718ada04\\\",\n\\\"public_key\\\":\\\"0432ccebecdd1c6c410084cbd50fc", "end": 112277, "score": 0.9997092485427856, "start": 112213, "tag": "KEY", "value": "746748b2f43dae2deb1e441c29ee7ed455ec5a4ecddc135b14f5779a718ada04" }, { "context": "c5a4ecddc135b14f5779a718ada04\\\",\n\\\"public_key\\\":\\\"0432ccebecdd1c6c410084cbd50fc69184e9488e88070dfcf07c2e8068ebeec2d289b1f176419320dc9f0f52b318a8a01121ed01639a88d0b41ef88d1c61c74725\\\"},\n\n{\\\"tx_hash", "end": 112394, "score": 0.997917652130127, "start": 112298, "tag": "KEY", "value": "0432ccebecdd1c6c410084cbd50fc69184e9488e88070dfcf07c2e8068ebeec2d289b1f176419320dc9f0f52b318a8a0" }, { "context": "cf07c2e8068ebeec2d289b1f176419320dc9f0f52b318a8a01121ed01639a88d0b41ef88d1c61c74725\\\"},\n\n{\\\"tx_hash\\\":\\\"62", "end": 112401, "score": 0.9860036969184875, "start": 112395, "tag": "KEY", "value": "121ed0" }, { "context": "\":\\\"2014-11-05T02:01:54.331Z\\\",\n\\\"private_key\\\":\\\"b09985abf485e7de368325bf6749a4bf94f654f9c4b130223c1b751a1ee52849\\\",\n\\\"public_key\\\":\\\"04c369656cca97108c10fdd420b41", "end": 112757, "score": 0.9997624754905701, "start": 112693, "tag": "KEY", "value": "b09985abf485e7de368325bf6749a4bf94f654f9c4b130223c1b751a1ee52849" }, { "context": "654f9c4b130223c1b751a1ee52849\\\",\n\\\"public_key\\\":\\\"04c369656cca97108c10fdd420b4145816689bb162583754ace26b3fb0aab78492001474c9006c55ce4c1ed2f09d2f5078fcd05ff3ef593b28a99d9b6ce667b4de\\\"},\n\n{\\\"tx_hash\\\":\\\"cd86d40b2707dee5e3edff0cf2c5ecb", "end": 112910, "score": 0.9997497200965881, "start": 112778, "tag": "KEY", "value": "04c369656cca97108c10fdd420b4145816689bb162583754ace26b3fb0aab78492001474c9006c55ce4c1ed2f09d2f5078fcd05ff3ef593b28a99d9b6ce667b4de\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.341Z\\\",\n\\\"private_key\\\":\\\"f4fce839a7b2b80ace0bdfcb4af2206b5d79903ed037c3eb85e5c095bdaaf18b\\\",\n\\\"public_key\\\":\\\"04651c94bbae68b4d4364d78bdef5", "end": 113237, "score": 0.9997385144233704, "start": 113173, "tag": "KEY", "value": "f4fce839a7b2b80ace0bdfcb4af2206b5d79903ed037c3eb85e5c095bdaaf18b" }, { "context": "9903ed037c3eb85e5c095bdaaf18b\\\",\n\\\"public_key\\\":\\\"04651c94bbae68b4d4364d78bdef5fbdcceb754c57e673e10ccdcc188b89ca33a5304a61db3a72693ea786596f3ef2447a37cd630abf6754db55d1c8f88022a02d\\\"},\n\n{\\\"tx_hash\\\":\\\"f8e2eed5464b174d25cc7d48836f668", "end": 113390, "score": 0.9997536540031433, "start": 113258, "tag": "KEY", "value": "04651c94bbae68b4d4364d78bdef5fbdcceb754c57e673e10ccdcc188b89ca33a5304a61db3a72693ea786596f3ef2447a37cd630abf6754db55d1c8f88022a02d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.357Z\\\",\n\\\"private_key\\\":\\\"c971c713ebd650e6ae8debab6f1598cc26c8b530076ab8e0a4316aae7fc94229\\\",\n\\\"public_key\\\":\\\"046b74c9c290bb232149a747c1820", "end": 113717, "score": 0.9997698068618774, "start": 113653, "tag": "KEY", "value": "c971c713ebd650e6ae8debab6f1598cc26c8b530076ab8e0a4316aae7fc94229" }, { "context": "8b530076ab8e0a4316aae7fc94229\\\",\n\\\"public_key\\\":\\\"046b74c9c290bb232149a747c1820e6c3c9fa39a868bac06991c07835b2136ae4caf30d34622acd2cd35288385f409d49a109a0ae95f3d82b167658cc1fb684645\\\"},\n\n{\\", "end": 113826, "score": 0.9997652769088745, "start": 113738, "tag": "KEY", "value": "046b74c9c290bb232149a747c1820e6c3c9fa39a868bac06991c07835b2136ae4caf30d34622acd2cd352883" }, { "context": "a868bac06991c07835b2136ae4caf30d34622acd2cd35288385f409d49a109a0ae95f3d82b167658cc1fb684645\\\"},\n\n{\\\"tx_has", "end": 113833, "score": 0.9995855689048767, "start": 113827, "tag": "KEY", "value": "5f409d" }, { "context": "6991c07835b2136ae4caf30d34622acd2cd35288385f409d49a109a0ae95f3d82b167658cc1fb684645\\\"},\n\n{\\\"tx_hash\\\"", "end": 113836, "score": 0.9196128845214844, "start": 113835, "tag": "KEY", "value": "a" }, { "context": "\":\\\"2014-11-05T02:01:54.374Z\\\",\n\\\"private_key\\\":\\\"3e02c5e76120b3f3561a6dc9aadd273862cf78b182cca8ca15af142e1dd50a8b\\\",\n\\\"public_key\\\":\\\"0456df6ed1ff25d0b4cdc81b98966", "end": 114196, "score": 0.9997302889823914, "start": 114132, "tag": "KEY", "value": "3e02c5e76120b3f3561a6dc9aadd273862cf78b182cca8ca15af142e1dd50a8b" }, { "context": "f78b182cca8ca15af142e1dd50a8b\\\",\n\\\"public_key\\\":\\\"0456df6ed1ff25d0b4cdc81b989668842817bae3daf62d055f654d08821b1ed85207be34875973915cb1c45b583f4ed6b793a2267a3a555f61b8e0fece0980a0e4\\\"},\n\n{\\\"tx_hash\\\":\\\"2e83d98c31147546570bb123716cf73", "end": 114349, "score": 0.9997310042381287, "start": 114217, "tag": "KEY", "value": "0456df6ed1ff25d0b4cdc81b989668842817bae3daf62d055f654d08821b1ed85207be34875973915cb1c45b583f4ed6b793a2267a3a555f61b8e0fece0980a0e4\\\"" }, { "context": "\":\\\"2015-02-28T02:51:43.930Z\\\",\n\\\"private_key\\\":\\\"f00ed794d0604e0a396729e3447bf51fd8b0d4219e2b3c41beb29acab8d53ca3\\\",\n\\\"public_key\\\":\\\"0391dbbe04fe756cbb2941b5b2eea", "end": 114676, "score": 0.9997692108154297, "start": 114612, "tag": "KEY", "value": "f00ed794d0604e0a396729e3447bf51fd8b0d4219e2b3c41beb29acab8d53ca3" }, { "context": "0d4219e2b3c41beb29acab8d53ca3\\\",\n\\\"public_key\\\":\\\"0391dbbe04fe756cbb2941b5b2eeac20dca0dae3206534b26b8d56ebcb5874a5d8\\\"},\n\n{\\\"tx_hash\\\":\\\"8905d041a4fe8903ba16f4880f43dba", "end": 114765, "score": 0.999764621257782, "start": 114697, "tag": "KEY", "value": "0391dbbe04fe756cbb2941b5b2eeac20dca0dae3206534b26b8d56ebcb5874a5d8\\\"" }, { "context": "\":\\\"2015-03-14T03:22:00.346Z\\\",\n\\\"private_key\\\":\\\"1090ea4192b459387d381e0c893cae82324e8dd254160187cd31310fde000167\\\",\n\\\"public_key\\\":\\\"0376072025e868b37c0a5a263412b", "end": 115092, "score": 0.999774158000946, "start": 115028, "tag": "KEY", "value": "1090ea4192b459387d381e0c893cae82324e8dd254160187cd31310fde000167" }, { "context": "e8dd254160187cd31310fde000167\\\",\n\\\"public_key\\\":\\\"0376072025e868b37c0a5a263412bd7f29093818054d7a7b64731411f6761cdc02\\\"},\n\n{\\\"tx_hash\\\":\\\"e9b5dfe44174ccd94fd6ede31da13fe", "end": 115181, "score": 0.9997714161872864, "start": 115113, "tag": "KEY", "value": "0376072025e868b37c0a5a263412bd7f29093818054d7a7b64731411f6761cdc02\\\"" }, { "context": "\",\n\\\"recipient\\\":\\\"18c8SznKPzHihmrbcM5wYdGSUHPzGuHbuB\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2015-05-19T00:0", "end": 115318, "score": 0.9986227750778198, "start": 115315, "tag": "KEY", "value": "buB" }, { "context": "\":\\\"2015-05-19T13:21:42.197Z\\\",\n\\\"private_key\\\":\\\"31121b5b67631c3ba378d7e0420483a4a2e2cf86bcac6d556ce0f40c1be714fa\\\",\n\\\"public_key\\\":\\\"0232327455b11703730bccb55803a", "end": 115508, "score": 0.9997678399085999, "start": 115444, "tag": "KEY", "value": "31121b5b67631c3ba378d7e0420483a4a2e2cf86bcac6d556ce0f40c1be714fa" }, { "context": "2cf86bcac6d556ce0f40c1be714fa\\\",\n\\\"public_key\\\":\\\"0232327455b11703730bccb55803a65709e973c85935d372de77278ddf5cc0b778\\\"},\n\n{\\\"tx_hash\\\":\\\"a5490f9df9b4d5f11e6c0a33cbce388", "end": 115597, "score": 0.9997636079788208, "start": 115529, "tag": "KEY", "value": "0232327455b11703730bccb55803a65709e973c85935d372de77278ddf5cc0b778\\\"" }, { "context": "\":\\\"2015-02-27T00:53:05.189Z\\\",\n\\\"private_key\\\":\\\"aa7cae139a89a270ffad7436146ae974850a69f04288ebae875760ec93089a38\\\",\n\\\"public_key\\\":\\\"02580c18f44dd28dd195a94c327e8", "end": 115924, "score": 0.9997466206550598, "start": 115860, "tag": "KEY", "value": "aa7cae139a89a270ffad7436146ae974850a69f04288ebae875760ec93089a38" }, { "context": "a69f04288ebae875760ec93089a38\\\",\n\\\"public_key\\\":\\\"02580c18f44dd28dd195a94c327e81d2ad83aec6ec240e36d4074e1197d2ed1427\\\"},\n\n{\\\"tx_hash\\\":\\\"2c056935b77b9644684f7dcd7d0b679", "end": 116013, "score": 0.9996750950813293, "start": 115945, "tag": "KEY", "value": "02580c18f44dd28dd195a94c327e81d2ad83aec6ec240e36d4074e1197d2ed1427\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.395Z\\\",\n\\\"private_key\\\":\\\"71dc14c7f3e4025aebfd51e41841bbd891edb799bfe63b8d3188d3f1e67c52ba\\\",\n\\\"public_key\\\":\\\"0459201fef606e28f2b1bfb5a3805", "end": 116340, "score": 0.999743640422821, "start": 116276, "tag": "KEY", "value": "71dc14c7f3e4025aebfd51e41841bbd891edb799bfe63b8d3188d3f1e67c52ba" }, { "context": "db799bfe63b8d3188d3f1e67c52ba\\\",\n\\\"public_key\\\":\\\"0459201fef606e28f2b1bfb5a380532d50a177c413d1cbc8bd527f3b15f0efa9f893187c21f3870b460a3ed1403af5abb8d37f700af816a22dc5541e299b5fa48f\\\"},\n\n{\\\"tx_hash\\\":\\\"39db27fa5adcaf0b828d5037a882a4a", "end": 116493, "score": 0.9997054934501648, "start": 116361, "tag": "KEY", "value": "0459201fef606e28f2b1bfb5a380532d50a177c413d1cbc8bd527f3b15f0efa9f893187c21f3870b460a3ed1403af5abb8d37f700af816a22dc5541e299b5fa48f\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.408Z\\\",\n\\\"private_key\\\":\\\"7aa8b8318e347d18d638d447a577a744bcf8abe7ef35e11616e07086606afe7d\\\",\n\\\"public_key\\\":\\\"041e7c049c226c6de1b488d76e667", "end": 116820, "score": 0.9988800883293152, "start": 116756, "tag": "KEY", "value": "7aa8b8318e347d18d638d447a577a744bcf8abe7ef35e11616e07086606afe7d" }, { "context": "8abe7ef35e11616e07086606afe7d\\\",\n\\\"public_key\\\":\\\"041e7c049c226c6de1b488d76e6670c5ec8d43930382aceac1661e4a72ed4770a87c84d955edf00e288136194315967fa34c397fcddfec5c22781e69a79bc18922\\\"},\n\n{\\\"tx_hash\\\":\\\"7e2f10ee736048c19c19c1a7202b11a", "end": 116973, "score": 0.9995813369750977, "start": 116841, "tag": "KEY", "value": "041e7c049c226c6de1b488d76e6670c5ec8d43930382aceac1661e4a72ed4770a87c84d955edf00e288136194315967fa34c397fcddfec5c22781e69a79bc18922\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.418Z\\\",\n\\\"private_key\\\":\\\"670cef68a8c9c717dc7e677870988e723bd94c4c91f394368f6988746aea2d25\\\",\n\\\"public_key\\\":\\\"04290c17da13076486ec59fbee121", "end": 117300, "score": 0.9997544884681702, "start": 117236, "tag": "KEY", "value": "670cef68a8c9c717dc7e677870988e723bd94c4c91f394368f6988746aea2d25" }, { "context": "94c4c91f394368f6988746aea2d25\\\",\n\\\"public_key\\\":\\\"04290c17da13076486ec59fbee121300f002063fa7804d3b73c55fe5573c98abdfaa533ecabf2bc5db6183e1b9f71d929246e0212101243767aa5f58bcb3bd0587\\\"},\n\n{\\\"tx_hash\\\":\\\"35189b74ac7e0cd8fb723b450f8d63f", "end": 117453, "score": 0.999735414981842, "start": 117321, "tag": "KEY", "value": "04290c17da13076486ec59fbee121300f002063fa7804d3b73c55fe5573c98abdfaa533ecabf2bc5db6183e1b9f71d929246e0212101243767aa5f58bcb3bd0587\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.427Z\\\",\n\\\"private_key\\\":\\\"af19fdd998f0d3a4402846e6ff4a1c4bf1cf4036163bbef70a340e71d149233d\\\",\n\\\"public_key\\\":\\\"04c2623968c6b40a92b964ce291d8339", "end": 117783, "score": 0.9984140992164612, "start": 117716, "tag": "KEY", "value": "af19fdd998f0d3a4402846e6ff4a1c4bf1cf4036163bbef70a340e71d149233d\\\"," }, { "context": "f4036163bbef70a340e71d149233d\\\",\n\\\"public_key\\\":\\\"04c2623968c6b40a92b964ce291d83390659444fdc402f8994a00cd10cf7f64abb11074cfc9138d920f3e1bd3ab66f4e9083ed6ab90100381d716627f9043181fb\\\"},\n\n{\\\"tx_hash\\\":\\\"eb286633e29904901ca2ae4df5bbaf1", "end": 117933, "score": 0.9997154474258423, "start": 117801, "tag": "KEY", "value": "04c2623968c6b40a92b964ce291d83390659444fdc402f8994a00cd10cf7f64abb11074cfc9138d920f3e1bd3ab66f4e9083ed6ab90100381d716627f9043181fb\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.444Z\\\",\n\\\"private_key\\\":\\\"2e1beadc2cc095bad9514bfaeb0aaf59118a3259fa86c205fdb01536bf5a5a80\\\",\n\\\"public_key\\\":\\\"041d595105ad528a9d1d9a451dd87", "end": 118260, "score": 0.9996129274368286, "start": 118196, "tag": "KEY", "value": "2e1beadc2cc095bad9514bfaeb0aaf59118a3259fa86c205fdb01536bf5a5a80" }, { "context": "a3259fa86c205fdb01536bf5a5a80\\\",\n\\\"public_key\\\":\\\"041d595105ad528a9d1d9a451dd8769a44a32ac995faa1989040ae0e23171bbd49b5e6e9f86933ab5ca37b0ab482847ad2e09c50b6c39b64e691ded5fd280eab2a\\\"},\n\n{\\\"tx_hash\\\":\\\"b4b82100bc96cb2531b11a228cebe6e", "end": 118413, "score": 0.9996590614318848, "start": 118281, "tag": "KEY", "value": "041d595105ad528a9d1d9a451dd8769a44a32ac995faa1989040ae0e23171bbd49b5e6e9f86933ab5ca37b0ab482847ad2e09c50b6c39b64e691ded5fd280eab2a\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.460Z\\\",\n\\\"private_key\\\":\\\"da1b8796b28f11115c7100247d7878ba3868dc5ed0a099e55390c1e8d69c11ae\\\",\n\\\"public_key\\\":\\\"04760dc9435d9b2a84860abcd4337", "end": 118740, "score": 0.9997692704200745, "start": 118676, "tag": "KEY", "value": "da1b8796b28f11115c7100247d7878ba3868dc5ed0a099e55390c1e8d69c11ae" }, { "context": "8dc5ed0a099e55390c1e8d69c11ae\\\",\n\\\"public_key\\\":\\\"04760dc9435d9b2a84860abcd4337a9a43601a7b54a5b0c486f9a934fc28ff6bdecd9174ae03792c607a110d95e32b51832958a12ed064a724e8b31c847049f3ed\\\"},\n\n{\\\"tx_hash\\\":\\\"633e453ecbc79bff9260bd1e2ae6fde", "end": 118893, "score": 0.9997532367706299, "start": 118761, "tag": "KEY", "value": "04760dc9435d9b2a84860abcd4337a9a43601a7b54a5b0c486f9a934fc28ff6bdecd9174ae03792c607a110d95e32b51832958a12ed064a724e8b31c847049f3ed\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.470Z\\\",\n\\\"private_key\\\":\\\"9f3fd1b6fee565ebb6e8237e1a62a4811da9c59eee487c0a460872d533fd1bdd\\\",\n\\\"public_key\\\":\\\"045da31a8c105b75a5b0f18ac5a21", "end": 119220, "score": 0.9997097849845886, "start": 119156, "tag": "KEY", "value": "9f3fd1b6fee565ebb6e8237e1a62a4811da9c59eee487c0a460872d533fd1bdd" }, { "context": "9c59eee487c0a460872d533fd1bdd\\\",\n\\\"public_key\\\":\\\"045da31a8c105b75a5b0f18ac5a21a752d3bbae245de37edd9a361e9992438e9f4948c697b28b38531955ff65378ae206aa1fb8855c87abc6fa034a7d0c59790f2\\\"},\n\n{\\\"tx_hash\\\":\\\"14ac6a2f3eabde6d34518e6b45a4b61", "end": 119373, "score": 0.9997071027755737, "start": 119241, "tag": "KEY", "value": "045da31a8c105b75a5b0f18ac5a21a752d3bbae245de37edd9a361e9992438e9f4948c697b28b38531955ff65378ae206aa1fb8855c87abc6fa034a7d0c59790f2\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.490Z\\\",\n\\\"private_key\\\":\\\"6fd65475931d2e4d3582ffff973085ec56f18be6f8618ece2a94579e", "end": 119642, "score": 0.9996544718742371, "start": 119636, "tag": "KEY", "value": "6fd654" }, { "context": "11-05T02:01:54.490Z\\\",\n\\\"private_key\\\":\\\"6fd65475931d2e4d3582ffff973085ec56f18be6f8618ece2a94579edb77", "end": 119646, "score": 0.996386706829071, "start": 119645, "tag": "KEY", "value": "3" }, { "context": "-05T02:01:54.490Z\\\",\n\\\"private_key\\\":\\\"6fd65475931d2e4d3582ffff973085ec56f18be6f8618ece2a94579edb771c", "end": 119648, "score": 0.981034517288208, "start": 119647, "tag": "KEY", "value": "d" }, { "context": "02:01:54.490Z\\\",\n\\\"private_key\\\":\\\"6fd65475931d2e4d3582ffff973085ec56f18be6f8618ece2a94579edb771c62\\\"", "end": 119652, "score": 0.997345507144928, "start": 119651, "tag": "KEY", "value": "d" }, { "context": "18be6f8618ece2a94579edb771c62\\\",\n\\\"public_key\\\":\\\"046c3a3188b6185a4c998e192528f956d7c23fe5449e416d2ccacbc0f238d291d61942075a48ac288fb957a04162178096a4daea28d638c32643af8f959708f4da\\\"},\n\n{\\\"tx_hash\\\":\\\"ce9a86fffc98ee5581d0afcc7e2c31b", "end": 119853, "score": 0.9997235536575317, "start": 119721, "tag": "KEY", "value": "046c3a3188b6185a4c998e192528f956d7c23fe5449e416d2ccacbc0f238d291d61942075a48ac288fb957a04162178096a4daea28d638c32643af8f959708f4da\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.499Z\\\",\n\\\"private_key\\\":\\\"d1669c355a3670a4fd9a28124160a07cdd9d1f0e0eaad94415ba30d4cff07678\\\",\n\\\"public_key\\\":\\\"04ad6fc4692520ca7ed13a98e82b2", "end": 120180, "score": 0.9997519254684448, "start": 120116, "tag": "KEY", "value": "d1669c355a3670a4fd9a28124160a07cdd9d1f0e0eaad94415ba30d4cff07678" }, { "context": "d1f0e0eaad94415ba30d4cff07678\\\",\n\\\"public_key\\\":\\\"04ad6fc4692520ca7ed13a98e82b22a35e182ccc8b5d2dd595221acc0f6da32f061cb09bd6e656ad64a177f7b91fc9d595a532a531a0ad4d31354c8c43c8af6ff9\\\"},\n\n{\\\"tx_hash\\\":\\\"a58ab327b123f52cfb4dcf", "end": 120324, "score": 0.9997410178184509, "start": 120201, "tag": "KEY", "value": "04ad6fc4692520ca7ed13a98e82b22a35e182ccc8b5d2dd595221acc0f6da32f061cb09bd6e656ad64a177f7b91fc9d595a532a531a0ad4d31354c8c43c" }, { "context": "\":\\\"2015-04-09T03:41:32.631Z\\\",\n\\\"private_key\\\":\\\"02da5e096175c5c1a7acf1c2765d8dbcb6ad17c0595b23d46f38f2ba467dc5c9\\\",\n\\\"public_key\\\":\\\"031ce436f668d59b4c99ddc530a6f", "end": 120660, "score": 0.9997419714927673, "start": 120596, "tag": "KEY", "value": "02da5e096175c5c1a7acf1c2765d8dbcb6ad17c0595b23d46f38f2ba467dc5c9" }, { "context": "d17c0595b23d46f38f2ba467dc5c9\\\",\n\\\"public_key\\\":\\\"031ce436f668d59b4c99ddc530a6ff46f455757455e34494acd3bec06ebd18b1d4\\\"},\n\n{\\\"tx_hash\\\":\\\"f349f7a051bdccbdaaa8a8aa6f4e1d7", "end": 120749, "score": 0.9997270703315735, "start": 120681, "tag": "KEY", "value": "031ce436f668d59b4c99ddc530a6ff46f455757455e34494acd3bec06ebd18b1d4\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.520Z\\\",\n\\\"private_key\\\":\\\"f1a30268e44d2ca6de03198244176b8ae6fdfa390acd908e3588bfaebf8a00b6\\\",\n\\\"public_key\\\":\\\"044fdf3c7eb30892c8acee0a9a82d", "end": 121076, "score": 0.9997180104255676, "start": 121012, "tag": "KEY", "value": "f1a30268e44d2ca6de03198244176b8ae6fdfa390acd908e3588bfaebf8a00b6" }, { "context": "dfa390acd908e3588bfaebf8a00b6\\\",\n\\\"public_key\\\":\\\"044fdf3c7eb30892c8acee0a9a82d27c48d80e9f964f0b2dd73e323ea863d59e652bd608ad7ebb146d192bb4511291386e0482dfd53b725e62762a4f661eb80523\\\"},\n\n{\\\"tx_hash\\\":\\\"1be02fd5d8ff79ff476c98e8579c03d", "end": 121229, "score": 0.9996324181556702, "start": 121097, "tag": "KEY", "value": "044fdf3c7eb30892c8acee0a9a82d27c48d80e9f964f0b2dd73e323ea863d59e652bd608ad7ebb146d192bb4511291386e0482dfd53b725e62762a4f661eb80523\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.546Z\\\",\n\\\"private_key\\\":\\\"a0a043e6aba57c55b055c4c857592dec1f014c75cd0ac854f32ddb8da9a0f65b\\\",\n\\\"public_key\\\":\\\"040299b2fb02490b355ee39eb9e79", "end": 121556, "score": 0.9997515082359314, "start": 121492, "tag": "KEY", "value": "a0a043e6aba57c55b055c4c857592dec1f014c75cd0ac854f32ddb8da9a0f65b" }, { "context": "14c75cd0ac854f32ddb8da9a0f65b\\\",\n\\\"public_key\\\":\\\"040299b2fb02490b355ee39eb9e79121d4f571bd5f5f16ebf894b75de980565bc1db506c53daacad0a677f789f1b2eb954b1d9627f5ee6c5a2a77ca42a3e911a90\\\"},\n\n{\\\"tx_hash\\\":\\\"d7f8eaa6c629835573b2ea32c2fff12", "end": 121709, "score": 0.9997380375862122, "start": 121577, "tag": "KEY", "value": "040299b2fb02490b355ee39eb9e79121d4f571bd5f5f16ebf894b75de980565bc1db506c53daacad0a677f789f1b2eb954b1d9627f5ee6c5a2a77ca42a3e911a90\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.556Z\\\",\n\\\"private_key\\\":\\\"c4c4e7c28d2795b5d7648063211875ad0c0a3abcf4a10c802ee64ae9aed8b7fb\\\",\n\\\"public_key\\\":\\\"049658cc2fb59ed09123039eab6e4", "end": 122036, "score": 0.9997171759605408, "start": 121972, "tag": "KEY", "value": "c4c4e7c28d2795b5d7648063211875ad0c0a3abcf4a10c802ee64ae9aed8b7fb" }, { "context": "a3abcf4a10c802ee64ae9aed8b7fb\\\",\n\\\"public_key\\\":\\\"049658cc2fb59ed09123039eab6e461b0380ccd934036caa11376f35901a07930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\", "end": 122145, "score": 0.9995821714401245, "start": 122057, "tag": "KEY", "value": "049658cc2fb59ed09123039eab6e461b0380ccd934036caa11376f35901a07930f8a6ade5992f0580d5d91c7" }, { "context": "934036caa11376f35901a07930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash", "end": 122153, "score": 0.9586396813392639, "start": 122146, "tag": "KEY", "value": "6a731ff" }, { "context": "76f35901a07930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash\\\":\\\"f", "end": 122159, "score": 0.6913080215454102, "start": 122158, "tag": "KEY", "value": "8" }, { "context": "901a07930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash\\\":\\\"f912b95e", "end": 122166, "score": 0.7809287905693054, "start": 122163, "tag": "KEY", "value": "dfa" }, { "context": "930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash\\\":\\\"f912b95edf2f3c2", "end": 122173, "score": 0.996098518371582, "start": 122169, "tag": "KEY", "value": "413e" }, { "context": "a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash\\\":\\\"f912b95edf2f3c2722", "end": 122176, "score": 0.7607848644256592, "start": 122174, "tag": "KEY", "value": "1e" }, { "context": "de5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\\\"},\n\n{\\\"tx_hash\\\":\\\"f912b95edf2f3c27222e7bf5fcd16bc", "end": 122189, "score": 0.9899308085441589, "start": 122177, "tag": "KEY", "value": "bf2dc66a1d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.570Z\\\",\n\\\"private_key\\\":\\\"035f575db8c8bd332f1f908a53a987b9dfaf7c9e3ed311085074fd23f626abdc\\\",\n\\\"public_key\\\":\\\"045badecc2e5d81bebb546a502366", "end": 122516, "score": 0.9996137619018555, "start": 122452, "tag": "KEY", "value": "035f575db8c8bd332f1f908a53a987b9dfaf7c9e3ed311085074fd23f626abdc" }, { "context": "f7c9e3ed311085074fd23f626abdc\\\",\n\\\"public_key\\\":\\\"045badecc2e5d81bebb546a50236623f044ef46f2831bab3bafc1b96172546bb3c2dfdea76c57dbd3ecc531c87713013e12bfbbfda5f704fd4890a68a2344d7d9e\\\"},\n\n{\\\"tx_hash\\\":\\\"030c377b490360e39c8bb321d235ce0", "end": 122669, "score": 0.9997521638870239, "start": 122537, "tag": "KEY", "value": "045badecc2e5d81bebb546a50236623f044ef46f2831bab3bafc1b96172546bb3c2dfdea76c57dbd3ecc531c87713013e12bfbbfda5f704fd4890a68a2344d7d9e\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.580Z\\\",\n\\\"private_key\\\":\\\"0c6eff1e964346f3b543ebe212e6c9ff113a8de495f229b497eb20a89a3695d1\\\",\n\\\"public_key\\\":\\\"0446b8cc299cef980aa1666a535e5", "end": 122996, "score": 0.9997273087501526, "start": 122932, "tag": "KEY", "value": "0c6eff1e964346f3b543ebe212e6c9ff113a8de495f229b497eb20a89a3695d1" }, { "context": "a8de495f229b497eb20a89a3695d1\\\",\n\\\"public_key\\\":\\\"0446b8cc299cef980aa1666a535e5f666c566f1acdac7b29cef74f9f0c47014392234e9c845fc126fc00be4a872c47bd24cbd7a2dd56a172346090d087124ac90d\\\"},\n\n{\\\"tx_hash\\\":\\\"a7d0a02d81ce67e33b948b226183585", "end": 123149, "score": 0.9997366070747375, "start": 123017, "tag": "KEY", "value": "0446b8cc299cef980aa1666a535e5f666c566f1acdac7b29cef74f9f0c47014392234e9c845fc126fc00be4a872c47bd24cbd7a2dd56a172346090d087124ac90d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.594Z\\\",\n\\\"private_key\\\":\\\"4edb50ac0b02bdebe5055657dd68fb33231e14f2394d1d8379661bac688e6e01\\\",\n\\\"public_key\\\":\\\"04b0264941fe427e9b04d512d96c1", "end": 123476, "score": 0.9996116757392883, "start": 123412, "tag": "KEY", "value": "4edb50ac0b02bdebe5055657dd68fb33231e14f2394d1d8379661bac688e6e01" }, { "context": "e14f2394d1d8379661bac688e6e01\\\",\n\\\"public_key\\\":\\\"04b0264941fe427e9b04d512d96c1f9ff92a15c1d2bcff404113234567735c8874e7359bdf36d233bb9bdd2dbc83df56b6db66af43e936392f6b600efe0562cd3d\\\"},\n\n{\\\"tx_hash", "end": 123593, "score": 0.9996088147163391, "start": 123497, "tag": "KEY", "value": "04b0264941fe427e9b04d512d96c1f9ff92a15c1d2bcff404113234567735c8874e7359bdf36d233bb9bdd2dbc83df56" }, { "context": "04113234567735c8874e7359bdf36d233bb9bdd2dbc83df56b6db66af43e936392f6b600efe0562cd3d\\\"},\n\n{\\\"tx_hash\\\":\\\"1cfe6f32d9ecd8467da2ef350cc1235", "end": 123629, "score": 0.9986885786056519, "start": 123594, "tag": "KEY", "value": "6db66af43e936392f6b600efe0562cd3d\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.604Z\\\",\n\\\"private_key\\\":\\\"faecc352ef229de2dae2d9510fe237ad36a5d8bc2b5dea60bc00da226ef726d3\\\",\n\\\"public_key\\\":\\\"048ec9fc5b33dff5adff761bf252a", "end": 123956, "score": 0.9993206858634949, "start": 123892, "tag": "KEY", "value": "faecc352ef229de2dae2d9510fe237ad36a5d8bc2b5dea60bc00da226ef726d3" }, { "context": "5d8bc2b5dea60bc00da226ef726d3\\\",\n\\\"public_key\\\":\\\"048ec9fc5b33dff5adff761bf252a945f73080e30f625a21bbd38a7f3df2be3eeed87dc6490e8d381b77726bdf06da314786bf2aeac80789dca8055ef5b810e44d\\\"},\n\n{\\\"tx_hash\\\":\\\"7351a3ecbf091b4bd26879f682cdd3e", "end": 124109, "score": 0.9996820092201233, "start": 123977, "tag": "KEY", "value": "048ec9fc5b33dff5adff761bf252a945f73080e30f625a21bbd38a7f3df2be3eeed87dc6490e8d381b77726bdf06da314786bf2aeac80789dca8055ef5b810e44d\\\"" }, { "context": "\":\\\"2015-03-01T03:32:15.363Z\\\",\n\\\"private_key\\\":\\\"884880dfca250d8cd0c607986eb6319e1a9617600d5556522c78a6833849150d\\\",\n\\\"public_key\\\":\\\"036c26d790bb0e782731e30daa63a", "end": 124436, "score": 0.9997580647468567, "start": 124372, "tag": "KEY", "value": "884880dfca250d8cd0c607986eb6319e1a9617600d5556522c78a6833849150d" }, { "context": "617600d5556522c78a6833849150d\\\",\n\\\"public_key\\\":\\\"036c26d790bb0e782731e30daa63af44e480345a679b9b737be247474e35bb1efc\\\"},\n\n{\\\"tx_hash\\\":\\\"f97397d2ec383e005bd9eb92a7537f1", "end": 124525, "score": 0.9997491240501404, "start": 124457, "tag": "KEY", "value": "036c26d790bb0e782731e30daa63af44e480345a679b9b737be247474e35bb1efc\\\"" }, { "context": "\":\\\"2015-05-19T18:12:12.879Z\\\",\n\\\"private_key\\\":\\\"7c0c8efd19a303d1545c0b3ee0ed05664161d85acb3b1deff5acdab0e0885171\\\",\n\\\"public_key\\\":\\\"02752eed5fb60b4f95dd67c5240cc", "end": 124852, "score": 0.9997593760490417, "start": 124788, "tag": "KEY", "value": "7c0c8efd19a303d1545c0b3ee0ed05664161d85acb3b1deff5acdab0e0885171" }, { "context": "1d85acb3b1deff5acdab0e0885171\\\",\n\\\"public_key\\\":\\\"02752eed5fb60b4f95dd67c5240cc77921ba864770cb3f7f75c51d7412b7ee84e3\\\"},\n\n{\\\"tx_hash\\\":\\\"8801507b6464f0c271b6dda43fd46c3", "end": 124941, "score": 0.9997553825378418, "start": 124873, "tag": "KEY", "value": "02752eed5fb60b4f95dd67c5240cc77921ba864770cb3f7f75c51d7412b7ee84e3\\\"" }, { "context": "\":\\\"2015-02-06T01:12:09.129Z\\\",\n\\\"private_key\\\":\\\"a8de9c1bc3bf8a07332e9b25e2eee8add878920846a7e3a6aa946f9b517305c2\\\",\n\\\"public_key\\\":\\\"03aa698fde8de43b212c6e57f9532", "end": 125268, "score": 0.9997736811637878, "start": 125204, "tag": "KEY", "value": "a8de9c1bc3bf8a07332e9b25e2eee8add878920846a7e3a6aa946f9b517305c2" }, { "context": "8920846a7e3a6aa946f9b517305c2\\\",\n\\\"public_key\\\":\\\"03aa698fde8de43b212c6e57f9532b1efb56c67f7545adad7618991ddc19aa8740\\\"},\n\n{\\\"tx_hash\\\":\\\"09ddafe9b2a44217c28b88c4b2b0b7a", "end": 125357, "score": 0.9997719526290894, "start": 125289, "tag": "KEY", "value": "03aa698fde8de43b212c6e57f9532b1efb56c67f7545adad7618991ddc19aa8740\\\"" }, { "context": "\":\\\"2015-04-11T04:03:53.529Z\\\",\n\\\"private_key\\\":\\\"a3210c1acd783a1e24c47e0732881260b39e346b42fbbdd52a4bd309cdfaa417\\\",\n\\\"public_key\\\":\\\"035182a4caf20e1da94627f68e7aa", "end": 125684, "score": 0.9997580647468567, "start": 125620, "tag": "KEY", "value": "a3210c1acd783a1e24c47e0732881260b39e346b42fbbdd52a4bd309cdfaa417" }, { "context": "e346b42fbbdd52a4bd309cdfaa417\\\",\n\\\"public_key\\\":\\\"035182a4caf20e1da94627f68e7aa7e8dda823ee91185f5ed270b123be28e19a9f\\\"},\n\n{\\\"tx_hash\\\":\\\"97dc3f7272e00a2adbc36134861ad20", "end": 125773, "score": 0.9996883869171143, "start": 125705, "tag": "KEY", "value": "035182a4caf20e1da94627f68e7aa7e8dda823ee91185f5ed270b123be28e19a9f\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.635Z\\\",\n\\\"private_key\\\":\\\"519a4ee16346a70dabea5d162a0b67c3ad4e896eab530984bd3e9680c70190d8\\\",\n\\\"public_key\\\":\\\"04b81d677fc15206181cb1ccb76fb", "end": 126100, "score": 0.9997577667236328, "start": 126036, "tag": "KEY", "value": "519a4ee16346a70dabea5d162a0b67c3ad4e896eab530984bd3e9680c70190d8" }, { "context": "e896eab530984bd3e9680c70190d8\\\",\n\\\"public_key\\\":\\\"04b81d677fc15206181cb1ccb76fb4645bf052e3563dd943557ace2a9889317a3d3a32c59c3973f635c29bb5c470", "end": 126163, "score": 0.9997344613075256, "start": 126121, "tag": "KEY", "value": "04b81d677fc15206181cb1ccb76fb4645bf052e356" }, { "context": "\":\\\"2014-11-05T02:01:54.664Z\\\",\n\\\"private_key\\\":\\\"7baa4771cfe5cd3f209ed1258143a90caf75ecc19a8ff03791bc95ebdb3af852\\\",\n\\\"public_key\\\":\\\"043880c7c5c845f0c3e30bc96aef0", "end": 126580, "score": 0.9997642636299133, "start": 126516, "tag": "KEY", "value": "7baa4771cfe5cd3f209ed1258143a90caf75ecc19a8ff03791bc95ebdb3af852" }, { "context": "5ecc19a8ff03791bc95ebdb3af852\\\",\n\\\"public_key\\\":\\\"043880c7c5c845f0c3e30bc96aef02eb1b5a48a25737497753e191ddbf720ad22f266607f9564f369f60facc02983d3da27b899a2eb9e9f14c35f89019797a8dc4\\\"},\n\n{\\\"tx_hash\\\":\\\"d10225248e5742e0001196eefef871e", "end": 126733, "score": 0.9997541904449463, "start": 126601, "tag": "KEY", "value": "043880c7c5c845f0c3e30bc96aef02eb1b5a48a25737497753e191ddbf720ad22f266607f9564f369f60facc02983d3da27b899a2eb9e9f14c35f89019797a8dc4\\\"" }, { "context": "\n\\\"recipient\\\":\\\"1GscL6FtdwR8HCGtntanruiUgx7WyaEKRp\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2014-08-09T00:0", "end": 126870, "score": 0.9996559619903564, "start": 126869, "tag": "KEY", "value": "p" }, { "context": "\":\\\"2014-11-05T02:01:54.674Z\\\",\n\\\"private_key\\\":\\\"47852849244f7bf6140f0596b6adbd83ae5c867ac92d41df5cbf71be487a3c1a\\\",\n\\\"public_key\\\":\\\"040559134da2ad53bc6474013b7a6", "end": 127060, "score": 0.9997517466545105, "start": 126996, "tag": "KEY", "value": "47852849244f7bf6140f0596b6adbd83ae5c867ac92d41df5cbf71be487a3c1a" }, { "context": "c867ac92d41df5cbf71be487a3c1a\\\",\n\\\"public_key\\\":\\\"040559134da2ad53bc6474013b7a6027b0ac55cf1fc57596a85d27abe2d658147b0f904af77ba6a86323641c57c61491dca36e8263a22399587c9a8a7c1af055f1\\\"},\n\n{\\\"tx_hash\\\":\\\"5f8636d47e297945df2152d366f4add", "end": 127213, "score": 0.9996835589408875, "start": 127081, "tag": "KEY", "value": "040559134da2ad53bc6474013b7a6027b0ac55cf1fc57596a85d27abe2d658147b0f904af77ba6a86323641c57c61491dca36e8263a22399587c9a8a7c1af055f1\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.684Z\\\",\n\\\"private_key\\\":\\\"8859fca82b92c241f3cab9d26574cd6a10e667ed3d4313f396be5da4b878fa99\\\",\n\\\"public_key\\\":\\\"04b582355d1b27cc55ebe27f83c01", "end": 127540, "score": 0.999759316444397, "start": 127476, "tag": "KEY", "value": "8859fca82b92c241f3cab9d26574cd6a10e667ed3d4313f396be5da4b878fa99" }, { "context": "667ed3d4313f396be5da4b878fa99\\\",\n\\\"public_key\\\":\\\"04b582355d1b27cc55ebe27f83c01ddcea0c905c1e87c7dc57a03fc84d1fb0c59e4033389bcd4cb", "end": 127590, "score": 0.974334716796875, "start": 127561, "tag": "KEY", "value": "04b582355d1b27cc55ebe27f83c01" }, { "context": ",\n\\\"public_key\\\":\\\"04b582355d1b27cc55ebe27f83c01ddcea0c905c1e87c7dc57a03fc84d1fb0c59e4033389bcd4cb7f77ba31f37e78490494bbdcab311b5bcc241d61927b42ddd41\\\"},\n\n{\\\"tx_hash\\\":\\\"87dc93e88", "end": 127671, "score": 0.9543091058731079, "start": 127592, "tag": "KEY", "value": "cea0c905c1e87c7dc57a03fc84d1fb0c59e4033389bcd4cb7f77ba31f37e78490494bbdcab311b5" }, { "context": "59e4033389bcd4cb7f77ba31f37e78490494bbdcab311b5bcc241d61927b42ddd41\\\"},\n\n{\\\"tx_hash\\\":\\\"87dc93e880ef54fd656", "end": 127681, "score": 0.8583696484565735, "start": 127674, "tag": "KEY", "value": "241d619" }, { "context": "bcd4cb7f77ba31f37e78490494bbdcab311b5bcc241d61927b42ddd41\\\"},\n\n{\\\"tx_hash\\\":\\\"87dc93e880ef54fd656d393b", "end": 127686, "score": 0.7114746570587158, "start": 127684, "tag": "KEY", "value": "42" }, { "context": "7f77ba31f37e78490494bbdcab311b5bcc241d61927b42ddd41\\\"},\n\n{\\\"tx_hash\\\":\\\"87dc93e880ef54fd656d393b071de", "end": 127691, "score": 0.8380616307258606, "start": 127690, "tag": "KEY", "value": "1" }, { "context": "\":\\\"2014-11-05T02:01:54.694Z\\\",\n\\\"private_key\\\":\\\"cbbb27956f2f47c7aa26c5e43e9e84d16d3feb0c14fce3710d9f80646c7e7b0b\\\",\n\\\"public_key\\\":\\\"047057be7dcd4e65023fe562ef1bd", "end": 128020, "score": 0.9997349977493286, "start": 127956, "tag": "KEY", "value": "cbbb27956f2f47c7aa26c5e43e9e84d16d3feb0c14fce3710d9f80646c7e7b0b" }, { "context": "feb0c14fce3710d9f80646c7e7b0b\\\",\n\\\"public_key\\\":\\\"047057be7dcd4e65023fe562ef1bdd025780c74d943d7ebb9e9e7d1b1e37cefed29147ea38cbe40eb343c4400193e85bb24796320158f33e11a387fb5e3118c8e7\\\"},\n\n{\\\"tx_hash\\\":\\\"4da9a8e99bd107aef496ef7d6a082ad", "end": 128173, "score": 0.9996540546417236, "start": 128041, "tag": "KEY", "value": "047057be7dcd4e65023fe562ef1bdd025780c74d943d7ebb9e9e7d1b1e37cefed29147ea38cbe40eb343c4400193e85bb24796320158f33e11a387fb5e3118c8e7\\\"" }, { "context": "513e38dba\\\",\n\\\"recipient\\\":\\\"183RdFzvnR4iDTYxfDCmuA9wG3F9AMHNiP\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2014-10-24T00:0", "end": 128310, "score": 0.9996737837791443, "start": 128297, "tag": "KEY", "value": "A9wG3F9AMHNiP" }, { "context": "\":\\\"2014-11-05T02:01:54.704Z\\\",\n\\\"private_key\\\":\\\"785c803685686f21e964f1bf790e830fa23b3ef4618102aeaa5ed371d24e2e24\\\",\n\\\"public_key\\\":\\\"0465468ad86e12aa95f17bd250428", "end": 128500, "score": 0.9997473955154419, "start": 128436, "tag": "KEY", "value": "785c803685686f21e964f1bf790e830fa23b3ef4618102aeaa5ed371d24e2e24" }, { "context": "b3ef4618102aeaa5ed371d24e2e24\\\",\n\\\"public_key\\\":\\\"0465468ad86e12aa95f17bd2504287893c2fd4543915b84518e689261cf363fec4d99a858e94e1e40c0407ee12dad516207c4e2369237af1d8b863f89d73a3bf08\\\"},\n\n{\\\"tx_hash\\\":\\\"49f2c9c84e1176113b6e5a8072c26a6", "end": 128653, "score": 0.9996516108512878, "start": 128521, "tag": "KEY", "value": "0465468ad86e12aa95f17bd2504287893c2fd4543915b84518e689261cf363fec4d99a858e94e1e40c0407ee12dad516207c4e2369237af1d8b863f89d73a3bf08\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.720Z\\\",\n\\\"private_key\\\":\\\"0b5ea59a99945b5383d689f0ac03183da4024f1a5b559270098b9f7dd9f70373\\\",\n\\\"public_key\\\":\\\"04b3c4c1df0282c25145312ea43be", "end": 128980, "score": 0.9997416734695435, "start": 128916, "tag": "KEY", "value": "0b5ea59a99945b5383d689f0ac03183da4024f1a5b559270098b9f7dd9f70373" }, { "context": "24f1a5b559270098b9f7dd9f70373\\\",\n\\\"public_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a5", "end": 129003, "score": 0.9995203018188477, "start": 129001, "tag": "KEY", "value": "04" }, { "context": "373\\\",\n\\\"public_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d", "end": 129031, "score": 0.6992647051811218, "start": 129027, "tag": "KEY", "value": "3be4" }, { "context": "\n\\\"public_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297", "end": 129034, "score": 0.5453286170959473, "start": 129033, "tag": "KEY", "value": "e" }, { "context": "\"public_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2", "end": 129036, "score": 0.6062324047088623, "start": 129035, "tag": "KEY", "value": "f" }, { "context": "ublic_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4", "end": 129038, "score": 0.9889602661132812, "start": 129037, "tag": "KEY", "value": "c" }, { "context": "ic_key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c60", "end": 129041, "score": 0.995984673500061, "start": 129040, "tag": "KEY", "value": "b" }, { "context": "key\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058b", "end": 129044, "score": 0.9945999383926392, "start": 129043, "tag": "KEY", "value": "c" }, { "context": "y\\\":\\\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb7", "end": 129046, "score": 0.7105549573898315, "start": 129045, "tag": "KEY", "value": "f" }, { "context": "4b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d7", "end": 129053, "score": 0.7533516883850098, "start": 129052, "tag": "KEY", "value": "5" }, { "context": "3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770", "end": 129055, "score": 0.9663259387016296, "start": 129054, "tag": "KEY", "value": "b" }, { "context": "4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d77042", "end": 129057, "score": 0.7415306568145752, "start": 129056, "tag": "KEY", "value": "8" }, { "context": "1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c3", "end": 129060, "score": 0.8462854027748108, "start": 129058, "tag": "KEY", "value": "aa" }, { "context": "0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a", "end": 129062, "score": 0.5377355217933655, "start": 129061, "tag": "KEY", "value": "1" }, { "context": "c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee2", "end": 129066, "score": 0.7965973019599915, "start": 129065, "tag": "KEY", "value": "d" }, { "context": "5145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee281", "end": 129068, "score": 0.5609288811683655, "start": 129067, "tag": "KEY", "value": "7" }, { "context": "312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee281694159e", "end": 129075, "score": 0.692634105682373, "start": 129071, "tag": "KEY", "value": "cbb7" }, { "context": "e414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee281694159ee6d7e", "end": 129080, "score": 0.5837947726249695, "start": 129079, "tag": "KEY", "value": "5" }, { "context": "e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee281694159ee6d7ed\\\"},", "end": 129085, "score": 0.7316566705703735, "start": 129083, "tag": "KEY", "value": "7d" }, { "context": "\":\\\"2015-05-20T02:41:24.667Z\\\",\n\\\"private_key\\\":\\\"4f0fb12a9df1fec00c0a79710043335c0aa8a03fcc3bed9a68111a2e18ed9fe6\\\",\n\\\"public_key\\\":\\\"034a4f186050363a7f351f32d79f0", "end": 129460, "score": 0.9997391104698181, "start": 129396, "tag": "KEY", "value": "4f0fb12a9df1fec00c0a79710043335c0aa8a03fcc3bed9a68111a2e18ed9fe6" }, { "context": "8a03fcc3bed9a68111a2e18ed9fe6\\\",\n\\\"public_key\\\":\\\"034a4f186050363a7f351f32d79f0d5b4bd7d38ef75e82f4a28238467836575c32\\\"},\n\n{\\\"tx_hash\\\":\\\"09aff87f6f8470af69fa7999fe1c8c5", "end": 129549, "score": 0.9997544288635254, "start": 129481, "tag": "KEY", "value": "034a4f186050363a7f351f32d79f0d5b4bd7d38ef75e82f4a28238467836575c32\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.741Z\\\",\n\\\"private_key\\\":\\\"b4b6cff7107aa5b97403d3d8f37925e11cd2fc14651ae79177c7494e201a299b\\\",\n\\\"public_key\\\":\\\"047538b95e4cd45e3e307c90f746c", "end": 129876, "score": 0.9997447729110718, "start": 129812, "tag": "KEY", "value": "b4b6cff7107aa5b97403d3d8f37925e11cd2fc14651ae79177c7494e201a299b" }, { "context": "2fc14651ae79177c7494e201a299b\\\",\n\\\"public_key\\\":\\\"047538b95e4cd45e3e307c90f746cdb3268ef5c652b34816136015ad916e2ade8c9be930a934510ba7cd153dc2a61d43ec4897b3832bb1d30d8bd9ed7b64a0d2d8\\\"},\n\n{\\\"tx_hash\\\":\\\"5faa33de1954e3d3e7a86dc2b3382cc", "end": 130029, "score": 0.9996756911277771, "start": 129897, "tag": "KEY", "value": "047538b95e4cd45e3e307c90f746cdb3268ef5c652b34816136015ad916e2ade8c9be930a934510ba7cd153dc2a61d43ec4897b3832bb1d30d8bd9ed7b64a0d2d8\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.758Z\\\",\n\\\"private_key\\\":\\\"4de6f506545918b145edbdbc421a282c81e2dadc7f2291cf47862dfc125a410d\\\",\n\\\"public_key\\\":\\\"042bfe600ab4286b391950c2d37ea", "end": 130356, "score": 0.9997640252113342, "start": 130292, "tag": "KEY", "value": "4de6f506545918b145edbdbc421a282c81e2dadc7f2291cf47862dfc125a410d" }, { "context": "2dadc7f2291cf47862dfc125a410d\\\",\n\\\"public_key\\\":\\\"042bfe600ab4286b391950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae6271", "end": 130429, "score": 0.9910526275634766, "start": 130377, "tag": "KEY", "value": "042bfe600ab4286b391950c2d37ea5e87e68739e73e303e43878" }, { "context": "e600ab4286b391950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae62710602", "end": 130433, "score": 0.5224981307983398, "start": 130432, "tag": "KEY", "value": "4" }, { "context": "0ab4286b391950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2", "end": 130436, "score": 0.5686985850334167, "start": 130435, "tag": "KEY", "value": "1" }, { "context": "b4286b391950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c2003", "end": 130441, "score": 0.7360695004463196, "start": 130437, "tag": "KEY", "value": "367d" }, { "context": "1950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925", "end": 130455, "score": 0.7344209551811218, "start": 130445, "tag": "KEY", "value": "790ebbab27" }, { "context": "5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925f2\\\"", "end": 130459, "score": 0.7518107295036316, "start": 130456, "tag": "KEY", "value": "758" }, { "context": "e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925f2\\\"},\n\n{\\\"t", "end": 130467, "score": 0.7609717845916748, "start": 130460, "tag": "KEY", "value": "88ae488" }, { "context": "3e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925f2\\\"},\n\n{\\\"tx_hash", "end": 130473, "score": 0.8577015995979309, "start": 130468, "tag": "KEY", "value": "c1951" }, { "context": "3878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925f2\\\"},\n\n{\\\"tx_hash\\\":\\\"62e706ab68ed837ad1bcf46af3bef", "end": 130507, "score": 0.8174384236335754, "start": 130475, "tag": "KEY", "value": "627106022b2c20033853a39b980925f2" }, { "context": "\":\\\"2014-11-05T02:01:54.776Z\\\",\n\\\"private_key\\\":\\\"1841e377e2446520edf13af406e6fb6c238436013f4395a3ccaa5240e157d112\\\",\n\\\"public_key\\\":\\\"043f22e8c99fdbb8976922d663bf0", "end": 130836, "score": 0.9997516870498657, "start": 130772, "tag": "KEY", "value": "1841e377e2446520edf13af406e6fb6c238436013f4395a3ccaa5240e157d112" }, { "context": "436013f4395a3ccaa5240e157d112\\\",\n\\\"public_key\\\":\\\"043f22e8c99fdbb8976922d663bf09e5800be21dddc559fa1316f71ffa3efcb5f0eb6f7ee2e8072976801f75b05860ea07e5d42168e5dacf4890b2712ba83455b7\\\"},\n\n{\\\"tx_hash\\\":\\\"bf63f9301f6c44b64b37bbb1f688d7e", "end": 130989, "score": 0.9997400045394897, "start": 130857, "tag": "KEY", "value": "043f22e8c99fdbb8976922d663bf09e5800be21dddc559fa1316f71ffa3efcb5f0eb6f7ee2e8072976801f75b05860ea07e5d42168e5dacf4890b2712ba83455b7\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.800Z\\\",\n\\\"private_key\\\":\\\"0fc0cbd3ffe37870fe3e6843fc67c50c78f869b2324dcaf58c04beddaa3d648b\\\",\n\\\"public_key\\\":\\\"044fddae95623392f70022c374218", "end": 131316, "score": 0.9997413754463196, "start": 131252, "tag": "KEY", "value": "0fc0cbd3ffe37870fe3e6843fc67c50c78f869b2324dcaf58c04beddaa3d648b" }, { "context": "869b2324dcaf58c04beddaa3d648b\\\",\n\\\"public_key\\\":\\\"044fddae95623392f70022c374218981e71114b10bfc9d100c5fbd98b399bd5fc41ad822cda681ee917b9db27c8a91f2a0751c609bcc6869d0f5b3a3b4fa1e905c\\\"},\n\n{\\\"tx_hash\\\":\\\"0a4c0eedc64788e0bd7bc5b6f904db3", "end": 131469, "score": 0.9997363090515137, "start": 131337, "tag": "KEY", "value": "044fddae95623392f70022c374218981e71114b10bfc9d100c5fbd98b399bd5fc41ad822cda681ee917b9db27c8a91f2a0751c609bcc6869d0f5b3a3b4fa1e905c\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.811Z\\\",\n\\\"private_key\\\":\\\"fc3e9814eb060484215c34fd1e10f1b3171cb96ff59558fb82326af1a91ac57f\\\",\n\\\"public_key\\\":\\\"04d66fa4be986e483c0edbd3ba93c", "end": 131796, "score": 0.9997602701187134, "start": 131732, "tag": "KEY", "value": "fc3e9814eb060484215c34fd1e10f1b3171cb96ff59558fb82326af1a91ac57f" }, { "context": "cb96ff59558fb82326af1a91ac57f\\\",\n\\\"public_key\\\":\\\"04d66fa4be986e483c0edbd3ba93c38e3278c35f7365234c6a7378def8ebb5ed860864c04a939b702235011b7b3", "end": 131858, "score": 0.999718427658081, "start": 131817, "tag": "KEY", "value": "04d66fa4be986e483c0edbd3ba93c38e3278c35f7" }, { "context": "\":\\\"2014-11-05T02:01:54.824Z\\\",\n\\\"private_key\\\":\\\"96c374dcf205300ed9c04de5858ca0c0110aab5c9e170e5a703ae871d509b017\\\",\n\\\"public_key\\\":\\\"04b607851467785e3a4d30cf25e97", "end": 132276, "score": 0.9997363090515137, "start": 132212, "tag": "KEY", "value": "96c374dcf205300ed9c04de5858ca0c0110aab5c9e170e5a703ae871d509b017" }, { "context": "aab5c9e170e5a703ae871d509b017\\\",\n\\\"public_key\\\":\\\"04b607851467785e3a4d30cf25e97dc90220031fd5406c20158cbd32f11a2e9fa42f078c267bc1779188c6ece48cebd38cd1f97f4d6601365a12749dae4def34e2\\\"},\n\n{\\\"tx_hash\\\":\\\"22d7711d3700984fe0f9a4b24ed6d9f", "end": 132429, "score": 0.9997087121009827, "start": 132297, "tag": "KEY", "value": "04b607851467785e3a4d30cf25e97dc90220031fd5406c20158cbd32f11a2e9fa42f078c267bc1779188c6ece48cebd38cd1f97f4d6601365a12749dae4def34e2\\\"" }, { "context": "03eee4a0d8878\\\",\n\\\"recipient\\\":\\\"1HSrRGG3xTTgXSSGsAJbNCrEQpuKajXSrG\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2014-06-19T00:0", "end": 132566, "score": 0.9993852972984314, "start": 132549, "tag": "KEY", "value": "AJbNCrEQpuKajXSrG" }, { "context": "\":\\\"2014-11-05T02:01:54.834Z\\\",\n\\\"private_key\\\":\\\"ea346c391198643d32fca75f81aa05f04b335f2c379064c085367ecde5abe7ab\\\",\n\\\"public_key\\\":\\\"04702fff5f942fd55f26b09ae33f1", "end": 132756, "score": 0.9997405409812927, "start": 132692, "tag": "KEY", "value": "ea346c391198643d32fca75f81aa05f04b335f2c379064c085367ecde5abe7ab" }, { "context": "35f2c379064c085367ecde5abe7ab\\\",\n\\\"public_key\\\":\\\"04702fff5f942fd55f26b09ae33f1d65b8a06c1ab5f414bfe724ded05a5dd34d1634f7618a4b62b825f1b85a099b53e0e7a03358dbd845ffb01ef836e17d5c47f3\\\"},\n\n{\\\"tx_hash\\\":\\\"7e8a9612907c313ecf112d77c8728e7", "end": 132909, "score": 0.9995130896568298, "start": 132777, "tag": "KEY", "value": "04702fff5f942fd55f26b09ae33f1d65b8a06c1ab5f414bfe724ded05a5dd34d1634f7618a4b62b825f1b85a099b53e0e7a03358dbd845ffb01ef836e17d5c47f3\\\"" }, { "context": "\":\\\"2014-11-05T02:01:54.882Z\\\",\n\\\"private_key\\\":\\\"29811d0014b32c6f92cca913bc6d1d96a256b4f299d7678729788cb319819f4e\\\",\n\\\"public_key\\\":\\\"04068ec6ee337d8e0a0720b7eb434", "end": 133236, "score": 0.9997606873512268, "start": 133172, "tag": "KEY", "value": "29811d0014b32c6f92cca913bc6d1d96a256b4f299d7678729788cb319819f4e" }, { "context": "6b4f299d7678729788cb319819f4e\\\",\n\\\"public_key\\\":\\\"04068ec6ee337d8e0a0720b7eb43465f0eb880538e2b46ef4379661eb8496", "end": 133268, "score": 0.9996591210365295, "start": 133257, "tag": "KEY", "value": "04068ec6ee3" }, { "context": "ec6ee337d8e0a0720b7eb43465f0eb880538e2b46ef4379661eb849650de02bc9d80a3ebd20aba8e478fb93381451fa839afb3", "end": 133314, "score": 0.8975049257278442, "start": 133312, "tag": "KEY", "value": "eb" }, { "context": "\":\\\"2014-11-05T02:01:55.071Z\\\",\n\\\"private_key\\\":\\\"261effaf3e3f745f1d193e8aba7ad2e18159ceb28f93b1d7000c5f9077a6503b\\\",\n\\\"public_key\\\":\\\"04f232b0dbbcf34b9d1a43d02452d", "end": 133715, "score": 0.9997448325157166, "start": 133651, "tag": "KEY", "value": "261effaf3e3f745f1d193e8aba7ad2e18159ceb28f93b1d7000c5f9077a6503b" }, { "context": "9ceb28f93b1d7000c5f9077a6503b\\\",\n\\\"public_key\\\":\\\"04f232b0dbbcf34b9d1a43d02452d514077f9654a3914f24d810570317bed745f3923de9c6b100bcd970980a93a3abcd5ef3cea9308ec0e137d68c7ab43d6ca8a1\\\"},\n\n{\\\"tx_hash\\\":\\\"1820a8227530e2de48b6f8901239ab9", "end": 133868, "score": 0.9997256994247437, "start": 133736, "tag": "KEY", "value": "04f232b0dbbcf34b9d1a43d02452d514077f9654a3914f24d810570317bed745f3923de9c6b100bcd970980a93a3abcd5ef3cea9308ec0e137d68c7ab43d6ca8a1\\\"" }, { "context": "\":\\\"2015-03-02T04:21:43.443Z\\\",\n\\\"private_key\\\":\\\"5746d6c6a4164532d92d723a9822d57f1bc351e27582307fd4b45dae082dd58f\\\",\n\\\"public_key\\\":\\\"03b1a81a23a4a2afcac9830c08395", "end": 134195, "score": 0.9997571706771851, "start": 134131, "tag": "KEY", "value": "5746d6c6a4164532d92d723a9822d57f1bc351e27582307fd4b45dae082dd58f" }, { "context": "351e27582307fd4b45dae082dd58f\\\",\n\\\"public_key\\\":\\\"03b1a81a23a4a2afcac9830c083952981c0574301faa544d40215fe3e01f6c2f1b\\\"},\n\n{\\\"tx_hash\\\":\\\"6833db89c0603cff2ff8ee9b3cf4a1c", "end": 134284, "score": 0.9997532963752747, "start": 134216, "tag": "KEY", "value": "03b1a81a23a4a2afcac9830c083952981c0574301faa544d40215fe3e01f6c2f1b\\\"" }, { "context": "\":\\\"2015-03-15T23:11:50.287Z\\\",\n\\\"private_key\\\":\\\"ff6433b2f95877aa9daca09c684282acde5f3974f0e5397c2d2af2ae4e0f0e68\\\",\n\\\"public_key\\\":\\\"026c551486a9ff9f1c669ff2caba5", "end": 134611, "score": 0.9997571110725403, "start": 134547, "tag": "KEY", "value": "ff6433b2f95877aa9daca09c684282acde5f3974f0e5397c2d2af2ae4e0f0e68" }, { "context": "f3974f0e5397c2d2af2ae4e0f0e68\\\",\n\\\"public_key\\\":\\\"026c551486a9ff9f1c669ff2caba547eb76d5f0fa070d4a3de242a3acbc66f669b\\\"},\n\n{\\\"tx_hash\\\":\\\"f1b9e9017b97007f4fcf", "end": 134689, "score": 0.9997327923774719, "start": 134632, "tag": "KEY", "value": "026c551486a9ff9f1c669ff2caba547eb76d5f0fa070d4a3de242a3ac" }, { "context": "\":\\\"2015-05-21T04:51:34.994Z\\\",\n\\\"private_key\\\":\\\"6a29c8f3b9ba919ff0ecf70e1f7992a01df88a7339032f6a980c6154a5124f7f\\\",\n\\\"public_key\\\":\\\"0240f4979b453ed4c0bea334f61b4", "end": 135027, "score": 0.9997206926345825, "start": 134963, "tag": "KEY", "value": "6a29c8f3b9ba919ff0ecf70e1f7992a01df88a7339032f6a980c6154a5124f7f" }, { "context": "88a7339032f6a980c6154a5124f7f\\\",\n\\\"public_key\\\":\\\"0240f4979b453ed4c0bea334f61b4237c705774d9b3b1aaef77caa19b9daefda1b\\\"},\n\n{\\\"tx_hash\\\":\\\"d9341c7ae399a33f05f3c2061fdcd16", "end": 135116, "score": 0.9997124671936035, "start": 135048, "tag": "KEY", "value": "0240f4979b453ed4c0bea334f61b4237c705774d9b3b1aaef77caa19b9daefda1b\\\"" }, { "context": "\":\\\"2015-02-07T02:03:43.065Z\\\",\n\\\"private_key\\\":\\\"26521f64c33d8d9ebae614282c0ea9324c5056c3c4106b4ba27913258b844668\\\",\n\\\"public_key\\\":\\\"02ea48fdb9ef5db8eab5295e752c5", "end": 135443, "score": 0.9996889233589172, "start": 135379, "tag": "KEY", "value": "26521f64c33d8d9ebae614282c0ea9324c5056c3c4106b4ba27913258b844668" }, { "context": "056c3c4106b4ba27913258b844668\\\",\n\\\"public_key\\\":\\\"02ea48fdb9ef5db8eab5295e752c50e24c84f510563b4e3c06a0834630dc4b34d4\\\"},\n\n{\\\"tx_hash\\\":\\\"d6c6ddcb450e1434dfdc4717b771d25", "end": 135532, "score": 0.9997241497039795, "start": 135464, "tag": "KEY", "value": "02ea48fdb9ef5db8eab5295e752c50e24c84f510563b4e3c06a0834630dc4b34d4\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.138Z\\\",\n\\\"private_key\\\":\\\"f733bbb38e1be6e7b866bb3fd6e3808bc5e042ee62b4e063ef2a8214623fc927\\\",\n\\\"public_key\\\":\\\"045769c85d840c4e3a5c84294993c", "end": 135859, "score": 0.9997462630271912, "start": 135795, "tag": "KEY", "value": "f733bbb38e1be6e7b866bb3fd6e3808bc5e042ee62b4e063ef2a8214623fc927" }, { "context": "042ee62b4e063ef2a8214623fc927\\\",\n\\\"public_key\\\":\\\"045769c85d840c4e3a5c84294993c702a9d4e92a507bbcbc436cdaf9266fec70bbf3070e07a1dea60f025a00e36b14d16b02749f6789527bb9d73e97d087d2c114\\\"},\n\n{\\\"tx_hash\\\":\\\"a648ca92a6a620cbda3e7dc59c45422", "end": 136012, "score": 0.9997403621673584, "start": 135880, "tag": "KEY", "value": "045769c85d840c4e3a5c84294993c702a9d4e92a507bbcbc436cdaf9266fec70bbf3070e07a1dea60f025a00e36b14d16b02749f6789527bb9d73e97d087d2c114\\\"" }, { "context": "43c445ca507ee702a\\\",\n\\\"recipient\\\":\\\"17wUqNtW71HeJTRMYX5WZZiZC37FaCwyQj\\\",\n\\\"status\\\":1,\n\\\"created_at\\\":\\\"2014-08-12T00:0", "end": 136149, "score": 0.9968865513801575, "start": 136128, "tag": "KEY", "value": "TRMYX5WZZiZC37FaCwyQj" }, { "context": "\":\\\"2014-11-05T02:01:55.288Z\\\",\n\\\"private_key\\\":\\\"c273ff88dbca1268de687fa4f462b306ef13d2e9d04e3b2c4715d88152783673\\\",\n\\\"public_key\\\":\\\"04f3c75af55d75eda66d6d1cc5ec2", "end": 136339, "score": 0.9997430443763733, "start": 136275, "tag": "KEY", "value": "c273ff88dbca1268de687fa4f462b306ef13d2e9d04e3b2c4715d88152783673" }, { "context": "3d2e9d04e3b2c4715d88152783673\\\",\n\\\"public_key\\\":\\\"04f3c75af55d75eda66d6d1cc5ec2d14ea5340aa536ae7f90ee0af8d9f81284dfed82c7453334fb53643358d88224e50d6a1a1e53c949c95228e90786c8f8a5c52\\\"},\n\n{\\\"tx_hash\\\":\\\"7825d568ec2485d01bb0a857e91fa49", "end": 136492, "score": 0.9994465708732605, "start": 136360, "tag": "KEY", "value": "04f3c75af55d75eda66d6d1cc5ec2d14ea5340aa536ae7f90ee0af8d9f81284dfed82c7453334fb53643358d88224e50d6a1a1e53c949c95228e90786c8f8a5c52\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.307Z\\\",\n\\\"private_key\\\":\\\"f94bd823a1c83a77b43433b4a190dac778590a356807023dcef8ce7ca023af4f\\\",\n\\\"public_key\\\":\\\"0485e233448113bd8787fd8ca8938", "end": 136819, "score": 0.9996966123580933, "start": 136755, "tag": "KEY", "value": "f94bd823a1c83a77b43433b4a190dac778590a356807023dcef8ce7ca023af4f" }, { "context": "90a356807023dcef8ce7ca023af4f\\\",\n\\\"public_key\\\":\\\"0485e233448113bd8787fd8ca8938d15549f0833cf7bd386db7c5a69b3007", "end": 136851, "score": 0.9996322393417358, "start": 136840, "tag": "KEY", "value": "0485e233448" }, { "context": "\":\\\"2014-11-05T02:01:55.318Z\\\",\n\\\"private_key\\\":\\\"65377ce7139db85ed2ae8d27d4bebae3aabcab1ab0da62695365980d8dd64ce7\\\",\n\\\"public_key\\\":\\\"04b8d311affb85b189403d8a97690", "end": 137299, "score": 0.999737560749054, "start": 137235, "tag": "KEY", "value": "65377ce7139db85ed2ae8d27d4bebae3aabcab1ab0da62695365980d8dd64ce7" }, { "context": "cab1ab0da62695365980d8dd64ce7\\\",\n\\\"public_key\\\":\\\"04b8d311affb85b189403d8a97690f926d20935aa828b8039c4b67ff4122a4e17b22003a4258ae5d35b6e8b79db7a06fceb658f3b55c3b1160493e77592f060d45\\\"},\n\n{\\\"tx_hash\\\":\\\"4219480d1f44541eede61328b015740", "end": 137452, "score": 0.9997594952583313, "start": 137320, "tag": "KEY", "value": "04b8d311affb85b189403d8a97690f926d20935aa828b8039c4b67ff4122a4e17b22003a4258ae5d35b6e8b79db7a06fceb658f3b55c3b1160493e77592f060d45\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.328Z\\\",\n\\\"private_key\\\":\\\"ede5155627a5cf05ad001e84c4aecc1d709c27d0ac89bb8c2b781ed3fba4e7c8\\\",\n\\\"public_key\\\":\\\"04af3bf26b9ba3b5555495a32680d", "end": 137779, "score": 0.9990972280502319, "start": 137715, "tag": "KEY", "value": "ede5155627a5cf05ad001e84c4aecc1d709c27d0ac89bb8c2b781ed3fba4e7c8" }, { "context": "c27d0ac89bb8c2b781ed3fba4e7c8\\\",\n\\\"public_key\\\":\\\"04af3bf26b9ba3b5555495a32680dea84412e99f17b2d5bfac9800810e6db1db31f6188467ecbd1b36d8169240a32279292a00a5aa957684839d219046e71683b8\\\"},\n\n{\\\"tx_hash\\\"", "end": 137898, "score": 0.9996220469474792, "start": 137800, "tag": "KEY", "value": "04af3bf26b9ba3b5555495a32680dea84412e99f17b2d5bfac9800810e6db1db31f6188467ecbd1b36d8169240a3227929" }, { "context": "800810e6db1db31f6188467ecbd1b36d8169240a32279292a00a5aa957684839d219046e71683b8\\\"},\n\n{\\\"tx_hash\\\":\\\"c", "end": 137902, "score": 0.9281140565872192, "start": 137901, "tag": "KEY", "value": "0" }, { "context": "0810e6db1db31f6188467ecbd1b36d8169240a32279292a00a5aa957684839d219046e71683b8\\\"},\n\n{\\\"tx_hash\\\":\\\"c8d18a", "end": 137907, "score": 0.9757504463195801, "start": 137903, "tag": "KEY", "value": "5aa9" }, { "context": "db31f6188467ecbd1b36d8169240a32279292a00a5aa957684839d219046e71683b8\\\"},\n\n{\\\"tx_hash\\\":\\\"c8d18a04fe3986a2f67df0a59a928", "end": 137930, "score": 0.9969719648361206, "start": 137912, "tag": "KEY", "value": "839d219046e71683b8" }, { "context": "\":\\\"2015-03-03T05:12:59.529Z\\\",\n\\\"private_key\\\":\\\"f27300e144b975e71df6cf6f4741350295f14b325c08b52866e94d2d7eaaa96e\\\",\n\\\"public_key\\\":\\\"0205fd465f833a50163298f614e3a", "end": 138259, "score": 0.9996481537818909, "start": 138195, "tag": "KEY", "value": "f27300e144b975e71df6cf6f4741350295f14b325c08b52866e94d2d7eaaa96e" }, { "context": "14b325c08b52866e94d2d7eaaa96e\\\",\n\\\"public_key\\\":\\\"0205fd465f833a50163298f614e3a84fb9ec55bdd3546b7035bf73b4cad7a1ef55\\\"},\n\n{\\\"tx_hash\\\":\\\"c859873bd52b52b4f2e1e33eada6c56", "end": 138348, "score": 0.9997541308403015, "start": 138280, "tag": "KEY", "value": "0205fd465f833a50163298f614e3a84fb9ec55bdd3546b7035bf73b4cad7a1ef55\\\"" }, { "context": "\":\\\"2015-03-04T03:03:56.466Z\\\",\n\\\"private_key\\\":\\\"671f0e00ec446fa3be79bd3f7448185c0dc9b2da54971e06dd6cf1d30e4b8336\\\",\n\\\"public_key\\\":\\\"02e5662b021aaf7308673b5654e6c", "end": 138675, "score": 0.9997631907463074, "start": 138611, "tag": "KEY", "value": "671f0e00ec446fa3be79bd3f7448185c0dc9b2da54971e06dd6cf1d30e4b8336" }, { "context": "9b2da54971e06dd6cf1d30e4b8336\\\",\n\\\"public_key\\\":\\\"02e5662b021aaf7308673b5654e6c04815c6ade57ccc334f9a315a0d0007c557cc\\\"},\n\n{\\\"tx_hash\\\":\\\"4aa383e4de6f7953fd0034f7c3d4b85", "end": 138764, "score": 0.9997591376304626, "start": 138696, "tag": "KEY", "value": "02e5662b021aaf7308673b5654e6c04815c6ade57ccc334f9a315a0d0007c557cc\\\"" }, { "context": "\":\\\"2015-03-05T01:32:01.215Z\\\",\n\\\"private_key\\\":\\\"3b1492ad54e57e09098710fc5d7443adf676cf4a9c3fcf5550b1654f3e72c609\\\",\n\\\"public_key\\\":\\\"027e995c8e959610fd3be6cba16e5", "end": 139091, "score": 0.9997361898422241, "start": 139027, "tag": "KEY", "value": "3b1492ad54e57e09098710fc5d7443adf676cf4a9c3fcf5550b1654f3e72c609" }, { "context": "6cf4a9c3fcf5550b1654f3e72c609\\\",\n\\\"public_key\\\":\\\"027e995c8e959610fd3be6cba16e5972adf0470bd11eb0e4a0916e4d34658b20e1\\\"},\n\n{\\\"tx_hash\\\":\\\"df0044bd6404470a20248f7c324865a", "end": 139180, "score": 0.9997315406799316, "start": 139112, "tag": "KEY", "value": "027e995c8e959610fd3be6cba16e5972adf0470bd11eb0e4a0916e4d34658b20e1\\\"" }, { "context": "\":\\\"2015-03-05T09:21:32.063Z\\\",\n\\\"private_key\\\":\\\"22eeb3988058fa7bda7332ee30692fe637838c9092308b69aa0cd040b1fb6613\\\",\n\\\"public_key\\\":\\\"02a83a7bc42cba465a807eeb597a5", "end": 139507, "score": 0.9997578263282776, "start": 139443, "tag": "KEY", "value": "22eeb3988058fa7bda7332ee30692fe637838c9092308b69aa0cd040b1fb6613" }, { "context": "38c9092308b69aa0cd040b1fb6613\\\",\n\\\"public_key\\\":\\\"02a83a7bc42cba465a807eeb597a5feb8587de54c2ec1b92b0ed96c0c235ab619d\\\"},\n\n{\\\"tx_hash\\\":\\\"ccedc74c3489c0943e0de27d7fc969e", "end": 139596, "score": 0.9997504949569702, "start": 139528, "tag": "KEY", "value": "02a83a7bc42cba465a807eeb597a5feb8587de54c2ec1b92b0ed96c0c235ab619d\\\"" }, { "context": "\":\\\"2015-05-05T13:02:49.422Z\\\",\n\\\"private_key\\\":\\\"9223400e89a60d46457faddd277f2875a7a41695dddd4668b6d64b92eaa11417\\\",\n\\\"public_key\\\":\\\"02d3aef03f6f4f67ff805b1075b8c", "end": 139923, "score": 0.9997714161872864, "start": 139859, "tag": "KEY", "value": "9223400e89a60d46457faddd277f2875a7a41695dddd4668b6d64b92eaa11417" }, { "context": "41695dddd4668b6d64b92eaa11417\\\",\n\\\"public_key\\\":\\\"02d3aef03f6f4f67ff805b1075b8c0d2853c07974bc519bf7febdc18a84e6ad6d8\\\"},\n\n{\\\"tx_hash\\\":\\\"610008c9614a4e60bf0e13649e67a01", "end": 140012, "score": 0.9997735619544983, "start": 139944, "tag": "KEY", "value": "02d3aef03f6f4f67ff805b1075b8c0d2853c07974bc519bf7febdc18a84e6ad6d8\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.413Z\\\",\n\\\"private_key\\\":\\\"9b03b25e99248eaa5aef1d54fc271eb218a369c327f8533421a5d8cf26686274\\\",\n\\\"public_key\\\":\\\"0409e67609b9c75264dd5affb4c8d", "end": 140339, "score": 0.9997760653495789, "start": 140275, "tag": "KEY", "value": "9b03b25e99248eaa5aef1d54fc271eb218a369c327f8533421a5d8cf26686274" }, { "context": "369c327f8533421a5d8cf26686274\\\",\n\\\"public_key\\\":\\\"0409e67609b9c75264dd5affb4c8de48ac791ec259d8e5dc879ee826215ece729bd694744bd11dfd5c10fa4889e6aca3b190ce9b146e8ddf893006bbcba020e", "end": 140437, "score": 0.9997478723526001, "start": 140360, "tag": "KEY", "value": "0409e67609b9c75264dd5affb4c8de48ac791ec259d8e5dc879ee826215ece729bd694744bd11" }, { "context": "59d8e5dc879ee826215ece729bd694744bd11dfd5c10fa4889e6aca3b190ce9b146e8ddf893006bbcba020ec47\\\"},\n\n{\\\"tx", "end": 140451, "score": 0.9996536374092102, "start": 140450, "tag": "KEY", "value": "e" }, { "context": "\":\\\"2014-11-05T02:01:55.424Z\\\",\n\\\"private_key\\\":\\\"7a7e71a6f49ae4494385a06d0d4fa38e86d4cdfb7952ca32dddab14c906ebf1a\\\",\n\\\"public_key\\\":\\\"045c8dfb7024a8051742f11abe2ff", "end": 140819, "score": 0.9997028708457947, "start": 140755, "tag": "KEY", "value": "7a7e71a6f49ae4494385a06d0d4fa38e86d4cdfb7952ca32dddab14c906ebf1a" }, { "context": "4cdfb7952ca32dddab14c906ebf1a\\\",\n\\\"public_key\\\":\\\"045c8dfb7024a8051742f11abe2ff065f391e2c610a04ed5904be840ee8c16c366dd9d4d12fd5be0381cabb7b7df720f8bcfa3a174d59f316793c414b320efded3\\\"},\n\n{\\\"tx_hash\\\":\\\"5b1cfb278417b9ecca5c0abff5d8255", "end": 140972, "score": 0.9996565580368042, "start": 140840, "tag": "KEY", "value": "045c8dfb7024a8051742f11abe2ff065f391e2c610a04ed5904be840ee8c16c366dd9d4d12fd5be0381cabb7b7df720f8bcfa3a174d59f316793c414b320efded3\\\"" }, { "context": "\":\\\"2014-11-05T02:01:55.435Z\\\",\n\\\"private_key\\\":\\\"09d23429a479e39bcdfc711730dd6eb7e1c5b765aac2f3d034619201e4264f59\\\",\n\\\"public_key\\\":\\\"04d49ece397f6b7044bbc44fc3f72", "end": 141299, "score": 0.9997307062149048, "start": 141235, "tag": "KEY", "value": "09d23429a479e39bcdfc711730dd6eb7e1c5b765aac2f3d034619201e4264f59" }, { "context": "5b765aac2f3d034619201e4264f59\\\",\n\\\"public_key\\\":\\\"04d49ece397f6b7044bbc44fc3f72ca15a611df51836cd240cc6a57af07c74ae530aa8ab4f9f6244d31bdf4aec82893dd089d27cc0bcc63536fd8fbbae5c539f9a\\\"},\n\n{\\\"tx_hash\\\":\\\"c37c292036ac8e53f45df7b1d579c99", "end": 141452, "score": 0.9997087121009827, "start": 141320, "tag": "KEY", "value": "04d49ece397f6b7044bbc44fc3f72ca15a611df51836cd240cc6a57af07c74ae530aa8ab4f9f6244d31bdf4aec82893dd089d27cc0bcc63536fd8fbbae5c539f9a\\\"" }, { "context": "\":\\\"2015-02-09T13:03:50.510Z\\\",\n\\\"private_key\\\":\\\"dd26ab63f38185cd1310da50e164baf5e27af2078c75395c7ed78372d534dc35\\\",\n\\\"public_key\\\":\\\"03b508d8e8b7d64fcf1620cf0602d", "end": 141779, "score": 0.999740719795227, "start": 141715, "tag": "KEY", "value": "dd26ab63f38185cd1310da50e164baf5e27af2078c75395c7ed78372d534dc35" }, { "context": "af2078c75395c7ed78372d534dc35\\\",\n\\\"public_key\\\":\\\"03b508d8e8b7d64fcf1620cf0602d14af6c00d1bf06682ee78bbf7b5817cc7383e\\\"},\n\n{\\\"tx_hash\\\":\\\"00e4789a46c033dae3037037617bc1f", "end": 141868, "score": 0.9997533559799194, "start": 141800, "tag": "KEY", "value": "03b508d8e8b7d64fcf1620cf0602d14af6c00d1bf06682ee78bbf7b5817cc7383e\\\"" }, { "context": "7383e\\\"},\n\n{\\\"tx_hash\\\":\\\"00e4789a46c033dae3037037617bc1f0dd2f93c0560cdbcd8787cb1168ede56f\\\",\n\\\"recipie", "end": 141914, "score": 0.9738969802856445, "start": 141911, "tag": "KEY", "value": "617" }, { "context": "hash\\\":\\\"00e4789a46c033dae3037037617bc1f0dd2f93c0560cdbcd8787cb1168ede56f\\\",\n\\\"recipient\\\":\\\"1KuNUh1cZ", "end": 141930, "score": 0.9889535307884216, "start": 141928, "tag": "KEY", "value": "60" }, { "context": "9a46c033dae3037037617bc1f0dd2f93c0560cdbcd8787cb1168ede56f\\\",\n\\\"recipient\\\":\\\"1KuNUh1cZvYpmj5S4SRAVSPW", "end": 141945, "score": 0.9916143417358398, "start": 141943, "tag": "KEY", "value": "68" }, { "context": "\":\\\"2015-02-08T01:12:05.179Z\\\",\n\\\"private_key\\\":\\\"60b68a30a07c07e2fa9f852b4b5e9fbd6ddf27dc4728c01a9b77b325dd557612\\\",\n\\\"public_key\\\":\\\"029402debd8ca3cb858a99b4c9dcd", "end": 142195, "score": 0.9997704029083252, "start": 142131, "tag": "KEY", "value": "60b68a30a07c07e2fa9f852b4b5e9fbd6ddf27dc4728c01a9b77b325dd557612" }, { "context": "f27dc4728c01a9b77b325dd557612\\\",\n\\\"public_key\\\":\\\"029402debd8ca3cb858a99b4c9dcd6f8bbc2d8bc6b6cb4e76337ab62819c0b46a5\\\"},\n\n{\\\"tx_hash\\\":\\\"da52e261090e4fb2cd27a4b3a03ee3f", "end": 142284, "score": 0.9997735619544983, "start": 142216, "tag": "KEY", "value": "029402debd8ca3cb858a99b4c9dcd6f8bbc2d8bc6b6cb4e76337ab62819c0b46a5\\\"" }, { "context": "\":\\\"2015-05-22T02:31:58.591Z\\\",\n\\\"private_key\\\":\\\"b1f146e21f751318654878360f3e1d44b39bf06e2af26cbdd343433721dabb33\\\",\n\\\"public_key\\\":\\\"030ed7179533823c47bae40148ad9", "end": 142611, "score": 0.9997805953025818, "start": 142547, "tag": "KEY", "value": "b1f146e21f751318654878360f3e1d44b39bf06e2af26cbdd343433721dabb33" }, { "context": "bf06e2af26cbdd343433721dabb33\\\",\n\\\"public_key\\\":\\\"030ed7179533823c47bae40148ad91044fcdee10d430a33dedf552fdbce9436314\\\"},\n\n{\\\"tx_h", "end": 142661, "score": 0.999707043170929, "start": 142632, "tag": "KEY", "value": "030ed7179533823c47bae40148ad9" }, { "context": "\":\\\"2015-02-11T00:32:22.795Z\\\",\n\\\"private_key\\\":\\\"ffe8d109ec414a605eeee0eeb5b8e89953b8dd8df9688ebfb80b835bf6deb626\\\",\n\\\"public_key\\\":\\\"03b5c5f211c8b9952f4fb2d2bbf74", "end": 143027, "score": 0.9996991753578186, "start": 142963, "tag": "KEY", "value": "ffe8d109ec414a605eeee0eeb5b8e89953b8dd8df9688ebfb80b835bf6deb626" }, { "context": "8dd8df9688ebfb80b835bf6deb626\\\",\n\\\"public_key\\\":\\\"03b5c5f211c8b9952f4fb2d2bbf74118408f25258b015adc268bd121041cd8455b\\\"},\n\n{\\\"tx_hash\\\":\\\"2ffed5570f19bffb44893b93b29d5e8", "end": 143116, "score": 0.9997218251228333, "start": 143048, "tag": "KEY", "value": "03b5c5f211c8b9952f4fb2d2bbf74118408f25258b015adc268bd121041cd8455b\\\"" }, { "context": "\":\\\"2015-02-11T00:32:22.423Z\\\",\n\\\"private_key\\\":\\\"e58ee5ff166bec6c58c482b76643d5004d099efba35f281b8c264e9dbabc7309\\\",\n\\\"public_key\\\":\\\"037e6f5d1ff85c72abf220990e825", "end": 143443, "score": 0.999650776386261, "start": 143379, "tag": "KEY", "value": "e58ee5ff166bec6c58c482b76643d5004d099efba35f281b8c264e9dbabc7309" }, { "context": "99efba35f281b8c264e9dbabc7309\\\",\n\\\"public_key\\\":\\\"037e6f5d1ff85c72abf220990e825e31140b50d26aa1ca2aa633aebac25295bfe7\\\"},\n\n{\\\"tx_hash\\\":\\\"fce90aaef1c40c8af54806e65521c13", "end": 143532, "score": 0.9997383952140808, "start": 143464, "tag": "KEY", "value": "037e6f5d1ff85c72abf220990e825e31140b50d26aa1ca2aa633aebac25295bfe7\\\"" }, { "context": "\":\\\"2015-02-11T23:22:08.636Z\\\",\n\\\"private_key\\\":\\\"5f9285bef116b31a4a366d94b8056e765af3a10601dc9733deb19a0fdd655947\\\",\n\\\"public_key\\\":\\\"0281526a9ed56e5109d5884bec310", "end": 143859, "score": 0.9997433423995972, "start": 143795, "tag": "KEY", "value": "5f9285bef116b31a4a366d94b8056e765af3a10601dc9733deb19a0fdd655947" }, { "context": "3a10601dc9733deb19a0fdd655947\\\",\n\\\"public_key\\\":\\\"0281526a9ed56e5109d5884bec310a8a7e8ede472d20bbade177cf2b8461349e14\\\"},\n\n{\\\"tx_hash\\\":\\\"7ba5c520cd592957a5fbee281b640b2", "end": 143948, "score": 0.999721348285675, "start": 143880, "tag": "KEY", "value": "0281526a9ed56e5109d5884bec310a8a7e8ede472d20bbade177cf2b8461349e14\\\"" }, { "context": "\":\\\"2015-03-22T18:25:58.264Z\\\",\n\\\"private_key\\\":\\\"5f6afb0031c609461646a39cdbba2f95bdfd14c722beb4c3dba2bced89be1251\\\",\n\\\"public_key\\\":\\\"0226e21828099b0bb37ca26f1f51d", "end": 144275, "score": 0.9997684359550476, "start": 144211, "tag": "KEY", "value": "5f6afb0031c609461646a39cdbba2f95bdfd14c722beb4c3dba2bced89be1251" }, { "context": "d14c722beb4c3dba2bced89be1251\\\",\n\\\"public_key\\\":\\\"0226e21828099b0bb37ca26f1f51d8b4bbc896f8d95b34e90652c4542de8f3c1f4\\\"},\n\n{\\\"tx_hash\\\":\\\"69637167f28291d8aa121614a47e824", "end": 144364, "score": 0.9997622966766357, "start": 144296, "tag": "KEY", "value": "0226e21828099b0bb37ca26f1f51d8b4bbc896f8d95b34e90652c4542de8f3c1f4\\\"" }, { "context": "\":\\\"2015-04-14T14:32:22.890Z\\\",\n\\\"private_key\\\":\\\"aa2835ae1b08eb6fd355d31862f6dbfbdda50e255d9ad3bb59ae8dfbbe3c99fd\\\",\n\\\"public_key\\\":\\\"03477fd4b6f3f06e92810eb4f2dbe", "end": 144691, "score": 0.9997724294662476, "start": 144627, "tag": "KEY", "value": "aa2835ae1b08eb6fd355d31862f6dbfbdda50e255d9ad3bb59ae8dfbbe3c99fd" }, { "context": "50e255d9ad3bb59ae8dfbbe3c99fd\\\",\n\\\"public_key\\\":\\\"03477fd4b6f3f06e92810eb4f2dbe1a851e92669c76099a68e90e84acadceb9fa3\\\"},\n\n{\\\"tx_hash\\\":\\\"85a5b7ba4b8cbf31561251a1497a5ae", "end": 144780, "score": 0.9997513294219971, "start": 144712, "tag": "KEY", "value": "03477fd4b6f3f06e92810eb4f2dbe1a851e92669c76099a68e90e84acadceb9fa3\\\"" }, { "context": "\":\\\"2015-05-23T05:31:50.072Z\\\",\n\\\"private_key\\\":\\\"be818860297168ebb6d9b376f7b65e88b73763ef9b9dfae523598588b960dfe7\\\",\n\\\"public_key\\\":\\\"021d17b4cfb7227a53fcbd89c6450", "end": 145107, "score": 0.9997503161430359, "start": 145043, "tag": "KEY", "value": "be818860297168ebb6d9b376f7b65e88b73763ef9b9dfae523598588b960dfe7" }, { "context": "763ef9b9dfae523598588b960dfe7\\\",\n\\\"public_key\\\":\\\"021d17b4cfb7227a53fcbd89c64504946ad819c4cea4295b4afccc5b68396471c7\\\"},\n\n{\\\"tx_hash\\\":\\\"e31f22e1bbd2ba8fb9cfca379bf14d8", "end": 145196, "score": 0.9997528195381165, "start": 145128, "tag": "KEY", "value": "021d17b4cfb7227a53fcbd89c64504946ad819c4cea4295b4afccc5b68396471c7\\\"" }, { "context": "\":\\\"2015-04-15T14:42:02.003Z\\\",\n\\\"private_key\\\":\\\"6e1662cc0e63c55672d277a15b9b9d1ebe0be755a7d617173c32a6a9d961c75a\\\",\n\\\"public_key\\\":\\\"02c836f0a5c5aa0ac4979cb7ece57", "end": 145523, "score": 0.9997608661651611, "start": 145459, "tag": "KEY", "value": "6e1662cc0e63c55672d277a15b9b9d1ebe0be755a7d617173c32a6a9d961c75a" }, { "context": "be755a7d617173c32a6a9d961c75a\\\",\n\\\"public_key\\\":\\\"02c836f0a5c5aa0ac4979cb7ece57357e0e351968b76ba7845498f9b3be8c6157b\\\"},\n\n{\\\"tx_hash\\\":\\\"c6b2274f27896e417929ae81b1d8b72", "end": 145612, "score": 0.9997208118438721, "start": 145544, "tag": "KEY", "value": "02c836f0a5c5aa0ac4979cb7ece57357e0e351968b76ba7845498f9b3be8c6157b\\\"" }, { "context": "\":\\\"2015-05-26T06:51:22.413Z\\\",\n\\\"private_key\\\":\\\"b9abb2181d70d4637e39f43081c01f80fa7732024d47daf3dc14a0771d9d48f1\\\",\n\\\"public_key\\\":\\\"03fd031351158d94ab243d9647534", "end": 145939, "score": 0.9997425079345703, "start": 145875, "tag": "KEY", "value": "b9abb2181d70d4637e39f43081c01f80fa7732024d47daf3dc14a0771d9d48f1" }, { "context": "732024d47daf3dc14a0771d9d48f1\\\",\n\\\"public_key\\\":\\\"03fd031351158d94ab243d96475344e87ef4705d4bc3c7f6a14b8f373b6464ecd6\\\"},\n\n{\\\"tx_hash\\\":\\\"83343c039915885b1f4038527ff3393", "end": 146028, "score": 0.9997476935386658, "start": 145960, "tag": "KEY", "value": "03fd031351158d94ab243d96475344e87ef4705d4bc3c7f6a14b8f373b6464ecd6\\\"" }, { "context": "\":\\\"2015-05-24T02:11:49.871Z\\\",\n\\\"private_key\\\":\\\"4dfce2005cc77bc5d1f31a74be715f65c398460e50dd14ed9869bf3e7833d673\\\",\n\\\"public_key\\\":\\\"03c111c14d15cfc305e53055640b9", "end": 146355, "score": 0.9995049238204956, "start": 146291, "tag": "KEY", "value": "4dfce2005cc77bc5d1f31a74be715f65c398460e50dd14ed9869bf3e7833d673" }, { "context": "8460e50dd14ed9869bf3e7833d673\\\",\n\\\"public_key\\\":\\\"03c111c14d15cfc305e53055640b9bdb1869cd1cc9108e3a9c492856bf0d1152f5\\\"},\n\n{\\\"tx_hash\\\":\\\"1f4065055093d010042577f05747abc", "end": 146444, "score": 0.9997617602348328, "start": 146376, "tag": "KEY", "value": "03c111c14d15cfc305e53055640b9bdb1869cd1cc9108e3a9c492856bf0d1152f5\\\"" }, { "context": "\":\\\"2015-05-25T06:51:33.537Z\\\",\n\\\"private_key\\\":\\\"62d45b39e228d1a95a4487bdc710bbe6e961a858c5bee4ca5b3d7b947d6c9d0f\\\",\n\\\"public_key\\\":\\\"03ed2af19cd3b3632d13cd103427eeb2", "end": 146774, "score": 0.9979652762413025, "start": 146707, "tag": "KEY", "value": "62d45b39e228d1a95a4487bdc710bbe6e961a858c5bee4ca5b3d7b947d6c9d0f\\\"," }, { "context": "1a858c5bee4ca5b3d7b947d6c9d0f\\\",\n\\\"public_key\\\":\\\"03ed2af19cd3b3632d13cd103427eeb204fa67406b44a34866a7a5d93729d4af42\\\"},\n\n{\\\"tx_hash\\\":\\\"4286ba63dbf5b0d8a5371e22e39fea9", "end": 146860, "score": 0.999762237071991, "start": 146792, "tag": "KEY", "value": "03ed2af19cd3b3632d13cd103427eeb204fa67406b44a34866a7a5d93729d4af42\\\"" }, { "context": "\":\\\"2015-05-29T14:03:00.926Z\\\",\n\\\"private_key\\\":\\\"074fcd7a780a7739fcdf6002c22f6288ab01487f525fdbd758d178f1e2a9a37e\\\",\n\\\"public_key\\\":\\\"023bc7c71d9573a9a8cc90baa4569", "end": 147187, "score": 0.9997553825378418, "start": 147123, "tag": "KEY", "value": "074fcd7a780a7739fcdf6002c22f6288ab01487f525fdbd758d178f1e2a9a37e" }, { "context": "1487f525fdbd758d178f1e2a9a37e\\\",\n\\\"public_key\\\":\\\"023bc7c71d9573a9a8cc90baa45696d19a5f1c735ad6174b37b2e4647f9ec33825\\\"},\n\n{\\\"tx_hash\\\":\\\"c34d5b08276f93a1c028f20664c0525", "end": 147276, "score": 0.9997504949569702, "start": 147208, "tag": "KEY", "value": "023bc7c71d9573a9a8cc90baa45696d19a5f1c735ad6174b37b2e4647f9ec33825\\\"" }, { "context": "\":\\\"2015-05-27T10:02:52.082Z\\\",\n\\\"private_key\\\":\\\"7680856b28d67c106f47cf60f4e2358add6f219c84a4112b04028406657468f4\\\",\n\\\"public_key\\\":\\\"02e41001d101a12923921ff3b0567", "end": 147603, "score": 0.9997751116752625, "start": 147539, "tag": "KEY", "value": "7680856b28d67c106f47cf60f4e2358add6f219c84a4112b04028406657468f4" }, { "context": "f219c84a4112b04028406657468f4\\\",\n\\\"public_key\\\":\\\"02e41001d101a12923921ff3b056700e8ef5b1e38d68538f73108273adcc9f9aaa\\\"},\n\n{\\\"tx_hash\\\":\\\"a7d4eb81767d73f97944fec27ca0034", "end": 147692, "score": 0.9997572302818298, "start": 147624, "tag": "KEY", "value": "02e41001d101a12923921ff3b056700e8ef5b1e38d68538f73108273adcc9f9aaa\\\"" }, { "context": "d73f97944fec27ca0034140370ffa5947ddae6df7a8102889d7bb\\\",\n\\\"recipient\\\":\\\"1EMD8PuWR74KASVpL8kLLj74iJGh", "end": 147773, "score": 0.9978697299957275, "start": 147772, "tag": "KEY", "value": "7" }, { "context": "\":\\\"2015-05-28T05:03:28.627Z\\\",\n\\\"private_key\\\":\\\"500c343ff9e75ed57e1c94d5137f56e5e84b69abebb737729786dd7c8d14e1c3\\\",\n\\\"public_key\\\":\\\"021eb0862c6d3380387654d43c412", "end": 148019, "score": 0.9997340440750122, "start": 147955, "tag": "KEY", "value": "500c343ff9e75ed57e1c94d5137f56e5e84b69abebb737729786dd7c8d14e1c3" }, { "context": "b69abebb737729786dd7c8d14e1c3\\\",\n\\\"public_key\\\":\\\"021eb0862c6d3380387654d43c4122a9516984343886f4099c0df3a16c92dcda22\\\"},\n\n{\\\"tx_hash\\\":\\\"7fc82e3563429340e8404d1f4995503", "end": 148108, "score": 0.9997524619102478, "start": 148040, "tag": "KEY", "value": "021eb0862c6d3380387654d43c4122a9516984343886f4099c0df3a16c92dcda22\\\"" }, { "context": "\":\\\"2015-05-31T11:21:33.999Z\\\",\n\\\"private_key\\\":\\\"2e8b4e0c67e5780d475e1bbd052308743b05ba59dcbcbc4aa28f65b2cf22f8be\\\",\n\\\"public_key\\\":\\\"03fa110a3e3a2e982b0eb33d338c4", "end": 148435, "score": 0.9997702836990356, "start": 148371, "tag": "KEY", "value": "2e8b4e0c67e5780d475e1bbd052308743b05ba59dcbcbc4aa28f65b2cf22f8be" }, { "context": "5ba59dcbcbc4aa28f65b2cf22f8be\\\",\n\\\"public_key\\\":\\\"03fa110a3e3a2e982b0eb33d338c46c6b89fb8caf09580a2a9c05e102f2cd677c8\\\"},\n\n{\\\"tx_hash\\\":\\\"de5f0b9034b658", "end": 148507, "score": 0.9997528791427612, "start": 148456, "tag": "KEY", "value": "03fa110a3e3a2e982b0eb33d338c46c6b89fb8caf09580a2a9c" }, { "context": "\":\\\"2015-05-30T03:32:00.344Z\\\",\n\\\"private_key\\\":\\\"03da981ac54d847be21ab01b95a0c5527b4e071e8b1efdb6381bbd3fca5a8eb9\\\",\n\\\"public_key\\\":\\\"023ddd316d412ab15431f9c3e3819", "end": 148851, "score": 0.9997444748878479, "start": 148787, "tag": "KEY", "value": "03da981ac54d847be21ab01b95a0c5527b4e071e8b1efdb6381bbd3fca5a8eb9" }, { "context": "e071e8b1efdb6381bbd3fca5a8eb9\\\",\n\\\"public_key\\\":\\\"023ddd316d412ab15431f9c3e3819b7d810f3d006f7124b345211a9d8c342418ed\\\"},\n\n{\\\"tx_hash\\\":\\\"f4e00063cd010063ef8ee04e192b609", "end": 148940, "score": 0.9997366666793823, "start": 148872, "tag": "KEY", "value": "023ddd316d412ab15431f9c3e3819b7d810f3d006f7124b345211a9d8c342418ed\\\"" }, { "context": "\":\\\"2015-04-16T04:03:16.440Z\\\",\n\\\"private_key\\\":\\\"14d3129bb9dc697fdebee99aceefd78d8f07858cc3b5451a28a705eb0a565ab6\\\",\n\\\"public_key\\\":\\\"0210bbb1bd44afba9a1d8a4e4324e", "end": 149267, "score": 0.9996525049209595, "start": 149203, "tag": "KEY", "value": "14d3129bb9dc697fdebee99aceefd78d8f07858cc3b5451a28a705eb0a565ab6" }, { "context": "7858cc3b5451a28a705eb0a565ab6\\\",\n\\\"public_key\\\":\\\"0210bbb1bd44afba9a1d8a4e4324e7bb62a3dc1cf9ac9b7435efd7f8adef176815\\\"},\n\n{\\\"tx_hash\\\":\\\"e4638d4474a25588230d6575e76300f", "end": 149356, "score": 0.9997244477272034, "start": 149288, "tag": "KEY", "value": "0210bbb1bd44afba9a1d8a4e4324e7bb62a3dc1cf9ac9b7435efd7f8adef176815\\\"" }, { "context": "\":\\\"2015-06-01T07:51:32.206Z\\\",\n\\\"private_key\\\":\\\"1db5cf6bf3041069bf2ff478d6b6ddbcf20c4af40550c6f36bc2e441deeb9c99\\\",\n\\\"public_key\\\":\\\"0262ea29c8cdb20534882933d0c45", "end": 149683, "score": 0.9997779130935669, "start": 149619, "tag": "KEY", "value": "1db5cf6bf3041069bf2ff478d6b6ddbcf20c4af40550c6f36bc2e441deeb9c99" }, { "context": "c4af40550c6f36bc2e441deeb9c99\\\",\n\\\"public_key\\\":\\\"0262ea29c8cdb20534882933d0c4590e5100c9c834cd8eec35a2c681a284d3938c\\\"},\n\n{\\\"tx_hash\\\":\\\"f143abba8681b940a49039520290d25", "end": 149772, "score": 0.9997637271881104, "start": 149704, "tag": "KEY", "value": "0262ea29c8cdb20534882933d0c4590e5100c9c834cd8eec35a2c681a284d3938c\\\"" }, { "context": "\":\\\"2015-04-18T08:41:32.317Z\\\",\n\\\"private_key\\\":\\\"4085a150d3654c1eff2442a35ff631f778553b58a64ceff89eb9abf18b4333ff\\\",\n\\\"public_key\\\":\\\"036047ba8879f8defb4f841eb7dea", "end": 150099, "score": 0.9997481107711792, "start": 150035, "tag": "KEY", "value": "4085a150d3654c1eff2442a35ff631f778553b58a64ceff89eb9abf18b4333ff" }, { "context": "53b58a64ceff89eb9abf18b4333ff\\\",\n\\\"public_key\\\":\\\"036047ba8879f8defb4f841eb7deae9c5ba5f39f98389a1294eaad4cd2bfb03cb7\\\"},\n\n{\\\"tx_hash\\\":\\\"243d27bcec12af06a1949493beaaff2", "end": 150188, "score": 0.9997504949569702, "start": 150120, "tag": "KEY", "value": "036047ba8879f8defb4f841eb7deae9c5ba5f39f98389a1294eaad4cd2bfb03cb7\\\"" }, { "context": "\":\\\"2015-06-03T12:03:21.213Z\\\",\n\\\"private_key\\\":\\\"135a29ad06823fc5db01707ac379ad6a65e4f51d0caf170174470b19139edded\\\",\n\\\"public_key\\\":\\\"02d625b3c35a84c99f1e0d8a908f5", "end": 150515, "score": 0.9997188448905945, "start": 150451, "tag": "KEY", "value": "135a29ad06823fc5db01707ac379ad6a65e4f51d0caf170174470b19139edded" }, { "context": "4f51d0caf170174470b19139edded\\\",\n\\\"public_key\\\":\\\"02d625b3c35a84c99f1e0d8a908f57b8512983bd6ced6a9e7ca6814b635d6725ba\\\"},\n\n{\\\"tx_hash\\\":\\\"52da0fa05666543b5274488c20e69f6", "end": 150604, "score": 0.9997606873512268, "start": 150536, "tag": "KEY", "value": "02d625b3c35a84c99f1e0d8a908f57b8512983bd6ced6a9e7ca6814b635d6725ba\\\"" }, { "context": "\":\\\"2015-06-03T12:03:22.708Z\\\",\n\\\"private_key\\\":\\\"718890619ea3bb1cc5af74b0708e76ff60547d6ae995f359494fe2c4df958804\\\",\n\\\"public_key\\\":\\\"0267c022706a465a5ab8bb05da5df", "end": 150931, "score": 0.999755322933197, "start": 150867, "tag": "KEY", "value": "718890619ea3bb1cc5af74b0708e76ff60547d6ae995f359494fe2c4df958804" }, { "context": "47d6ae995f359494fe2c4df958804\\\",\n\\\"public_key\\\":\\\"0267c022706a465a5ab8bb05da5df59e1cb97137ab43a9be214cd6ad967a51c67f\\\"},\n\n{\\\"tx_hash\\\":\\\"df6cf8d16929c774087741f382af107", "end": 151020, "score": 0.9997543692588806, "start": 150952, "tag": "KEY", "value": "0267c022706a465a5ab8bb05da5df59e1cb97137ab43a9be214cd6ad967a51c67f\\\"" }, { "context": "\":\\\"2015-06-04T16:21:45.524Z\\\",\n\\\"private_key\\\":\\\"a0451e50edbc88a0075561a57b6fedc5f0987ba2745f73f672baf28f0bca6127\\\",\n\\\"public_key\\\":\\\"036a0ce19c67d41faac969151323f", "end": 151347, "score": 0.9997473359107971, "start": 151283, "tag": "KEY", "value": "a0451e50edbc88a0075561a57b6fedc5f0987ba2745f73f672baf28f0bca6127" }, { "context": "87ba2745f73f672baf28f0bca6127\\\",\n\\\"public_key\\\":\\\"036a0ce19c67d41faac969151323f105ef582abe1628a7c965dc79629a607c38f0\\\"},\n\n{\\\"tx_hash\\\":\\\"4e8eb46448426032879947076c199bb", "end": 151436, "score": 0.9997022151947021, "start": 151368, "tag": "KEY", "value": "036a0ce19c67d41faac969151323f105ef582abe1628a7c965dc79629a607c38f0\\\"" }, { "context": "\":\\\"2015-06-05T11:31:57.539Z\\\",\n\\\"private_key\\\":\\\"acf3dec09ef3c643b099d444a099b596daae40c34f6e52f9da0bf233dcc60272\\\",\n\\\"public_key\\\":\\\"02b578dd620e0384589f643d344af", "end": 151763, "score": 0.9997588396072388, "start": 151699, "tag": "KEY", "value": "acf3dec09ef3c643b099d444a099b596daae40c34f6e52f9da0bf233dcc60272" }, { "context": "e40c34f6e52f9da0bf233dcc60272\\\",\n\\\"public_key\\\":\\\"02b578dd620e0384589f643d344af274b69b9da73bc4eb109eeea418a48a08bd70\\\"},\n\n{\\\"tx_hash\\\":\\\"3abb61b9874c7cfccae4600afb118d5", "end": 151852, "score": 0.9997397065162659, "start": 151784, "tag": "KEY", "value": "02b578dd620e0384589f643d344af274b69b9da73bc4eb109eeea418a48a08bd70\\\"" }, { "context": "\":\\\"2015-04-20T09:41:54.346Z\\\",\n\\\"private_key\\\":\\\"60e3ee581c07bd3665239d24d3825b4b8bfb51abea5b8de969b29ac39a4245d5\\\",\n\\\"public_key\\\":\\\"035a60386823a62a83245d9a21065", "end": 152179, "score": 0.9997698664665222, "start": 152115, "tag": "KEY", "value": "60e3ee581c07bd3665239d24d3825b4b8bfb51abea5b8de969b29ac39a4245d5" }, { "context": "b51abea5b8de969b29ac39a4245d5\\\",\n\\\"public_key\\\":\\\"035a60386823a62a83245d9a21065fbf50d7c9048d46e563a55761a4184a34bb2c\\", "end": 152217, "score": 0.9997182488441467, "start": 152200, "tag": "KEY", "value": "035a60386823a62a8" }, { "context": "\":\\\"2015-06-06T05:40:52.213Z\\\",\n\\\"private_key\\\":\\\"b5363d7b7e427b6deae4b02b85e9af2ba93c8ca8f3bf9789366b7ee07577d77d\\\",\n\\\"public_key\\\":\\\"031c48a33176e9b693f5757dc6793", "end": 152595, "score": 0.9997621774673462, "start": 152531, "tag": "KEY", "value": "b5363d7b7e427b6deae4b02b85e9af2ba93c8ca8f3bf9789366b7ee07577d77d" }, { "context": "c8ca8f3bf9789366b7ee07577d77d\\\",\n\\\"public_key\\\":\\\"031c48a33176e9b693f5757dc6793cb9ec5030f950e3ba399473b7f53bd7549602\\\"},\n\n{\\\"tx_hash\\\":\\\"c236a3e52c9001d605d053622d27022", "end": 152684, "score": 0.9997615814208984, "start": 152616, "tag": "KEY", "value": "031c48a33176e9b693f5757dc6793cb9ec5030f950e3ba399473b7f53bd7549602\\\"" }, { "context": "\":\\\"2015-04-22T08:41:53.733Z\\\",\n\\\"private_key\\\":\\\"e583eb42ac506a8fb94d40e3caf44995cbe063fc98c13d64de1503552f10f8aa\\\",\n\\\"public_key\\\":\\\"02abbbe3b368a9a5705cca1a983d7", "end": 153011, "score": 0.9995260834693909, "start": 152947, "tag": "KEY", "value": "e583eb42ac506a8fb94d40e3caf44995cbe063fc98c13d64de1503552f10f8aa" }, { "context": "063fc98c13d64de1503552f10f8aa\\\",\n\\\"public_key\\\":\\\"02abbbe3b368a9a5705cca1a983d794353ed8b8bc46bcee53f6f0876099f668839\\\"},\n\n{\\\"tx_hash\\\":\\\"54a521b952245944108a36505046f8a", "end": 153100, "score": 0.9997475743293762, "start": 153032, "tag": "KEY", "value": "02abbbe3b368a9a5705cca1a983d794353ed8b8bc46bcee53f6f0876099f668839\\\"" }, { "context": "\":\\\"2015-06-08T10:22:23.891Z\\\",\n\\\"private_key\\\":\\\"09e6480de5aa168281597b01c0e2781a927678e190ccaebee15671b81e4d083d\\\",\n\\\"public_key\\\":\\\"0304df49a999d7a158b018c789cbc", "end": 153427, "score": 0.9997706413269043, "start": 153363, "tag": "KEY", "value": "09e6480de5aa168281597b01c0e2781a927678e190ccaebee15671b81e4d083d" }, { "context": "678e190ccaebee15671b81e4d083d\\\",\n\\\"public_key\\\":\\\"0304df49a999d7a158b018c789cbcb9f4210d66a431833d75ee0a0a6222eb382df\\\"},\n\n{\\\"tx_hash\\\":\\\"1aef91a65dafac5d25a3b25e8318fd6", "end": 153516, "score": 0.9997677803039551, "start": 153448, "tag": "KEY", "value": "0304df49a999d7a158b018c789cbcb9f4210d66a431833d75ee0a0a6222eb382df\\\"" }, { "context": "\":\\\"2015-06-09T08:11:58.711Z\\\",\n\\\"private_key\\\":\\\"c4b9f5512529a17661922bfec3a9d6eb8c05f3a302ffe0fa735bb0516d9f40fe\\\",\n\\\"public_key\\\":\\\"03b28204242c47a50e0886d1a04ef", "end": 153843, "score": 0.9997643232345581, "start": 153779, "tag": "KEY", "value": "c4b9f5512529a17661922bfec3a9d6eb8c05f3a302ffe0fa735bb0516d9f40fe" }, { "context": "5f3a302ffe0fa735bb0516d9f40fe\\\",\n\\\"public_key\\\":\\\"03b28204242c47a50e0886d1a04eff6d44543786b5a4ea2cfbb062e1b7571d610f\\\"},\n\n{\\\"tx_hash\\\":\\\"52d153459978f94e1ac50d794604af2", "end": 153932, "score": 0.9997633099555969, "start": 153864, "tag": "KEY", "value": "03b28204242c47a50e0886d1a04eff6d44543786b5a4ea2cfbb062e1b7571d610f\\\"" }, { "context": "\":\\\"2015-06-09T23:11:42.877Z\\\",\n\\\"private_key\\\":\\\"917c0f46fc859ea1f57d7c57029c6e264a0bd254034cc822cceef1392358760b\\\",\n\\\"public_key\\\":\\\"03cda54bd6e22c7adc81f8a3c34f9", "end": 154259, "score": 0.999762237071991, "start": 154195, "tag": "KEY", "value": "917c0f46fc859ea1f57d7c57029c6e264a0bd254034cc822cceef1392358760b" }, { "context": "bd254034cc822cceef1392358760b\\\",\n\\\"public_key\\\":\\\"03cda54bd6e22c7adc81f8a3c34f93bb6788c0727272952024e94bd7220aacdee2\\\"},\n\n{\\\"tx_hash\\\":\\\"1add190c1855f385345fddb9b2a47c9", "end": 154348, "score": 0.9997614622116089, "start": 154280, "tag": "KEY", "value": "03cda54bd6e22c7adc81f8a3c34f93bb6788c0727272952024e94bd7220aacdee2\\\"" }, { "context": "\":\\\"2015-06-12T07:11:49.584Z\\\",\n\\\"private_key\\\":\\\"97725ded135c5adc8d0a72930dd4c8a3d4c355151a683aeb179943934b04652f\\\",\n\\\"public_key\\\":\\\"03ab09855ba1e170e4ba3dddf39a7", "end": 154675, "score": 0.999696671962738, "start": 154611, "tag": "KEY", "value": "97725ded135c5adc8d0a72930dd4c8a3d4c355151a683aeb179943934b04652f" }, { "context": "355151a683aeb179943934b04652f\\\",\n\\\"public_key\\\":\\\"03ab09855ba1e170e4ba3dddf39a79590b4e2feb5a2bcff00d08b4062c08fcc59b\\\"},\n\n{\\\"tx_hash\\\":\\\"6e7b11c90f4a1efe1f66ea101c1fe67", "end": 154764, "score": 0.9997285008430481, "start": 154696, "tag": "KEY", "value": "03ab09855ba1e170e4ba3dddf39a79590b4e2feb5a2bcff00d08b4062c08fcc59b\\\"" }, { "context": "\":\\\"2015-06-10T11:32:12.558Z\\\",\n\\\"private_key\\\":\\\"d73e22daf34675a1f6fbe447b32f3fe702b968ba748080654e683ef46a72a540\\\",\n\\\"public_key\\\":\\\"03edcead542cdef293cbb4dd855fe", "end": 155091, "score": 0.999718964099884, "start": 155027, "tag": "KEY", "value": "d73e22daf34675a1f6fbe447b32f3fe702b968ba748080654e683ef46a72a540" }, { "context": "968ba748080654e683ef46a72a540\\\",\n\\\"public_key\\\":\\\"03edcead542cdef293cbb4dd855fec9a2c7056d06261d8e7826fc1f32c48f93811\\\"},\n\n{\\\"tx_hash\\\":\\\"", "end": 155149, "score": 0.9996264576911926, "start": 155112, "tag": "KEY", "value": "03edcead542cdef293cbb4dd855fec9a2c705" }, { "context": "\":\\\"2015-06-11T10:21:57.744Z\\\",\n\\\"private_key\\\":\\\"15c1240175cc20d63622f3a0483012ad36cb2414bf8c52387d2eb799ef763dac\\\",\n\\\"public_key\\\":\\\"0215d6a5f089644b65bb3dee39b4c", "end": 155507, "score": 0.9997431635856628, "start": 155443, "tag": "KEY", "value": "15c1240175cc20d63622f3a0483012ad36cb2414bf8c52387d2eb799ef763dac" }, { "context": "b2414bf8c52387d2eb799ef763dac\\\",\n\\\"public_key\\\":\\\"0215d6a5f089644b65bb3dee39b4c0cf356094387742bc69569a9ad6c6f8e49590\\\"},\n\n{\\\"tx_hash\\\":\\\"0591f38e4fa3ea24901ecef1f004a73", "end": 155596, "score": 0.9997441172599792, "start": 155528, "tag": "KEY", "value": "0215d6a5f089644b65bb3dee39b4c0cf356094387742bc69569a9ad6c6f8e49590\\\"" }, { "context": "\":\\\"2015-06-16T09:03:09.965Z\\\",\n\\\"private_key\\\":\\\"f7dfbb08b629caa4020f6468bbfe9f1eb8f281aa5cb5a96480b03edd364bb3fa\\\",\n\\\"public_key\\\":\\\"0371d69f11146b9cfe8f38967f175", "end": 155923, "score": 0.9997508525848389, "start": 155859, "tag": "KEY", "value": "f7dfbb08b629caa4020f6468bbfe9f1eb8f281aa5cb5a96480b03edd364bb3fa" }, { "context": "281aa5cb5a96480b03edd364bb3fa\\\",\n\\\"public_key\\\":\\\"0371d69f11146b9cfe8f38967f17502e6050868d4af7bdd21741c9b19a98179e86\\\"},\n\n{\\\"tx_hash\\\":\\\"e6830222ea64aaffdf6bec6f939c672", "end": 156012, "score": 0.9997590184211731, "start": 155944, "tag": "KEY", "value": "0371d69f11146b9cfe8f38967f17502e6050868d4af7bdd21741c9b19a98179e86\\\"" }, { "context": "\":\\\"2015-06-13T13:31:55.735Z\\\",\n\\\"private_key\\\":\\\"98794910d11ada9b81f8abc7d8e4d3d81a89d2f5fce556afe7b8551ffcf388bd\\\",\n\\\"public_key\\\":\\\"0306530d49e472a05b4c8d3427ee0", "end": 156339, "score": 0.9997649192810059, "start": 156275, "tag": "KEY", "value": "98794910d11ada9b81f8abc7d8e4d3d81a89d2f5fce556afe7b8551ffcf388bd" }, { "context": "9d2f5fce556afe7b8551ffcf388bd\\\",\n\\\"public_key\\\":\\\"0306530d49e472a05b4c8d3427ee01ab19c5cfec4b9575f1533e90ab5897da0d5d\\\"},\n\n{\\\"tx_hash\\\":\\\"2cf1696dffc4fd60815d4b9ec51e21c", "end": 156428, "score": 0.9997639060020447, "start": 156360, "tag": "KEY", "value": "0306530d49e472a05b4c8d3427ee01ab19c5cfec4b9575f1533e90ab5897da0d5d\\\"" }, { "context": "\":\\\"2015-06-14T03:51:39.522Z\\\",\n\\\"private_key\\\":\\\"df96369a0728578d32a08fa17a10f536c4a123488e46f23cfa43a2ea738793f7\\\",\n\\\"public_key\\\":\\\"02854aa07ec3d76329c37576a9aac", "end": 156755, "score": 0.99973064661026, "start": 156691, "tag": "KEY", "value": "df96369a0728578d32a08fa17a10f536c4a123488e46f23cfa43a2ea738793f7" }, { "context": "123488e46f23cfa43a2ea738793f7\\\",\n\\\"public_key\\\":\\\"02854aa07ec3d76329c37576a9aaca485481a768cf738fdc6189a4395c2a0ebb68\\\"},\n\n{\\\"tx_hash\\\":\\\"ebd5df214591d2917a5bdc6f842d1e3", "end": 156844, "score": 0.9997337460517883, "start": 156776, "tag": "KEY", "value": "02854aa07ec3d76329c37576a9aaca485481a768cf738fdc6189a4395c2a0ebb68\\\"" }, { "context": "\":\\\"2015-06-15T02:51:53.312Z\\\",\n\\\"private_key\\\":\\\"cf546d5e1abbc6e393b578e9a67bd5aed6cbc1ef74db30ed0cf2b396f1b7f956\\\",\n\\\"public_key\\\":\\\"03d79666b43d720fa55295a03c3e5", "end": 157171, "score": 0.9997723698616028, "start": 157107, "tag": "KEY", "value": "cf546d5e1abbc6e393b578e9a67bd5aed6cbc1ef74db30ed0cf2b396f1b7f956" }, { "context": "bc1ef74db30ed0cf2b396f1b7f956\\\",\n\\\"public_key\\\":\\\"03d79666b43d720fa55295a03c3e5c9d20cf3986ff537559583736ddbfc8542565\\\"},\n\n{\\\"tx_hash\\\":\\\"9ecc5fb8218f44360626dd2be29d166", "end": 157260, "score": 0.9997614026069641, "start": 157192, "tag": "KEY", "value": "03d79666b43d720fa55295a03c3e5c9d20cf3986ff537559583736ddbfc8542565\\\"" }, { "context": "\":\\\"2015-06-18T00:51:41.767Z\\\",\n\\\"private_key\\\":\\\"37696e1dd63c24136689e9f07ce90e96359bc4ce9fd8b07380b3a129e61be106\\\",\n\\\"public_key\\\":\\\"0285c5a6c8c60431f508e809ed6d4", "end": 157587, "score": 0.9997391104698181, "start": 157523, "tag": "KEY", "value": "37696e1dd63c24136689e9f07ce90e96359bc4ce9fd8b07380b3a129e61be106" }, { "context": "bc4ce9fd8b07380b3a129e61be106\\\",\n\\\"public_key\\\":\\\"0285c5a6c8c60431f508e809ed6d4ea185b4d59e62448b6e3f0dec007a04d78448\\\"},\n\n{\\\"tx_hash\\\":\\\"7a4c8c771d9e7f86e1fd4cc9312b1f1", "end": 157676, "score": 0.9997120499610901, "start": 157608, "tag": "KEY", "value": "0285c5a6c8c60431f508e809ed6d4ea185b4d59e62448b6e3f0dec007a04d78448\\\"" }, { "context": "\":\\\"2015-06-17T03:02:55.614Z\\\",\n\\\"private_key\\\":\\\"a10c48144d44ee4257fb6f17918fe5084cc627312cababc962b40c698b284d99\\\",\n\\\"public_key\\\":\\\"03b856f166c3829732e2e1ec03bb9", "end": 158003, "score": 0.999765932559967, "start": 157939, "tag": "KEY", "value": "a10c48144d44ee4257fb6f17918fe5084cc627312cababc962b40c698b284d99" }, { "context": "627312cababc962b40c698b284d99\\\",\n\\\"public_key\\\":\\\"03b856f166c3829732e2e1ec03bb9af7458241e032923092b9492bf69341942258\\\"},\n\n{\\\"tx_hash\\\":\\\"0251488c32a8f9689069d4309", "end": 158086, "score": 0.9916961789131165, "start": 158024, "tag": "KEY", "value": "03b856f166c3829732e2e1ec03bb9af7458241e032923092b9492bf6934194" }, { "context": "\":\\\"2015-06-19T01:21:56.644Z\\\",\n\\\"private_key\\\":\\\"d3f9c365785be2e3086722fc17aee13bfa2bf14529b0f09c74997d8a27234114\\\",\n\\\"public_key\\\":\\\"02e85c8f5d1dd48051bef01f52760", "end": 158419, "score": 0.9997285008430481, "start": 158355, "tag": "KEY", "value": "d3f9c365785be2e3086722fc17aee13bfa2bf14529b0f09c74997d8a27234114" }, { "context": "bf14529b0f09c74997d8a27234114\\\",\n\\\"public_key\\\":\\\"02e85c8f5d1dd48051bef01f52760dca4c50855d4804926ca0cc2c36ad7f053951\\\"},\n\n{\\\"tx_hash\\\":\\\"e5fe48f5866d164c22002519e0c2222", "end": 158508, "score": 0.9997175931930542, "start": 158440, "tag": "KEY", "value": "02e85c8f5d1dd48051bef01f52760dca4c50855d4804926ca0cc2c36ad7f053951\\\"" }, { "context": "\":\\\"2015-06-21T11:31:45.628Z\\\",\n\\\"private_key\\\":\\\"25f78b029ae4eba0c4d117ea296dc90079706e962e7d6a64c26585c373465bbb\\\",\n\\\"public_key\\\":\\\"03e5155e4f7b33200b604e678bbdb", "end": 158835, "score": 0.999707043170929, "start": 158771, "tag": "KEY", "value": "25f78b029ae4eba0c4d117ea296dc90079706e962e7d6a64c26585c373465bbb" }, { "context": "06e962e7d6a64c26585c373465bbb\\\",\n\\\"public_key\\\":\\\"03e5155e4f7b33200b604e678bbdbb375777e21029f1c1ecbb72c6d14f51ce73a3\\\"},\n\n{\\\"tx_hash\\\":\\\"432085e2792541b3e3ed0f2754833af", "end": 158924, "score": 0.9997566938400269, "start": 158856, "tag": "KEY", "value": "03e5155e4f7b33200b604e678bbdbb375777e21029f1c1ecbb72c6d14f51ce73a3\\\"" }, { "context": "\":\\\"2015-06-21T01:41:47.825Z\\\",\n\\\"private_key\\\":\\\"bb2c7b6847be74f2e0a21fa735196ddbd2bb6b41d571122c793fd79f6521198c\\\",\n\\\"public_key\\\":\\\"022eb92466d49adda605fa97d909f", "end": 159251, "score": 0.9997685551643372, "start": 159187, "tag": "KEY", "value": "bb2c7b6847be74f2e0a21fa735196ddbd2bb6b41d571122c793fd79f6521198c" }, { "context": "b6b41d571122c793fd79f6521198c\\\",\n\\\"public_key\\\":\\\"022eb92466d49adda605fa97d909f535403e712740748b489d7fcd86060b5278f8\\\"},\n\n{\\\"tx_hash\\\":\\\"4970c8abdfb28495a96d211faace07a", "end": 159340, "score": 0.9997707605361938, "start": 159272, "tag": "KEY", "value": "022eb92466d49adda605fa97d909f535403e712740748b489d7fcd86060b5278f8\\\"" }, { "context": "\":\\\"2015-05-17T04:02:55.691Z\\\",\n\\\"private_key\\\":\\\"4ff93fd0dc509d99ab9dcfa43ebcd14587d4759629c5dd884285f4c601b01f46\\\",\n\\\"public_key\\\":\\\"0230c2ac584f1a35a35500fbfb8ea", "end": 159667, "score": 0.9997634291648865, "start": 159603, "tag": "KEY", "value": "4ff93fd0dc509d99ab9dcfa43ebcd14587d4759629c5dd884285f4c601b01f46" }, { "context": "4759629c5dd884285f4c601b01f46\\\",\n\\\"public_key\\\":\\\"0230c2ac584f1a35a35500fbfb8eaab37aa9d41a75da4f18f9f6d15bb51519bd50\\\"},\n\n{\\\"tx_hash\\\":\\\"132e5f8e5f84d7520877cc0a85faaf9", "end": 159756, "score": 0.9997554421424866, "start": 159688, "tag": "KEY", "value": "0230c2ac584f1a35a35500fbfb8eaab37aa9d41a75da4f18f9f6d15bb51519bd50\\\"" }, { "context": "\":\\\"2015-06-22T01:03:10.433Z\\\",\n\\\"private_key\\\":\\\"798daf4c5bc92209525a6a829462168f601794b9083a65aea4c555e393ae3b24\\\",\n\\\"public_key\\\":\\\"034b19bfb3e3e1d1e9c4c6d8b0ca2", "end": 160083, "score": 0.9997749924659729, "start": 160019, "tag": "KEY", "value": "798daf4c5bc92209525a6a829462168f601794b9083a65aea4c555e393ae3b24" }, { "context": "794b9083a65aea4c555e393ae3b24\\\",\n\\\"public_key\\\":\\\"034b19bfb3e3e1d1e9c4c6d8b0ca2f9c567962a7b2cfaa4ba120f99072d45ac92b\\\"},\n\n{\\\"tx_hash\\\":\\\"8773ab632d07e73ead837a6972a446e", "end": 160172, "score": 0.9997593760490417, "start": 160104, "tag": "KEY", "value": "034b19bfb3e3e1d1e9c4c6d8b0ca2f9c567962a7b2cfaa4ba120f99072d45ac92b\\\"" }, { "context": "\":\\\"2015-06-23T04:03:04.737Z\\\",\n\\\"private_key\\\":\\\"78c500dd8e47960fe23c6b02da4ce8f9d817d200a555b51134db80a8a7fdca3f\\\",\n\\\"public_key\\\":\\\"03464ddda63d09b25af81106f76a4", "end": 160499, "score": 0.9997496604919434, "start": 160435, "tag": "KEY", "value": "78c500dd8e47960fe23c6b02da4ce8f9d817d200a555b51134db80a8a7fdca3f" }, { "context": "7d200a555b51134db80a8a7fdca3f\\\",\n\\\"public_key\\\":\\\"03464ddda63d09b25af81106f76a420ad05badfaa0737f8a86bd2673560ca84fa1\\\"},\n\n{\\\"tx_hash\\\":\\\"0a51ed48f6f07a1939007ded92c001d", "end": 160588, "score": 0.9997072219848633, "start": 160520, "tag": "KEY", "value": "03464ddda63d09b25af81106f76a420ad05badfaa0737f8a86bd2673560ca84fa1\\\"" }, { "context": "\":\\\"2015-06-29T02:04:21.779Z\\\",\n\\\"private_key\\\":\\\"eaf9fab37d3c7473d04f8129d3e71b23be2b1e08e6116e506683b8a86e0bcf99\\\",\n\\\"public_key\\\":\\\"038a7820684a32ed17a463595880c", "end": 160915, "score": 0.9997400045394897, "start": 160851, "tag": "KEY", "value": "eaf9fab37d3c7473d04f8129d3e71b23be2b1e08e6116e506683b8a86e0bcf99" }, { "context": "b1e08e6116e506683b8a86e0bcf99\\\",\n\\\"public_key\\\":\\\"038a7820684a32ed17a463595880c1d32d8cbeeed5fe66408d9b0864e9e751f8e9\\\"},\n\n{\\\"tx_hash\\\":\\\"14b40e99a0b4095d1fa01797c00f20e", "end": 161004, "score": 0.9994763731956482, "start": 160936, "tag": "KEY", "value": "038a7820684a32ed17a463595880c1d32d8cbeeed5fe66408d9b0864e9e751f8e9\\\"" }, { "context": "\":\\\"2015-06-24T03:11:52.700Z\\\",\n\\\"private_key\\\":\\\"138c5fae0132fcabdd9f541629a01dd4c4a2d6a86b2207651bd32c37b709798b\\\",\n\\\"public_key\\\":\\\"033f3d0439299c64704701d29d7f4", "end": 161331, "score": 0.9997262358665466, "start": 161267, "tag": "KEY", "value": "138c5fae0132fcabdd9f541629a01dd4c4a2d6a86b2207651bd32c37b709798b" }, { "context": "2d6a86b2207651bd32c37b709798b\\\",\n\\\"public_key\\\":\\\"033f3d0439299c64704701d29d7f432c1a0e8b0ee0da3ab86e4a536007d8da8b98\\\"},\n\n{\\\"tx_hash\\\":\\\"5a21c329e5b23ef62f4a16dc35d3692", "end": 161420, "score": 0.9997124075889587, "start": 161352, "tag": "KEY", "value": "033f3d0439299c64704701d29d7f432c1a0e8b0ee0da3ab86e4a536007d8da8b98\\\"" }, { "context": "\":\\\"2015-06-29T09:21:54.514Z\\\",\n\\\"private_key\\\":\\\"cf520b9b13f3da61fc4b9a7b360a068266c16c732ad3be78eeb2dc786c0ebaeb\\\",\n\\\"public_key\\\":\\\"022a3357d71cf7c57a79f3a61205f", "end": 161747, "score": 0.9996662735939026, "start": 161683, "tag": "KEY", "value": "cf520b9b13f3da61fc4b9a7b360a068266c16c732ad3be78eeb2dc786c0ebaeb" }, { "context": "16c732ad3be78eeb2dc786c0ebaeb\\\",\n\\\"public_key\\\":\\\"022a3357d71cf7c57a79f3a61205fd2f1591bdfc0f5351a39f9d6ed86cd4084839\\\"},\n\n{\\\"tx_hash\\\":\\\"f6866bdd5ed4615db6a97859c2f8e5f", "end": 161836, "score": 0.9997435212135315, "start": 161768, "tag": "KEY", "value": "022a3357d71cf7c57a79f3a61205fd2f1591bdfc0f5351a39f9d6ed86cd4084839\\\"" }, { "context": "\":\\\"2015-06-25T03:41:44.439Z\\\",\n\\\"private_key\\\":\\\"3ef242ebfccc2182734e92dffae246bd57d76333e3ca1cea64c04b53fc9d680f\\\",\n\\\"public_key\\\":\\\"034e532613c0f915927a5226e29cf", "end": 162163, "score": 0.9997456669807434, "start": 162099, "tag": "KEY", "value": "3ef242ebfccc2182734e92dffae246bd57d76333e3ca1cea64c04b53fc9d680f" }, { "context": "76333e3ca1cea64c04b53fc9d680f\\\",\n\\\"public_key\\\":\\\"034e532613c0f915927a5226e29cf1aebf5d20cde124820d3264f68e81acd2962b\\\"},\n\n{\\\"tx_hash\\\":\\\"6a79539f070bdae09b72d9b082eca46", "end": 162252, "score": 0.9997411370277405, "start": 162184, "tag": "KEY", "value": "034e532613c0f915927a5226e29cf1aebf5d20cde124820d3264f68e81acd2962b\\\"" }, { "context": "\":\\\"2015-06-30T06:51:40.083Z\\\",\n\\\"private_key\\\":\\\"0932252b3d7f242516a8a93fbd5fdf0e19fec093b914561ab5771cd8a45715f6\\\",\n\\\"public_key\\\":\\\"03e719d42e9275d255bb8d7598e37", "end": 162579, "score": 0.999755322933197, "start": 162515, "tag": "KEY", "value": "0932252b3d7f242516a8a93fbd5fdf0e19fec093b914561ab5771cd8a45715f6" }, { "context": "ec093b914561ab5771cd8a45715f6\\\",\n\\\"public_key\\\":\\\"03e719d42e9275d255bb8d7598e37ee967fdadb5c28a966034521590a70a22260b\\\"},\n\n{\\\"tx_hash\\\":\\\"70d5d808ae48b52ca18684e6109a484", "end": 162668, "score": 0.9997574687004089, "start": 162600, "tag": "KEY", "value": "03e719d42e9275d255bb8d7598e37ee967fdadb5c28a966034521590a70a22260b\\\"" }, { "context": "\":\\\"2015-06-27T05:41:55.735Z\\\",\n\\\"private_key\\\":\\\"9575a13ce0e4e9dc932a1054546d51c5a893decd4affcb095ad6021b40e2f125\\\",\n\\\"public_key\\\":\\\"0262165833accd3cc27e419787d61", "end": 162995, "score": 0.9997645616531372, "start": 162931, "tag": "KEY", "value": "9575a13ce0e4e9dc932a1054546d51c5a893decd4affcb095ad6021b40e2f125" }, { "context": "3decd4affcb095ad6021b40e2f125\\\",\n\\\"public_key\\\":\\\"0262165833accd3cc27e419787d61a0b3958d99e4aadae5a2d0148be3e31f6aaad\\\"},\n\n{\\\"tx_hash\\\":\\\"abf23d913ebaba5b6cfe4ce380db285", "end": 163084, "score": 0.9997687935829163, "start": 163016, "tag": "KEY", "value": "0262165833accd3cc27e419787d61a0b3958d99e4aadae5a2d0148be3e31f6aaad\\\"" }, { "context": "\":\\\"2015-06-27T05:41:56.162Z\\\",\n\\\"private_key\\\":\\\"f3366cd4a2e204ab4363c43bb7bb18148ef449a271022f575a59c3306493570f\\\",\n\\\"public_key\\\":\\\"0367dfa09a5f7ed0aa20893853db6", "end": 163411, "score": 0.9997633695602417, "start": 163347, "tag": "KEY", "value": "f3366cd4a2e204ab4363c43bb7bb18148ef449a271022f575a59c3306493570f" }, { "context": "449a271022f575a59c3306493570f\\\",\n\\\"public_key\\\":\\\"0367dfa09a5f7ed0aa20893853db6297e67377e9291b5a6daff84e63a4e0b4159f\\\"},\n\n{\\\"tx_hash\\\":\\\"a4744de93164483dce44c6c8410e6af", "end": 163500, "score": 0.999751627445221, "start": 163432, "tag": "KEY", "value": "0367dfa09a5f7ed0aa20893853db6297e67377e9291b5a6daff84e63a4e0b4159f\\\"" }, { "context": "\":\\\"2015-07-01T01:32:29.865Z\\\",\n\\\"private_key\\\":\\\"025fa36a5104680922df2280c9d6cb006555c6bff91e50e79d75c101d88c6e7c\\\",\n\\\"public_key\\\":\\\"028abae5d67d726059915c874321e", "end": 163827, "score": 0.9997619986534119, "start": 163763, "tag": "KEY", "value": "025fa36a5104680922df2280c9d6cb006555c6bff91e50e79d75c101d88c6e7c" }, { "context": "5c6bff91e50e79d75c101d88c6e7c\\\",\n\\\"public_key\\\":\\\"028abae5d67d726059915c874321ec57e679eadd7d9845e54044fcd5795e7a0e8b\\\"},\n\n{\\\"tx_hash\\\":\\\"a5b28a937d054a6478d38693016045a", "end": 163916, "score": 0.9997498393058777, "start": 163848, "tag": "KEY", "value": "028abae5d67d726059915c874321ec57e679eadd7d9845e54044fcd5795e7a0e8b\\\"" }, { "context": "\":\\\"2015-07-02T08:03:21.668Z\\\",\n\\\"private_key\\\":\\\"f16e2cd4864226645b24fc319c5804914ab39c18f7302207659635e249948ed2\\\",\n\\\"public_key\\\":\\\"023252ba58cfa6372d31b72d58ea2", "end": 164243, "score": 0.9997493028640747, "start": 164179, "tag": "KEY", "value": "f16e2cd4864226645b24fc319c5804914ab39c18f7302207659635e249948ed2" }, { "context": "39c18f7302207659635e249948ed2\\\",\n\\\"public_key\\\":\\\"023252ba58cfa6372d31b72d58ea20120383ab219fc21b84150941d2c165f2411a\\\"},\n\n{\\\"tx_hash\\\":\\\"f3274f2af4242950308efe62989c158", "end": 164332, "score": 0.9997568726539612, "start": 164264, "tag": "KEY", "value": "023252ba58cfa6372d31b72d58ea20120383ab219fc21b84150941d2c165f2411a\\\"" }, { "context": "\":\\\"2015-07-04T06:41:30.502Z\\\",\n\\\"private_key\\\":\\\"4ac51c3aa0aa10e8dc93efe5aa2a4af464698acdfbd4e7cadc2d2c98c06ba82b\\\",\n\\\"public_key\\\":\\\"022935969ebef594626b2d8ae3e7a", "end": 164659, "score": 0.9997730255126953, "start": 164595, "tag": "KEY", "value": "4ac51c3aa0aa10e8dc93efe5aa2a4af464698acdfbd4e7cadc2d2c98c06ba82b" }, { "context": "98acdfbd4e7cadc2d2c98c06ba82b\\\",\n\\\"public_key\\\":\\\"022935969ebef594626b2d8ae3e7a70db0030db4847d8ac0ef39c4d03b71c0d1", "end": 164694, "score": 0.9997091889381409, "start": 164680, "tag": "KEY", "value": "022935969ebef5" }, { "context": "\":\\\"2015-07-03T06:32:06.750Z\\\",\n\\\"private_key\\\":\\\"68dcae9e4bbcd61c2e36bed37b97306568cd753c9457c132136edf72027e3583\\\",\n\\\"public_key\\\":\\\"02593ae4d08912627d48042d71ba4", "end": 165075, "score": 0.9997444748878479, "start": 165011, "tag": "KEY", "value": "68dcae9e4bbcd61c2e36bed37b97306568cd753c9457c132136edf72027e3583" }, { "context": "d753c9457c132136edf72027e3583\\\",\n\\\"public_key\\\":\\\"02593ae4d08912627d48042d71ba4b203399e315749388ea30034208f6d6888ae5\\\"},\n\n{\\\"tx_hash\\\":\\\"cf76060ed1587fbc2fc30d09b973d0f", "end": 165164, "score": 0.9997490048408508, "start": 165096, "tag": "KEY", "value": "02593ae4d08912627d48042d71ba4b203399e315749388ea30034208f6d6888ae5\\\"" }, { "context": "\":\\\"2015-07-05T06:21:41.284Z\\\",\n\\\"private_key\\\":\\\"c6cd7111a61ee0f5c3491cd7164a01c6900c4e7d812f900d147ec95646442711\\\",\n\\\"public_key\\\":\\\"029a9fcaa8d30e8fd02667107e82a", "end": 165491, "score": 0.9996219873428345, "start": 165427, "tag": "KEY", "value": "c6cd7111a61ee0f5c3491cd7164a01c6900c4e7d812f900d147ec95646442711" }, { "context": "c4e7d812f900d147ec95646442711\\\",\n\\\"public_key\\\":\\\"029a9fcaa8d30e8fd02667107e82a482c577c7fe608784e4c7c76474452c455c36\\\"},\n\n{\\\"tx_hash\\\":\\\"0b66e834d067c4a3335606dbf447ed3", "end": 165580, "score": 0.9997276663780212, "start": 165512, "tag": "KEY", "value": "029a9fcaa8d30e8fd02667107e82a482c577c7fe608784e4c7c76474452c455c36\\\"" }, { "context": "\":\\\"2015-07-06T14:11:51.991Z\\\",\n\\\"private_key\\\":\\\"3f7219a37c872a7e60f7b17767625cc5d9b36311b74b1875ca4ce3398e9b844b\\\",\n\\\"public_key\\\":\\\"02022f7f79d72614f907ed0d74169", "end": 165907, "score": 0.9997571706771851, "start": 165843, "tag": "KEY", "value": "3f7219a37c872a7e60f7b17767625cc5d9b36311b74b1875ca4ce3398e9b844b" }, { "context": "36311b74b1875ca4ce3398e9b844b\\\",\n\\\"public_key\\\":\\\"02022f7f79d72614f907ed0d741697ac7c7819aca6648c14131bde36126bd532b3\\\"},\n\n{\\\"tx_hash\\\":\\\"004643d1f77530586b0e30169663c90", "end": 165996, "score": 0.999747633934021, "start": 165928, "tag": "KEY", "value": "02022f7f79d72614f907ed0d741697ac7c7819aca6648c14131bde36126bd532b3\\\"" }, { "context": "\":\\\"2015-07-07T12:11:25.844Z\\\",\n\\\"private_key\\\":\\\"8ad7a8f5dac447cdaab4025219640639c1d318339b594802967147aa62ecb9f1\\\",\n\\\"public_key\\\":\\\"027678351c8915ecf9f705bdf5aac", "end": 166323, "score": 0.9997714757919312, "start": 166259, "tag": "KEY", "value": "8ad7a8f5dac447cdaab4025219640639c1d318339b594802967147aa62ecb9f1" }, { "context": "318339b594802967147aa62ecb9f1\\\",\n\\\"public_key\\\":\\\"027678351c8915ecf9f705bdf5aac3a435cbbde290015a85e0dffdf2bc3d95d87d\\\"},\n\n{\\\"tx_hash\\\":\\\"54e41c4a8079f406d2c67678b251d2e", "end": 166412, "score": 0.9997735023498535, "start": 166344, "tag": "KEY", "value": "027678351c8915ecf9f705bdf5aac3a435cbbde290015a85e0dffdf2bc3d95d87d\\\"" }, { "context": "\":\\\"2015-07-09T02:51:31.994Z\\\",\n\\\"private_key\\\":\\\"72f50d42532585e478cffe216152317b5ff1f69ae3a308db69ff6f68f8a80253\\\",\n\\\"public_key\\\":\\\"0332dce354feb2cbcebf8181a7485", "end": 166739, "score": 0.9997739195823669, "start": 166675, "tag": "KEY", "value": "72f50d42532585e478cffe216152317b5ff1f69ae3a308db69ff6f68f8a80253" }, { "context": "1f69ae3a308db69ff6f68f8a80253\\\",\n\\\"public_key\\\":\\\"0332dce354feb2cbcebf8181a7485806b7cb33afe669dccbef8e4bd01dcae28239\\\"},\n\n{\\\"tx_hash\\\":\\\"c428c7960df93d59d0ca4178000561d", "end": 166828, "score": 0.9997703433036804, "start": 166760, "tag": "KEY", "value": "0332dce354feb2cbcebf8181a7485806b7cb33afe669dccbef8e4bd01dcae28239\\\"" }, { "context": "\":\\\"2015-07-10T04:11:23.760Z\\\",\n\\\"private_key\\\":\\\"91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea\\\",\n\\\"public_key\\\":\\\"03a2d0121dd45ab8a2b0bec0ae8c1", "end": 167155, "score": 0.9996822476387024, "start": 167091, "tag": "KEY", "value": "91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea" }, { "context": "5066ab1c97ff38a48ac95a3e2baea\\\",\n\\\"public_key\\\":\\\"03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\\\"},\n\n{\\\"tx_hash\\\":\\\"de4f6c1f419c02b72d7ace7543193c3", "end": 167244, "score": 0.9996463656425476, "start": 167176, "tag": "KEY", "value": "03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\\\"" }, { "context": "\":\\\"2015-07-11T00:00:38.774Z\\\",\n\\\"private_key\\\":\\\"8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815\\\",\n\\\"public_key\\\":\\\"0311241d491539de3f622afe966e0", "end": 167571, "score": 0.9997508525848389, "start": 167507, "tag": "KEY", "value": "8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815" }, { "context": "408ea0fa87c114c8b117d45efd815\\\",\n\\\"public_key\\\":\\\"0311241d491539de3f622afe966e0377a2379997a00d06f0412661d2611c541978\\\"},\n\n{\\\"tx_hash\\\":\\\"3e2", "end": 167632, "score": 0.9994044899940491, "start": 167592, "tag": "KEY", "value": "0311241d491539de3f622afe966e0377a2379997" }, { "context": "\":\\\"2015-07-08T05:02:14.659Z\\\",\n\\\"private_key\\\":\\\"6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b\\\",\n\\\"public_key\\\":\\\"028c2b3752cb51cd1ba30284ae3fc", "end": 167987, "score": 0.9997471570968628, "start": 167923, "tag": "KEY", "value": "6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b" }, { "context": "c7dff0ac6261aa00579b29a3f0f3b\\\",\n\\\"public_key\\\":\\\"028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\\\"},\n\n{\\\"tx_hash\\\":\\\"52f3a8cd1d346efd018f8de36078e16", "end": 168076, "score": 0.9997329711914062, "start": 168008, "tag": "KEY", "value": "028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\\\"" }, { "context": "\":\\\"2015-05-11T17:11:41.661Z\\\",\n\\\"private_key\\\":\\\"1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2\\\",\n\\\"public_key\\\":\\\"035311a5c807df1835184077423b2", "end": 168403, "score": 0.9997349381446838, "start": 168339, "tag": "KEY", "value": "1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2" }, { "context": "9249bd1096625f12f5205820aefb2\\\",\n\\\"public_key\\\":\\\"035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\\\"},\n\n{\\\"tx_hash\\\":\\\"de7614884e8e6a02c79357f4d54d12f", "end": 168492, "score": 0.9997325539588928, "start": 168424, "tag": "KEY", "value": "035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\\\"" }, { "context": "\":\\\"2015-05-12T11:02:43.981Z\\\",\n\\\"private_key\\\":\\\"c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984\\\",\n\\\"public_key\\\":\\\"037108b890b7b7d18d47652df4d0a", "end": 168819, "score": 0.9997731447219849, "start": 168755, "tag": "KEY", "value": "c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984" }, { "context": "008ce4b8b51e8b56a1c2fcefa3984\\\",\n\\\"public_key\\\":\\\"037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\\\"}]\"\n|#\n\\\"status\\\":1,\r\n\\\"created_at\\\":\\\"2015-07-10T", "end": 168908, "score": 0.999765157699585, "start": 168840, "tag": "KEY", "value": "037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\\\"" }, { "context": ":\\\"2015-07-10T04:11:23.760Z\\\",\r\n\\\"private_key\\\":\\\"91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea\\\",\r\n\\\"public_key\\\":\\\"03a2d0121dd45ab8a2b0bec0ae8c", "end": 169104, "score": 0.9996181726455688, "start": 169040, "tag": "KEY", "value": "91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea" }, { "context": "066ab1c97ff38a48ac95a3e2baea\\\",\r\n\\\"public_key\\\":\\\"03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\\\"},\r\n\r\n{\\\"tx_hash\\\":\\\"de4f6c1f419c02b72d7ace7543193", "end": 169194, "score": 0.9996676445007324, "start": 169126, "tag": "KEY", "value": "03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\\\"" }, { "context": ":\\\"2015-07-11T00:00:38.774Z\\\",\r\n\\\"private_key\\\":\\\"8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815\\\",\r\n\\\"public_key\\\":\\\"0311241d491539de3f622afe966e", "end": 169528, "score": 0.9997435212135315, "start": 169464, "tag": "KEY", "value": "8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815" }, { "context": "08ea0fa87c114c8b117d45efd815\\\",\r\n\\\"public_key\\\":\\\"0311241d491539de3f622afe966e0377a2379997a00d06f0412661d2611c541978\\\"},\r\n\r\n{\\\"tx_hash\\\":\\\"3e24e38058cbd1f39d2f510de1bd3", "end": 169618, "score": 0.999690055847168, "start": 169550, "tag": "KEY", "value": "0311241d491539de3f622afe966e0377a2379997a00d06f0412661d2611c541978\\\"" }, { "context": ":\\\"2015-07-08T05:02:14.659Z\\\",\r\n\\\"private_key\\\":\\\"6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b\\\",\r\n\\\"public_key\\\":\\\"028c2b3752cb51cd1ba30284ae3f", "end": 169952, "score": 0.999776303768158, "start": 169888, "tag": "KEY", "value": "6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b" }, { "context": "7dff0ac6261aa00579b29a3f0f3b\\\",\r\n\\\"public_key\\\":\\\"028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\\\"},\r\n\r\n{\\\"tx_hash\\\":\\\"52f3a8cd1d346efd018f8de36078e", "end": 170042, "score": 0.9997745752334595, "start": 169974, "tag": "KEY", "value": "028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\\\"" }, { "context": ":\\\"2015-05-11T17:11:41.661Z\\\",\r\n\\\"private_key\\\":\\\"1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2\\\",\r\n\\\"public_key\\\":\\\"035311a5c807df1835184077423b", "end": 170376, "score": 0.9997808337211609, "start": 170312, "tag": "KEY", "value": "1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2" }, { "context": "249bd1096625f12f5205820aefb2\\\",\r\n\\\"public_key\\\":\\\"035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\\\"},\r\n\r\n{\\\"tx_hash\\\":\\\"de7614884e8e6a02c79357f4d54d1", "end": 170466, "score": 0.9997745752334595, "start": 170398, "tag": "KEY", "value": "035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\\\"" }, { "context": "14884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbcd2d5ae707\\\",\r\n\\\"recipient\\\":\\\"1CvynMV8j7MaMSpK822sFQcu1h5QP", "end": 170551, "score": 0.9990622997283936, "start": 170541, "tag": "KEY", "value": "cd2d5ae707" }, { "context": ":\\\"2015-05-12T11:02:43.981Z\\\",\r\n\\\"private_key\\\":\\\"c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984\\\",\r\n\\\"public_key\\\":\\\"037108b890b7b7d18d47652df4d0", "end": 170800, "score": 0.9997919797897339, "start": 170736, "tag": "KEY", "value": "c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984" }, { "context": "08ce4b8b51e8b56a1c2fcefa3984\\\",\r\n\\\"public_key\\\":\\\"037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\\\"}]\"\r\n|#\r\n", "end": 170890, "score": 0.9997815489768982, "start": 170822, "tag": "KEY", "value": "037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\\\"" } ]
Crypto/timestamps.lisp
dbmcclain/Lisp-Actors
43
;; timestamps.lisp -- Verifiable time stamps using the Bitcoin chain ;; from www.originstmp.org ;; ;; DM/RAL 07/15 ;; ------------------------------------------------------------------- #| The MIT License Copyright (c) 2017-2018 Refined Audiometrics Laboratory, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |# (in-package :ecc-crypto-b571) (defun timestamp-file (&key fname title) (let* ((hashv (sha3-256-file fname)) (hashn (convert-bytes-to-int hashv))) (list hashn (timestamps :create-stamp :hash hashn :title title)))) (defun timestamps (op &key hash title) ;; hash - numeric, needed for op :create-stamp and :get-stamp ;; title - optional for op :create-stamp ;; auth code obtined from www.originstamp.org/developer ;; and needs to be renewed after every 1M creates ;; ;; Invocation: ;; (timestamps :get-all-stamps) ;; (timestamps :get-stamp :hash xxxxxx) ;; (timestamps :get-all-transactions) ;; (timestamps :create-stamp :hash xxxx [:title "your title"]) ;; (let* ((auth "d5e61940f461ab9c0c625cb8f2fbc45e") (auth-line (format nil "Authorization: Token token=\"~A\"" auth)) (host-line "Host: www.originstamp.org")) (with-open-stream (http (comm:open-tcp-stream ;; Lispworks specific "www.originstamp.org" 80)) ;; leave off the "http://" prefix (assert http) (flet ((crlf (&optional (str "")) (concatenate 'string str '(#\return #\newline)))) (dolist (line (case op (:create-stamp ;; create a new TS (let* ((data (concatenate 'string (format nil "{\"hash_sha256\":\"~64,'0X\"" hash) (if title (format nil ",\"title\":\"~A\"" title) "") "}")) (dlen (length data))) `("POST /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line "Content-Type: application/json" ,(format nil "Content-Length: ~D" dlen) ;; this line is needed "" ;; needs this blank line ahead of data ,data))) (:get-stamp ;; get one specific TS `(,(format nil "GET /api/stamps/~64,'0X HTTP/1.1" hash) ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-stamps ;; get all TS for the day `("GET /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-transactions ;; get all TS for the day `("GET /api/transactions HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) )) (princ (crlf line) http)) (princ (crlf) http) (force-output http)) (terpri) (write-string "Waiting for reply...") (loop for ch = (read-char-no-hang http nil :eof) until ch do (progn (write-char #\.) (force-output)) (sleep 0.25) finally (unless (eq ch :eof) (unread-char ch http))) (terpri) (let* ((okay-line "HTTP/1.1 200 OK") (nok (length okay-line)) (lines (loop for line = (read-line http nil nil) while (and line (> (length line) 1)) collect (write-line line)))) (unless (and (>= (length (first lines)) nok) (string-equal (subseq (first lines) 0 nok) okay-line)) (error "Can't get timestamp data")) (let* ((key "Content-Length:") (nkey (length key)) (line (member key lines :key (lambda (s) (subseq s 0 (min (length s) nkey))) :test #'string-equal))) (if line (let* ((ndata (parse-integer (car line) :start nkey)) (data (make-string ndata))) (read-sequence data http) data) lines)) )))) #| (timestamps :get-stamp :hash #xD633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227) "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-12T00:00:31.863Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\", \"transaction\":{\"tx_hash\":\"6ed05fd3cfdd58eab8c349a9a77f6782613f1edc304aa4de3f36ffbed09051ee\", \"recipient\":\"1JM3GCAc2gWKZ8C2PYk3f6yBB8ZFVj5htR\", \"status\":0, \"created_at\":\"2015-07-12T00:00:31.788Z\", \"updated_at\":\"2015-07-12T00:00:32.309Z\", \"private_key\":\"a7c8783b60a02f392a20b4683d07284b5bd43a2f9872d967597399fb9a0493f3\", \"public_key\":\"02865be123fa2daf9b2b2ea3f46bd849965c3be094039ce3ab8e2be3003710e3ec\", \"seed\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227 <<-- !! 050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1 23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885 640982b83bc1aa015d8f60b6ed5f0799fa42a51760313decc854a9b91840bbd8 ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4 4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f <<-- !! 7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530 3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4 7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0 abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92 23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27 3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\"}}" |# #| ;; :create-stamp ;; "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-11T23:30:27.273Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\"}" |# #| ;; :get-stamp ;; "{\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}" |# #| ;; :get-all-stamps "[ {\"hash_sha256\":\"3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4\", \"created_at\":\"2015-07-11T14:31:48.972Z\", \"updated_at\":\"2015-07-11T14:31:48.972Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530\", \"created_at\":\"2015-07-11T17:35:13.487Z\", \"updated_at\":\"2015-07-11T17:35:13.487Z\", \"submitted_at\":null, \"title\":\"testing\"}, {\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}, {\"hash_sha256\":\"ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4\", \"created_at\":\"2015-07-11T18:00:42.182Z\", \"updated_at\":\"2015-07-11T18:00:42.182Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"640982b83bc1aa015d8f60b6ed5f0799fa42a51760313decc854a9b91840bbd8\", \"created_at\":\"2015-07-11T18:01:04.967Z\", \"updated_at\":\"2015-07-11T18:01:04.967Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885\", \"created_at\":\"2015-07-11T18:01:38.495Z\", \"updated_at\":\"2015-07-11T18:01:38.495Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1\", \"created_at\":\"2015-07-11T19:01:22.027Z\", \"updated_at\":\"2015-07-11T19:01:22.027Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\", \"created_at\":\"2015-07-11T07:20:36.463Z\", \"updated_at\":\"2015-07-11T07:20:36.463Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27\", \"created_at\":\"2015-07-11T11:14:37.135Z\", \"updated_at\":\"2015-07-11T11:14:37.135Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92\", \"created_at\":\"2015-07-11T11:22:07.051Z\", \"updated_at\":\"2015-07-11T11:22:07.051Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0\", \"created_at\":\"2015-07-11T12:48:24.442Z\", \"updated_at\":\"2015-07-11T12:48:24.442Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"} ]" |# #| ;; :get-all-transactions "[ {\"tx_hash\":\"5cc6cd42202553b3b57ea5a250b394fec174c0bd610da2598fda03ede170f90f\", \"recipient\":\"17rYW4DofgBrV2k8k2ky7xLuzUwp5inoJa\", \"status\":1, \"created_at\":\"2015-01-12T00:01:11.800Z\", \"updated_at\":\"2015-01-12T04:21:30.983Z\", \"private_key\":\"0c4709e0e21369cb73ca0ddf97775f2bcdbf7461a2558105ada9086e6069645b\", \"public_key\":\"030c35ecbf936c8bf6e53fa0fcb7822237158f2ddd096594223cb48b88d35fde12\"}, {\"tx_hash\":\"bdc6244b11575e29329ca10a65e6b171b377e6574eb3d6f0cf524fbe054322cf\", \"recipient\":\"1Vant4CVGow6RvEcsPBgEmFCN5bBzkpen\", \"status\":1, \"created_at\":\"2014-06-06T00:05:07.709Z\", \"updated_at\":\"2014-11-05T02:01:52.887Z\", \"private_key\":\"f7d286ec06df0f0b278f7f2976bdcfeb61cb15e9bb8906d7730ffa079c1adf00\", \"public_key\":\"0495cca1916fc8d4ade304ef1aae5e68809fb3a9d70338a914dd751344830311dc26230a31bf88db1abdc85f2d7e6d489153a9fcf253aa807b23bf1adbd4a94161\"}, {\"tx_hash\":\"b65f0530d2b56e1f30547f9e0046166a2ced52dbb082cbf4f6bf7bd452a5eec2\", \"recipient\":\"1NUiXjKtSzj6obrZY6VR1Uydd23R9Cc35E\", \"status\":1, \"created_at\":\"2014-05-19T00:01:19.640Z\", \"updated_at\":\"2014-11-05T02:01:52.906Z\", \"private_key\":\"69f84c65bb28ec14ce722fb7cec0335820f16dde44b7ea1af251b53054394ab1\", \"public_key\":\"046b8f836097ee7ce437fe8cbef79ffd0122c3eff945f3552f19b38539f2677055bcf85c87b0d2692c636d04748715c07cf25403459c887aed63ff72cc64fd3fde\"}, {\"tx_hash\":\"a4f4d37ce4ae65b6403bdfb843879633baef5267486d936e6e2b1f75f0669a10\", \"recipient\":\"1CKKrtq5ur5ZFtQGwwZDBzuRRd1cswqNrs\", \"status\":1, \"created_at\":\"2014-03-20T18:32:24.377Z\", \"updated_at\":\"2014-11-05T02:01:52.923Z\", \"private_key\":\"5818658756094f3e5b32b49039cbde329b4e9b59702e1f8766212c5a302363cc\", \"public_key\":\"04f5c8c43121346d5ceaf82a7765da7ce9d53df8e6fdc31e04899ef822c24a8eb957bb23a1123e34a55a2dae6af8f122e074d2c49cf0cc35bd55bd89d262a80392\"}, {\"tx_hash\":\"f4ea6b84442ab6b72160f6633b7c43a6186c30e16c276da2bc8dc0f768ef1680\", \"recipient\":\"125Qkz8J4VdyoxVL2wQK3mdCkdzt8zfcKA\", \"status\":1, \"created_at\":\"2014-05-29T00:02:40.501Z\", \"updated_at\":\"2014-11-05T02:01:52.940Z\", \"private_key\":\"34c4372c4b381a9b56745fe485fc777abf0ab5b17f5b5ef7878f334b23786825\", \"public_key\":\"04aed6f0e99ae96975066fc0c21f9f1ff42485e5db1e5c6dd3b83532e42ef23c8566f286312e5563cb1ccc8d3f8980aa03b8df1c0cfabef582608c4f399c934e52\"}, {\"tx_hash\":\"05a46466ae2021a0bce6d5329c7528ee9b3c1b2fdda67bf6a7c04b28f5c0bf52\", \"recipient\":\"18q4mRvakf9UJWQAqcmn8wWHYQ2NKwNjpX\", \"status\":1, \"created_at\":\"2014-05-30T00:02:38.551Z\", \"updated_at\":\"2014-11-05T02:01:53.516Z\", \"private_key\":\"1fba92f7a17afe4935dc813e64a7aa3a236929256825fd42d70ad95f3b7c2462\", \"public_key\":\"04d05babdbd06d8f2f78b68808e92395af8a49222a1099096fba93c24546042b3f488d5f208bdde3bc53e9ef2e72ee66c775729535bb1162a1ada1445afe8cfe0c\"}, {\"tx_hash\":\"ed6a0c5266ef634d3ff70e8edea9eb48ec4dc659a32a1c2a3ec4e0bcecb31db9\", \"recipient\":\"1ESG8CkoREhCZYx4kB1UEBnhNtzSAvVPXm\", \"status\":1, \"created_at\":\"2014-05-17T00:01:16.285Z\", \"updated_at\":\"2014-11-05T02:01:53.546Z\", \"private_key\":\"7d7e0cb8a9288dd7d05a06026a4057fd191b62c8d5414161ce4599418142a55e\", \"public_key\":\"04ab49b94316152af2bcd263756c8d972499679dddf4915baff2bfcbfec9a4efe6b87be5a4141666d72be05cdd456239bcee8a1d280db4d01798c2415f95008751\"}, {\"tx_hash\":\"b31b5e20c24cdbd9effcaebd5fb2d13ff03a6ba5fca4a8b367e230dcae7f490e\", \"recipient\":\"13B1WpaQ3Tk4BqQ4LX3eysQwvSn5uHsgW8\", \"status\":1, \"created_at\":\"2014-08-22T00:02:02.373Z\", \"updated_at\":\"2014-11-05T02:01:53.761Z\", \"private_key\":\"b58d509caaa3f86bba12e9bf18a9f1ae6bf56315ded5e5c625ace2dc537a341e\", \"public_key\":\"04413115b0d9117a95ddd3de14e0d6718eca167a63b09825390c29c648ce231fd64ffafb72a15b3bbcdbcdf6c5e4ae113bfada24565a9bb74d9415f541dc4274c1\"}, {\"tx_hash\":\"9a33b45134905cc6877af56f52060480b389e3fa4ea759ae8c504aed5c503158\", \"recipient\":\"1FWwNFMeKtjrmXgwaYZE6hAodrM7ozDNt9\", \"status\":1, \"created_at\":\"2014-08-02T00:01:41.468Z\", \"updated_at\":\"2014-11-05T02:01:53.924Z\", \"private_key\":\"fb60576b17a5003f245e3d153205ede104c080642a77864039bf44040ca72b08\", \"public_key\":\"04c2ffd07ec46197e3ade8b1973aebd1d84e50790aebaf7f2d374dbed5b4a97f03970e1470d9132fb18141e07dd68940c2a9923eca6fd87a4bb94992095b869330\"}, {\"tx_hash\":\"0c0fcf84d098e9a66c0848e9fc00662a82203c700c408038665157670c4554e9\", \"recipient\":\"1AST2VqYHnrmjv86FiRepvTJBSrXomLjRF\", \"status\":1, \"created_at\":\"2015-01-14T00:01:22.624Z\", \"updated_at\":\"2015-01-14T01:21:27.230Z\", \"private_key\":\"1b3b7b080ed361e3171a9e04c586568ebe0067e1b4fdbedf669afb8a330be7c4\", \"public_key\":\"0255d5ed6953f267c13d8cbde8e9fbb74746462f4384954cdfef5ba9d7a3a05e95\"}, {\"tx_hash\":\"5633980ac2a46f7ade29eb20da90307402ce7dbbe8c3d6ee2af8494584200a60\", \"recipient\":\"1ESYYyMmngUUHZk2YTnFdxuw6ddV57CYSx\", \"status\":1, \"created_at\":\"2015-03-23T00:00:30.572Z\", \"updated_at\":\"2015-03-23T03:41:45.110Z\", \"private_key\":\"c74c71353f05b968b22dcfbceebc72faf106eaa4006aaa116a9765deb37ff061\", \"public_key\":\"027fbbaabe8a9e808acb0b12c9c3a3a5ec040515afe6660c9f4620b76947afbd5f\"}, {\"tx_hash\":\"d6e8a78c75cbae895ce35cac701e722f475fb11bc7759a690771d586d92868f3\", \"recipient\":\"1N7BuAVEMxt38jxcHzPusWX1DbRJ8wxWRE\", \"status\":1, \"created_at\":\"2015-01-15T00:01:20.165Z\", \"updated_at\":\"2015-01-15T02:21:43.280Z\", \"private_key\":\"b1e62f87f8620a8c854d6c498a3140984f0f9150bfa11eb6f6f2a671ce292560\", \"public_key\":\"034c92ab3ce98a5bfaf5d2f51f020de0606c42584f093564b665cb0fdaf776da76\"}, {\"tx_hash\":\"a82e164dc639f8c2427b6585135da31007b066862643c2e88286d2ecc85b23cd\", \"recipient\":\"1HBfuMBfsQBLAmTJjQf7VZtJqJ1G4j9FTR\", \"status\":1, \"created_at\":\"2015-05-05T15:27:32.230Z\", \"updated_at\":\"2015-05-06T06:11:57.254Z\", \"private_key\":\"fed68abd80d2a328c462434422dab297c8dd80f4a47c961b83e9d4730843f5e2\", \"public_key\":\"02817b4adcb21ea9c0be130dbbe4c4562276c603db180d65fa6828585f08943650\"}, {\"tx_hash\":\"d6568ebd966d2cef00885e3460ca2025ba42fdb56f80b67f34730d84964b48b5\", \"recipient\":\"1QCRzwHxuK3AQcmjgiPCUHBsoy1hPkMmQv\", \"status\":1, \"created_at\":\"2014-03-08T18:34:02.426Z\", \"updated_at\":\"2014-11-05T02:01:52.951Z\", \"private_key\":\"10ed3e980e62d373e5ee300d51ef954aa049b615ea5d597323285cfaba4b9c29\", \"public_key\":\"04be695f8af1fa9b7de536759df508b623a166e9bc96adad560c577af16b29ae6a0268a3805c7840a30573e4fbb6af5bc9895ac0fe4f04e0bb4e206e181056b7bd\"}, {\"tx_hash\":\"2831a771337e431791d1281992e20be6fba1bb12f154efce516a9c1da1c0c817\", \"recipient\":\"1P9y1ahAfqUWWAvWB6nvyfGJGkGgqkTGz4\", \"status\":1, \"created_at\":\"2014-05-15T00:01:07.853Z\", \"updated_at\":\"2014-11-05T02:01:52.961Z\", \"private_key\":\"7d01ce525f9b8df8de5599e41891c44dcc1e2b337891bd0904c44a4b465bc67d\", \"public_key\":\"049cdba1d356124cd20782ebb470fb259b7fd5273aaa4b7ad694407165cdcd8effa6c29ea3121b22d84bba6a1150708c44f94d9f1c3c63d81a585cfa68c893946d\"}, {\"tx_hash\":\"85f5a8e7319a1ddc28fbf58e7f7f67b4b5441ed720bc82699d7f14037db4d039\", \"recipient\":\"1MmuY2ywp7Fort4CRAGhb9ap4jMNE2MZJZ\", \"status\":1, \"created_at\":\"2014-06-13T00:05:47.200Z\", \"updated_at\":\"2014-11-05T02:01:52.974Z\", \"private_key\":\"c20381615d5974d93c866023c4763f219dc704906f7043f587722144ccbf98cc\", \"public_key\":\"04dd10cb063a0fafc0aea92e6d39aa870dffb7b3d2a87f95a81b5ae0089c34febe867f18b1ef2c14699077e2825b977d44ecbbfb53d7e10be6683bdb08ee9b63aa\"}, {\"tx_hash\":\"9a33c1b174a8cad687e2081383c94db4dd601e58cf8df8e24baa493b2fda573d\", \"recipient\":\"14EoknsfxEvzNEXtqKz4hhfjB1Q6iUSqJW\", \"status\":1, \"created_at\":\"2014-07-01T00:02:12.587Z\", \"updated_at\":\"2014-11-05T02:01:54.167Z\", \"private_key\":\"fb9a0bd7c86af880aed682ead260dd211d35a8160b18fc7f6fa14eefd9c670fb\", \"public_key\":\"04e57203fa268ef54c93c083f86464408b2fe1bd3183be67e6c6cdffaba3f877d6c0994fc41ab35c82c67c73a9e8a000a5a7a5295d40a7b35a9d3f901613724dd9\"}, {\"tx_hash\":\"3bd108eff5534cbaf85747376118f5e834fef1fdd7b165d1db2f1d1d8ebb99ac\", \"recipient\":\"1DSFfRafiWZWyTnqiTaMy27HA1amfaK9sr\", \"status\":1, \"created_at\":\"2014-07-03T00:02:38.416Z\", \"updated_at\":\"2014-11-05T02:01:54.193Z\", \"private_key\":\"3865d08058c9c9f8524eff9adef8c3771daa85153ab5366c0368b2ef17d5ae97\", \"public_key\":\"04c896167494c4f5e6501c24950b94ab8ccbf26cec0ada292961cca5fedea403b2dcfd2f948353091c8257592937c9415d7c63d59c89066adb2780bf9326377773\"}, {\"tx_hash\":\"76846c2a77902e57ab1e75b3313394567e76ec31b90bbe0161cb7479d725f64c\", \"recipient\":\"1BTGAMpZ9e25y3tm3J5SnP9ugAz5Ktco7\", \"status\":1, \"created_at\":\"2014-07-26T00:03:34.143Z\", \"updated_at\":\"2014-11-05T02:01:54.384Z\", \"private_key\":\"737521d94b6e4f37e6c5fea71e244b47ed043c45c8952a77a36c1afa2ebbce72\", \"public_key\":\"04e254bf5f65374d3d4b857f621f9fc6d3b621dc60c6b4080d131456db835aae03ec5b77e319393090589d789d083b53f9f91f970a22c9ef974ff3b05e99ce9f14\"}, {\"tx_hash\":\"6262b99f22bcce8bacad6c46211213731ce249392195b2f3d968ed060f4bf27e\", \"recipient\":\"15LyoqNbG5jox9Ve68ciUseW4Wm8bGbRNK\", \"status\":1, \"created_at\":\"2014-08-31T09:53:39.904Z\", \"updated_at\":\"2014-11-05T02:01:54.510Z\", \"private_key\":\"bee478f7e8c85f24d58edf4bef616235968b290ae5308d0ef2259fbacf02a267\", \"public_key\":\"04728fbea6cac2bfcce4e573faa46f9dfba09965ac285b0687a6cd39fc8670384e53e9804b687e30d5955c3deccdc429732f012c0fd69db318b9196e5746fe06f3\"}, {\"tx_hash\":\"daf0600d1a28ae86882adc03b8f583462bbc8f0174f79a03058db9a8658a36bb\", \"recipient\":\"1EFiGL8eF7D3waeEskfdfsvMicVrUfBacc\", \"status\":1, \"created_at\":\"2015-02-12T00:01:25.830Z\", \"updated_at\":\"2015-02-12T07:41:56.531Z\", \"private_key\":\"b591ee7c5a64a36d2258873d28f2845477b357dfce709fa2dfe04ba76d419dec\", \"public_key\":\"0397711cdb60fbd551a162a029956980524a87ab26251badac92fe34cd1e7b472e\"}, {\"tx_hash\":\"052aab2bd27b31b81ac39bad164cd38a244dce6f43ae489cb2805c0367c2ccc2\", \"recipient\":\"1JF1Js5TY2uCH2Uqaqe5ksaWPtJeZnWEub\", \"status\":1, \"created_at\":\"2015-05-14T00:00:48.476Z\", \"updated_at\":\"2015-05-14T03:03:00.807Z\", \"private_key\":\"13eb60184656f64032076b4ec173aa49e0a60008e5427b29f44702fb8f615fa0\", \"public_key\":\"02a3c5a2e07a891888bbb5a3b31a07ef81d792a0c2a940c94bae6e18229b7d7a43\"}, {\"tx_hash\":\"b9d3496573b5d1e867d77315a2fd917e9b6b34f9ed917c4247e182f10ce82d17\", \"recipient\":\"1Gw4kbqa3rbKWc1GpRGQfMATqQkWg5vLi2\", \"status\":1, \"created_at\":\"2014-11-13T01:02:52.146Z\", \"updated_at\":\"2014-11-14T00:21:40.358Z\", \"private_key\":\"a7e451c7455d3f06db42ed5f169b4cba8e57923048bc091ba7753280f2284790\", \"public_key\":\"0364ce196c16aacebb3a2e0f5840ab9113fa1b9824063251fc61ab9c603fc429ba\"}, {\"tx_hash\":\"21e08bd07f30d6cd503e4ce64a0fdb786dc50e34cf488006c904b6b05963e687\", \"recipient\":\"15P6v2v7HsTmT9XU9Qxr7rQa1sQftHwzzp\", \"status\":1, \"created_at\":\"2015-03-17T00:01:09.998Z\", \"updated_at\":\"2015-03-17T09:03:29.537Z\", \"private_key\":\"238943026621dcb27e1a2e905da0e4df60b09d690c34460ca5a826f52342913d\", \"public_key\":\"02d5feec473fa8f83ee52478fce24512a8fdab9ba03525bfa760040d341526bce3\"}, {\"tx_hash\":\"7561a3bf4a53fadca684639e877af39abdb1c77e04ba1f856476ba56ae72cb94\", \"recipient\":\"1G9RXzGyoqQfJHzoQkH9a2EPDNQ8bnb1mF\", \"status\":1, \"created_at\":\"2014-07-10T00:03:12.573Z\", \"updated_at\":\"2014-11-05T02:01:52.991Z\", \"private_key\":\"9046f1d856de34d7e5762d71f39cc972a210c9194be83fdd1dacf30479bd550f\", \"public_key\":\"04d02a28ae18aaf266075fc973c09621d76a11ea64a944111d20d7c16f9964c5d008bfe4a926d8568cfe2a74f18a08cce521b648b714434a78c503084231198a66\"}, {\"tx_hash\":\"274b0e7143eee9a23d166f6d60c9f8d0af11ed655254285559ec2225971c3939\", \"recipient\":\"15StrEcsCmSNfktcfXBrato4VdaZCkbUAQ\", \"status\":1, \"created_at\":\"2014-06-26T00:02:37.128Z\", \"updated_at\":\"2014-11-05T02:01:53.001Z\", \"private_key\":\"09dc9cf9b4e563a9ec1486fba581008fffd2cca484f9e8cd1b3cdcd4bb888a44\", \"public_key\":\"0483eeae686580b32c2d7d7c6fd5b39adda777203931c96841dc92cd97c2c55df7a57941561c2885fd8851ab2a5f50a921436b368cd9ab9eeb709e9ca481d89c21\"}, {\"tx_hash\":\"0c28e0f4ebe036df09ded5ee33323d9c5518d6a37dfa45964ae7ff7d1eda7050\", \"recipient\":\"13McrP98NcUniCecfGL6GpivHTRzoVChPX\", \"status\":1, \"created_at\":\"2014-09-12T00:00:18.694Z\", \"updated_at\":\"2014-11-05T02:01:54.536Z\", \"private_key\":\"923f93bf3d6d13aad34c198e4f9f205f39e41f12eb456c3f395880fc0a27a7ff\", \"public_key\":\"04be9536046b77db1e5ac7b59bfad5302453ffbdc357c8ed82242d1baf5431c3a24e46959339e9dd9ddd292bb18de91b8b864ed9b40cc89a5cc036e8b88244b1dd\"}, {\"tx_hash\":\"7334c1369680e4f999e97b3bd9315e3d0a521cf50587c582de50ab0f72f201b6\", \"recipient\":\"14RWr2qjHCgmPtet2BCeqRqTfnA9LfRc1R\", \"status\":1, \"created_at\":\"2014-10-21T00:03:54.249Z\", \"updated_at\":\"2014-11-05T02:01:54.615Z\", \"private_key\":\"06737cee30c6ad8831de0a6621c9bd7b1fdd64540c2142293b5b35f30bb0c14c\", \"public_key\":\"04a4fa83e35142c7b1b94a041fe651e5eccfd25acc1ec61ed817c853adf8de5fee4faab80664ae95864b67b493e56917069df084dc23026f051e1ed1026d6b75c8\"}, {\"tx_hash\":\"15872e495968e5f68893d13a75c3101980d9b44104d2af509ff65e5c8ac448d5\", \"recipient\":\"1JhPmLzpUY5TwTggvzmV6Vve4NHPTDCopy\", \"status\":1, \"created_at\":\"2014-09-19T00:02:05.121Z\", \"updated_at\":\"2014-11-05T02:01:54.625Z\", \"private_key\":\"22a2f43caa5414f6d64c3d28e1fc824a75bb173ab750dfc0ca45fbaeb1e21e3b\", \"public_key\":\"043e2c6cab8285bb47455687e11898ba3bbddf943ccbdc8d517a10a98ad5e9783dc53dd18ec46de21c8613e8225c11ac810ca5b039bb947369af0d2bd8c9bacfc4\"}, {\"tx_hash\":\"551131e5f5fc48b7816ff07acfeedc5c7fc55d66050145e58d5f3523ee75142f\", \"recipient\":\"1JU5XyFZTBh9w5simV6e8EzdCioNVTim1H\", \"status\":1, \"created_at\":\"2014-08-26T00:02:03.885Z\", \"updated_at\":\"2014-11-05T02:01:54.645Z\", \"private_key\":\"a5814d9dc878bc744ca7988352d2f0e5f15e9d995c315bad747ae7a85961144f\", \"public_key\":\"040732ecd23426eb99741c2707dbbcb74bcaf94d4d95d7f06bf2ede7403e11b1d0f0e1c50e0f6526500a7404c2906b5af0cd678c7cb971530fbfea93a946f2995c\"}, {\"tx_hash\":\"4747e4c8524c82fc737caf89f9ad666abad4715cf4f99dd796c4c2d002ff22dc\", \"recipient\":\"1Kiwqx8Rrw8XafDNBnsrUX1j5ohy1Yn6oG\", \"status\":1, \"created_at\":\"2014-11-14T00:01:45.775Z\", \"updated_at\":\"2014-11-14T14:51:47.987Z\", \"private_key\":\"5cdd1269eaffeca5340ffceb6be10fc362747d5a6a366ffd3ca40e9f983f146e\", \"public_key\":\"028e0ee7aa13e67f343f2a6ab46185c9de95419495e48b914414989c55254c65f5\"}, {\"tx_hash\":\"4d10a835b5e9a974596755f95407c825d9249eda6feaf4305e1a7fc1119d43cc\", \"recipient\":\"13UCP7B7P9cG9NZAqykTSUfwZYi2x6XaiB\", \"status\":1, \"created_at\":\"2014-11-15T00:01:19.086Z\", \"updated_at\":\"2014-11-15T08:32:36.799Z\", \"private_key\":\"a73f0ca8defa94d5edee84b6331cb16a2dac88a45b12cca89c1077ee4af400eb\", \"public_key\":\"02ecd34d7caa9f2045db74eee05053caff1a4aa83c893495a8eb51df1373e0ca8c\"}, {\"tx_hash\":\"b03cf3b1c193dc66800bf809f7ea3f853431f2fa94621b573b22e5fbcf71491b\", \"recipient\":\"1451zcXorHeHQ5tioGCRoMpSXqX2rezUHU\", \"status\":1, \"created_at\":\"2015-05-06T00:00:55.528Z\", \"updated_at\":\"2015-05-06T06:11:57.704Z\", \"private_key\":\"d6af2f3f662ef00992ac6e7c75b2a3ad78bff16ab852efe24115b43bf22eaf03\", \"public_key\":\"03bc60554a4cb229feb85c4c3907785a8532263bb392b5d790ae7f81e201809695\"}, {\"tx_hash\":\"d33c092e34a89d60dc718f22903735d053668b5414ed97089491e41608a0889f\", \"recipient\":\"13G6DWSFygS6kU6wq3nEehwTgqH4preN62\", \"status\":1, \"created_at\":\"2014-05-14T00:01:35.969Z\", \"updated_at\":\"2014-11-05T02:01:53.011Z\", \"private_key\":\"a2c4ad08c4ba5e04d6e8558f5b5c964dc99d2a0792dad153dd06465a34cb62f5\", \"public_key\":\"04249c03a55ae8fb404295391d3a326de5e7960bbd9e194c2e2010e09d8a3b5cc7dbf8fa7bf07b8f07e631281f027ea78e743d67fd6bf4a13d94e4bcadc35c9393\"}, {\"tx_hash\":\"50d46c1696c07d2e4aed3f0f6b8ec365cdbab74a5e0c87c2470d208c842fb0f4\", \"recipient\":\"1DHnLfeb1hDakgk2fVcG6aDyMzK6Vgcynm\", \"status\":1, \"created_at\":\"2014-09-23T00:02:10.197Z\", \"updated_at\":\"2014-11-05T02:01:53.022Z\", \"private_key\":\"c916ea8d7207898958439efad7b0faa753425dad9cb9a1a4256820876892931c\", \"public_key\":\"0452a147585174d85f326df0875a19669943ec5e5336d0e1029b80eaf17564268036de4b522e590847aec38f1895d73978dd9d2b3151418acad19ece2cf14cd706\"}, {\"tx_hash\":\"c9b4bfdcf61b770c1f6b80b575aacd21c08a28146a2b74a829260fb54eea083c\", \"recipient\":\"14gcu52GekwuQBwwto6RpbWQDgv3JhpaGu\", \"status\":1, \"created_at\":\"2014-10-11T00:00:55.209Z\", \"updated_at\":\"2014-11-05T02:01:53.046Z\", \"private_key\":\"0ce1cc475772c535bd0053b5c3e43ab415bf26903642d7737168ff1cea1a558d\", \"public_key\":\"04ed86fe2649cec4b835224e62d45c3676f1e3fbd8a9c079ac7278994f7bfb3a8e6990abc97dc05774163317417509c22e4e69593eec6194fa15d86f90bf7705cd\"}, {\"tx_hash\":\"04642f3f029eda2b48640642ca970ac2b190132876542d36918772ea5b7191ed\", \"recipient\":\"1LdBELrbXZbKedG5qKJwgA35Gep7RXKwk5\", \"status\":1, \"created_at\":\"2014-06-17T00:01:54.014Z\", \"updated_at\":\"2014-11-05T02:01:54.730Z\", \"private_key\":\"d138ed28d4dcc7c678bb6562a7250b9ca71ac3b528ef6b9a5d9c31d365f1cffe\", \"public_key\":\"04d3f31a343168d54ee2c37075e86873c88b1c2ac7fc0225a309ab7af30b85e3ac8e8eac52da965d377b20561bd4667923f8188003c27a6ce62296d8be78dbf6e0\"}, {\"tx_hash\":\"d1d7623456bfe389152c7e5d7075728c1045c62b054022d7e9b95c5ef117e890\", \"recipient\":\"195mgMWrgSmjy2Ax3r1N3rvood3YN5wsLR\", \"status\":1, \"created_at\":\"2014-07-02T00:02:37.176Z\", \"updated_at\":\"2014-11-05T02:01:54.979Z\", \"private_key\":\"6b6542584866076598b63cb6adbad08d0fdd9f250f1c71b782d586f0b914272f\", \"public_key\":\"048438e4fa2b9e38e3248eae495d2240eb0ffab485d0119c1921251e084ebb90c4a1bcdd0a7758e6fe76ef5adbce6711c92ba28fe35ff72e236218d36b160743ab\"}, {\"tx_hash\":\"b5175cd928c898cf3a9f3283666386c44dc6343db5ff788ddf597d13e4438e3b\", \"recipient\":\"18F4Anawmto2ypQW4xTMmCwJgQPvJSuBaL\", \"status\":1, \"created_at\":\"2014-07-09T00:00:28.290Z\", \"updated_at\":\"2014-11-05T02:01:55.102Z\", \"private_key\":\"b9200b1a5fbd360b8039c3f10f48388b76408361c46e8d32610b7e1fc2cfdef5\", \"public_key\":\"04a640490f6c04e0c305f86361e122d731356a7c93f90409f7ebfa6d891cfa6dbd0f22b772b67eeaf3551898029e884bac8f4e6aa3366f6d006defa673f95a2a44\"}, {\"tx_hash\":\"44f2cf8058d4d5c1f7aaa019ba404c0726b187828726b598e4369be230387a25\", \"recipient\":\"1kynpGAAYNNGGBWakw1GXisuNWVa3Wiz3\", \"status\":1, \"created_at\":\"2014-11-16T00:01:16.227Z\", \"updated_at\":\"2014-11-16T03:51:50.052Z\", \"private_key\":\"831b92d1aa41dcd9c0e85c21edf40bfd595c7c2b6cb8c603b24e9e8fc39ee1cd\", \"public_key\":\"033ff5321b1d617fda82d1f6bebbea8b26ff0f3216bb3ebcbae25500725594b858\"}, {\"tx_hash\":\"eb5f0cef8a03ff68980d045e2c27689f130a043e8ece31a5b9c9fb4636f95002\", \"recipient\":\"14BfdJrP64JpWPQG58FUcJhM9AFTkDyKnC\", \"status\":1, \"created_at\":\"2015-01-17T00:23:37.472Z\", \"updated_at\":\"2015-01-17T04:11:33.558Z\", \"private_key\":\"43c0502453a232da29e30359a8492137c87fcd4c8b9e17cbc40f3521f8e30ff7\", \"public_key\":\"029f99da5354afde84d03f16af423485812d29c1109bd3fe84d00c81586ab2ed44\"}, {\"tx_hash\":\"c205529af8313c48102dfa8cc78e309b9440cabb0eeb3f24e73d43dc22c7cf07\", \"recipient\":\"1EV7LBAXZEuw4mDfCR3FE8yJJT8cNqDp9L\", \"status\":1, \"created_at\":\"2015-02-13T00:00:48.588Z\", \"updated_at\":\"2015-02-13T05:32:20.428Z\", \"private_key\":\"cb458daeea219ac9bf4562992266e28959b228f9a2316cbca7e36abb9c79b952\", \"public_key\":\"029405bb9a4cc52435525b906bddbf12214afd1e28a5664d86624daf16c1363da4\"}, {\"tx_hash\":\"15baee9509fa0e591634d5da7e3d540dd7a1d9c6a030c807b09b2351028d6abf\", \"recipient\":\"1PmAGdacqT3Hzr259qdVz85egChWfQphtv\", \"status\":1, \"created_at\":\"2015-05-07T00:00:52.308Z\", \"updated_at\":\"2015-05-07T04:21:52.571Z\", \"private_key\":\"3186ac813cc3867407f70571a1b1d3fe88a0cf246af0c8853312608aededd717\", \"public_key\":\"0233e8be7ac425bffa9678597339a4fac60b722cdabbe5bdf3f26d6c11087dce33\"}, {\"tx_hash\":\"cb4cda0073b401d796e0f2c96e8f5a84fec1f506a07c40de2b634e4df9598266\", \"recipient\":\"19NSGsvtjMrgukZzUrd5uyNrJimunqF6G4\", \"status\":1, \"created_at\":\"2014-05-22T00:00:39.567Z\", \"updated_at\":\"2014-11-05T02:01:53.058Z\", \"private_key\":\"f37d79877dfe29ea694ceea88d2c1f3221b8907c68fe980082071ce9ff815c06\", \"public_key\":\"048d7c6dfa1d1136a28407496c53b715b51c0f5bd6253e755213c0a65965245abd7505dfae8b135d72259dde7e6e279cb2e64171fbbdbf3585a6548191440fac31\"}, {\"tx_hash\":\"f0dbb6df8156cc81cafa247814664d39c9d93537d5ddebef3b68367d7eb45f9a\", \"recipient\":\"12FuhxfFtx1trdppKajTUruc4xjVtMouLt\", \"status\":1, \"created_at\":\"2014-04-23T00:00:40.650Z\", \"updated_at\":\"2014-11-05T02:01:53.109Z\", \"private_key\":\"a18e2e283a58d6f6a1cbcdff920d4e92c9b86378f3fcc4f40f1e0d92b7a9cd7b\", \"public_key\":\"0483d1d9ba63793fc10fa73daca41de8be2b992eba1c3aa49f8fb559b858af19e1c25064e04bde8e119355a96106263d9632ba57b0f24d2dd401a8b26ac2820a05\"}, {\"tx_hash\":\"886b51655b0695ac6f1b8ea08847c5c427086177232636f4dfb4cc7556d99116\", \"recipient\":\"12Yu1gc4wy9PuSjmkQsBrb8Pc2Ptr3BaVm\", \"status\":1, \"created_at\":\"2014-04-24T00:01:43.397Z\", \"updated_at\":\"2014-11-05T02:01:53.119Z\", \"private_key\":\"8a158d968a8c020f6f1dccc51b35cdcb457aaf3238301a2a17ce10a3817c8883\", \"public_key\":\"04bb31ba65bb934f4e4f3247f27060910ff136ff9320240bdfe437f3e61eeed4c8972aff6758b74bb1ce075042aa6d8814507f3f0f9c265f9204ccd821d733dadd\"}, {\"tx_hash\":\"66a5d6bd7f492a5ccfd86eba7f9e945854f0b3c41f30bd439bce76530bb89ac9\", \"recipient\":\"1P5RUSCntazC4sDSzXwEC7nJhy6EzSP7MA\", \"status\":1, \"created_at\":\"2014-07-31T00:01:58.647Z\", \"updated_at\":\"2014-11-05T02:01:55.258Z\", \"private_key\":\"71bb534e70b39726f89060e23fbe5996b00bd7f3de454f6eb14462f423a4fba1\", \"public_key\":\"0400e6755f589eeb2a0202fa7efce84b5b1cedcab50a4501d4739a19808ae95d2c32cf0ba4a1f63caa1bab11244402614b8d908200a5ff18a57044b2d36c73010f\"}, {\"tx_hash\":\"576e4dd53fbab59178efb1bba3b9659c8596fa92178020a3e7dcf06c139e822e\", \"recipient\":\"1ByhvYLBaXUtgoVfAcWMp4bGfoueBpvmtP\", \"status\":1, \"created_at\":\"2014-10-22T00:03:29.755Z\", \"updated_at\":\"2014-11-05T02:01:55.445Z\", \"private_key\":\"3318c71742e4e6286ed2a2afb154b522c10b2306966b554f99caf99a382945ad\", \"public_key\":\"0499ae0087b0929d075ebab2c134d2f9a20857da83b0ac2b402dbf9b24d2361f5a62ec2bbb47ac1f2d51af263c91163c8adb994c2aada3a6779ccb20ec61c818a4\"}, {\"tx_hash\":\"43b51534677a771d3ef3236280cee0916f74b563a9c9004c94a2b0d1d711622c\", \"recipient\":\"17VE1uPUYpvCexRR9QmpuU6v5MAWYTra2W\", \"status\":1, \"created_at\":\"2014-11-17T00:01:53.251Z\", \"updated_at\":\"2014-11-17T14:21:47.075Z\", \"private_key\":\"5a8659e78d26e1cf4c3555a205e699b088e7506b8b896b70de946228e81b4b65\", \"public_key\":\"03a09315d53cf5729f804ae263429567c1f218d42027bcec139acd2991952a173c\"}, {\"tx_hash\":\"1f59e364b4fc3eaf62b77d458c2ce94445b349a323bb86170bf1fa9c99646868\", \"recipient\":\"19p2Zqgbs3wB399BENWA77K668rkHsuu2D\", \"status\":1, \"created_at\":\"2015-04-08T00:00:35.575Z\", \"updated_at\":\"2015-04-08T06:32:03.752Z\", \"private_key\":\"a43d6467d9eb951f23e6ee556f3a45fae1706237d40b007edeefde2a7a8e7604\", \"public_key\":\"037806957b24003910b4485ac0c13e7a5158ffdad323d4ebeef45c2de1637a3648\"}, {\"tx_hash\":\"2c813acaadd48e6552fa291aa72a01d9820b150975ffdd57285c7f4833fde4a3\", \"recipient\":\"1H7x369d3dh1MFVV6nn7MsNiNNtsHN5Q3B\", \"status\":1, \"created_at\":\"2014-11-18T00:01:53.635Z\", \"updated_at\":\"2014-11-18T00:41:49.817Z\", \"private_key\":\"5686bc1699e94233c63ffb0d05934bf83342dff09ab65b9d0485cf6066a50c4f\", \"public_key\":\"022a8231d4364c7605e81e1cb3b0f792c96a330685f99d50c3b7cb220e5741bb56\"}, {\"tx_hash\":\"3bbff16458b61246a95bb1e17a3965d886222e56a9c22dc79bc733019a5b963a\", \"recipient\":\"1Pz6V2qChiufKqXGs2opZYvtTtVr8JuLKZ\", \"status\":1, \"created_at\":\"2014-11-19T00:01:23.886Z\", \"updated_at\":\"2014-11-19T01:32:58.124Z\", \"private_key\":\"0f9beffa195fa20d67c3a18ca8e05f8deaff0904b6bc72beebe5f8bcd27d6666\", \"public_key\":\"024d639bc9805b3dfe0d5af18a4a82fdf8c378bbabb502c4c1f0a58d631e0dfb78\"}, {\"tx_hash\":\"8ebe0d670073ba67c736f2920ee082c908c1f86d6b1ead5d3efe313d864de029\", \"recipient\":\"1H6Hv8pLzCUZ3ZjiH5tmajmjZX9auiea93\", \"status\":1, \"created_at\":\"2014-11-20T00:01:45.097Z\", \"updated_at\":\"2014-11-20T02:04:37.604Z\", \"private_key\":\"f102939e5f29777ae44968ef1a73ce68382b32b6d63eb54f8726543dd3b77d73\", \"public_key\":\"020e6360e67b85a40729a5ff8e441e57419ad4d4dacd4de9519f5621af30c3f3d4\"}, {\"tx_hash\":\"946f2b211b6741f2699f6c8f029caab2e97889b857bd0f8fe9c227575702a45c\", \"recipient\":\"15VRET362id6vRn6a2Zqn6vBrfSwAE6TK7\", \"status\":1, \"created_at\":\"2014-06-14T00:00:37.408Z\", \"updated_at\":\"2014-11-05T02:01:53.129Z\", \"private_key\":\"f731a1ee280e63ef70a49997a4419a39c2f3ff0c80348cfde7ab73a493078770\", \"public_key\":\"0468939836d53bcb615a33dad8b1d868efa620dd6a258e477ef2c5de213afd2925775a7f80dfe625c591f3ae4398416c87e1d481dc70d739c553772b0e051f775b\"}, {\"tx_hash\":\"19c42ab5ec36db0d5127f82c5ae7ac96351fd071938ac40146a0713f8e4a8e11\", \"recipient\":\"12Tn73UVzb7fMVFQbJqgmzHBUD1YbmRiF9\", \"status\":1, \"created_at\":\"2014-11-21T00:01:12.416Z\", \"updated_at\":\"2014-11-21T02:03:45.847Z\", \"private_key\":\"4bf7ba2605d314574146a74b422986eea2886193308cf7eda252f8b507e129aa\", \"public_key\":\"021058ced7248273debd77d0dc0b5bea82eedbcba940884742f47becf933e42a69\"}, {\"tx_hash\":\"9466a3c8c7d333ffc72dfc16e1992cf1dca269d8c758da90050aebe7b9f22dea\", \"recipient\":\"18qtwsM6kqKNum4ic9fKDFAscAAt9HZM4r\", \"status\":1, \"created_at\":\"2015-01-18T00:00:55.356Z\", \"updated_at\":\"2015-01-27T09:39:31.697Z\", \"private_key\":\"5df7c58923cff0c3e6f483b669d665b9ba942f46732f7a25ad4bbf0877a3efa1\", \"public_key\":\"023a2dc2fc7dbc6db344aa5cf522c8d795ad5f192b91ed7a487026ea92862e7f83\"}, {\"tx_hash\":\"440321c778c38f3c821a0664b3a52092aaed336df3e591bb1ac514f08a56333c\", \"recipient\":\"1FYdtZzuBusLmptCNHdLAKYEX76b3rEJvW\", \"status\":1, \"created_at\":\"2015-02-14T00:00:59.765Z\", \"updated_at\":\"2015-02-14T03:32:33.451Z\", \"private_key\":\"cf8d2d406a5e5c6b98da1c02bac23cbfce7402db593e1c3fbeac735e5172199c\", \"public_key\":\"02ac79b78d3b079394ae76978fcdced9ebb088b082f22f089b60c1a253fee134c2\"}, {\"tx_hash\":\"6553bf0bdf60ae8cd779ccf35e40a730d5cd09bdd70e522de01831f5c9ebb9cd\", \"recipient\":\"12TEbw4Bd4V9ms4kuH1kC6Yaj2kuzcYJ1c\", \"status\":1, \"created_at\":\"2015-03-06T00:01:42.198Z\", \"updated_at\":\"2015-03-06T02:12:06.336Z\", \"private_key\":\"120591da350a83cc8c4824d4287b60336752ffbc04b6f41a134845726ba211f4\", \"public_key\":\"02aa64879afcca357c31846e2883f62a68a42e754d43645429d18223936ca19589\"}, {\"tx_hash\":\"69ab4452a2455324f089cd888e23cb93aaf9b4d40cecaff30a7375d0970545b9\", \"recipient\":\"1EkqZqmm9iECCJ9pwGrt3KhoaJ7qkFGn3K\", \"status\":1, \"created_at\":\"2015-03-16T00:01:11.445Z\", \"updated_at\":\"2015-03-16T01:51:28.986Z\", \"private_key\":\"00382b3411f96713a3219ec51d9d1c00f7674fff8723fc0a69c40a1261bf3b17\", \"public_key\":\"027fdc523bf14900aa4de123b8d6627fae97f40e103fd5d3a294aa5acd12c24683\"}, {\"tx_hash\":\"99f5c46372957b146e5f644874c3359a40542302d960cda5dc65770b64d6235f\", \"recipient\":\"1Ccq5ZYou8qLjigYaTYbiisTKrVQJrCi7H\", \"status\":1, \"created_at\":\"2015-05-15T00:00:40.396Z\", \"updated_at\":\"2015-05-18T09:51:29.803Z\", \"private_key\":\"6efee64827ef07699e4047347384dcf1fe318562f616874d9ca29911db2893c1\", \"public_key\":\"0221ee36be7dd9660af80a45e7966705736775a60674012c2fba0252ea05faa93f\"}, {\"tx_hash\":\"e55d281e60d25023cb07adacc376c8f5285241625318661547832f965a8f12b6\", \"recipient\":\"1LnSbzpdzb6JAyWMXrWQCr8gGF1mUhhkAv\", \"status\":1, \"created_at\":\"2015-05-08T00:01:21.989Z\", \"updated_at\":\"2015-05-08T08:12:20.765Z\", \"private_key\":\"723806784434266cb6a9e9701bbec4c0e76753a09fb503f6151d148191a2c748\", \"public_key\":\"03ba4fd62f94886febc36265e3cb77af197c738be30d6170e932769a7348586355\"}, {\"tx_hash\":\"10417bfe88b10ca116cba61fca45788f2284a4e8cc57e75f79e85670447b3ffa\", \"recipient\":\"1Kbn3jYP1aiJW4CEP2wrt2z2qGCmvamQk4\", \"status\":1, \"created_at\":\"2014-07-08T16:09:30.595Z\", \"updated_at\":\"2014-11-05T02:01:53.152Z\", \"private_key\":\"e650256c4b2909eca53b1ff7c42025263a224448af880c7c24b6bd1854f70143\", \"public_key\":\"04a079f3de5d55377f46583bb57c4b678079226cdf95b9042bd535e629c427f59d39d456f6aafaba762399081914fd0daf6d1aa789694bfe93d57c42de37c58b21\"}, {\"tx_hash\":\"5f8768b7abd0cc28643c1aafaa691e0b93b7331a401d977d5898b35a5479a197\", \"recipient\":\"13eYJskv4gMUxjHFA6fnok3ihmhqoG3zRW\", \"status\":1, \"created_at\":\"2014-07-12T00:00:38.014Z\", \"updated_at\":\"2014-11-05T02:01:53.162Z\", \"private_key\":\"ec2b3258941a80c3e478eee326e781fd3809375054214f319fc749e6ad8670e8\", \"public_key\":\"0412c7f7bc3312c0127248936206c7cd721a223193fe6635ea4c581965279bbcc8954c8c8c6b405234c8337f472de4c3f5deef241f6138c3737cf01e220d3efd2f\"}, {\"tx_hash\":\"9509fc4f47f1404fd99f868c6ec9d486f35a079cbf8b49f10f98e77c3817669d\", \"recipient\":\"1ByDk6GFEvrB98xM81p6nrD4nVTsbKShFr\", \"status\":1, \"created_at\":\"2014-06-29T00:02:42.268Z\", \"updated_at\":\"2014-11-05T02:01:53.172Z\", \"private_key\":\"8ba148ef7f9caba5b0985031484270ef9848d5bd2e52545eab75c4c0244a7205\", \"public_key\":\"04b894e099684e1908d552e232022aaa60955f25ef60e3d938b58e7d84e953668c22215558d724a304b1428508b8b755c70bff2a0ee9d1d81f2351ec59dc5e5c79\"}, {\"tx_hash\":\"446a6b8f158e8755806b6672bf6acbc82b817ca5e405e940ae366847290e9d4e\", \"recipient\":\"1KT2Y2nY3pzuZoVX7XYDAGFBJD7oeckXPv\", \"status\":1, \"created_at\":\"2015-05-13T00:00:32.811Z\", \"updated_at\":\"2015-05-13T16:02:38.947Z\", \"private_key\":\"1cc6e2cf7a830bcaca0c2c714aa4ffb4d00a2deea5383f5c241b98cb1acef803\", \"public_key\":\"02964b9f3684c002168802552ec3069e168ba04c5b857ea05e100750394f15bf38\"}, {\"tx_hash\":\"e37f0a9c8f1b52fd8883cae81f41892c496fb1ab0676d913b72d2cbacb7ce3fa\", \"recipient\":\"1LFjG2Q4yiGNEXWoufmRCSSXc2yW9Ab4kL\", \"status\":1, \"created_at\":\"2015-05-09T00:00:40.427Z\", \"updated_at\":\"2015-05-09T02:22:06.134Z\", \"private_key\":\"02d444a239779ae0183e84f8ff75590e8fc9efd28b765e1c716cc924c33c9124\", \"public_key\":\"02a6f14075e09a122083e38f033847d39845c81bdfa3358e089ec71845ea79a3c4\"}, {\"tx_hash\":\"2e088f04c5dc0324f16771a491df3ffadca947def262c8146c4020f4352ff100\", \"recipient\":\"1GJyjbuNUPGfDxe35x73na5weTLN7BUiDs\", \"status\":1, \"created_at\":\"2014-11-22T00:01:31.302Z\", \"updated_at\":\"2014-11-22T01:21:28.008Z\", \"private_key\":\"cd7679280b720d0de41abbec3e4b4e8577685b6037e20dd261ec879160bfb414\", \"public_key\":\"0335bf0f6a43e0f394caf882e175cae58f21c88852823aeb41d59bdbe6cd23941f\"}, {\"tx_hash\":\"7a97fbfe87a98cffe1a832a3244b1ac046af816313219adbe6d29b2c7786b3f9\", \"recipient\":\"1C6HmpjvvHk7kH7EFaBwnb3X22nEtxASu3\", \"status\":1, \"created_at\":\"2014-11-23T00:00:44.164Z\", \"updated_at\":\"2014-11-23T01:03:36.035Z\", \"private_key\":\"95b4d298f8eba04b26d4adb144e068e41624ee4dc0a4e529f7e8f0e7faaf0eca\", \"public_key\":\"03095199780c60cc22f7193efb1bbe1c5836c7e643f872b579d89bcb4d68d83560\"}, {\"tx_hash\":\"d3419d432015929785e88d5dfc9f3e6e46509be12c1980935c9982eef399957f\", \"recipient\":\"13KPpnsDF7EZibdb9ggHALsmr16GogAUUZ\", \"status\":1, \"created_at\":\"2015-05-10T00:01:05.797Z\", \"updated_at\":\"2015-05-10T15:31:57.006Z\", \"private_key\":\"dbea14764191f7393b6c0faac87580879d2c0e4bc20a18a010088333b4393db1\", \"public_key\":\"0234c35a455cd7897091b8d1778f3d48781245d92950c69f4f878c23a37741e92c\"}, {\"tx_hash\":\"2d9cdc612ed78cc0a0c02d4ab5df99a785c59110406357cb4147a1e3592661a6\", \"recipient\":\"15i2e32VvqKRqFiEEXno8We83KtABN5iT4\", \"status\":1, \"created_at\":\"2015-02-15T00:00:33.715Z\", \"updated_at\":\"2015-02-15T02:41:53.066Z\", \"private_key\":\"2f7a2370bb0b28ad6c8f3e3d07b2d704359434ebbeacdc8d9a15431426b18fcd\", \"public_key\":\"034db30b146f09ae6f95bfcff45486f41024be68cee7c2d181ddff85b6057bd6c9\"}, {\"tx_hash\":\"b06394a816cf500167defc419064187a333f2fec63b9962da28031c5984dfe77\", \"recipient\":\"1J2v8YLu1gMgj5mCZFBsfUfusD8pszvgqr\", \"status\":1, \"created_at\":\"2015-02-16T00:00:57.522Z\", \"updated_at\":\"2015-02-16T13:03:24.902Z\", \"private_key\":\"c138b470742e4edb0c06bd2dcd9f869ba37170f4bf095910d899d0df4971e598\", \"public_key\":\"0281bd2813fc67cbbc6183e50f0a7ef5e7b4c2cbc3f937e3f9a95edd8d04c2325d\"}, {\"tx_hash\":\"5df96fbce787ad35836a2eb7c0b3ab095cb43fd1e1cfbdcce1828d80ed2634f5\", \"recipient\":\"1EVWovQT8xr435oiEvcqW9awNgx7Gz1Bxr\", \"status\":1, \"created_at\":\"2015-02-17T00:01:10.722Z\", \"updated_at\":\"2015-02-17T09:32:14.650Z\", \"private_key\":\"80c9c1acf4761eba2f860f7319276e5e7291e6edc4105c17ee80afa74b800f53\", \"public_key\":\"03aba50cba1b95e66b6bc90f4b2e57611a7ac107e440e6ceb0b2abf631713a318c\"}, {\"tx_hash\":\"80d790815a6ae2b4982989af7285562223b19e359f830bfa4fefd930840622bc\", \"recipient\":\"12NJQhG7xroqBCTH4v6EJ4WM85fhujQyxP\", \"status\":1, \"created_at\":\"2015-02-19T00:01:02.305Z\", \"updated_at\":\"2015-02-19T02:41:52.068Z\", \"private_key\":\"43e872a53ef104fedb7c17df6bae8c63343e5535083f08dcfeb56c544da58484\", \"public_key\":\"027f122d03e7d9441003f63690857f9bb7bff092bdddc6c275b72528ce7856bccc\"}, {\"tx_hash\":\"ef50c29dccfa428d99a26d404acc7a80c0a299c4f80d0d5b0aee68b430b89a4e\", \"recipient\":\"1K3Rcr6sdkQsLSSDY2ujzQe9JGk7Q7EqT7\", \"status\":1, \"created_at\":\"2015-02-18T00:01:45.090Z\", \"updated_at\":\"2015-02-18T14:03:27.288Z\", \"private_key\":\"6cbd1b28112cda0d50969ef3929e2b13d7e1fa806bb6728d31a30a7f3f1ea67f\", \"public_key\":\"036ef7ae3f8fa2b2e54756bb8632425f394d4addc206a0a735fea3b1a3f702db41\"}, {\"tx_hash\":\"263d31cd4eb2d684dc0ab311112f5dc17b9c755431170e592e99703e58e5e62d\", \"recipient\":\"1BiqJri9R56QSv7jQs2KDYvT5KTLHGxEKC\", \"status\":1, \"created_at\":\"2014-07-16T17:33:17.581Z\", \"updated_at\":\"2014-11-05T02:01:53.187Z\", \"private_key\":\"795491021f09a66cd93056e985f4a02d31be5aee06df95ef425ce7366f981b1c\", \"public_key\":\"045541edc137a245a65cc2f07d6d4ef1829bb5130d3a22ed3de04486621ac476e314b6380d515c300250bf66fb4983b23728d9a38d26eb0d7f80f1e1f2cdbb4ee3\"}, {\"tx_hash\":\"c636d3b28f960236325d4c2638f82f429924c6c0cac4ac48b9e7fee8e53ff8d6\", \"recipient\":\"18K4M4qo5yymYFhbkmAriSFVfnpPP6uwSm\", \"status\":1, \"created_at\":\"2014-07-08T00:03:01.018Z\", \"updated_at\":\"2014-11-05T02:01:53.198Z\", \"private_key\":\"91c36b1aac2c23d1e041afc9f068b9d4df2511c93b002822e49ff9d4bbfb1720\", \"public_key\":\"044ae0d9dab46ff1d5f7f06db8bee30e9f6399c95c566ec54921316c861b1148802858fc2229be5cebf1783089e8b93baf28283dbe3a6d9401671b0629f4879939\"}, {\"tx_hash\":\"ef9e6c1c337661b22ef1b508b917d0b4f23df98e107a556996e69dbdf3a79176\", \"recipient\":\"1F9bCHaCPa79fWiULnVPybY1W2H6gmvDyN\", \"status\":1, \"created_at\":\"2014-07-29T00:02:15.701Z\", \"updated_at\":\"2014-11-05T02:01:53.208Z\", \"private_key\":\"71749262eb0b78b8f9410917de640e1ecb1be625e0da66e0cfc64f45e3ba0035\", \"public_key\":\"044a0fa820d8fedf98b19305cc7838ff92f1dbd8842bca27502e4e32f9930914b21770d544301661f05d9abce8033d12fc3e537f8b0b90ab1249647ae649ca9608\"}, {\"tx_hash\":\"cf815a603fb0d2348c786f219fc71a7ee222a161d713fb53d4fb1e084ae67232\", \"recipient\":\"1GpzYXKGXjnPxzMWdeSvNPpwC8CMumthNo\", \"status\":1, \"created_at\":\"2014-11-24T00:00:50.076Z\", \"updated_at\":\"2014-11-24T02:32:17.019Z\", \"private_key\":\"5de6bf0f97ec7c608effa8246d5fa6080e93a229ab4529e596c72e4c38aec933\", \"public_key\":\"03e4dd506e68752ab16d89c80827dbc12478e5414eb19c726a726fbbbfd1544671\"}, {\"tx_hash\":\"4d8dfb4699b0d1ac7e438c1182a0cc4db2a85404d87e4e883d4746d78fbf4346\", \"recipient\":\"1HCTW9GnX1qa1h2q9RLBbMGFX4zDrj9h7G\", \"status\":1, \"created_at\":\"2015-03-21T00:01:02.326Z\", \"updated_at\":\"2015-03-22T21:51:31.967Z\", \"private_key\":\"a03b8153a2264d45d19ff39f9e055cf70fce9fa19affaa854a81abcdcbfe8f0c\", \"public_key\":\"03a440e08d803daef868ffeed9bbb914edd8a57fe1ea8272969593968655a52e53\"}, {\"tx_hash\":\"2f4d1c4640b86d094bb2d225a8a414ebbab8bf4c1356ac5e422618cece0b618b\", \"recipient\":\"126NsPsUqPVwoabfJoMK9uB6vh9p7wDfrC\", \"status\":1, \"created_at\":\"2015-02-20T00:01:18.581Z\", \"updated_at\":\"2015-02-20T02:03:39.623Z\", \"private_key\":\"9430d7f562abd8b7ce88c7a6bea45dca913d79b57081639d2ac0981443ae3d80\", \"public_key\":\"033517a9a2010d08d982f6b9b64db580719b43d458ff9b0e254fa383b64a6c2588\"}, {\"tx_hash\":\"cc610efdac09b0dd95d0801eb589d66654f636dbc58fc10b7cfdad8aa9eb6d59\", \"recipient\":\"1HZC6Uzp3UtKgtWTvJjcvvXLNKN4EVHGyZ\", \"status\":1, \"created_at\":\"2015-03-07T00:00:44.051Z\", \"updated_at\":\"2015-03-08T17:03:36.014Z\", \"private_key\":\"bd4443dc91f7995a11fcea24eecb02abdf6143a9f78748e6e74b210772b0526e\", \"public_key\":\"03262cc8dbee43147a2edc7285338e145461557cd7424be7f8dbfc492159088467\"}, {\"tx_hash\":\"97fd31ba4defc8344e4cfbb8df10c5a884a7a3790f71dac27d4ae19662d505d0\", \"recipient\":\"1JouHbiPyT4JB6UfHDokWqv4dMhrbuD6Zc\", \"status\":1, \"created_at\":\"2014-07-18T00:03:40.087Z\", \"updated_at\":\"2014-11-05T02:01:53.218Z\", \"private_key\":\"20f7ee1e3ab18ec7a413344e314b0ee4639b39f44008b6309d0eceee175dbae5\", \"public_key\":\"04cd82d871496a996961a62e3d5fcd7d36711cf7d88269ca598391ece912af978b5221cb0e41f5f1d90134b1ac72dd7e24a9e7f19c365b248f88490bf1806c2758\"}, {\"tx_hash\":\"a2d14ba75d34d95002f2d94acecf5791f82f576281ca69eee043d8fa04eb3953\", \"recipient\":\"1Cqzwjjta16HLPFmi43rqkuuRRGAroo1wd\", \"status\":1, \"created_at\":\"2014-07-24T00:03:35.045Z\", \"updated_at\":\"2014-11-05T02:01:53.228Z\", \"private_key\":\"54cd91fceaac4795244354d97acc9df6e105f2c67c89ce0dc5d425280e66c199\", \"public_key\":\"046ce8b9bb09ace0bb9800eba5d50227c3fbe3c3285754882a4476beaf64e3ba1c883a17e9d907be20f12a2748ecc4a32004aff46041dc5a5d072648e10b44037a\"}, {\"tx_hash\":\"405e034591a7d1c978ca66b24b5cdc51dc4e326ebdec361e77a952ba28f1cd54\", \"recipient\":\"1rKydRpQNRoFymrCFdq4BDqC4GHJ4YBmn\", \"status\":1, \"created_at\":\"2014-07-23T00:03:47.019Z\", \"updated_at\":\"2014-11-05T02:01:53.242Z\", \"private_key\":\"b0b25e7777cbecb4bfd4ccdfb25f1c43c74d0f2c206a924f5fbcdbe07f8d9596\", \"public_key\":\"049916dc85897aae622d7988fe3b33397aed6183f06863dbe25ee3d64c4a086eb18bc4e2b439fad16cb7e02e4caa1d7a6d48df86085df7dc847155c488c361ffea\"}, {\"tx_hash\":\"3b2b6ef09ee244411e9383ac42d82cf15b890a5ab5b1cf0201b1b829dd0f4a11\", \"recipient\":\"18WCREWiEE3qETHSNW4X2vnHuFgZaLf2q9\", \"status\":1, \"created_at\":\"2014-11-25T00:01:30.406Z\", \"updated_at\":\"2014-11-25T02:31:49.377Z\", \"private_key\":\"dcdfddf513bd1cdac4a662a0b48e6400104248f688c065aa3db7089984f94214\", \"public_key\":\"023d6b3a566192d7868ecc87b66c422b718f8eaf0954ab2489502864f5cd7c7411\"}, {\"tx_hash\":\"36741940f0a73484912a4b2aca38fb75f346bbcdde8e6ecd0ac5e7d97d9317c5\", \"recipient\":\"159984tsJx6V6godf1pdQd2j221bjShPev\", \"status\":1, \"created_at\":\"2015-01-19T00:01:05.848Z\", \"updated_at\":\"2015-01-27T09:39:32.317Z\", \"private_key\":\"8ea2c187876178abc0446df68b5ce1b29eb6e6cff3edee681cc8d373b12ef103\", \"public_key\":\"030e1953e7af164480c142e3f5b3dd8629b1ad05f36cc463014f236c13d322b7b0\"}, {\"tx_hash\":\"24a8242ea0aabb23ffe395035ed0fbdac4c90031d233ec7b94f282ab097b38fc\", \"recipient\":\"1CMZh1o75M8pVV44e1ynr7QMgR3oxejQo7\", \"status\":1, \"created_at\":\"2015-01-20T00:01:05.066Z\", \"updated_at\":\"2015-01-27T09:39:32.791Z\", \"private_key\":\"fe6c2fd627f009b4c5f496a329ecd4335ee2dd7d793b6870645f575369afa3c6\", \"public_key\":\"032462e0eaf5da9b2a29a28e4d2e5e320a8070980a28d4514ecec8533b76ffb876\"}, {\"tx_hash\":\"d23151f82e9b92e559a8092f79a57e6df23294163c33dad6be962b0c4aacf4c7\", \"recipient\":\"1JrbM1Fx95CNRSz138bC9USpCpYVHhs1qv\", \"status\":1, \"created_at\":\"2015-01-29T00:01:19.007Z\", \"updated_at\":\"2015-01-29T02:21:48.672Z\", \"private_key\":\"6e00610ded1ba5f5dac66347d0c86dd7a86b3cccfd603401788f3684835d8ca9\", \"public_key\":\"027769a94092aa5197ec0ef60d3e408df38f265cb020cfabf06c7e9e0f1c2944d2\"}, {\"tx_hash\":\"04bd372bbcd317cad494f960a0b3f78e023fdf8aa62b976020797508e5ddf49f\", \"recipient\":\"1Jf7k1bmqG1x6TT7KhdCNi2iJMtpY5DTLJ\", \"status\":1, \"created_at\":\"2015-02-20T07:47:02.435Z\", \"updated_at\":\"2015-02-20T08:32:18.258Z\", \"private_key\":\"d266f45f04660dd22ca83986b98a84b231838718a88de7d7a0c5a75c19506310\", \"public_key\":\"02ebfce9e76876ff2294b076f10c07ede6642ac034c3df1a8491ded8b9ae2263b9\"}, {\"tx_hash\":\"820810819ca30b3ba0b42509e64ee6a0cd270d633fa62e5afd0d2e49b7a7c056\", \"recipient\":\"129KNMKCkx7WcyYHS83uAddf3A6c6QBdfS\", \"status\":1, \"created_at\":\"2015-01-28T00:00:59.364Z\", \"updated_at\":\"2015-02-01T09:11:38.062Z\", \"private_key\":\"94d2d50522380d7843a8dfa3051d6c5122a7833dddab31d16c51939d5530af27\", \"public_key\":\"03c639be124a29bca750120e58cff390027f843895dbdb4f8768c09e93634ecc31\"}, {\"tx_hash\":\"f1844287d3de2fb8e5ba2524f0d543e9aa354e53a90fe13a5b90d087e94d7c1c\", \"recipient\":\"1FS7WwQpgAAHuiceKgNY57WZwWHE1V4XsW\", \"status\":1, \"created_at\":\"2015-02-22T00:00:54.359Z\", \"updated_at\":\"2015-02-22T06:41:36.344Z\", \"private_key\":\"5e5072744b016a579ab24ae6811995748f32a6a75ab8798138b45f3c7c29ee21\", \"public_key\":\"0362f244fbcd7948608f761d1b37351ca422ceb52e5d0560986373e8b44a27cd1f\"}, {\"tx_hash\":\"119f044d51c887a18bc0aa6bc31dff70beb18348a6d3ee1efc044a3185f6c4b9\", \"recipient\":\"1HhzMeiFhtwxy5bsq8e1uLe4MM569ru8ar\", \"status\":1, \"created_at\":\"2015-03-08T00:01:35.284Z\", \"updated_at\":\"2015-03-08T17:03:36.683Z\", \"private_key\":\"1e69ca8d0c865e7465c5033c4af7913bda2306fd3a3b53550660d50e8e460e0d\", \"public_key\":\"03958851b51dc568cc7ddd75be4291af797e80acb97f262924c08a18d75b498729\"}, {\"tx_hash\":\"d1b8c561fb07e6bc0162e1a35c090e9811a7eac8ba8f28f49451ded4d97a646e\", \"recipient\":\"1Fnqr2gpQ6u2jsj45JStrVicX5mZtPVQG3\", \"status\":1, \"created_at\":\"2014-03-19T18:33:04.956Z\", \"updated_at\":\"2014-11-05T02:01:53.252Z\", \"private_key\":\"e2548d886cba076d6a2152714d7499b79e55fba38d87e3fdcd3cd06b950e072d\", \"public_key\":\"040d13312e2bff9514a2036672d69955b38915c710263ef0cfe6855b11014d9c0f1fb23cd8339d69275005cb5d9dfbc8410447280a6eb7838a38d6e9704bd58fbe\"}, {\"tx_hash\":\"4028f8e6e85378d7bda36539b58159b22d0fcf658e5cba84ff3c3bd6cd1fcdf3\", \"recipient\":\"1HA1cai9V1uzCT62tWuSfydbgtLgyt8bTy\", \"status\":1, \"created_at\":\"2014-03-21T18:30:23.280Z\", \"updated_at\":\"2014-11-05T02:01:53.261Z\", \"private_key\":\"126b5ba1b5b41d31dc84f7312c7f1f6986dfa80580104cab749c79eb34fb5491\", \"public_key\":\"040e28c86b7c867dd02f172e5bde21bbe55f8a53c2208a476faaa629b0f2f9cdaed16c0dd252bc87d4ed21f18eb97dbe196ea5efb8bdb158fb963a08f946fdddff\"}, {\"tx_hash\":\"e96df52be3a2b2560dcf8967a629fa21a3567b86dfda8e2960557945574d1759\", \"recipient\":\"17apfom6T4LZEKd9XtC1yxAsRiCMx65hZr\", \"status\":1, \"created_at\":\"2014-04-10T00:01:30.432Z\", \"updated_at\":\"2014-11-05T02:01:53.271Z\", \"private_key\":\"79ef921fc6e588bfbd10aa055d12a23d505118b2f061040063b8329d43710cd6\", \"public_key\":\"04663f8f570a8c53f72fef0032476665b5665f61729ce3492813ffc0199191edca5fb3d95be1a08dc96cd3963c8af85cbe1679f7789123ab7f8cb025b64227f3e9\"}, {\"tx_hash\":\"3fba2e0fe527f85fa90da49fef624714099cb6c37ab206278fea54e01b85ea60\", \"recipient\":\"16K3cnJZbE72eRnowCEmgR5CSTzvkKKVyq\", \"status\":1, \"created_at\":\"2014-04-19T00:01:48.161Z\", \"updated_at\":\"2014-11-05T02:01:53.280Z\", \"private_key\":\"976f1c678e1d5574e0bfa9ba51776c6487efe0690b56cb189f972aea225e12d1\", \"public_key\":\"04f95ce975aabe43b27442360ff3dce14d864a22f8c420490a40ebad553399b9299f3c542a4b328f4d53ffc1a13bcf016754cc350f65d813825a4804597d811e9d\"}, {\"tx_hash\":\"a0f39b6c1489b99c3641fc98833d3c6816668b0925735af6381fed990a5fda45\", \"recipient\":\"1ArhbdchmwQXHd8SwymQsQJkdjFURXz7ao\", \"status\":1, \"created_at\":\"2014-06-07T00:04:15.129Z\", \"updated_at\":\"2014-11-05T02:01:53.289Z\", \"private_key\":\"796b2de388963e2237f77d599fcfee235a457eace3f58f9ba9a7c4d0f78e4436\", \"public_key\":\"04f21243ddf8b008b80f0ff3422bb618cdad8b14bbe4ca32af195c92abb8453d9328f86b5cbfcdd78783d190b009a6265c59f28c1bc5f3c5f2877f2d09a5588753\"}, {\"tx_hash\":\"4e9c565741cdc89df91406b17605ff014a896917b6b531d248d24c898cff1c28\", \"recipient\":\"1A19BhZBV4EstbyWAPaXjnM2K1y5rhhpAm\", \"status\":1, \"created_at\":\"2014-06-08T00:00:28.939Z\", \"updated_at\":\"2014-11-05T02:01:53.299Z\", \"private_key\":\"7cb60258698d66e661da2b273e44684703904e10a9c71849bdcb653ba753932a\", \"public_key\":\"04493a19ddf04b447c12487cc2bc546987f71f73ee463adfd19b7bce17a3b363e4a9bee8ea6f1adefe11660b05f8980113e56eb55ed2752b1e62615128000143ef\"}, {\"tx_hash\":\"638825d12cecdcd45100de8364da6cd62350bc0851cba288613583ee6b8f9871\", \"recipient\":\"1LayyTVH9XLo5SC48fwQ6sQS8uH94HzeVM\", \"status\":1, \"created_at\":\"2014-11-26T00:01:03.506Z\", \"updated_at\":\"2014-11-26T02:41:13.596Z\", \"private_key\":\"33d1e1df02da9f31f4b35ec47cf26ecc9347394a742adb1d15eabfa47d79d037\", \"public_key\":\"03e2db6702cd38282b89e67d7be890417f67e486a47701084b99054d1bf374c3b9\"}, {\"tx_hash\":\"af1370ba00198de53709e1db13245a2651078bfc91b6720c9c9f8c44087144e9\", \"recipient\":\"176XGqHurSCZwTB5KtM2A65oCHicRjkPUm\", \"status\":1, \"created_at\":\"2015-01-30T00:00:52.768Z\", \"updated_at\":\"2015-02-01T08:32:00.780Z\", \"private_key\":\"42fcadb4edc199886dda943fe200c31212fc8c0b4131b9ecdf95afd66416c370\", \"public_key\":\"02296cf861cfcaf3d855070557d211fdbd7933d24eb48870613e53d5abcb86c79d\"}, {\"tx_hash\":\"4e0e85de3430e92744c5db1bd8424f63146d85ae1d3735beb51d10bc6ff5e598\", \"recipient\":\"1DKH1SfrZ4J92D2DFnUfLXLPmYpYr38fUS\", \"status\":1, \"created_at\":\"2015-01-23T00:01:53.137Z\", \"updated_at\":\"2015-02-01T09:11:38.573Z\", \"private_key\":\"0f56eaa06c1542ca75fd02c97ea821585387927d4cd75976ba133ec3801b32c3\", \"public_key\":\"022df77e586f361f7a54865839ce2a27fc7790b4c508d16670956ef516517d58bc\"}, {\"tx_hash\":\"a38fdad21e38e56dafbf2c12da1552d19181356d807c80bf3b542be88a9edae3\", \"recipient\":\"1FdDPvRK7ZdTu2yJLUxKcdVWvycq9X4FAD\", \"status\":1, \"created_at\":\"2015-01-21T00:01:05.382Z\", \"updated_at\":\"2015-02-01T09:11:39.068Z\", \"private_key\":\"b79b2db92019f243906a8fa2eab5f095bb001bc1a74898a156473a16eb45d61e\", \"public_key\":\"026d4a7b644587bd693d121186959dd6b8b0d2ed154cef639b76823e17b1ed9a22\"}, {\"tx_hash\":\"f155d9e6f0e63848112fdd4ee56b0b3583b69a8085a83e3857258522c50a33bf\", \"recipient\":\"185ZkrVnneUkhzmAjzXRm9Eq1htKsmHeCz\", \"status\":1, \"created_at\":\"2015-04-12T00:01:12.172Z\", \"updated_at\":\"2015-04-13T03:32:15.143Z\", \"private_key\":\"188aaa96d8328b22af02d91662ec604a20805e87168965d884d2bce7c413acdf\", \"public_key\":\"02689751bb700089f15ef285590959ce44ae2ef07721ce812dbc4531158a040845\"}, {\"tx_hash\":\"940b1c299bc80d09db22878e96589f8181a0ce4bce8df5f6a26e65fdd7538360\", \"recipient\":\"1CpuH9WNK5Mw4ZqCjVy9AKjHZkDosJDwXA\", \"status\":1, \"created_at\":\"2014-09-27T00:03:57.190Z\", \"updated_at\":\"2014-11-05T02:01:53.308Z\", \"private_key\":\"08c7cc51ff329c9980e2a4d7638bb15458ffd81ab8b9808016b9da2bead06c06\", \"public_key\":\"04f70ea95a1660abd8d2384d40d0a454c4b04d4636f839edf27390a7fec6ef1f993703683a778e708ffb83ddbead1baad60f9a2df3a546115c578e0d3607ec3bf8\"}, {\"tx_hash\":\"3bda48eaa0d8a65b722dc323e8403a0a269323c4731cd9ee3f2947c1b02f4d4e\", \"recipient\":\"1PPavrDe6vdr7efY4YyJqipTmcZnosULN\", \"status\":1, \"created_at\":\"2014-08-29T00:04:03.885Z\", \"updated_at\":\"2014-11-05T02:01:53.318Z\", \"private_key\":\"7574f25f69ef2e027b9557bf7b494101694e5d5ec6f8f7a066aac83b0351d507\", \"public_key\":\"041156822502cd2063e5e862708998d0cf63e148243ab5a8411f7c133acc729adc399eadb6f418bb5ec3ee43b3a8d0f0874683bddd5a9007de2f5c7710b2a6247b\"}, {\"tx_hash\":\"006d98d7cc04610e99e26064ca341f8e1e03ad3b488137a63dcb9c52090fe221\", \"recipient\":\"1FiYmARFCDRhoQYdwHBWKSnogFZdqT1VRc\", \"status\":1, \"created_at\":\"2014-11-27T00:01:26.805Z\", \"updated_at\":\"2014-11-27T08:31:38.423Z\", \"private_key\":\"3ce403a65a7c24f0dd5f18fb9c9dc8959fb28284cb81da950fed82ce11dcb021\", \"public_key\":\"03dfa606b650b7133a3cc08ef048c3a7c3fcfbd4ad18a618f365b6e9958fd877d0\"}, {\"tx_hash\":\"6ac17d327a1af6d4c23d4df61e6c8ec7ffd19582f4417b749d6066384cee1643\", \"recipient\":\"1AihosgYQiPPwnttgo8xm1n81e8J7h2xCq\", \"status\":1, \"created_at\":\"2014-11-28T00:00:42.741Z\", \"updated_at\":\"2014-11-28T01:31:35.785Z\", \"private_key\":\"d201e07ee63f7a40c5f44a236c69ac1ced101ee9ae36c11d98b46e1d0d89cb03\", \"public_key\":\"032c60ea10aa61e8e98f201403028a2eb90476ca8c07be634986a57fdc910b1aa0\"}, {\"tx_hash\":\"9d5fbf9b2a08ab1fa138e4e186c9ebd8c1d0e93b43b94ebd356723f555bf083e\", \"recipient\":\"18Ptciey75pUzyRWZGyqvwvsrGX87tAtbm\", \"status\":1, \"created_at\":\"2014-11-29T00:01:35.977Z\", \"updated_at\":\"2014-11-29T14:02:32.236Z\", \"private_key\":\"1479e1faea25aeb35cf85707f7cde30e1722806b8e2e22bf240e2b67c810d4af\", \"public_key\":\"024436581d5f1edee56dbf6c976e620305f423d9bedab81d7a3634dc7f8ae7f30a\"}, {\"tx_hash\":\"a0565e9c65c5e6521fc808edd311456912dbd1ef4d1953563b744130febbe397\", \"recipient\":\"12oje7qNQMu3W7kwp4nAuP6aQPAidw83tt\", \"status\":1, \"created_at\":\"2014-11-30T00:01:06.188Z\", \"updated_at\":\"2014-11-30T03:41:26.418Z\", \"private_key\":\"f45668263a977a60c0111a93f2070f7bc20558f26840dd007c4d3083a90b1a95\", \"public_key\":\"03647e5790930f67ada5dede83ff7c7f6cf6b3076d3a6c98348fa8635853a753d5\"}, {\"tx_hash\":\"788901fe347df34bbba5b0b811b7dcb40adc9336b8869e3f26225d102832927c\", \"recipient\":\"13GP9Bv9kegfFauVeqKWHcvqCYCFWVWVxe\", \"status\":1, \"created_at\":\"2014-12-01T00:00:53.067Z\", \"updated_at\":\"2014-12-01T01:02:20.176Z\", \"private_key\":\"6f1a59678b01764f1eb415a53cf135de56e8bbafc36d18924f6b3c7c1fade191\", \"public_key\":\"029e1d34b7bb8b8bbcf7e8861131caaf5a4fd7c985043706dd6e967c8a4bf1f933\"}, {\"tx_hash\":\"62e612858a11f764d6de72da806540d088e8aa7ac225142178122350c76f2c40\", \"recipient\":\"1MSn81x2n5bPk5rATRvbjMwGnX2tyEzuUU\", \"status\":1, \"created_at\":\"2014-12-02T00:00:42.038Z\", \"updated_at\":\"2014-12-02T10:31:40.609Z\", \"private_key\":\"3ee1911f540e78be0ede946c0fff0749d6e2736a0450a293bbca2d1cfff7a9b8\", \"public_key\":\"020fac513f0c6494fe31fe73ba07868aca1efede5f2ffbcc3a13bba44d879737d3\"}, {\"tx_hash\":\"a740c53413f576cc6774c5e0e5e577e395a4f7df50fd5bf4676fb9f0c650a8d7\", \"recipient\":\"18ahpKZ7b6n9kCGXyL3yk3J1KANSEUNbbf\", \"status\":1, \"created_at\":\"2014-12-04T00:00:49.839Z\", \"updated_at\":\"2014-12-04T05:21:26.521Z\", \"private_key\":\"e254e813d967d45239dafedaa459a62dbb241a5b428f0e20fad82cc4e89f909b\", \"public_key\":\"0326aa95f31beadd0d92dc2de14063c4f02c1dca6a623956f19799977b795af52b\"}, {\"tx_hash\":\"1596943406db888462b84b833319044a41a5f2639a2c972cd420ed0d2c95d786\", \"recipient\":\"1D6brAwYaq3DifUbNBPqLMi1ZZgsGaRbsx\", \"status\":1, \"created_at\":\"2014-12-05T00:01:39.128Z\", \"updated_at\":\"2014-12-05T04:41:18.769Z\", \"private_key\":\"e7974b349795db137054c9810ea68d56f715c3b4775af4f0820da5b33899355e\", \"public_key\":\"035d76821c1133b8243558742444d47597969ca8fe27c4d5388f3e068f675fd975\"}, {\"tx_hash\":\"8fd29553b5dcbbee3f9f2348cc44fddd72f29da252df8a23bdf99b98c8a3a8e0\", \"recipient\":\"1Ezjd74wFjwn94y8uGrU4VzgbD5MnAYm3u\", \"status\":1, \"created_at\":\"2014-12-06T00:00:48.354Z\", \"updated_at\":\"2014-12-06T03:31:32.361Z\", \"private_key\":\"84d66e22396612964d9cf18381fea09cbc0650db00eb8f8fbf1c842b9c474534\", \"public_key\":\"030edff4a25438aaa67e2275bb51f0e1eb68771979dc304106d9552237a739bf4c\"}, {\"tx_hash\":\"32240fc3fdbd0584dbe3cfd219c8991e50ff7c7277cbb08ef8a9a4972326d8c7\", \"recipient\":\"1Aj9bFfaXKsXoJF2Ksnu7ALFSLow5kPrX4\", \"status\":1, \"created_at\":\"2014-12-07T00:01:17.515Z\", \"updated_at\":\"2014-12-07T01:03:04.602Z\", \"private_key\":\"f266f6c53b2c4c11e6cbeee0ddc5dc1451424cd7841b09e572bbcf5154fde925\", \"public_key\":\"03e8c9ad12b7442bbf49883036171343bbbd00a3870161f27efe22236fa89e7d95\"}, {\"tx_hash\":\"cc6fb0bda4f2e417df47924453e28a64600699d544f6485b3e00b2dd5ffdec45\", \"recipient\":\"1KkFSNDPzBKbd6ASjU8JuX5RTM58XbWJmt\", \"status\":1, \"created_at\":\"2014-12-08T00:00:57.494Z\", \"updated_at\":\"2014-12-08T06:21:25.426Z\", \"private_key\":\"bce19c2f3d86b90fa19c978b8ff9fbf0b34a68d2cf6dd8f5ae98b2272724da07\", \"public_key\":\"031b3e0e39024099ef6748c4ff0d35b97b1c32d9c9b3d55603d96ca89031e93167\"}, {\"tx_hash\":\"ff889c510fb6c7f3f3461b29d8ed4e07166e4096f6880828abadbc5196fc4521\", \"recipient\":\"1LpqkAAE1YbZbNKP242xSevL5vxum8jVjs\", \"status\":1, \"created_at\":\"2014-12-09T00:00:27.922Z\", \"updated_at\":\"2014-12-09T21:31:35.358Z\", \"private_key\":\"afb2eec5f7efb84d778ed975576f4957ed9e49f0c461030ce57fbd84904e191e\", \"public_key\":\"02c8ec7261d2fd7d924e2479123f22a0e569e763d263ac8bc40f18faf85706c51f\"}, {\"tx_hash\":\"d2c9f2e2744e13456bf403d6e7ee88e48d34680aa6fd3a5f77b095e5d93e5c81\", \"recipient\":\"1FendAsmKLEbDYuRDdeit9t4dsjd1RRxUs\", \"status\":1, \"created_at\":\"2014-12-10T00:01:05.687Z\", \"updated_at\":\"2014-12-10T01:11:25.531Z\", \"private_key\":\"cf09274f0eb16994b76b9633502161e4751d1ad67dfdbce86fce1c8878f51d32\", \"public_key\":\"02f04e4f61e7d11e465ab36200c25a565dec69d058cb5df6071cd718bd86c259f9\"}, {\"tx_hash\":\"e82455ed01cda5baf84d93790701f8ecb7f08cbad38c69cc4d2941d891c8f25f\", \"recipient\":\"1HfUEjA2i1F7w8RVchpo17Sezij6CQoCkd\", \"status\":1, \"created_at\":\"2014-12-12T00:00:34.338Z\", \"updated_at\":\"2014-12-15T07:11:58.195Z\", \"private_key\":\"c1f20b6079403baac1f3853624b938f46c875fa713d1f53c6b889a26c8b7bb6a\", \"public_key\":\"034e989f1c70b44ce005bc281f69b920325e65bc96d5aa445da0ee617e4d0888f8\"}, {\"tx_hash\":\"9bc74c1389e34c836e4b66b8106bb1f3506e1b77bc639ffdeecdbfb71c52e566\", \"recipient\":\"1PSyeNNXJu6jGbQh8LFRem8erokxyiQfue\", \"status\":1, \"created_at\":\"2014-06-10T00:02:54.117Z\", \"updated_at\":\"2014-11-05T02:01:53.328Z\", \"private_key\":\"edb624a48a7717a7a081f1a7926c98923ced522e99152336d07c2b5ee0e838af\", \"public_key\":\"040c0182d8e79c33479c5510411a888efff992c8d218be3ec5a721ade2ab9718e4707992afe8e4099e2b2b2e45b6daca8f09ac5690c9110589c5a64c71a64aa463\"}, {\"tx_hash\":\"4e3f39c404deeee1ea63393a5cb789374896f320f2f5322830a1297ea6f3db52\", \"recipient\":\"1PZFokPxzHYgAukejrVNjF43L4re3FyRsj\", \"status\":1, \"created_at\":\"2014-06-20T20:23:21.378Z\", \"updated_at\":\"2014-11-05T02:01:53.344Z\", \"private_key\":\"9f95ec49696d9e0057329178bd58792aa4d2e651d1690e1b07949feacbecdc19\", \"public_key\":\"0441c7e5617b0d2f513012e1ea64ac69cb8d4bfb6ed29ab4e468081086a153c98ab0e8e40051039f451ee5a59c88b339d062f0ce54cb01411d41265bc39fee1a6d\"}, {\"tx_hash\":\"7729867b65e959d3ca78eb27428b8a9a4b446a8868383e8fe9853f93409e6d08\", \"recipient\":\"16fGJQsyyzJRvA7EUyEUpnWKG9MXGHYKkW\", \"status\":1, \"created_at\":\"2014-03-22T18:30:07.901Z\", \"updated_at\":\"2014-11-05T02:01:53.353Z\", \"private_key\":\"c8a23de81df036e1b5bec6dabfed2c2701a7b2d9b2611256ad8e806d729b44db\", \"public_key\":\"041a35b00541e6b810caf249689686f2affd58246be1bf64da4a12640db39b1b92890a994bad3104db5df3ecc39648a8b8eefa1059ba081816358a54d8c0fc2af2\"}, {\"tx_hash\":\"c62c201342aa9f5bdc0bf22e075dac5d70057a939be3176800f574ad87739c6b\", \"recipient\":\"1EcwbLEhkqrYcpHBkmGD9wktwbo6vxccmx\", \"status\":1, \"created_at\":\"2014-05-16T00:02:21.191Z\", \"updated_at\":\"2014-11-05T02:01:53.363Z\", \"private_key\":\"bcf1c80da32d0c487acf7b48951a4aee69143bcc037c3d956af3fffb1ec87aaa\", \"public_key\":\"045a9b42a576814b61e393e02789fa4bd29316f4dac6b63ffa50c4dc23e6bc50f16b1a7d96c5a5116393cce68c2eea162b3f3f89e04c63fa6616709fc873fa73f0\"}, {\"tx_hash\":\"d14350bae9ebfd6d5fd1d1a14260725c523a2418acc9452a67699354987bdb70\", \"recipient\":\"1KazxQSy9NJ5iGJkn55BJGT7nKAkt4nGqi\", \"status\":1, \"created_at\":\"2014-10-03T00:02:30.353Z\", \"updated_at\":\"2014-11-05T02:01:53.372Z\", \"private_key\":\"109a48b8319280016e2a2febdffc05e08455cc50528aa004548b495f20472577\", \"public_key\":\"04120fbee840958337a8d0278cf491d8145a36b8d93def9e9f6a9742cdb4080d97e0a0d187021686ccfed63c083ed2312aa7cf91e018627f677d306b205fa7f432\"}, {\"tx_hash\":\"f19de2eda6ceb4465f0f2f6e51699b7e34d374c8bc7c8ca0d952c41aa2ab190a\", \"recipient\":\"15DA5aCRy12vvMZ7MYsd8y6UmXBvxFNie2\", \"status\":1, \"created_at\":\"2014-10-04T00:01:16.836Z\", \"updated_at\":\"2014-11-05T02:01:53.382Z\", \"private_key\":\"0a125f1aef09d73afac6bc8d9e7afc231d0352cd47139d7a2c9e9df222c0bd0c\", \"public_key\":\"040e82d92ea3d273d4393b4e9855365e511c416dc40779036d203b9e59008fff5bcd1d5565e366077cb77d025c23afc31c701fb49f71b7acdfcc7a884f2d106d65\"}, {\"tx_hash\":\"955fce669b8e39ae8019c252d8b87fd5e54d62c9f5257dc8c1df2286a7731625\", \"recipient\":\"1Lo6YAJP1aChnPQ41LRVyiwyr9T6PUiUoo\", \"status\":1, \"created_at\":\"2014-09-29T00:00:58.816Z\", \"updated_at\":\"2014-11-05T02:01:53.410Z\", \"private_key\":\"9749fcfe0f6694fb835c5435120def7abb95cbb1cdbd796f588c34ce66b104ca\", \"public_key\":\"04862a88984b896d2d00ee3ba509eb57a4d9874264c5d6c7c0882c24aa18418fd73eb8ce9277bc1f8a14402f5fcc214889ab3031bd322a0711e8b9a8bcca91fbc1\"}, {\"tx_hash\":\"eb2f56a706f8695c21866542c6fee70fe4c0f6e4b84e1402fe1d6701d0d40cef\", \"recipient\":\"1A6ZjoJe4hdMj7AMCdpWuYtLqBjVbqvoWq\", \"status\":1, \"created_at\":\"2015-02-21T00:01:32.561Z\", \"updated_at\":\"2015-02-21T23:51:38.171Z\", \"private_key\":\"625554c1f90ef6414fba91bc927d98d1e16f52db45992a625dd6cc0a04946d01\", \"public_key\":\"0278d0cbe6364776067cf1df6ab21b49116f1cfd129ac19808c51fa64efe02a327\"}, {\"tx_hash\":\"7f8d7ef78b392baa65b3564ca4c2af9dc1505f2fb9bced620de471097d85dfc7\", \"recipient\":\"16vStVunYSJLab2nYWojf5239YvztKZrHV\", \"status\":1, \"created_at\":\"2014-12-03T00:10:56.380Z\", \"updated_at\":\"2014-12-03T03:21:12.903Z\", \"private_key\":\"fac10a76fc58cb4db63f271333e8427224b635fcb213a98a7021b90ba9c9e0c5\", \"public_key\":\"025a26f6dd247d4f9087dcaf2fedf296441d6a533cdf2d4504146d7cabf4962fe1\"}, {\"tx_hash\":\"ac053b59823bb9fc4f466ccebad61c126f5f5b87c721819438e43b9423fa459e\", \"recipient\":\"137QUkdudDw1R86va7c2o7xkFVrPeB4TGS\", \"status\":1, \"created_at\":\"2014-12-11T00:00:41.846Z\", \"updated_at\":\"2014-12-12T03:03:00.623Z\", \"private_key\":\"dd7ca9be82ac43b4617c0303890cd7d3dcab9a0734d70112e7f042686155da23\", \"public_key\":\"030af256d3a126058f4cca78d046ff333fe50575be5fdccbf96276611f9ef652ed\"}, {\"tx_hash\":\"6d61fbd4c7c7cb957ba9bad778f6884f7a4b6fa586c2b49ce860ade584ced4bf\", \"recipient\":\"1DruqemSaF2WiaUMVCC8VEeEVXP5rkBjrW\", \"status\":1, \"created_at\":\"2015-03-09T00:01:22.368Z\", \"updated_at\":\"2015-03-09T02:51:37.961Z\", \"private_key\":\"981aae545566e6e14a0e5986a26529cf23f750abad23fd1202426a1904fb5907\", \"public_key\":\"02d73978621fc8bcf09bb1b05600a405561ec83004524e71c9f7438a04fa3e138e\"}, {\"tx_hash\":\"110f9cc7eed95cdab83a75159dc80ce98c5fa6e1ac9809444fafaad9dbf9af76\", \"recipient\":\"18XsBQ1mkRo34Uwd8jGyXTo8cqNL4sSCWz\", \"status\":1, \"created_at\":\"2014-10-08T00:03:09.097Z\", \"updated_at\":\"2014-11-05T02:01:53.420Z\", \"private_key\":\"ed6586801c0a49b773cb9d9f67e89bd22a2b4c9f5a8bb999e973661fd7b4a184\", \"public_key\":\"047982be2498f3ed5fe2b32a65f28bf86e960f81419593e3d91906fa2cf5866b55aa11a918b0902733b7f1570fd9030603f765497ab2a01d082af67a18bb3273d0\"}, {\"tx_hash\":\"c35a6d329334d51d8131c9b2d90b5539f6473bc04ad0ee1ee5a9701b824106fd\", \"recipient\":\"1FddQAF7Ekad3ZbCPvjDa7mJCKLJoRWq53\", \"status\":1, \"created_at\":\"2014-09-06T00:01:48.575Z\", \"updated_at\":\"2014-11-05T02:01:53.430Z\", \"private_key\":\"71a81201529ee34a4658112f9012ad880b61512f276b1b0272aeb77c98bc9a1d\", \"public_key\":\"04491d08744b45eb9d296ebebc87e5332ba79e57cab78b9f8fb3700cb5146d436303ef1190fe72dfebe7d1d831d69039bfdc6654e2f32a0a0e426fa4dc61235e92\"}, {\"tx_hash\":\"0cdee6fec1e8fcfeef6877a3eb3755ca90874afe13fd3371e1041fb0d824507d\", \"recipient\":\"1Q6EwC7CpCMa9wfevktBXWhPZVicLzxpik\", \"status\":1, \"created_at\":\"2014-10-10T00:04:43.291Z\", \"updated_at\":\"2014-11-05T02:01:53.447Z\", \"private_key\":\"6218934b21bace8094be87d7ce42a46079d3903da78c02f8c93e7c53fa14c8d1\", \"public_key\":\"048676e0ce04a0c9aad3e045ae422f1d45ef4a50e6e856c4e77b52777e4b2e99d0d42c2aa16e4d77bc38493654338386185f8ec442747a75709f80dc2eb02abf27\"}, {\"tx_hash\":\"e5f2600d775cce0ffaad0d49e17268da513ead7a7ceb1feb7f6c24d3883c9a68\", \"recipient\":\"1L5nvobdgFUGkoV9DFqmeNW4hHMogDPRQE\", \"status\":1, \"created_at\":\"2014-12-16T00:01:32.944Z\", \"updated_at\":\"2014-12-16T02:11:47.375Z\", \"private_key\":\"e88e69bc79b710e8cbd9dd7f58ab73ad95cb6a6ec6d6c147e5dca42df1c6b2b8\", \"public_key\":\"03dc0e265fcd2b2cb22b928cbf949d311c399fff1d5434ab698a047b5c17bf5a45\"}, {\"tx_hash\":\"4a59a8642442e211c434124a361d857cc6b7eee4ff62ba578b9b7e4ad6a879e9\", \"recipient\":\"1McvkcqHXrHAiJTzFwjLMTVNpAMATGstnQ\", \"status\":1, \"created_at\":\"2014-12-13T00:02:00.649Z\", \"updated_at\":\"2014-12-13T01:51:27.991Z\", \"private_key\":\"3e2570e93a41342806e8b905ea90f8f763219d2facf5a5f675c6a131b0a373cc\", \"public_key\":\"02daefafe4740ecef42e88f2aab2649c7c1f5b89b33c81e9ac4149568888d7d48e\"}, {\"tx_hash\":\"da504ee3868a3b33a17c1046107b374051759c2534fbca7d7303fc029b62a2a3\", \"recipient\":\"1PAqJm6XMcDkbxahziREZA5cLZHJpB37pv\", \"status\":1, \"created_at\":\"2015-05-16T00:01:20.924Z\", \"updated_at\":\"2015-05-18T09:51:31.248Z\", \"private_key\":\"0c64b79aafc4462cbd17a430970301fe4c86913e8a5d83a17a593d460f72f5a0\", \"public_key\":\"03062379ab208353f751ec71e69103c814c426692efc5dccbd07d62cc7966e34cf\"}, {\"tx_hash\":\"2b60edaf17da94fd876eb298ec76cfc871e1b277a257a4af8ab409dc1d36715c\", \"recipient\":\"19TBcRdoZkGTXozqYQxCJhw6dudmzNbApg\", \"status\":1, \"created_at\":\"2014-12-14T00:01:20.919Z\", \"updated_at\":\"2014-12-14T01:21:22.291Z\", \"private_key\":\"6790ffba71c9f400e6ce3af8489e15319c5c41cb26aceaf4b9988922ca261bf4\", \"public_key\":\"025735f9e278fe9b9907d5511d04563fa9bbaef327defb5ae7b39df28da13c359b\"}, {\"tx_hash\":\"ad9d0483ef79b303615d1a78d09846ad164e75785fac6e898441b025b81aade9\", \"recipient\":\"1KyDvfF9KixQpVU6GPU7HWDh7646TZNQbp\", \"status\":1, \"created_at\":\"2014-12-15T00:01:18.403Z\", \"updated_at\":\"2014-12-15T01:41:27.818Z\", \"private_key\":\"206746ed43049a8caea32e1b52187ea20e6c7a67d72d06320beb39ce36db0c6f\", \"public_key\":\"02bf0f95ab91596eecbb76815723b03153d53a56ffee6d624324e4f396c70a5a53\"}, {\"tx_hash\":\"257f8e66371e728160d020a90299c5aaf5532816cb6adbb14bedc7608273c3eb\", \"recipient\":\"1DJjj57xGxVm6oM69hEs9FyLvAjKEZ8U3Q\", \"status\":1, \"created_at\":\"2015-02-03T08:25:13.022Z\", \"updated_at\":\"2015-02-03T18:11:44.812Z\", \"private_key\":\"83233700bc835942c37ed5fb080620df09b6bb67b0bb87574116eae33ade315f\", \"public_key\":\"0282e6119a830419786b3521214980c3399e47399dca45c1a08c68c9ff9196f631\"}, {\"tx_hash\":\"14c9813897febd3ce406717b010bb2e2c78afe584099d050b1b10f5699c14f62\", \"recipient\":\"1FP4VeiaEPon1ibJTqGaZu7TLj6hkTjWr2\", \"status\":1, \"created_at\":\"2014-12-17T00:01:29.311Z\", \"updated_at\":\"2014-12-17T08:04:36.447Z\", \"private_key\":\"61e794e782442742efbf20c935884be7ec3a7ba6174960c544bc20ba12ebc6c7\", \"public_key\":\"0279782892ef5bb40a03edbe76504dc58999e1632feec82c5415af8dbaabb25d5f\"}, {\"tx_hash\":\"4ea030d2b5f63ac3a4fb39b4cd14e9071d46d7d07051c3a0d5f3fb086ea65013\", \"recipient\":\"1HfLpsy6B6uSRcepq18m2cMfwJETjEXTnp\", \"status\":1, \"created_at\":\"2015-02-24T00:00:37.074Z\", \"updated_at\":\"2015-02-24T04:21:53.109Z\", \"private_key\":\"b825479f9c2dc020624c2ddf675c539b03dbd9ddd465195fd96e2a2d1b056cc2\", \"public_key\":\"03097a78d1fbe986d1ac36d3808e7c67eb09b5f6ee33f0771f8f739f48cda369d8\"}, {\"tx_hash\":\"85d6f06fabb725147f196ff23ecca82bb1e22ea651630023bb30ae9e9e73175f\", \"recipient\":\"1JhwSqmqdyXT32ZKnLMJYcwjqxpLbW16Ln\", \"status\":1, \"created_at\":\"2015-04-18T18:38:35.335Z\", \"updated_at\":\"2015-04-19T05:51:45.524Z\", \"private_key\":\"ce9757eb478c339989e8096a45428bbc5e9be86ade59c00fab55f396fb933b98\", \"public_key\":\"02adb69a0a109a9446c3abb3f8e0f104143d267be25d1450f17fdce32f7959ff6d\"}, {\"tx_hash\":\"fc3282c0ba4c0858091ba7ac8486cd9d0fd65d8f17ec52ac1aafdcbfb4a87608\", \"recipient\":\"1NeNjHBHBZTWJxwBrVgiS5Qwhm5v1ybU82\", \"status\":1, \"created_at\":\"2014-12-19T00:01:33.692Z\", \"updated_at\":\"2014-12-26T15:02:35.179Z\", \"private_key\":\"a5cafcef1f74c0ab747ed4a6f8503a6fa23950dd3b69bedb899928470172c227\", \"public_key\":\"036ca7e0f4428373d02726ee7ccf8d58b90bc3626dcbd205cb4a667aedca6b6833\"}, {\"tx_hash\":\"5ef24006465b48e339ce3d7ae5af6da353cfc37af0a502711f02acfaaf518a99\", \"recipient\":\"16KYScxfa8xaXLuvJ7yRshhhrG7NBy9ZxT\", \"status\":1, \"created_at\":\"2014-07-07T00:03:23.585Z\", \"updated_at\":\"2014-11-05T02:01:53.456Z\", \"private_key\":\"c733bbf50970fd41f161210ccbde3aac5abce22e0edea024776a0b054c19f95d\", \"public_key\":\"04b553fd93c35c185bb68f62e6262b2165cd95567d124da7716e81a95efd0cecaa189b596f078f973f65ba8d1bc02a55cee7fd52aec3adb136840dbf57677f3dde\"}, {\"tx_hash\":\"ba88a190f4c65b3a069e74b04580c32351dcb76286c87bed6809cd4f966cf315\", \"recipient\":\"1EHe5Fw8K7Q5TtxaWbLodznj97FFFPAVjX\", \"status\":1, \"created_at\":\"2014-03-24T18:30:49.312Z\", \"updated_at\":\"2014-11-05T02:01:53.466Z\", \"private_key\":\"a3eb11993e80e7ac5fc5f544fccb853a96e23c2636dbc027fbc35bf5f4f93ecc\", \"public_key\":\"04bb1ae921f50ca0dedf3e4bb9003ac154677f17eba6b8e3807d88291a67d98821e0366000c540b98bfa4d9e21c3aa20ff7c110452beb44f83e85435b8705c3065\"}, {\"tx_hash\":\"09088155124078b04884d8dea35fa262dea21ca50dfce2a4e29e1b4244b4cd1f\", \"recipient\":\"1APCpFuFrd5uk5PM6NsbcTavcYnSvoCDSz\", \"status\":1, \"created_at\":\"2014-06-03T00:01:18.232Z\", \"updated_at\":\"2014-11-05T02:01:53.485Z\", \"private_key\":\"b49779f36c83debe6304824ea4afb9cb2b79867184810ab3dbccaac9f69d9db9\", \"public_key\":\"04a739be91d22750758be75ec4cfdf5422a02439ab791fa183934addd5590470dd9c473c8c8cfe1cfb07b01746dfaed83745f00283f63791d52764fc4872a7954f\"}, {\"tx_hash\":\"8955284fb0cdddd166c10c66f1dbd15e82313aa0fcbb23bcdb800a3c7ef74d75\", \"recipient\":\"17GZiqkCqJ5gkn9QefEZeZ3XsHPQcdQoKH\", \"status\":1, \"created_at\":\"2014-06-28T00:02:58.649Z\", \"updated_at\":\"2014-11-05T02:01:53.494Z\", \"private_key\":\"3392c859559b0ec1007f31092bf2b13725f18166547d41c95e4626704409a6a6\", \"public_key\":\"0442bca53944607234a4ccbf6d3beaee114f7cdd45d8a14716bbafa578e64a525a9ed89b43d5d1d55ec03b7cc6be0b1cb0a6da4338bcd05957bfca2de1b5b6492e\"}, {\"tx_hash\":\"708f1c7125cfc80ae6f5504f349d02d93ebd77ec8d75e7c5491de7145e64a3f1\", \"recipient\":\"1Q8dVs8WpKsB6ej3hHCqs9i3WDJmWp1Z8u\", \"status\":1, \"created_at\":\"2015-02-04T00:00:52.844Z\", \"updated_at\":\"2015-02-04T02:02:40.718Z\", \"private_key\":\"6e7054cb82549bd83662c9b95ae930a5feec13331385d91b7f3e87607ccaf601\", \"public_key\":\"0340709adb58a5cdab904b40670154afdaabf98b7ae83e99e3ce5e3180754d19ca\"}, {\"tx_hash\":\"6c81aee4f3a1c06a98dd7be17d08435693f0744dc1a915194d0b721077e61cff\", \"recipient\":\"1FoHf6ZfSJxXxYNxUJyiqWJgWGRabxM6Jk\", \"status\":1, \"created_at\":\"2014-12-21T00:01:30.330Z\", \"updated_at\":\"2014-12-26T08:20:35.137Z\", \"private_key\":\"9bf6ad1633b6ba059c68ffacb2fe4014842ccedd82e7d40f5beddce45cbdc2c9\", \"public_key\":\"02c0aff585590ade02636575024ce4e2c890d3092cacdfa41e7c1efd97e6207fcc\"}, {\"tx_hash\":\"c169fbead005637c6506e47c6298334e86943c711d9cf7672d45f9ba4ce46c24\", \"recipient\":\"13WcphmngCvPaG5hrp622DH9iKXZzp6QTD\", \"status\":1, \"created_at\":\"2015-02-23T00:00:33.304Z\", \"updated_at\":\"2015-02-23T09:03:46.995Z\", \"private_key\":\"e459d34b4a03cb833e193350c47e062658c8bb2040e897c8702b9609aa1bd955\", \"public_key\":\"02561adbc8c85267a509b9d22820fe93d4599f0d9c879b5399d7bc9ba4e762a90c\"}, {\"tx_hash\":\"04fd971aff7716594dad0dd659e76b0508c0aea08f7f4b2ca65cbefbdfcf08ba\", \"recipient\":\"12ws8wHDrKDiq9J6YnPwbn7TzxXuyPEE3a\", \"status\":1, \"created_at\":\"2015-02-25T00:01:13.418Z\", \"updated_at\":\"2015-02-25T02:32:01.536Z\", \"private_key\":\"835855fb248dc3af3f2a4c62f09c38d637d48df2e262235dc3e0bee285693658\", \"public_key\":\"0260655dff2e586a4df6fab49dfe2e851753cf18b68b145824c79315f197c087c7\"}, {\"tx_hash\":\"acd740897db33b8fe5f136c0e7bb6dbe8250c34a450385a96f5aafa1fb6876f3\", \"recipient\":\"1LP7rnZ9XVsdRzSZpcwtrtZYi7yGtPc6R8\", \"status\":1, \"created_at\":\"2015-05-17T00:00:47.271Z\", \"updated_at\":\"2015-05-17T18:02:55.407Z\", \"private_key\":\"d26eab1116317315d6141a95f5a887a875681e9a51e4258afbbacd68bd2d200a\", \"public_key\":\"03c4eb3585c965a017f83a5690de95315245a7a7216c4e66318c09095325a95477\"}, {\"tx_hash\":\"ffba72b4b4ad75be9f99d70d7400137de02d319813d48c43e632ac65428e62f5\", \"recipient\":\"18aW1v7jWJqPB26oZv5BdtSYbwJyZowmBB\", \"status\":1, \"created_at\":\"2014-12-23T00:01:30.832Z\", \"updated_at\":\"2014-12-26T08:20:35.902Z\", \"private_key\":\"73e7a80d839c5640f5243d7d5690b9423c0b7765b15b76e6128bf58deeffef75\", \"public_key\":\"027b8d8fb51f859cd896a3b529eeda8bb890abdb0ceb322b554086254d6a3a9e7c\"}, {\"tx_hash\":\"02bb58e93fad82be2181a9df61e0c6b18bd3bad7c485f7fdfda3b3e28ef538d4\", \"recipient\":\"19kH2E8187iQhY1cfhsrCEYxKM7mDwmfKo\", \"status\":1, \"created_at\":\"2014-12-22T00:01:15.052Z\", \"updated_at\":\"2014-12-26T08:20:36.257Z\", \"private_key\":\"a945659753cd101eee0d639e4395d7f9764a6b5900ecbabfeee5d2f26daeec9d\", \"public_key\":\"02584ece2f48a8af47fd31aa74408fdb5028b73ac9167654269f1b97da06e5ae80\"}, {\"tx_hash\":\"61ce589b5c7bf41a7faa951fc61ae33870740a513b21d64dedba6057a4f35918\", \"recipient\":\"1Km8AHFos4KyNN6ugKjnNxg8E9LjXrY4X3\", \"status\":1, \"created_at\":\"2014-12-24T00:01:18.656Z\", \"updated_at\":\"2014-12-26T08:20:36.599Z\", \"private_key\":\"4113e3d64b5feb74c350673fbcd6836c9bdb481ef6ff44717c3cd18df980c5fc\", \"public_key\":\"03df74e5f553464382b71fc81829a9c36016ff7401a3326722b1002ea6bb6112ce\"}, {\"tx_hash\":\"0db2399293136f4269af3365e5abe3b55b0ec87ae40de82c37de6078c8b53fcc\", \"recipient\":\"1NB822hbEk2xW7RVDukH6NBCZfA3PAULsq\", \"status\":1, \"created_at\":\"2015-02-23T09:29:40.970Z\", \"updated_at\":\"2015-02-23T11:32:12.414Z\", \"private_key\":\"ca4bcd86b45bace84fc21f880c49c34e2032be17cec7406654f68465bb399f7d\", \"public_key\":\"0243dc90a6432aa95d936b1d17e4c2540bdcadaf203fc31aa2ccd3a62fd7399240\"}, {\"tx_hash\":\"0269c5bfa1a3772836a48fc03f6f9c24448aa1de73c06b10cd50db81c4f0f35e\", \"recipient\":\"1PhoU2YpwwsdGgzxMLZQtnChL9vNW3L2tb\", \"status\":1, \"created_at\":\"2014-12-20T00:01:31.878Z\", \"updated_at\":\"2014-12-26T08:20:36.999Z\", \"private_key\":\"754f6658ab6810dbb18a526945d34cb7827f0720acfabb613deb3ee47b1b43c7\", \"public_key\":\"0218f1e15f5f42116d34e56f761d0c2199e02b73d8db91b76b69a9d4868dc6df4b\"}, {\"tx_hash\":\"7e0724c204189970d7597b4d54b6f4eda90d229251f240dce8fca03adfab0a2e\", \"recipient\":\"1FwfcMq3t1rPxr98vqX1nKLZex3iVhmHbV\", \"status\":1, \"created_at\":\"2014-12-26T00:01:24.323Z\", \"updated_at\":\"2014-12-26T08:20:37.294Z\", \"private_key\":\"844b37f6c440f724d4b9163e023a36f6dc04736948444d4c8bc635ccc96fe6b7\", \"public_key\":\"023af3f861557559cc4e691609506f5cd71007940d88683d3dffa575261293be9c\"}, {\"tx_hash\":\"a0330747df03510406923c21bfeb097d751e8b4771147a296b9e04347e667d17\", \"recipient\":\"13SXAQxZYFoAcpoNuMaktRmf5YzAY6garW\", \"status\":1, \"created_at\":\"2014-12-26T08:19:28.404Z\", \"updated_at\":\"2014-12-26T15:02:35.691Z\", \"private_key\":\"51f09ac7bc7be80ce451281b0b91d23506e0aa45b5f356c0fc1f351f5d2b7613\", \"public_key\":\"0379352e0901010c38e0f7f96e27a9cdce9659957fca201b6489041b1ea5e865ab\"}, {\"tx_hash\":\"7e31fb18377e5799a96b1c973eebc9c076ad3d6bf79679cfa642d0bb1aaa29ff\", \"recipient\":\"1GJmoifR2xG3fyjWUFhU6sawrze9cD3TuE\", \"status\":1, \"created_at\":\"2014-12-25T00:01:46.938Z\", \"updated_at\":\"2014-12-26T15:02:36.335Z\", \"private_key\":\"9f254d835921c3365b200b423936f792182d8b508ef8cb3274cb81a4f33f0043\", \"public_key\":\"023b1ee98c3966e94223250278771f8fee37e9fce9fba118275ed9ba69319320d3\"}, {\"tx_hash\":\"2e9f04c056b71a8c1a1aa6fbb19382268ed43dc3d8ff540d16c717b0a09d1915\", \"recipient\":\"1BUUyEebCA8u5dtrEjUXtFNDy9XPCrAjMb\", \"status\":1, \"created_at\":\"2014-12-27T00:00:50.433Z\", \"updated_at\":\"2014-12-27T01:11:40.472Z\", \"private_key\":\"fa1bd8837a20ea190f725ccec69054387e230f0e340afef943d8632b4560d74d\", \"public_key\":\"030bdb5e755cb477387cdea2896ed9d90d2a4428f7599ece54ad1c19b33eef4f90\"}, {\"tx_hash\":\"bf8334fd848413ff2e5de56a7ab2fd0d66a5313c259a2f759bc124293510020a\", \"recipient\":\"198LNYTZimueegcUkkZJwhm8kNAsneEzLf\", \"status\":1, \"created_at\":\"2014-12-28T00:01:08.816Z\", \"updated_at\":\"2014-12-28T03:02:55.126Z\", \"private_key\":\"d4bbd1a11ecdc0c24f07c920d9fe2ed6162aa36bcffb8b2c3643195da9f5152b\", \"public_key\":\"0201f802ff6415a41d11464e62e3f5ad12e4f39f5c5626737d8a0dc51385aef5c0\"}, {\"tx_hash\":\"ffa5713c36e3323697503c224f9162daf1fcc649488f8e8a999487b533df4c2c\", \"recipient\":\"1KswqBC8LhYioAFmpvnBTxhVpEaBNemNAX\", \"status\":1, \"created_at\":\"2014-12-29T00:00:53.795Z\", \"updated_at\":\"2014-12-29T01:02:54.033Z\", \"private_key\":\"f185ebbf67f2b4810d4562b586a3ce5658cae4d0adc95eae84a8aceba3d7c9b9\", \"public_key\":\"022d456138ee179503b5874bc6dfa9a1d4d2f0c6c60b24eef0df5dc5143c6c0ca0\"}, {\"tx_hash\":\"3fee60b09cc02aa7b6bbc7c4dd4118ec290aa2d4f43c2583c66f3363187c4e44\", \"recipient\":\"19SfasMJXPr3JiZceesi9t67qq1FfN7xKF\", \"status\":1, \"created_at\":\"2014-12-30T00:14:55.489Z\", \"updated_at\":\"2014-12-30T13:31:37.244Z\", \"private_key\":\"d32df6f49f395c348fe7825cb89d76fc0985608c86f00fe39ff373a10a4c0d67\", \"public_key\":\"02fb6b22ce3b43640de47dcb971374c4648c330b119a07c98edbd81994904953f0\"}, {\"tx_hash\":\"f464b79ade56edc9d7f8bbb6c3d63f800e4bd2decbf0705e30610a70193ad797\", \"recipient\":\"1JTgD9GW1SAcAii6BoyaFCDdjgxtC7xJ1n\", \"status\":1, \"created_at\":\"2015-02-05T00:01:13.704Z\", \"updated_at\":\"2015-02-05T12:12:12.061Z\", \"private_key\":\"466496deb7bafa68a40048b05fb82c80d96a9adf385d21b574850a0d463d2544\", \"public_key\":\"038803862a23108439f69ae049d6f5a2b9befc75115f57fcc29ba8d8b3283b33c9\"}, {\"tx_hash\":\"77509145bed99546b2182b5d587bd00519bd6b102b8b93e64040e903d8ebd501\", \"recipient\":\"1HrrMHEodPsFBPwHEZi2ufpF6bT6mcS9DB\", \"status\":1, \"created_at\":\"2015-02-26T00:01:10.617Z\", \"updated_at\":\"2015-02-26T05:42:36.352Z\", \"private_key\":\"767aff12e7937a91ac7d99e69f22dbe5466f7daede8241577fa7999ccb90518e\", \"public_key\":\"029c4fff483310f5f3c1807d73dfd01fa764d6351cf53a5794897bfc8852e0cdde\"}, {\"tx_hash\":\"16b023d73816bf57d476ada2ed857e9c6ac892630306115dcdbfe2e2f9b9adf1\", \"recipient\":\"1B3x9F5uGFFZfNZkTJxDsi4mJ8r2x1oGgq\", \"status\":1, \"created_at\":\"2015-04-06T00:01:26.334Z\", \"updated_at\":\"2015-04-06T03:21:37.565Z\", \"private_key\":\"afca8ff5d01f9659c0caa0e30cc91084381c837b4a2244b0a184d4facc4bd44d\", \"public_key\":\"021410de0c2b8ede64f03150c86995b6b4b787bacc1d3f4eff6827d9aaf95a6be5\"}, {\"tx_hash\":\"04f07eaedb3a19de552c10a4178a9ca291449fc43dd64f530f1a04aed0e2824d\", \"recipient\":\"1Nu9pBXYk5J1eQWhxxx4YTauXxdYCaHdGp\", \"status\":1, \"created_at\":\"2015-04-05T08:32:01.354Z\", \"updated_at\":\"2015-04-05T10:12:02.208Z\", \"private_key\":\"8768eb5427eb4eb8bcc3c3edabf6f3b6db97613280081734bcd2e02d5c52eaaf\", \"public_key\":\"03016f946c412f82569453b9ad6dca5a490fd875656e8487e72a8b2418a7e01757\"}, {\"tx_hash\":\"47389bb2838241eca93235f00211b7518ab7aeffd8300f02c981c92bccdcfe36\", \"recipient\":\"1Atm6DgJN8VA7N5LVtYHqC2joxefhenp3A\", \"status\":1, \"created_at\":\"2015-04-07T00:01:05.058Z\", \"updated_at\":\"2015-04-07T13:03:15.670Z\", \"private_key\":\"259c9b16c170b0d30f33f1be53c8f2c55c7af88dab5ca38dd6ca248ab063f0e9\", \"public_key\":\"03adb93ed21fcfe713eeab1b4f9fcc0c3a0637de52d061ed321281f1c5ea5624c5\"}, {\"tx_hash\":\"1780f4b7edc3ceffb85cf853d864461f8564c4a1d4dcfc8a7e40808aa2eb417a\", \"recipient\":\"15CoibLa7ZtkEXVjBcbe7pVR9KvaxkL72u\", \"status\":1, \"created_at\":\"2015-04-13T00:00:46.102Z\", \"updated_at\":\"2015-04-13T03:32:15.501Z\", \"private_key\":\"c66a51344e5b55f1e287e9ff543f897e6d550c3ed1c8882e54be4e40b21bb08f\", \"public_key\":\"029ae96cd96d46bf7570eab945a9dc5cdbc88c7b581cef5c99329da5d94eb84566\"}, {\"tx_hash\":\"d3eb9cd216da609b9cc29258aab0cea8852ebd46cf26ea0e0ba36f6a43d7b9b2\", \"recipient\":\"18xoaDAM4WRammpNaDLbkDczxPauHS4C61\", \"status\":1, \"created_at\":\"2015-04-17T00:01:20.730Z\", \"updated_at\":\"2015-04-18T08:41:32.039Z\", \"private_key\":\"9f5e3eca85febeff1f86263dd9ba58dd22a8fc6bbb74cff9f0aa1587601c9260\", \"public_key\":\"03f8b1602d5326e69146441f5b8d610447d7788bd241f289c5d1dbff7f9ee42039\"}, {\"tx_hash\":\"7b00e00558dbe54e07687e966fbf76711ad99d61f3f63c220da5fae0780c72aa\", \"recipient\":\"13VYpPMgWij54Q8ayvQ2PGQ8EgQxCbvuvf\", \"status\":1, \"created_at\":\"2015-04-18T18:31:13.174Z\", \"updated_at\":\"2015-04-18T19:11:52.573Z\", \"private_key\":\"ca260864e63cfbab7fdd707838f9ea5ffcc3b754eccfabcc3d13db3d1dd89ea3\", \"public_key\":\"029f5ad8d4d4db41f9e28ab7d0a3ccff5fb30005b941b09b8e97be6272ff64410a\"}, {\"tx_hash\":\"bda2605ebd825142d4e78dc58522aad5524ca5bf7ea1f1d5f95ebb7d488191f1\", \"recipient\":\"1AFseaQSqi2aU9JvfCpst34pe3CMs5J5S\", \"status\":1, \"created_at\":\"2015-04-21T00:01:39.586Z\", \"updated_at\":\"2015-04-21T08:51:37.763Z\", \"private_key\":\"df7d27f7a1b565a4a5679aa1d70d34228a9703d8b6a62f1c541d957e5c90d437\", \"public_key\":\"02991e931baa3b740b81070b696d5518bae44dc06114040fc46cf6b4930f31a8dd\"}, {\"tx_hash\":\"cb18d149f57c62f5cdd9e74937df1c2d3603201ca546448476a167045d7f587b\", \"recipient\":\"1GmkofsaApUKUg2XWFK54NSkQXmPMCvmCX\", \"status\":1, \"created_at\":\"2014-08-20T00:01:21.131Z\", \"updated_at\":\"2014-11-05T02:01:53.507Z\", \"private_key\":\"d3ba3bbe82aeb9079afc79f68cc84f57eff10fa43ea3bcb4d135e05cc47f2cd4\", \"public_key\":\"045590e8a114878a699f8fc269cd768637b3a77d0d91fa40cdf56c09a0267d6f8a63102ecc67a87c7d22910e3ecd42e07b5bc82f14b2be2f6dbe662474229f5ea7\"}, {\"tx_hash\":\"b4d902789d21c7108e28ce0612225eb3655f3afbb4532b65beb981c66ff06293\", \"recipient\":\"1Mn8aEDGiJTVsdX8XXyxHgQvCbptutvC9X\", \"status\":1, \"created_at\":\"2015-01-03T00:01:02.526Z\", \"updated_at\":\"2015-01-03T19:02:35.343Z\", \"private_key\":\"43d97b5938931031897a39d7aa03c24d1986a3a633dc3c71a360cb4db242af22\", \"public_key\":\"038ec24f461d7cbb94f22043f08c9aaa511dcab32986fc303b3eed9b4290c1edf3\"}, {\"tx_hash\":\"4a6851a492d1e56b9b1b9ba4fa277aaea526799e8eed0edb5f497aaa2ccd6900\", \"recipient\":\"184A4UWM9ivKTXfvt2iM4RNFfZhekTA8Qm\", \"status\":1, \"created_at\":\"2014-12-31T00:01:17.007Z\", \"updated_at\":\"2014-12-31T15:21:27.404Z\", \"private_key\":\"21ee4b99b1e2b73b934375d0b166287641c9318270cf3b810fdcb68bc85e63d1\", \"public_key\":\"039041ed3d38df7b33154deee0f0e7f00d1406d71b7924e987ab14f40205f1fb6a\"}, {\"tx_hash\":\"182ab2e142833d58a844be450b0f480aa2f3be2493da19c32dfff7eff09e5854\", \"recipient\":\"1FvuMPjGzNEUrMjqqXqNyVg7NuLPs4aBf3\", \"status\":1, \"created_at\":\"2015-01-01T00:00:24.765Z\", \"updated_at\":\"2015-01-01T04:31:34.367Z\", \"private_key\":\"2baca669f0f370009e2a3c460b09c310fd3ad979558b58bceac19b1c8bcb144d\", \"public_key\":\"037f8bf4b48a8476578e0aed93afa26005a8a1bd796df88b3548b46b78fd182126\"}, {\"tx_hash\":\"0412d45d4e794d781a326a606a4824084d2661d2f3a884bc3f9e163ae9ff5122\", \"recipient\":\"1MMvuNXHRHAVWFZp73ucF8xi2pJK8Fg76J\", \"status\":1, \"created_at\":\"2015-01-02T00:01:00.556Z\", \"updated_at\":\"2015-01-02T11:41:39.408Z\", \"private_key\":\"cf067495c0eb4d4f8e1dad6a6d05195a4b4ead71a08143d37625acddefd8971f\", \"public_key\":\"02f51f59952447048709c032ae8f112b84a057a32f11827b2aa2ae57513070d4f6\"}, {\"tx_hash\":\"1a0fc9688bd38866c7f3abb5b35bd8509f57439d7910e96327fa6c56f1a34d2c\", \"recipient\":\"1JzVYgQean3sdpnBvivV9F8Cq1g6vZ6c9o\", \"status\":1, \"created_at\":\"2015-01-04T00:01:25.742Z\", \"updated_at\":\"2015-01-04T09:51:38.685Z\", \"private_key\":\"61763ccd8e7d42ea1a1a3c8828c9e7d29aa486752c8401a9b96ff4e2761b11c0\", \"public_key\":\"033a97a1d3704f37145895eb08e2362b2962a5ced7a478cfb4bfdd99ad833bac42\"}, {\"tx_hash\":\"0bc8b895e90f140900914892e656dd7b19f94d64087f2a50c67dd88e47a9b8a1\", \"recipient\":\"1Joj67nyw3nQJ1ySzALRx5CB2ZTCfi4Y1a\", \"status\":1, \"created_at\":\"2015-01-07T00:01:32.764Z\", \"updated_at\":\"2015-01-07T06:11:30.856Z\", \"private_key\":\"de6bbfd326fc08dba35e02eef97a78462290c67a2ef25e30c52cd4afc0757625\", \"public_key\":\"03650de7cc5310ec99b67f7d4fd4005d59fe08ce0eff8d6c29fef2809547f2de78\"}, {\"tx_hash\":\"51d5ab218951cd8ad36c22c90e9b2ad72bd13c3e762dae3d37287204c766a640\", \"recipient\":\"1QBt3BVddLe65A6Kbau9e3LRWwFowj5EVk\", \"status\":1, \"created_at\":\"2015-01-05T00:00:52.961Z\", \"updated_at\":\"2015-01-05T07:02:51.195Z\", \"private_key\":\"3c3d120a144d42f8ed27b90daec96e5eb6b80159e5c8d458780c1fcaa8024021\", \"public_key\":\"0397728d3f5c9f6b36046255f7923f2ebcce85083ea8ba4bc306ae0bf955fdbd9c\"}, {\"tx_hash\":\"9de1fecd8f4155859710d8502941f940b46c542b5710723cee1213f350f51697\", \"recipient\":\"1MUEjrGUMaxCyJ2Mhz8Wda9Bq4HwusP7ze\", \"status\":1, \"created_at\":\"2015-01-06T00:01:33.365Z\", \"updated_at\":\"2015-01-06T05:21:35.194Z\", \"private_key\":\"b21a062bbd36b1f1f631e92ff90c72b9edeeb94dbf573cf42fb45fc036da2b3e\", \"public_key\":\"03218b89814e87159a3b247c88f1e06bf2b78a436e4b5b798810d7d3f592f20d00\"}, {\"tx_hash\":\"fc77ed3cc859b6ea0d52444492203c913351519685578f810af34ac7a928abf8\", \"recipient\":\"17fU1Z87HxJAbW2tQYd9TUKTbS5EBJukCV\", \"status\":1, \"created_at\":\"2015-01-09T00:01:20.374Z\", \"updated_at\":\"2015-01-09T02:31:37.362Z\", \"private_key\":\"abfcc6d49011e81b8935682aa8bc64a67835d3b7c27a626a1bd96ae70e4e8d08\", \"public_key\":\"03c06de354b0b7d6e7d7b79e35a39de9df1c7f272f4cb0c8066c67c1ba2e48d37d\"}, {\"tx_hash\":\"d948f615c9c8ac456573839b7a7e91127ab1df19b8f122d7f79659e167ae324b\", \"recipient\":\"1J2pJm19owYLgi368QQa4T7xskPrMQv4Lp\", \"status\":1, \"created_at\":\"2015-01-08T00:01:27.134Z\", \"updated_at\":\"2015-01-08T02:21:36.417Z\", \"private_key\":\"d8b2f7185c8c78e2cf04f7ad796f71a46984c4daa11f2f17c1b66f5b26d04d19\", \"public_key\":\"0214393b2180e16b93fc3d9de97669b947313115b42efd87e084a744a5d221bfe6\"}, {\"tx_hash\":\"269b902c36787deb2541e1596d7a70102fd20afecd3b4ce29a86a2d82d0d01f0\", \"recipient\":\"1FmpRoghBZStYAFid53nwV3BG5cWCZYXdN\", \"status\":1, \"created_at\":\"2015-01-10T00:00:58.092Z\", \"updated_at\":\"2015-01-10T08:11:48.324Z\", \"private_key\":\"2db85f4b75babbeeea41995b8a7be5e3d2da0ddb367a565f762e79e8064ac428\", \"public_key\":\"0287a415bf817acf4e8383ba532987796664805d90a25335d056efbff73ce07b80\"}, {\"tx_hash\":\"cfeec1dcec94c588483a0f25a63aa6eed71c4895d8e4be8a5105085506717cb1\", \"recipient\":\"1B8RVypPq5kMJHYqW6tqRNzpxfCK2wFZj7\", \"status\":1, \"created_at\":\"2015-01-11T00:05:00.799Z\", \"updated_at\":\"2015-01-11T09:02:32.880Z\", \"private_key\":\"21a81d189c3350349b62b9f8bab9232163538b229544e9af6cffdbf8eb11a15b\", \"public_key\":\"025d82924ccaae2ff2ab6b75d90cf48c19a15c549d1f5e4a7be54d3e17f1d0eaeb\"}, {\"tx_hash\":\"9e412776afc88a91f0dc0921b2d0533afc75f66ac4db988205ca0de1c28af5ef\", \"recipient\":\"169pNiqDKiQpRXfZCDe64yuukUCnBPpjCg\", \"status\":1, \"created_at\":\"2014-05-20T00:01:28.933Z\", \"updated_at\":\"2014-11-05T02:01:53.527Z\", \"private_key\":\"39b1809ca5cd73f5fb1233cbc4504122b475dad4df2adaeb460e5b0ec0ebbb08\", \"public_key\":\"043cf118f77d82750a4852f39fa18f1d4533628efa5fcb1e3a1d2d49585c0de7d9f224877ee78a755aeeb7c13f434a5d03d09344380b39caf75af4944ed6e3b7f1\"}, {\"tx_hash\":\"959730b5fd7ff6df09f8e971c80806b68a0376bdc7dc2f994e1350c7c5211723\", \"recipient\":\"1B5KeyLZUxavyVC8W1Xf7zsKTmUZbVPauF\", \"status\":1, \"created_at\":\"2014-06-02T00:04:04.653Z\", \"updated_at\":\"2014-11-05T02:01:53.537Z\", \"private_key\":\"87bcdbfbbf7410bd1cae2598eabdf35f4a00ed0a92e1299fce458b587ccbc30f\", \"public_key\":\"04951ea0640fa8047f480419310356f9612da0168670684662c13ba4e4c3e6900232d9ef74614dbaf3b9cbbc4ff6364664928fa7d8ae7c489f92d2c9d868644c46\"}, {\"tx_hash\":\"c00940fe6d0976db9e53a5f41505ccea920846bcb459c1fcc06f46202657d79b\", \"recipient\":\"1L6eng3JME8eCnVFKDZdpjy2FfygoQwjhL\", \"status\":1, \"created_at\":\"2014-05-18T00:00:25.190Z\", \"updated_at\":\"2014-11-05T02:01:53.556Z\", \"private_key\":\"994ccde9c55ad5f8e1b1942db448f1287195d2e2afcaffde8248ef1c1d2cc017\", \"public_key\":\"04e4bfaf6afd9303b4b83370ac7ea7bfddea1a921c6615ea0064905eeb5c618b4999f96f6470dfa3f8389a55c095a8350bfa5a218de9d2bbcd0b903be16780a446\"}, {\"tx_hash\":\"3b42e20f69db1ad6f00ca56a0b2ae7c483c4f2733be759bdbc69b49feb318703\", \"recipient\":\"1QKkr49YoLFo6Z6inHiPhfhAYFxWj9K7Hy\", \"status\":1, \"created_at\":\"2014-04-18T13:22:49.602Z\", \"updated_at\":\"2014-11-05T02:01:53.565Z\", \"private_key\":\"efff3139a5216f7e80a9b5d4d71ab6d1324a697ba20daaa4dd975348923ee84c\", \"public_key\":\"046cc59df6b9c4cc5197328eb1949231c88966a44ba380b2c47b7fd65546aff536df9bfab0a0d816d9a4016fd62d399f95e71b0cb9645a219e9ab9c9acb0d8e046\"}, {\"tx_hash\":\"36330ecb94f53ef7502618885e4ee1eee0a1cf8b13ba4bfa1041a1f75ad85b31\", \"recipient\":\"12JYZfZp1MeB1HhmNAnYenFw26GW5oHomv\", \"status\":1, \"created_at\":\"2014-05-31T00:00:16.891Z\", \"updated_at\":\"2014-11-05T02:01:53.590Z\", \"private_key\":\"175e36efc5178d85438e83752e413dfba939fcf13600687923eba2c518a9b6fc\", \"public_key\":\"04ae1bfdbc34d4786104d5816e9d1339044d1c6f7673b9b4cad09a990da3a65ffb830254d72ef6c2ff8070a5bb84956fc7c770d60dcc53c2eaf0cddbf0f6cdf976\"}, {\"tx_hash\":\"b83800314a4c8bd79393fac714eea04a7b5d7df75d1d3c3331fb9b6c0c529d69\", \"recipient\":\"1L7rfCAkY5EDCEGwuZEuwJtccrxGN7BZMn\", \"status\":1, \"created_at\":\"2014-07-25T00:04:29.040Z\", \"updated_at\":\"2014-11-05T02:01:53.601Z\", \"private_key\":\"2297aee3e474ef00241adeba64fb5f7aab2091c38f8a398a7aa8f93c86f356b3\", \"public_key\":\"04bce5843da8e8879197a965940ed51c396b14e692451023b2f489cf623de203acf51200ee85dcb4529cd98e4612f9566645757f9eb5c1834912037fb3afcb37fe\"}, {\"tx_hash\":\"23d03659209b3c6fa8ea08cee15e4bb6a76bbd33212d1764baf0b1a21e41a72a\", \"recipient\":\"13RQZEUPLLTUJZ4DxTG3ffRqoSwZuWqyS4\", \"status\":1, \"created_at\":\"2014-08-01T00:01:40.493Z\", \"updated_at\":\"2014-11-05T02:01:53.619Z\", \"private_key\":\"db8b86008429a08cd35368dfcd253c9090d8e8f536b60d603f584cc6fa543e59\", \"public_key\":\"041fc9291757e74416f1bcaf00f19cc1d8695f0aad1303d2725549babf66362793673cda21a4472e1551add4437824ed3ccdc34bf8264c61989a21f483d69e4878\"}, {\"tx_hash\":\"3661ef8aa0cdabf903e6ff9ea240b485655e8d0a42275e9e52a42122a32f9ccf\", \"recipient\":\"1wy2p4BV8MfPnMQMRNiNqYQEhEB7LgQYj\", \"status\":1, \"created_at\":\"2014-08-14T00:02:18.460Z\", \"updated_at\":\"2014-11-05T02:01:53.628Z\", \"private_key\":\"f2cbf3f7eb3a70165ac0cda36757bd781c985defea4c70a55c02cac662f50061\", \"public_key\":\"04713383422a965b2a5fbb918945104f4f39f66a4102c3c8321af963e25fef736859884f708303049dde9496af30cf17f8abf3b80620ed597f545c112e628eaffa\"}, {\"tx_hash\":\"8bc4889e0134508b4cdec5cd972fcfc7ceecb4e02dd1c79c714992c9fbc0271a\", \"recipient\":\"1Ee8boWJvKykTevPbsnUVXwBtwXfmEcArm\", \"status\":1, \"created_at\":\"2014-07-21T00:03:33.063Z\", \"updated_at\":\"2014-11-05T02:01:53.638Z\", \"private_key\":\"2608f83789fdeda48aa274b0ab3b9594a081cb7255bf52f6fefdf55d713248f7\", \"public_key\":\"04048d6062354ede32b1c4e275d1f588502fd5e9301c5fc2bca698634eae2e9bac26f169f46e8ca459a250f36c70e2ba882149d4900d8ffb68b2d7216c2500f4b2\"}, {\"tx_hash\":\"ffcdf1aae1acb22d9c81641e545ba20918a65eff2458c3e2c473dd27b6c63927\", \"recipient\":\"19sAkdCSQPPXfieXbYtDsoRAY8iWeerxBb\", \"status\":1, \"created_at\":\"2014-07-28T00:04:33.768Z\", \"updated_at\":\"2014-11-05T02:01:53.647Z\", \"private_key\":\"0c5685176d7b0594f6fe6182403f6f79a1ebe9daeb0c1405825eb99bb5ad4daf\", \"public_key\":\"045a01281da061850238e9704f2c1cbb3b3f16f5d88d8579f598bdab2ffefc616aa8ae19e74b46061025e741785d19eb91d371a9b2b276da821655378184543bfd\"}, {\"tx_hash\":\"e4b2966b3f9c99ba188d3667cbc32b476745bb7f2bc7d40f7ea333aab9312323\", \"recipient\":\"1Nsd7DeFSfgWPmscYx9VEj9ZbPHvs3mE2f\", \"status\":1, \"created_at\":\"2014-08-10T00:01:44.536Z\", \"updated_at\":\"2014-11-05T02:01:53.656Z\", \"private_key\":\"88c3918c7f7c873bb3b00b79865ba5c9464031c0f98651ffb1558f226e9ddf65\", \"public_key\":\"04aab3e693017d7137e3fab17a3488473968dda14bab60ae574df3fed29f61963b2a322dfc4d05b32cb6998d3ea11a6c0f207379af2bbc5ae8259bba8cd8e1c5fb\"}, {\"tx_hash\":\"025e34722395211a0f05847679334a66b36d5da52e974fb4ce1ebae62df0e7ed\", \"recipient\":\"1KbD8WUePmwXmpAMrH1jmws9aLxa3tLRL2\", \"status\":1, \"created_at\":\"2014-07-16T20:37:30.619Z\", \"updated_at\":\"2014-11-05T02:01:53.675Z\", \"private_key\":\"ece17df0425227fa2f4d764b17f8f10123f38d72713b3faccc2e3e1159d74e9b\", \"public_key\":\"040c7d98252c3aa9f13dac550f6a6a987de4ce7bf457c2e02be45408304fec6f85c36a92bd431c54fee3de9b5131b2c4730198396fd34b95cd247c362a49701279\"}, {\"tx_hash\":\"51f87059c234fb2ff758895c8e7c990059bf46a5d54a1aa31c32f27641b20a24\", \"recipient\":\"1F1M4K4KfGq5qtzB4CsXBjdHriYufu85Ah\", \"status\":1, \"created_at\":\"2014-07-16T20:53:56.446Z\", \"updated_at\":\"2014-11-05T02:01:53.685Z\", \"private_key\":\"270decfd0d142ff9442efc67985b41b133e827ddc4393a19d04fd3c73fdec210\", \"public_key\":\"04c605891c4b90ad3fe70ff7b8affb34a6a579618e3c304a874b38dbce59c6e141a668aac3a85d248806154cec01f5e400679bff0b3de88f430a14853facead2f4\"}, {\"tx_hash\":\"4e468ff7adbb480a6020188ed6c5103582f17673a2c297cec5fc0c5e3b80e98e\", \"recipient\":\"14habrH2ScUbrWcWy5NpaXuoefQ2CnpNLe\", \"status\":1, \"created_at\":\"2014-09-08T00:02:04.828Z\", \"updated_at\":\"2014-11-05T02:01:53.703Z\", \"private_key\":\"9bd6799aadfd8c2b2c511c089c7f905eb831189b6b49ceff454ebfa9c69c4bb1\", \"public_key\":\"04c13fcdc487ce7d6ea2b8e50f591c66bc20d3d019900a58f2ed98a4d3a9864e57b4ea0e3de9ad6c6d085ac8b0319d68ec8445cb1e1a7a13fef7988855d0d0a21e\"}, {\"tx_hash\":\"ee1b6b5b44cc6926aa7c4a76a82fed0966ecf20160d2c5d127a8f993ca0f5459\", \"recipient\":\"14jqg33KWdjJqq5ExtudvsepTMdT5j3aeR\", \"status\":1, \"created_at\":\"2014-09-24T00:01:07.631Z\", \"updated_at\":\"2014-11-05T02:01:53.724Z\", \"private_key\":\"baffb965fad45a248fd883e33e46cd66366986151462988fb797454702d1cbf0\", \"public_key\":\"049d16c0b1259152996dfeca5fcce6981ad96408589163e195ab2b742b7bc731ac6c9148f19033fed57712a0eecb5b8d18131c52d539683985f8b5adfa95818e9f\"}, {\"tx_hash\":\"4ec4374f1caa4646199806f21645052c8540ac060974c3fb143dc8a1289718fc\", \"recipient\":\"161mmBrmvm9K7S6sgCFmC2h4NJ77aAPAkJ\", \"status\":1, \"created_at\":\"2014-09-14T00:01:40.268Z\", \"updated_at\":\"2014-11-05T02:01:53.735Z\", \"private_key\":\"dbb97e30e5cbd2eb901aab5087d6ce037df426412c59ad1f992d603f594e3fa9\", \"public_key\":\"04414b1e0319b226719f916f46c576411623a100e7eda826ededdd80598a4e847960314b5b49394a89f42c3576faf552d667f33f8d1160106333b18f965304399c\"}, {\"tx_hash\":\"10fcab160176e81e8df317706742da904d9128040c0a84ac00d91845e5b05be1\", \"recipient\":\"18GFJ5Um4ictjRcPg1Utpi5Kvk585dW7zV\", \"status\":1, \"created_at\":\"2014-09-16T00:02:37.395Z\", \"updated_at\":\"2014-11-05T02:01:53.745Z\", \"private_key\":\"8994bc15af244dc4e77635710e29e7e7b0d98b1a1efc8171178f9bb2d14cdd03\", \"public_key\":\"0453b2cd3ab247ba10c87829c3a7c742964877ddb00490bb62f8f502e08de992ea8b10b81345d9eac99631b91aa9035bc887991248951ac460e9f7d2033a9bd921\"}, {\"tx_hash\":\"0684e3a180763c820330628a2173f54961120ac0f0921f49b93117ff965a8a77\", \"recipient\":\"1BLEAyLhuDjHyRweJH4ntnFC98CiA71hLo\", \"status\":1, \"created_at\":\"2014-08-23T00:01:03.235Z\", \"updated_at\":\"2014-11-05T02:01:53.784Z\", \"private_key\":\"56804c90e29b45bad78b53392cd3c1ed19087acc388df3ffe350453c1cb902ae\", \"public_key\":\"0450318588b0c03d10b8ad1c960eb9e1376b2079ac9dfdbd03e76206d22d83e77fe8167d84a8d0f9bbe928cc6f1cc46efac99f92b2da1aa61977b5cfd28a79032b\"}, {\"tx_hash\":\"98cfc06713213692a745a3d10e992dac492ecb178345d6370509cd039e5a1422\", \"recipient\":\"1CK6H3xA5w44XwFMRmeFbAv7fjZ8YZMapr\", \"status\":1, \"created_at\":\"2014-10-20T00:03:25.551Z\", \"updated_at\":\"2014-11-05T02:01:53.800Z\", \"private_key\":\"e5c2af1bad0022a21a19d6ee10f1cdb8436c3882c1432f9fd8f08814d0116697\", \"public_key\":\"04f2b299732876a4cf3070966c861e93a9c799f6e2274a3a172d61e457bb69b4e8e6b6a9ecc85d385c1d13d9227f1a331b67f40b3806fd94fc302fd4be13fe7bae\"}, {\"tx_hash\":\"155411ca3c5dac0298dff2ace9e3b855609645365c00e744e830d8a0c8ebccca\", \"recipient\":\"18EgiSrkM48ZWB8CiQtVVVPPyDWitatto6\", \"status\":1, \"created_at\":\"2014-10-02T00:01:06.472Z\", \"updated_at\":\"2014-11-05T02:01:53.811Z\", \"private_key\":\"bf2ed9a7659ea3c3819fd6c8f40927fe0db3dca050820f8ce234ecdf81f97946\", \"public_key\":\"04ed1200c3650061f4f68eb4279b67f3b92e56bb178260787489584cf31b86871b0d923a76d9aa3d6e2d2fb2eadb8ba9dd2c4f76856f2ddeb286f72f6b0c310876\"}, {\"tx_hash\":\"7b8ba249ca64b3900aa6c08d929a94c60c446a5ca33d19e54744b4cf0f43c525\", \"recipient\":\"1FDVeHvKAmgryxuJ3tNJYsnPpLuvYWufG6\", \"status\":1, \"created_at\":\"2014-10-05T00:00:46.280Z\", \"updated_at\":\"2014-11-05T02:01:53.828Z\", \"private_key\":\"df359afc7ccd771eeb5c19162ff2c4592327ea4abf42138ec1c96484e0277b36\", \"public_key\":\"04e3f8706dd54219469f6ffb1457c75406ba6b972fde6b8c2b6eebf26d7d99b18f55d70f3184a5cab9ed4316478123a4b871858965739bff28ef30182d222efacc\"}, {\"tx_hash\":\"a578adb058de0aa8ab5c122ed9a7396018e611aac7751f37cacdc46e7ebdfb77\", \"recipient\":\"14WKY4JEEG8jXRTtdHm24NMJgae1kbJtU5\", \"status\":1, \"created_at\":\"2014-10-15T00:02:07.663Z\", \"updated_at\":\"2014-11-05T02:01:53.844Z\", \"private_key\":\"bfc3803e981f7744555de7c2486cef53e6a2e509cc62a284bac283c13533c911\", \"public_key\":\"04199dc8ae2fdf302c64cf9fbc52c4b8296eebd13d2cef5e18596885181ba4c57fa1889c341d5e833771d23c40e2cd5fa3c305ae7fc1c8591a739bc2b375187e9b\"}, {\"tx_hash\":\"f111ee1d4f16fddf35a5634a2fe5fa6e6b68240f2156d5a1f6e236ff9ee57f1b\", \"recipient\":\"1Nizee17zZ4Dhk5gysqBnCeLPSJXY6pqLR\", \"status\":1, \"created_at\":\"2014-05-25T00:00:59.698Z\", \"updated_at\":\"2014-11-05T02:01:53.853Z\", \"private_key\":\"2fe4bd1ecec9acb4f704edf91793ad28435ba548d5e45e4a458231cf03cd7739\", \"public_key\":\"04ad25e291f53426c4213362b48b4fa22b727da11cd9262fecfdb4f92490bf6cf3f148e4eae41dc6fbba690b6c68880418d928aaf5d9b3cb8077619c1e332ad584\"}, {\"tx_hash\":\"9181cd4434d9bb2ba6a840b4161334cd519b47de81efab3d3b9db3f262065b2a\", \"recipient\":\"1KNMWBTfJZaZEvok96hLrDwpStKQHFvJtC\", \"status\":1, \"created_at\":\"2014-06-05T00:03:47.226Z\", \"updated_at\":\"2014-11-05T02:01:53.863Z\", \"private_key\":\"ab0a7f5bc77e68a4abd04e1e1d239aaffa659dd5ca7d29f74848541b6454cb40\", \"public_key\":\"04e099ef0ddc6111f67c284139edfea15c182033af36ce50b1f184c79e360c16764b427b8f6e8c55dbd5c9656763429f550d52c59fcfc12e971936cbdb722f98df\"}, {\"tx_hash\":\"3d0e2a091327adf984350745f7c66dcb7875c03855a083978ac7d5c6af3c936f\", \"recipient\":\"1JpEtyrKVnjKctfEZLt4dTfGEPJT4RuSgX\", \"status\":1, \"created_at\":\"2014-05-27T00:03:38.266Z\", \"updated_at\":\"2014-11-05T02:01:53.879Z\", \"private_key\":\"18145fb74d418eecd1159aa1ba52bbfe0916dc8fc399432bdfed854dafe9663e\", \"public_key\":\"0408d7cd00d97c6905a78019dd9d6ac1c4333ea7fa44613aaeb70a0379f9040cf4a57de0c078b52278d40e9232662427fb2b4ae51b69ee5437c9429d128b22c5e6\"}, {\"tx_hash\":\"76a88d221e6c8748027642db86c76a6179fd7c9e67e9b8462626ad9ec2785be0\", \"recipient\":\"12H9khkAqWA4E1Qum2FCwYRaQT8ozt9foL\", \"status\":1, \"created_at\":\"2014-10-29T21:55:10.444Z\", \"updated_at\":\"2014-11-05T02:01:53.889Z\", \"private_key\":\"6baa1fb4fbfbec054d5e80566b39cc3c5e1ff5423e934bc0d7433e8a6d7e5538\", \"public_key\":\"047d83130cb4054032bb870365a388f63bbce0938ce3da508aefb91d88c14ecc56d2700bbdcbf99d392d60e7e9f2f263000e1aa91def214c1b76f8cb82af53d17a\"}, {\"tx_hash\":\"00558a6bf42975bc24ad0c46951ac4d36b284b7d2f8869798de217e67326aef7\", \"recipient\":\"1C2kUE3cHanHaPCogP14tR7h5V876zXwSx\", \"status\":1, \"created_at\":\"2014-09-15T00:01:20.644Z\", \"updated_at\":\"2014-11-05T02:01:53.905Z\", \"private_key\":\"160a6318a034567f223f2dc2d89487b404f9849f5c065b0dff520c8f5e17279c\", \"public_key\":\"0439bf418a409b41c677ffd2bd907ce77d06a73bdbda1d3ca90a6b87e55d9d2287419c98dba37d0e17c9a62dda9df786c7657f45b25608400917abba92b2827af6\"}, {\"tx_hash\":\"7d170a86f561701d9b3fe793f1ab5c27c3b08fdafd1a037cb0a6facf07d70a43\", \"recipient\":\"1GSSHwJNz9ZWczwb5cDECK9DhoJTym6itU\", \"status\":1, \"created_at\":\"2014-05-08T00:02:24.003Z\", \"updated_at\":\"2014-11-05T02:01:53.915Z\", \"private_key\":\"45c6e1b0b331a84c61e53d8bfaec0fcb7c9fa3a6ad99309b14a1a34e638de629\", \"public_key\":\"04c090f10dbfd1352ea678a80192983693e28ea287a5d05a886e6ed71d24f3f45673b9336b43f82e87ed5dbe0f09e78357bbf4716f2e96b7080afc354abf8e919a\"}, {\"tx_hash\":\"4c7994c370b0b7a58f3df65e0fcc5223cd57b2ffd3548a6395f0424be5306d46\", \"recipient\":\"145fVeQPhJGJf6Jq5UhbJw7UVpnopbCBqh\", \"status\":1, \"created_at\":\"2015-05-18T00:00:58.730Z\", \"updated_at\":\"2015-05-18T09:51:31.657Z\", \"private_key\":\"e8722be7b40bbf2f32329f69187819a3ddf61577121ceb056803542e4350dc01\", \"public_key\":\"039c056d3fa372c77b869bf13b8646df501b68b76009cb45ad7782d42fc1519677\"}, {\"tx_hash\":\"b1b35b093ffb7ba24155cbbb211041377f3a2c44be0d4a376860024ba2331602\", \"recipient\":\"1E2ZWykKZUP11yo4YS8vyFXLWAJeYKPbrx\", \"status\":1, \"created_at\":\"2014-10-26T00:00:55.447Z\", \"updated_at\":\"2014-11-05T02:01:53.934Z\", \"private_key\":\"3f67d33e84fc9735a611651dccfbff8994124b80a93dd5d4793febd56193d8a6\", \"public_key\":\"0437f4d9adeb3495729cce1cefe2f5cb16aba99ab4df9bd7f080bf3f453853dad131474c7af9801c6bee23b19d9ccc51faddfaec8be907227f0dc637f7838a4b20\"}, {\"tx_hash\":\"1552390c50242cddb935f58c88f3c12dd189a55fd661b864764792d689f68f35\", \"recipient\":\"1JrKRhniUKoTsUSZsui8zDTaGGKfqAo7Ub\", \"status\":1, \"created_at\":\"2014-06-18T00:04:04.229Z\", \"updated_at\":\"2014-11-05T02:01:53.946Z\", \"private_key\":\"59acf5d4d66a837402f653052f6c94b972ae1ae90e6ece7476e04a93ecfef1ea\", \"public_key\":\"0487c8d374455accc2b1030f49b7c85d92c67d913bf193afec2a3431173df7803c9524cf294f66f65a0f2dfc320c55ab2b770cca4a30764aa5392124fb53b08a22\"}, {\"tx_hash\":\"364cfa51f9dd1a3f66d1997d3dfc14097aa2c4f302543996304a386452127148\", \"recipient\":\"1HqhqeHDwfvqUV6s2d6oWA6rBfwxmvuu8Y\", \"status\":1, \"created_at\":\"2014-06-16T00:00:46.148Z\", \"updated_at\":\"2014-11-05T02:01:54.054Z\", \"private_key\":\"6d7af705888d011c072defb9d091e694d3e8b82e5d546b5a46c4c99c80bc3b99\", \"public_key\":\"04fd0e350898e63ce0f846fe8f4dc3c8bb7c7b3a148e38ee297d91b815bc35e9d541a4c2fd6fdbc12c75c7ca10f238d780c6dfb4af13b3b302fddc8eee4d39351c\"}, {\"tx_hash\":\"e7380c96301a7c5644f6064cc1000db9d863a36722f0b9eb5ac4fee8250ccbeb\", \"recipient\":\"16X7Z3WkAwgZdtRc67BjzJaaAyVGC9XvVw\", \"status\":1, \"created_at\":\"2014-06-21T00:03:29.175Z\", \"updated_at\":\"2014-11-05T02:01:54.084Z\", \"private_key\":\"f59914901f476c84a435f5be13f9a11729859e266c91b91abe7b2359228da6ce\", \"public_key\":\"042ed0b725a1acc0a63af5190c8af892a081f253a7b1037961c69b532808ce0dc5f82eab2aabcbcf5e619d72b721801fbff8bbfd0440597ef70f8095e7c3c9f17d\"}, {\"tx_hash\":\"e4aad1c75c097eac80e68c2df0db1870c0abb3c9a0ed3ac2b2d06feb88cd0bcb\", \"recipient\":\"19TyvYS74Ho6RDUyoDNZaS9sVTYJdvjcKn\", \"status\":1, \"created_at\":\"2014-06-22T00:02:54.977Z\", \"updated_at\":\"2014-11-05T02:01:54.095Z\", \"private_key\":\"447c1674b23336c9140c15dc989a1da98735d83a8e63cf7da8d64ac2b2d310df\", \"public_key\":\"046637bf2d3b33493380c250c170a8df0d7a9260330d42af477d3ff4153190fa1f71bb9a3b46beabcc37097c12bd1dfc547bff7ba4578aa963952219659b1919e1\"}, {\"tx_hash\":\"c533d2f3b74b6e53fd69e0d284779158c91d17bc05f0856c1d4a0a5d8f8d18c4\", \"recipient\":\"15qyS9x5RYnaKodT5gYjrhTLA1qw9jfsdo\", \"status\":1, \"created_at\":\"2014-06-24T00:03:43.006Z\", \"updated_at\":\"2014-11-05T02:01:54.110Z\", \"private_key\":\"8a64d171816ad307cf608563d481c58298f8d6f1f94b8608dd61797432bdf641\", \"public_key\":\"0458e765cf40ed67aeb3af21765983c5dd42fa7f61fafb4404b3a62a401d093374a62f8a59a32454bee4bdbf6014eb3de6f87747f23b6b7f17413fea783f21cd9f\"}, {\"tx_hash\":\"c5735f619ea9450afba8a3c39654f5acf60d1ffbc6135ea77703d5216342917f\", \"recipient\":\"154uJzLAiosPPiRD3QLEh1nEk3iZjVu5gk\", \"status\":1, \"created_at\":\"2014-06-25T00:03:27.933Z\", \"updated_at\":\"2014-11-05T02:01:54.120Z\", \"private_key\":\"4c09fd2fbcd7bfe60d925bd91f55869645e3bc7f3d8c4708f83fe440d1f2e1c8\", \"public_key\":\"0416c275f2ee2eb68334d20d03368bd0fa6f66dd28c4a2a51383715b72cdc53363f95dbfd14e26946cb1081f911ed4b0656eb0a8b926fa33bceeb0cf6488843909\"}, {\"tx_hash\":\"daf1a9dd37cfa364750ad4623f9494f9180f4a6c0d6c7820075ca907e9181d6a\", \"recipient\":\"1Bn1CULrCZqwH3sPMVBvP7Jo1z5U9DRL6G\", \"status\":1, \"created_at\":\"2014-06-27T00:02:00.853Z\", \"updated_at\":\"2014-11-05T02:01:54.130Z\", \"private_key\":\"7b034cdd763b812c60772cf8e9e62676f667a3f1afe21ecbd0576a7718132abf\", \"public_key\":\"04e91f82b069b5d08bc511d4eee35ee35de80d8bdd126e19e2cc503b7b878da5238772657585bc597aaaef4f821ef80570aeb56daae5a80f4ce39afaccb70e1580\"}, {\"tx_hash\":\"918f4636b7da99f39ef93395e618fb8150fb99b5822c2bef9bda681ad0653229\", \"recipient\":\"1Q9oX1DrVd39UVx39vV8CxSXyJTXUhnzia\", \"status\":1, \"created_at\":\"2014-07-05T00:00:23.364Z\", \"updated_at\":\"2014-11-05T02:01:54.147Z\", \"private_key\":\"f66bb383dc12dad84b8d5e9ac24d63938e159d316326bc12f327e3274e5ee7a4\", \"public_key\":\"04d17fa40097c04facfe7a8b0fe000720de1221ccf6668ed3b48120110530192d8b9488519af7d39a57b8f3958447f72bc9c286bf6c94c17d87074f3e91a8c67cb\"}, {\"tx_hash\":\"f3bcd428858081ff82f64a583c347aa714b1c1394b8757f2944f9848d1f6724d\", \"recipient\":\"17Tqrjw1BvscnyobeiPAH8Nqxf1TQD44x2\", \"status\":1, \"created_at\":\"2014-06-30T00:01:35.126Z\", \"updated_at\":\"2014-11-05T02:01:54.157Z\", \"private_key\":\"ab860b998d496dff1ade01bf32314508ddf9d09959ddc64f574ad5d265e23f61\", \"public_key\":\"04af6109210fa42f605ce48c177842c9e6c10825b30cfa48e8ef081a906de7329a78b052ea4874fd8e40e1522c33b3a527927d036813c922cbc5388c152cc6627b\"}, {\"tx_hash\":\"1daaf9ec98513538ff85f476c801cab0736428ccc786f8221c68f84e9e432764\", \"recipient\":\"138PyficovYkH7Ut9oRjxTMyJRiWyf8XRG\", \"status\":1, \"created_at\":\"2014-07-15T00:03:11.112Z\", \"updated_at\":\"2014-11-05T02:01:54.179Z\", \"private_key\":\"d7d02307eefe5368ec4b17bbc6de453099ed0e0f81ff1d5d27dc1728555316aa\", \"public_key\":\"043c83d03181c16b087e0cb4eb6bdd24f8435c05fa36880dfd2c1a93bca94f06737df4eae0ef00cd9f7ca5abc88104b9c4dd5286b2a742a4b30bb7b3c70ddddb3d\"}, {\"tx_hash\":\"adf352f73e98f56ed55e1c4fe9f46d406b4686b4162ab66f5fc7246f5d8313d2\", \"recipient\":\"18Rigxnx6D9aCgJfrbNu8stUihJio7zhuK\", \"status\":1, \"created_at\":\"2014-07-16T00:02:59.233Z\", \"updated_at\":\"2014-11-05T02:01:54.211Z\", \"private_key\":\"c4857f0d4b74caca9c511c342c9c49508e113e5adbe5972de7a180d9566659c2\", \"public_key\":\"0441190cdfdee4ce9ac98ada810a6d3cc657cafd72ee4aa3817f21b48ee477ef34efcba82f586ea5ccd8aefd1f74cbe47c1aca6c7ee8c3a2dee06261429c99da3e\"}, {\"tx_hash\":\"6ea75d536848f9a1dc8d0e04510767d2e2fb34055605fd52a1b2a3a2c4cece04\", \"recipient\":\"1DQUJ4Z6ygitDpopQskPRCuQwm9Ez8ajdM\", \"status\":1, \"created_at\":\"2014-07-17T00:01:57.057Z\", \"updated_at\":\"2014-11-05T02:01:54.313Z\", \"private_key\":\"746748b2f43dae2deb1e441c29ee7ed455ec5a4ecddc135b14f5779a718ada04\", \"public_key\":\"0432ccebecdd1c6c410084cbd50fc69184e9488e88070dfcf07c2e8068ebeec2d289b1f176419320dc9f0f52b318a8a01121ed01639a88d0b41ef88d1c61c74725\"}, {\"tx_hash\":\"623cd0dccd6281011ccf7935f69e261e6ffa267d0d229d6f7d9cbe8decc89b11\", \"recipient\":\"1QCuZWoH5xCTgQbfxH7uzxNo3FtxDAxNdq\", \"status\":1, \"created_at\":\"2014-08-07T00:01:52.728Z\", \"updated_at\":\"2014-11-05T02:01:54.331Z\", \"private_key\":\"b09985abf485e7de368325bf6749a4bf94f654f9c4b130223c1b751a1ee52849\", \"public_key\":\"04c369656cca97108c10fdd420b4145816689bb162583754ace26b3fb0aab78492001474c9006c55ce4c1ed2f09d2f5078fcd05ff3ef593b28a99d9b6ce667b4de\"}, {\"tx_hash\":\"cd86d40b2707dee5e3edff0cf2c5ecba63bfd969b501190ec7c311130f084285\", \"recipient\":\"1479tCiLWz5aKvM8SKxko9uiTrX8K2HwpG\", \"status\":1, \"created_at\":\"2014-07-30T00:04:26.693Z\", \"updated_at\":\"2014-11-05T02:01:54.341Z\", \"private_key\":\"f4fce839a7b2b80ace0bdfcb4af2206b5d79903ed037c3eb85e5c095bdaaf18b\", \"public_key\":\"04651c94bbae68b4d4364d78bdef5fbdcceb754c57e673e10ccdcc188b89ca33a5304a61db3a72693ea786596f3ef2447a37cd630abf6754db55d1c8f88022a02d\"}, {\"tx_hash\":\"f8e2eed5464b174d25cc7d48836f6683cbee14080a191dd81f2ec7979b8bd4c4\", \"recipient\":\"12rB5WuthGjSCgJ4tzw9gHrLmoHYTqUQqQ\", \"status\":1, \"created_at\":\"2014-08-06T00:00:39.527Z\", \"updated_at\":\"2014-11-05T02:01:54.357Z\", \"private_key\":\"c971c713ebd650e6ae8debab6f1598cc26c8b530076ab8e0a4316aae7fc94229\", \"public_key\":\"046b74c9c290bb232149a747c1820e6c3c9fa39a868bac06991c07835b2136ae4caf30d34622acd2cd35288385f409d49a109a0ae95f3d82b167658cc1fb684645\"}, {\"tx_hash\":\"8ee99265fb77f830ba79759d509ce585196e2c6623c99866aa3e19a2dbc43066\", \"recipient\":\"1YYekbc3L3cM2Fq2UE1fnxxK1TBfjxPhX\", \"status\":1, \"created_at\":\"2014-07-19T00:03:31.239Z\", \"updated_at\":\"2014-11-05T02:01:54.374Z\", \"private_key\":\"3e02c5e76120b3f3561a6dc9aadd273862cf78b182cca8ca15af142e1dd50a8b\", \"public_key\":\"0456df6ed1ff25d0b4cdc81b989668842817bae3daf62d055f654d08821b1ed85207be34875973915cb1c45b583f4ed6b793a2267a3a555f61b8e0fece0980a0e4\"}, {\"tx_hash\":\"2e83d98c31147546570bb123716cf7359ece3d3eb342adf4fb4c5a3db211d68f\", \"recipient\":\"1EWrwRRuPeFZqtuupHKXfFJVsVNyxwdGYg\", \"status\":1, \"created_at\":\"2015-02-28T00:01:10.314Z\", \"updated_at\":\"2015-02-28T02:51:43.930Z\", \"private_key\":\"f00ed794d0604e0a396729e3447bf51fd8b0d4219e2b3c41beb29acab8d53ca3\", \"public_key\":\"0391dbbe04fe756cbb2941b5b2eeac20dca0dae3206534b26b8d56ebcb5874a5d8\"}, {\"tx_hash\":\"8905d041a4fe8903ba16f4880f43dba84ee8e4eb1fb57a7ada22a5eb00406050\", \"recipient\":\"1NEVG8nLCVfdsBe2pJTxFEzvvKnh3AA5qV\", \"status\":1, \"created_at\":\"2015-03-13T00:00:58.406Z\", \"updated_at\":\"2015-03-14T03:22:00.346Z\", \"private_key\":\"1090ea4192b459387d381e0c893cae82324e8dd254160187cd31310fde000167\", \"public_key\":\"0376072025e868b37c0a5a263412bd7f29093818054d7a7b64731411f6761cdc02\"}, {\"tx_hash\":\"e9b5dfe44174ccd94fd6ede31da13fe9608d2ed9addbf81b93ac7bf7bd8ac4ae\", \"recipient\":\"18c8SznKPzHihmrbcM5wYdGSUHPzGuHbuB\", \"status\":1, \"created_at\":\"2015-05-19T00:00:42.053Z\", \"updated_at\":\"2015-05-19T13:21:42.197Z\", \"private_key\":\"31121b5b67631c3ba378d7e0420483a4a2e2cf86bcac6d556ce0f40c1be714fa\", \"public_key\":\"0232327455b11703730bccb55803a65709e973c85935d372de77278ddf5cc0b778\"}, {\"tx_hash\":\"a5490f9df9b4d5f11e6c0a33cbce388d37176ecc988594daaa1a752bd029f01c\", \"recipient\":\"1EyRXrtiGcsVDAPv5WacybHY4SvbzVeaJk\", \"status\":1, \"created_at\":\"2015-02-27T00:01:33.835Z\", \"updated_at\":\"2015-02-27T00:53:05.189Z\", \"private_key\":\"aa7cae139a89a270ffad7436146ae974850a69f04288ebae875760ec93089a38\", \"public_key\":\"02580c18f44dd28dd195a94c327e81d2ad83aec6ec240e36d4074e1197d2ed1427\"}, {\"tx_hash\":\"2c056935b77b9644684f7dcd7d0b679fe8fc8e02aae314ba0d03cc40043db054\", \"recipient\":\"19WDbpqrZttg4uG3L3Jj1UHWEGCnSbT73s\", \"status\":1, \"created_at\":\"2014-07-22T00:03:43.152Z\", \"updated_at\":\"2014-11-05T02:01:54.395Z\", \"private_key\":\"71dc14c7f3e4025aebfd51e41841bbd891edb799bfe63b8d3188d3f1e67c52ba\", \"public_key\":\"0459201fef606e28f2b1bfb5a380532d50a177c413d1cbc8bd527f3b15f0efa9f893187c21f3870b460a3ed1403af5abb8d37f700af816a22dc5541e299b5fa48f\"}, {\"tx_hash\":\"39db27fa5adcaf0b828d5037a882a4a5efcf6bd3551fefe171a339d3fa418c86\", \"recipient\":\"1Kyh12UYzPeLygRc73UMDUTydREBJLSnTx\", \"status\":1, \"created_at\":\"2014-08-08T00:00:57.109Z\", \"updated_at\":\"2014-11-05T02:01:54.408Z\", \"private_key\":\"7aa8b8318e347d18d638d447a577a744bcf8abe7ef35e11616e07086606afe7d\", \"public_key\":\"041e7c049c226c6de1b488d76e6670c5ec8d43930382aceac1661e4a72ed4770a87c84d955edf00e288136194315967fa34c397fcddfec5c22781e69a79bc18922\"}, {\"tx_hash\":\"7e2f10ee736048c19c19c1a7202b11a7a438ba7e7bba7128f559bf9c8c463eab\", \"recipient\":\"12M3XZJf9pppmVHidyxJSXi9Xo3ei5ZXun\", \"status\":1, \"created_at\":\"2014-09-21T00:01:02.250Z\", \"updated_at\":\"2014-11-05T02:01:54.418Z\", \"private_key\":\"670cef68a8c9c717dc7e677870988e723bd94c4c91f394368f6988746aea2d25\", \"public_key\":\"04290c17da13076486ec59fbee121300f002063fa7804d3b73c55fe5573c98abdfaa533ecabf2bc5db6183e1b9f71d929246e0212101243767aa5f58bcb3bd0587\"}, {\"tx_hash\":\"35189b74ac7e0cd8fb723b450f8d63f9b52b628dc5dd3599eadde8d1bbd2a332\", \"recipient\":\"13MePxVWGvK2qxd3vhef2Wf79zYQiGNwQL\", \"status\":1, \"created_at\":\"2014-08-13T00:02:04.590Z\", \"updated_at\":\"2014-11-05T02:01:54.427Z\", \"private_key\":\"af19fdd998f0d3a4402846e6ff4a1c4bf1cf4036163bbef70a340e71d149233d\", \"public_key\":\"04c2623968c6b40a92b964ce291d83390659444fdc402f8994a00cd10cf7f64abb11074cfc9138d920f3e1bd3ab66f4e9083ed6ab90100381d716627f9043181fb\"}, {\"tx_hash\":\"eb286633e29904901ca2ae4df5bbaf14aa25e4c8387d985adc4873dceba9798b\", \"recipient\":\"19pR3kzPsghsaXsgBXHHoF4zzjXKDvf3AF\", \"status\":1, \"created_at\":\"2014-08-16T00:03:17.308Z\", \"updated_at\":\"2014-11-05T02:01:54.444Z\", \"private_key\":\"2e1beadc2cc095bad9514bfaeb0aaf59118a3259fa86c205fdb01536bf5a5a80\", \"public_key\":\"041d595105ad528a9d1d9a451dd8769a44a32ac995faa1989040ae0e23171bbd49b5e6e9f86933ab5ca37b0ab482847ad2e09c50b6c39b64e691ded5fd280eab2a\"}, {\"tx_hash\":\"b4b82100bc96cb2531b11a228cebe6e81871d919219aae23d0cff67b9103a3bd\", \"recipient\":\"15amQEzENHMw1Cgd6dawfU1Mceh695453a\", \"status\":1, \"created_at\":\"2014-08-19T00:02:33.963Z\", \"updated_at\":\"2014-11-05T02:01:54.460Z\", \"private_key\":\"da1b8796b28f11115c7100247d7878ba3868dc5ed0a099e55390c1e8d69c11ae\", \"public_key\":\"04760dc9435d9b2a84860abcd4337a9a43601a7b54a5b0c486f9a934fc28ff6bdecd9174ae03792c607a110d95e32b51832958a12ed064a724e8b31c847049f3ed\"}, {\"tx_hash\":\"633e453ecbc79bff9260bd1e2ae6fde79199871e8817b27664e389801ca27b95\", \"recipient\":\"17H66Co6zon2Lm83SCdLfGwn4LgGiyAJkf\", \"status\":1, \"created_at\":\"2014-08-15T00:01:15.375Z\", \"updated_at\":\"2014-11-05T02:01:54.470Z\", \"private_key\":\"9f3fd1b6fee565ebb6e8237e1a62a4811da9c59eee487c0a460872d533fd1bdd\", \"public_key\":\"045da31a8c105b75a5b0f18ac5a21a752d3bbae245de37edd9a361e9992438e9f4948c697b28b38531955ff65378ae206aa1fb8855c87abc6fa034a7d0c59790f2\"}, {\"tx_hash\":\"14ac6a2f3eabde6d34518e6b45a4b611029b71d43b12d4547b2be076486230dc\", \"recipient\":\"1GqJQ3CB3QQSqfx7n5YMMWiXZpCzCm8v7N\", \"status\":1, \"created_at\":\"2014-09-03T00:01:25.216Z\", \"updated_at\":\"2014-11-05T02:01:54.490Z\", \"private_key\":\"6fd65475931d2e4d3582ffff973085ec56f18be6f8618ece2a94579edb771c62\", \"public_key\":\"046c3a3188b6185a4c998e192528f956d7c23fe5449e416d2ccacbc0f238d291d61942075a48ac288fb957a04162178096a4daea28d638c32643af8f959708f4da\"}, {\"tx_hash\":\"ce9a86fffc98ee5581d0afcc7e2c31b3629425821edb1f340da71cfc5bc67815\", \"recipient\":\"13KLTTQASP88L6p12ELqJy4bjnDSEwozCz\", \"status\":1, \"created_at\":\"2014-08-27T00:00:50.518Z\", \"updated_at\":\"2014-11-05T02:01:54.499Z\", \"private_key\":\"d1669c355a3670a4fd9a28124160a07cdd9d1f0e0eaad94415ba30d4cff07678\", \"public_key\":\"04ad6fc4692520ca7ed13a98e82b22a35e182ccc8b5d2dd595221acc0f6da32f061cb09bd6e656ad64a177f7b91fc9d595a532a531a0ad4d31354c8c43c8af6ff9\"}, {\"tx_hash\":\"a58ab327b123f52cfb4dcf55ab20f370b64c216c46225e0fda9daa463485caf1\", \"recipient\":\"13pj86PtizzrVsWBK67xrVsit4fcFxoboX\", \"status\":1, \"created_at\":\"2015-04-09T00:01:17.301Z\", \"updated_at\":\"2015-04-09T03:41:32.631Z\", \"private_key\":\"02da5e096175c5c1a7acf1c2765d8dbcb6ad17c0595b23d46f38f2ba467dc5c9\", \"public_key\":\"031ce436f668d59b4c99ddc530a6ff46f455757455e34494acd3bec06ebd18b1d4\"}, {\"tx_hash\":\"f349f7a051bdccbdaaa8a8aa6f4e1d7c1e525fcad210503f968881b9ca3f3953\", \"recipient\":\"1FDYRCzyrBxtPQEUcYtPn31Z57sEWdSZ77\", \"status\":1, \"created_at\":\"2014-09-11T00:00:58.352Z\", \"updated_at\":\"2014-11-05T02:01:54.520Z\", \"private_key\":\"f1a30268e44d2ca6de03198244176b8ae6fdfa390acd908e3588bfaebf8a00b6\", \"public_key\":\"044fdf3c7eb30892c8acee0a9a82d27c48d80e9f964f0b2dd73e323ea863d59e652bd608ad7ebb146d192bb4511291386e0482dfd53b725e62762a4f661eb80523\"}, {\"tx_hash\":\"1be02fd5d8ff79ff476c98e8579c03df39f86d4c84728a5dfbc16cdc970ec15f\", \"recipient\":\"18zCuxKJB3BrFuxneGZvqXuCK6ePn5uxJx\", \"status\":1, \"created_at\":\"2014-09-13T00:01:26.758Z\", \"updated_at\":\"2014-11-05T02:01:54.546Z\", \"private_key\":\"a0a043e6aba57c55b055c4c857592dec1f014c75cd0ac854f32ddb8da9a0f65b\", \"public_key\":\"040299b2fb02490b355ee39eb9e79121d4f571bd5f5f16ebf894b75de980565bc1db506c53daacad0a677f789f1b2eb954b1d9627f5ee6c5a2a77ca42a3e911a90\"}, {\"tx_hash\":\"d7f8eaa6c629835573b2ea32c2fff12e716f7ee715c93d758d7054bc4ee1856e\", \"recipient\":\"17kK2Yjiyx45UFcegEjoJGL6AbP8bNnHRQ\", \"status\":1, \"created_at\":\"2014-08-28T00:01:40.142Z\", \"updated_at\":\"2014-11-05T02:01:54.556Z\", \"private_key\":\"c4c4e7c28d2795b5d7648063211875ad0c0a3abcf4a10c802ee64ae9aed8b7fb\", \"public_key\":\"049658cc2fb59ed09123039eab6e461b0380ccd934036caa11376f35901a07930f8a6ade5992f0580d5d91c7d6a731ff63217822bfdfa07d413e31e8bf2dc66a1d\"}, {\"tx_hash\":\"f912b95edf2f3c27222e7bf5fcd16bc289e703332374bc6c06494806bb19721c\", \"recipient\":\"1EymstwppqpjDLnppAzzkaP4oRewC2WtFL\", \"status\":1, \"created_at\":\"2014-10-17T00:02:39.244Z\", \"updated_at\":\"2014-11-05T02:01:54.570Z\", \"private_key\":\"035f575db8c8bd332f1f908a53a987b9dfaf7c9e3ed311085074fd23f626abdc\", \"public_key\":\"045badecc2e5d81bebb546a50236623f044ef46f2831bab3bafc1b96172546bb3c2dfdea76c57dbd3ecc531c87713013e12bfbbfda5f704fd4890a68a2344d7d9e\"}, {\"tx_hash\":\"030c377b490360e39c8bb321d235ce04bce32a930d844033989c17607c1fa545\", \"recipient\":\"1BdRoLwdDTyg5pwi9t1S2kFova32Yzr2ux\", \"status\":1, \"created_at\":\"2014-08-21T00:01:45.354Z\", \"updated_at\":\"2014-11-05T02:01:54.580Z\", \"private_key\":\"0c6eff1e964346f3b543ebe212e6c9ff113a8de495f229b497eb20a89a3695d1\", \"public_key\":\"0446b8cc299cef980aa1666a535e5f666c566f1acdac7b29cef74f9f0c47014392234e9c845fc126fc00be4a872c47bd24cbd7a2dd56a172346090d087124ac90d\"}, {\"tx_hash\":\"a7d0a02d81ce67e33b948b22618358527a9286073bf0e9cf46e1c80865ebdaec\", \"recipient\":\"1NvZdFo4sfTGd2g6MEo3mwwWD9psA6DNQ7\", \"status\":1, \"created_at\":\"2014-09-30T00:02:40.948Z\", \"updated_at\":\"2014-11-05T02:01:54.594Z\", \"private_key\":\"4edb50ac0b02bdebe5055657dd68fb33231e14f2394d1d8379661bac688e6e01\", \"public_key\":\"04b0264941fe427e9b04d512d96c1f9ff92a15c1d2bcff404113234567735c8874e7359bdf36d233bb9bdd2dbc83df56b6db66af43e936392f6b600efe0562cd3d\"}, {\"tx_hash\":\"1cfe6f32d9ecd8467da2ef350cc12355744f3394b7263f1438fb0a0348261f9f\", \"recipient\":\"1JwkcQiauoeuRoAw3tAV8NsHox46zavWxL\", \"status\":1, \"created_at\":\"2014-10-18T00:04:07.895Z\", \"updated_at\":\"2014-11-05T02:01:54.604Z\", \"private_key\":\"faecc352ef229de2dae2d9510fe237ad36a5d8bc2b5dea60bc00da226ef726d3\", \"public_key\":\"048ec9fc5b33dff5adff761bf252a945f73080e30f625a21bbd38a7f3df2be3eeed87dc6490e8d381b77726bdf06da314786bf2aeac80789dca8055ef5b810e44d\"}, {\"tx_hash\":\"7351a3ecbf091b4bd26879f682cdd3e9a0d6dcf03046d006bbe955f0d7328cb5\", \"recipient\":\"17w1KLLKTRELdWjUTG3PhJh5ZNP9faNwHg\", \"status\":1, \"created_at\":\"2015-03-01T00:02:10.733Z\", \"updated_at\":\"2015-03-01T03:32:15.363Z\", \"private_key\":\"884880dfca250d8cd0c607986eb6319e1a9617600d5556522c78a6833849150d\", \"public_key\":\"036c26d790bb0e782731e30daa63af44e480345a679b9b737be247474e35bb1efc\"}, {\"tx_hash\":\"f97397d2ec383e005bd9eb92a7537f188fc6c35ca851d791beaca510275d3c9e\", \"recipient\":\"1Fzbp3xAjvLW3rsis7tBdhUHYhk62my6qJ\", \"status\":1, \"created_at\":\"2015-05-19T17:36:52.626Z\", \"updated_at\":\"2015-05-19T18:12:12.879Z\", \"private_key\":\"7c0c8efd19a303d1545c0b3ee0ed05664161d85acb3b1deff5acdab0e0885171\", \"public_key\":\"02752eed5fb60b4f95dd67c5240cc77921ba864770cb3f7f75c51d7412b7ee84e3\"}, {\"tx_hash\":\"8801507b6464f0c271b6dda43fd46c306bafe1e96b1e026ff3dc702916484ce8\", \"recipient\":\"1CXMpUCwgXsFv3kVuCWNKndLxdkPucgMXg\", \"status\":1, \"created_at\":\"2015-02-06T00:00:50.455Z\", \"updated_at\":\"2015-02-06T01:12:09.129Z\", \"private_key\":\"a8de9c1bc3bf8a07332e9b25e2eee8add878920846a7e3a6aa946f9b517305c2\", \"public_key\":\"03aa698fde8de43b212c6e57f9532b1efb56c67f7545adad7618991ddc19aa8740\"}, {\"tx_hash\":\"09ddafe9b2a44217c28b88c4b2b0b7a2fd5b058ccd4423e2c533f267fca34f55\", \"recipient\":\"19zViZWqcAk9hZ4FkvSgXTQ36TrMM29gdX\", \"status\":1, \"created_at\":\"2015-04-11T00:01:10.824Z\", \"updated_at\":\"2015-04-11T04:03:53.529Z\", \"private_key\":\"a3210c1acd783a1e24c47e0732881260b39e346b42fbbdd52a4bd309cdfaa417\", \"public_key\":\"035182a4caf20e1da94627f68e7aa7e8dda823ee91185f5ed270b123be28e19a9f\"}, {\"tx_hash\":\"97dc3f7272e00a2adbc36134861ad20f0c39a099b794781a896c585d66cc2994\", \"recipient\":\"1DJew7kboAeRf9ZvZsXkr7CdhNBs3mxuNb\", \"status\":1, \"created_at\":\"2014-09-20T00:02:49.930Z\", \"updated_at\":\"2014-11-05T02:01:54.635Z\", \"private_key\":\"519a4ee16346a70dabea5d162a0b67c3ad4e896eab530984bd3e9680c70190d8\", \"public_key\":\"04b81d677fc15206181cb1ccb76fb4645bf052e3563dd943557ace2a9889317a3d3a32c59c3973f635c29bb5c470ae3d9ad32371f7374f1df14004553d65011643\"}, {\"tx_hash\":\"6e77511b73eb74999f1baa1da4c01f05da61362dcbb2a5b92cf2bfc9ba80a833\", \"recipient\":\"1HJdTKwaMiJTJg2qSWkAaR6VLAoQfZFo4j\", \"status\":1, \"created_at\":\"2014-10-19T00:03:29.701Z\", \"updated_at\":\"2014-11-05T02:01:54.664Z\", \"private_key\":\"7baa4771cfe5cd3f209ed1258143a90caf75ecc19a8ff03791bc95ebdb3af852\", \"public_key\":\"043880c7c5c845f0c3e30bc96aef02eb1b5a48a25737497753e191ddbf720ad22f266607f9564f369f60facc02983d3da27b899a2eb9e9f14c35f89019797a8dc4\"}, {\"tx_hash\":\"d10225248e5742e0001196eefef871e2abc6ec682bbb547449278c053e87f4eb\", \"recipient\":\"1GscL6FtdwR8HCGtntanruiUgx7WyaEKRp\", \"status\":1, \"created_at\":\"2014-08-09T00:02:52.005Z\", \"updated_at\":\"2014-11-05T02:01:54.674Z\", \"private_key\":\"47852849244f7bf6140f0596b6adbd83ae5c867ac92d41df5cbf71be487a3c1a\", \"public_key\":\"040559134da2ad53bc6474013b7a6027b0ac55cf1fc57596a85d27abe2d658147b0f904af77ba6a86323641c57c61491dca36e8263a22399587c9a8a7c1af055f1\"}, {\"tx_hash\":\"5f8636d47e297945df2152d366f4addffbf59a1f34ed23599509af5918e7c8d6\", \"recipient\":\"19cEFAbviq8Jn8wnkhC66RfVypq21QmBL2\", \"status\":1, \"created_at\":\"2014-09-04T00:01:21.963Z\", \"updated_at\":\"2014-11-05T02:01:54.684Z\", \"private_key\":\"8859fca82b92c241f3cab9d26574cd6a10e667ed3d4313f396be5da4b878fa99\", \"public_key\":\"04b582355d1b27cc55ebe27f83c01ddcea0c905c1e87c7dc57a03fc84d1fb0c59e4033389bcd4cb7f77ba31f37e78490494bbdcab311b5bcc241d61927b42ddd41\"}, {\"tx_hash\":\"87dc93e880ef54fd656d393b071de5ae248f7d6d16dfc64ab681d76a3a51637e\", \"recipient\":\"1KX1Uj6wZ3XvbVQ8JZuERwjNTPdQV1NA9A\", \"status\":1, \"created_at\":\"2014-09-09T00:02:16.514Z\", \"updated_at\":\"2014-11-05T02:01:54.694Z\", \"private_key\":\"cbbb27956f2f47c7aa26c5e43e9e84d16d3feb0c14fce3710d9f80646c7e7b0b\", \"public_key\":\"047057be7dcd4e65023fe562ef1bdd025780c74d943d7ebb9e9e7d1b1e37cefed29147ea38cbe40eb343c4400193e85bb24796320158f33e11a387fb5e3118c8e7\"}, {\"tx_hash\":\"4da9a8e99bd107aef496ef7d6a082ad6f0ad40ff3555ac79c7e88b4513e38dba\", \"recipient\":\"183RdFzvnR4iDTYxfDCmuA9wG3F9AMHNiP\", \"status\":1, \"created_at\":\"2014-10-24T00:03:15.523Z\", \"updated_at\":\"2014-11-05T02:01:54.704Z\", \"private_key\":\"785c803685686f21e964f1bf790e830fa23b3ef4618102aeaa5ed371d24e2e24\", \"public_key\":\"0465468ad86e12aa95f17bd2504287893c2fd4543915b84518e689261cf363fec4d99a858e94e1e40c0407ee12dad516207c4e2369237af1d8b863f89d73a3bf08\"}, {\"tx_hash\":\"49f2c9c84e1176113b6e5a8072c26a664eae697155b059bf5b0369823bf6d59d\", \"recipient\":\"129FhScAaPJrMhRVDQR6gUj8mQLYrH6u9r\", \"status\":1, \"created_at\":\"2014-10-25T00:02:36.246Z\", \"updated_at\":\"2014-11-05T02:01:54.720Z\", \"private_key\":\"0b5ea59a99945b5383d689f0ac03183da4024f1a5b559270098b9f7dd9f70373\", \"public_key\":\"04b3c4c1df0282c25145312ea43be414e2f6c02b02c0f26991a52b681aa711e4d970afcbb7c84d5d297d2d4c6058bb723cd4d770421c34a4ee281694159ee6d7ed\"}, {\"tx_hash\":\"8be98aeda1900f4c0dad61489aefc1319d6739213a82af48c46152aa8a1748b9\", \"recipient\":\"14csJV8qA2JxqqycQRsGWEipak8QyGpsyE\", \"status\":1, \"created_at\":\"2015-05-20T00:01:16.616Z\", \"updated_at\":\"2015-05-20T02:41:24.667Z\", \"private_key\":\"4f0fb12a9df1fec00c0a79710043335c0aa8a03fcc3bed9a68111a2e18ed9fe6\", \"public_key\":\"034a4f186050363a7f351f32d79f0d5b4bd7d38ef75e82f4a28238467836575c32\"}, {\"tx_hash\":\"09aff87f6f8470af69fa7999fe1c8c57ac3bbcb27632201de4fb4d47b01cf434\", \"recipient\":\"17w55VgkraGP7ePuoi8R51VGXUz6N2VrMr\", \"status\":1, \"created_at\":\"2014-07-13T00:03:11.848Z\", \"updated_at\":\"2014-11-05T02:01:54.741Z\", \"private_key\":\"b4b6cff7107aa5b97403d3d8f37925e11cd2fc14651ae79177c7494e201a299b\", \"public_key\":\"047538b95e4cd45e3e307c90f746cdb3268ef5c652b34816136015ad916e2ade8c9be930a934510ba7cd153dc2a61d43ec4897b3832bb1d30d8bd9ed7b64a0d2d8\"}, {\"tx_hash\":\"5faa33de1954e3d3e7a86dc2b3382cc4bb34467397bb1fb42ea6607a6eccd985\", \"recipient\":\"1Jhh1fiPXujNKyQXx4Hp8HdrjUvNJNrsPw\", \"status\":1, \"created_at\":\"2014-07-04T00:02:40.993Z\", \"updated_at\":\"2014-11-05T02:01:54.758Z\", \"private_key\":\"4de6f506545918b145edbdbc421a282c81e2dadc7f2291cf47862dfc125a410d\", \"public_key\":\"042bfe600ab4286b391950c2d37ea5e87e68739e73e303e43878c254ff1f367d0bf6790ebbab279758e88ae4881c1951ae627106022b2c20033853a39b980925f2\"}, {\"tx_hash\":\"62e706ab68ed837ad1bcf46af3bef4332317e4d207a8e3baeac281a64e964094\", \"recipient\":\"15nW73dJdqnJKyhwF2kT74631LxGMtxrws\", \"status\":1, \"created_at\":\"2014-09-22T00:01:16.469Z\", \"updated_at\":\"2014-11-05T02:01:54.776Z\", \"private_key\":\"1841e377e2446520edf13af406e6fb6c238436013f4395a3ccaa5240e157d112\", \"public_key\":\"043f22e8c99fdbb8976922d663bf09e5800be21dddc559fa1316f71ffa3efcb5f0eb6f7ee2e8072976801f75b05860ea07e5d42168e5dacf4890b2712ba83455b7\"}, {\"tx_hash\":\"bf63f9301f6c44b64b37bbb1f688d7e9e6dbdd0aeac00acc3416d75248d25d84\", \"recipient\":\"1Gu89n93x7ejfcFaEzqqcnSSv74dqfATJ2\", \"status\":1, \"created_at\":\"2014-09-18T00:01:30.745Z\", \"updated_at\":\"2014-11-05T02:01:54.800Z\", \"private_key\":\"0fc0cbd3ffe37870fe3e6843fc67c50c78f869b2324dcaf58c04beddaa3d648b\", \"public_key\":\"044fddae95623392f70022c374218981e71114b10bfc9d100c5fbd98b399bd5fc41ad822cda681ee917b9db27c8a91f2a0751c609bcc6869d0f5b3a3b4fa1e905c\"}, {\"tx_hash\":\"0a4c0eedc64788e0bd7bc5b6f904db320ccee05bab4bfc7e3768ada9c65db7b8\", \"recipient\":\"1K626vn2b75F7E6ga4BT6NGfBJLgRy4b2a\", \"status\":1, \"created_at\":\"2014-03-06T18:12:18.631Z\", \"updated_at\":\"2014-11-05T02:01:54.811Z\", \"private_key\":\"fc3e9814eb060484215c34fd1e10f1b3171cb96ff59558fb82326af1a91ac57f\", \"public_key\":\"04d66fa4be986e483c0edbd3ba93c38e3278c35f7365234c6a7378def8ebb5ed860864c04a939b702235011b7b38db4472209a8779aef7e41a8af6d89caf614dd9\"}, {\"tx_hash\":\"f2dd148488005569176b02106d53800921a45b253b85b3266584e791e7ce8dab\", \"recipient\":\"18qJB63Fu25HDJEnPhvyJoHzV95q44tawR\", \"status\":1, \"created_at\":\"2014-06-20T00:02:59.970Z\", \"updated_at\":\"2014-11-05T02:01:54.824Z\", \"private_key\":\"96c374dcf205300ed9c04de5858ca0c0110aab5c9e170e5a703ae871d509b017\", \"public_key\":\"04b607851467785e3a4d30cf25e97dc90220031fd5406c20158cbd32f11a2e9fa42f078c267bc1779188c6ece48cebd38cd1f97f4d6601365a12749dae4def34e2\"}, {\"tx_hash\":\"22d7711d3700984fe0f9a4b24ed6d9f0002d92e186ed70a004c03eee4a0d8878\", \"recipient\":\"1HSrRGG3xTTgXSSGsAJbNCrEQpuKajXSrG\", \"status\":1, \"created_at\":\"2014-06-19T00:03:08.596Z\", \"updated_at\":\"2014-11-05T02:01:54.834Z\", \"private_key\":\"ea346c391198643d32fca75f81aa05f04b335f2c379064c085367ecde5abe7ab\", \"public_key\":\"04702fff5f942fd55f26b09ae33f1d65b8a06c1ab5f414bfe724ded05a5dd34d1634f7618a4b62b825f1b85a099b53e0e7a03358dbd845ffb01ef836e17d5c47f3\"}, {\"tx_hash\":\"7e8a9612907c313ecf112d77c8728e7454809f74db005a5d95f01a699c2a2244\", \"recipient\":\"1Mbrt1KyLjjNbfht8uHvgZCRBAwBmeHRYz\", \"status\":1, \"created_at\":\"2014-07-11T00:02:53.893Z\", \"updated_at\":\"2014-11-05T02:01:54.882Z\", \"private_key\":\"29811d0014b32c6f92cca913bc6d1d96a256b4f299d7678729788cb319819f4e\", \"public_key\":\"04068ec6ee337d8e0a0720b7eb43465f0eb880538e2b46ef4379661eb849650de02bc9d80a3ebd20aba8e478fb93381451fa839afb37c6b4083e681e97bc42d25f\"}, {\"tx_hash\":\"1ced7a8bb16d007989137638f80c2e7e98f3693792fdf6ba10f67fc5800d66b9\", \"recipient\":\"1k8ZH4KMF8jjNhiZqpH1dAc3TCdPoWtFz\", \"status\":1, \"created_at\":\"2014-07-06T00:03:46.146Z\", \"updated_at\":\"2014-11-05T02:01:55.071Z\", \"private_key\":\"261effaf3e3f745f1d193e8aba7ad2e18159ceb28f93b1d7000c5f9077a6503b\", \"public_key\":\"04f232b0dbbcf34b9d1a43d02452d514077f9654a3914f24d810570317bed745f3923de9c6b100bcd970980a93a3abcd5ef3cea9308ec0e137d68c7ab43d6ca8a1\"}, {\"tx_hash\":\"1820a8227530e2de48b6f8901239ab9bfb2bef14ce8e82c32650236b197fb5c7\", \"recipient\":\"13sQenmSSWutGBf531Vfo6qihS3VgyHx6s\", \"status\":1, \"created_at\":\"2015-03-02T00:01:18.650Z\", \"updated_at\":\"2015-03-02T04:21:43.443Z\", \"private_key\":\"5746d6c6a4164532d92d723a9822d57f1bc351e27582307fd4b45dae082dd58f\", \"public_key\":\"03b1a81a23a4a2afcac9830c083952981c0574301faa544d40215fe3e01f6c2f1b\"}, {\"tx_hash\":\"6833db89c0603cff2ff8ee9b3cf4a1cb0274566b8c432fb79b16eeebcb3741f6\", \"recipient\":\"1JwjA5kbMBHw94vBRib2cSu6TNcYh8UQfC\", \"status\":1, \"created_at\":\"2015-03-15T00:01:12.338Z\", \"updated_at\":\"2015-03-15T23:11:50.287Z\", \"private_key\":\"ff6433b2f95877aa9daca09c684282acde5f3974f0e5397c2d2af2ae4e0f0e68\", \"public_key\":\"026c551486a9ff9f1c669ff2caba547eb76d5f0fa070d4a3de242a3acbc66f669b\"}, {\"tx_hash\":\"f1b9e9017b97007f4fcffa3b7704da134d62c2db6d53f0b3ba236bd88c599a76\", \"recipient\":\"1FQ4TEV3482bmV5dysx4fBbkMhF34mMvzN\", \"status\":1, \"created_at\":\"2015-05-21T00:00:34.812Z\", \"updated_at\":\"2015-05-21T04:51:34.994Z\", \"private_key\":\"6a29c8f3b9ba919ff0ecf70e1f7992a01df88a7339032f6a980c6154a5124f7f\", \"public_key\":\"0240f4979b453ed4c0bea334f61b4237c705774d9b3b1aaef77caa19b9daefda1b\"}, {\"tx_hash\":\"d9341c7ae399a33f05f3c2061fdcd1674857bd244aede6aba86b00b202b30b6c\", \"recipient\":\"1BTq9R1V4txJzDHAAcSifDM4FopS4MNmos\", \"status\":1, \"created_at\":\"2015-02-07T00:00:26.651Z\", \"updated_at\":\"2015-02-07T02:03:43.065Z\", \"private_key\":\"26521f64c33d8d9ebae614282c0ea9324c5056c3c4106b4ba27913258b844668\", \"public_key\":\"02ea48fdb9ef5db8eab5295e752c50e24c84f510563b4e3c06a0834630dc4b34d4\"}, {\"tx_hash\":\"d6c6ddcb450e1434dfdc4717b771d25c0c0efad04e7ab6946cadae496942c445\", \"recipient\":\"1PF4wiajPbdfQAwFs3qn1YAXNAtXiWdc4R\", \"status\":1, \"created_at\":\"2014-08-05T00:01:02.573Z\", \"updated_at\":\"2014-11-05T02:01:55.138Z\", \"private_key\":\"f733bbb38e1be6e7b866bb3fd6e3808bc5e042ee62b4e063ef2a8214623fc927\", \"public_key\":\"045769c85d840c4e3a5c84294993c702a9d4e92a507bbcbc436cdaf9266fec70bbf3070e07a1dea60f025a00e36b14d16b02749f6789527bb9d73e97d087d2c114\"}, {\"tx_hash\":\"a648ca92a6a620cbda3e7dc59c4542269a8c0895a3ce52443c445ca507ee702a\", \"recipient\":\"17wUqNtW71HeJTRMYX5WZZiZC37FaCwyQj\", \"status\":1, \"created_at\":\"2014-08-12T00:02:02.109Z\", \"updated_at\":\"2014-11-05T02:01:55.288Z\", \"private_key\":\"c273ff88dbca1268de687fa4f462b306ef13d2e9d04e3b2c4715d88152783673\", \"public_key\":\"04f3c75af55d75eda66d6d1cc5ec2d14ea5340aa536ae7f90ee0af8d9f81284dfed82c7453334fb53643358d88224e50d6a1a1e53c949c95228e90786c8f8a5c52\"}, {\"tx_hash\":\"7825d568ec2485d01bb0a857e91fa49c849d0f14bf3ba00033eed9c52347959b\", \"recipient\":\"1JEvnUs6xYdSFszAfypnRFmCTqvarUHmyb\", \"status\":1, \"created_at\":\"2014-09-05T00:01:10.782Z\", \"updated_at\":\"2014-11-05T02:01:55.307Z\", \"private_key\":\"f94bd823a1c83a77b43433b4a190dac778590a356807023dcef8ce7ca023af4f\", \"public_key\":\"0485e233448113bd8787fd8ca8938d15549f0833cf7bd386db7c5a69b3007c74eaac1fc99f6132b468f1b90bd078ad375e4ed75e0572c28d8e1305ad9710dc4e87\"}, {\"tx_hash\":\"63186ca40ef1330ddfd4c8b2c283a25726b6122e78810e4d28fa6702939e63cf\", \"recipient\":\"15VzZi3gFGLMxfFUvq7YtAD94sYWb2ppmh\", \"status\":1, \"created_at\":\"2014-10-07T00:04:18.578Z\", \"updated_at\":\"2014-11-05T02:01:55.318Z\", \"private_key\":\"65377ce7139db85ed2ae8d27d4bebae3aabcab1ab0da62695365980d8dd64ce7\", \"public_key\":\"04b8d311affb85b189403d8a97690f926d20935aa828b8039c4b67ff4122a4e17b22003a4258ae5d35b6e8b79db7a06fceb658f3b55c3b1160493e77592f060d45\"}, {\"tx_hash\":\"4219480d1f44541eede61328b015740d4c197d6b798581455612af034171f5f8\", \"recipient\":\"1Jiz6h7uZBf7qNim8gsqR77jSxT6fPRJAQ\", \"status\":1, \"created_at\":\"2014-09-10T00:02:07.158Z\", \"updated_at\":\"2014-11-05T02:01:55.328Z\", \"private_key\":\"ede5155627a5cf05ad001e84c4aecc1d709c27d0ac89bb8c2b781ed3fba4e7c8\", \"public_key\":\"04af3bf26b9ba3b5555495a32680dea84412e99f17b2d5bfac9800810e6db1db31f6188467ecbd1b36d8169240a32279292a00a5aa957684839d219046e71683b8\"}, {\"tx_hash\":\"c8d18a04fe3986a2f67df0a59a92870931cd83a5e804cb743db25008de95f13e\", \"recipient\":\"134Yg6CsVgwXvHYuRrFn4HutxHPutVdDew\", \"status\":1, \"created_at\":\"2015-03-03T00:02:14.707Z\", \"updated_at\":\"2015-03-03T05:12:59.529Z\", \"private_key\":\"f27300e144b975e71df6cf6f4741350295f14b325c08b52866e94d2d7eaaa96e\", \"public_key\":\"0205fd465f833a50163298f614e3a84fb9ec55bdd3546b7035bf73b4cad7a1ef55\"}, {\"tx_hash\":\"c859873bd52b52b4f2e1e33eada6c5695a23ad1d2812966e17bea24e27a4e1d6\", \"recipient\":\"1N7zsioZcNvYV8fEuZgqoZgp4sBKaCmK8F\", \"status\":1, \"created_at\":\"2015-03-04T00:01:27.787Z\", \"updated_at\":\"2015-03-04T03:03:56.466Z\", \"private_key\":\"671f0e00ec446fa3be79bd3f7448185c0dc9b2da54971e06dd6cf1d30e4b8336\", \"public_key\":\"02e5662b021aaf7308673b5654e6c04815c6ade57ccc334f9a315a0d0007c557cc\"}, {\"tx_hash\":\"4aa383e4de6f7953fd0034f7c3d4b8560b3d4413830ca9c3951be7148f474bfa\", \"recipient\":\"1NP6YELeLM8rAvcaTdWd488zGxcKMdu8HB\", \"status\":1, \"created_at\":\"2015-03-05T00:01:23.190Z\", \"updated_at\":\"2015-03-05T01:32:01.215Z\", \"private_key\":\"3b1492ad54e57e09098710fc5d7443adf676cf4a9c3fcf5550b1654f3e72c609\", \"public_key\":\"027e995c8e959610fd3be6cba16e5972adf0470bd11eb0e4a0916e4d34658b20e1\"}, {\"tx_hash\":\"df0044bd6404470a20248f7c324865abae7cf55203329e96fa8d38a40704d40e\", \"recipient\":\"15vNTK3VGHmNh4ZXKxGcJtW4RL7HwrW3hm\", \"status\":1, \"created_at\":\"2015-03-05T07:01:23.044Z\", \"updated_at\":\"2015-03-05T09:21:32.063Z\", \"private_key\":\"22eeb3988058fa7bda7332ee30692fe637838c9092308b69aa0cd040b1fb6613\", \"public_key\":\"02a83a7bc42cba465a807eeb597a5feb8587de54c2ec1b92b0ed96c0c235ab619d\"}, {\"tx_hash\":\"ccedc74c3489c0943e0de27d7fc969e736fadd748b91b9c30874be10abbe8031\", \"recipient\":\"1JFNFsMNmPKXyGvzkcmfgEhAgeB59cPre3\", \"status\":1, \"created_at\":\"2015-05-05T00:01:01.506Z\", \"updated_at\":\"2015-05-05T13:02:49.422Z\", \"private_key\":\"9223400e89a60d46457faddd277f2875a7a41695dddd4668b6d64b92eaa11417\", \"public_key\":\"02d3aef03f6f4f67ff805b1075b8c0d2853c07974bc519bf7febdc18a84e6ad6d8\"}, {\"tx_hash\":\"610008c9614a4e60bf0e13649e67a0160faaf2fdace74db1d58e34d8069cf7fd\", \"recipient\":\"14CvSMCLEqcEJXfyxQ15qP4NHPQEsuTEyc\", \"status\":1, \"created_at\":\"2014-09-17T00:01:45.324Z\", \"updated_at\":\"2014-11-05T02:01:55.413Z\", \"private_key\":\"9b03b25e99248eaa5aef1d54fc271eb218a369c327f8533421a5d8cf26686274\", \"public_key\":\"0409e67609b9c75264dd5affb4c8de48ac791ec259d8e5dc879ee826215ece729bd694744bd11dfd5c10fa4889e6aca3b190ce9b146e8ddf893006bbcba020ec47\"}, {\"tx_hash\":\"60ed5cf4eb7df8fd5440253b6ac9f38ee475b613350b849a1b84f79e2c7a3be5\", \"recipient\":\"1HdE74JRCoRtvabShnrVR6W33g7n7kN5bm\", \"status\":1, \"created_at\":\"2014-09-25T00:02:36.163Z\", \"updated_at\":\"2014-11-05T02:01:55.424Z\", \"private_key\":\"7a7e71a6f49ae4494385a06d0d4fa38e86d4cdfb7952ca32dddab14c906ebf1a\", \"public_key\":\"045c8dfb7024a8051742f11abe2ff065f391e2c610a04ed5904be840ee8c16c366dd9d4d12fd5be0381cabb7b7df720f8bcfa3a174d59f316793c414b320efded3\"}, {\"tx_hash\":\"5b1cfb278417b9ecca5c0abff5d82559d68cac6b3c0957ed4662fcde49e9bb79\", \"recipient\":\"1LTLoErGNyJftJiKNhx7f65yeP6GDe2C8i\", \"status\":1, \"created_at\":\"2014-10-23T00:03:01.135Z\", \"updated_at\":\"2014-11-05T02:01:55.435Z\", \"private_key\":\"09d23429a479e39bcdfc711730dd6eb7e1c5b765aac2f3d034619201e4264f59\", \"public_key\":\"04d49ece397f6b7044bbc44fc3f72ca15a611df51836cd240cc6a57af07c74ae530aa8ab4f9f6244d31bdf4aec82893dd089d27cc0bcc63536fd8fbbae5c539f9a\"}, {\"tx_hash\":\"c37c292036ac8e53f45df7b1d579c991a14d71dda38e3cda127f3b9e6bc5dd28\", \"recipient\":\"13MAP4k1pemMJSy37Gs1bDkuXebQzBHDft\", \"status\":1, \"created_at\":\"2015-02-09T00:00:31.189Z\", \"updated_at\":\"2015-02-09T13:03:50.510Z\", \"private_key\":\"dd26ab63f38185cd1310da50e164baf5e27af2078c75395c7ed78372d534dc35\", \"public_key\":\"03b508d8e8b7d64fcf1620cf0602d14af6c00d1bf06682ee78bbf7b5817cc7383e\"}, {\"tx_hash\":\"00e4789a46c033dae3037037617bc1f0dd2f93c0560cdbcd8787cb1168ede56f\", \"recipient\":\"1KuNUh1cZvYpmj5S4SRAVSPWT27jUfybvE\", \"status\":1, \"created_at\":\"2015-02-08T00:00:40.432Z\", \"updated_at\":\"2015-02-08T01:12:05.179Z\", \"private_key\":\"60b68a30a07c07e2fa9f852b4b5e9fbd6ddf27dc4728c01a9b77b325dd557612\", \"public_key\":\"029402debd8ca3cb858a99b4c9dcd6f8bbc2d8bc6b6cb4e76337ab62819c0b46a5\"}, {\"tx_hash\":\"da52e261090e4fb2cd27a4b3a03ee3f5405439ed6c9c879a6adf6547dd30fe39\", \"recipient\":\"17xca7Da51PXG1R3Nn3nodKvWxC6HUEmwb\", \"status\":1, \"created_at\":\"2015-05-22T00:00:51.136Z\", \"updated_at\":\"2015-05-22T02:31:58.591Z\", \"private_key\":\"b1f146e21f751318654878360f3e1d44b39bf06e2af26cbdd343433721dabb33\", \"public_key\":\"030ed7179533823c47bae40148ad91044fcdee10d430a33dedf552fdbce9436314\"}, {\"tx_hash\":\"e6f168271eb096f8531eeeb8a7ad7f7013c5aa0b1a67c811530e9ea9ce46dfbb\", \"recipient\":\"1NgeXp6dcody7TmUJGdMJ8yV6bAZZwNp7o\", \"status\":1, \"created_at\":\"2015-02-10T00:01:15.427Z\", \"updated_at\":\"2015-02-11T00:32:22.795Z\", \"private_key\":\"ffe8d109ec414a605eeee0eeb5b8e89953b8dd8df9688ebfb80b835bf6deb626\", \"public_key\":\"03b5c5f211c8b9952f4fb2d2bbf74118408f25258b015adc268bd121041cd8455b\"}, {\"tx_hash\":\"2ffed5570f19bffb44893b93b29d5e83dd123ca2867bd7aae3437a66b8315d6c\", \"recipient\":\"14ek3CPMHb1J5nAWcWhGxjWNqehd11Pun8\", \"status\":1, \"created_at\":\"2015-02-11T00:01:12.172Z\", \"updated_at\":\"2015-02-11T00:32:22.423Z\", \"private_key\":\"e58ee5ff166bec6c58c482b76643d5004d099efba35f281b8c264e9dbabc7309\", \"public_key\":\"037e6f5d1ff85c72abf220990e825e31140b50d26aa1ca2aa633aebac25295bfe7\"}, {\"tx_hash\":\"fce90aaef1c40c8af54806e65521c1394d2ff2b132e1e03b1ab89f87cce9ba89\", \"recipient\":\"1EETrb2TDoHFYUKZn7vBfC7mgfVReN8szA\", \"status\":1, \"created_at\":\"2015-02-11T22:29:03.282Z\", \"updated_at\":\"2015-02-11T23:22:08.636Z\", \"private_key\":\"5f9285bef116b31a4a366d94b8056e765af3a10601dc9733deb19a0fdd655947\", \"public_key\":\"0281526a9ed56e5109d5884bec310a8a7e8ede472d20bbade177cf2b8461349e14\"}, {\"tx_hash\":\"7ba5c520cd592957a5fbee281b640b26a1ba0ab87110c7a575690a0a7169e2ad\", \"recipient\":\"1P19fwU71UiP6UdYrhqXpXgKK9uZ7U2KUi\", \"status\":1, \"created_at\":\"2015-03-17T20:21:18.737Z\", \"updated_at\":\"2015-03-22T18:25:58.264Z\", \"private_key\":\"5f6afb0031c609461646a39cdbba2f95bdfd14c722beb4c3dba2bced89be1251\", \"public_key\":\"0226e21828099b0bb37ca26f1f51d8b4bbc896f8d95b34e90652c4542de8f3c1f4\"}, {\"tx_hash\":\"69637167f28291d8aa121614a47e82437fbe61c1c789b07566cd7e89cb53bbe5\", \"recipient\":\"192FGXVbLFXyHL5x7nYakAP2e1Rs5f3nWt\", \"status\":1, \"created_at\":\"2015-04-14T00:00:26.323Z\", \"updated_at\":\"2015-04-14T14:32:22.890Z\", \"private_key\":\"aa2835ae1b08eb6fd355d31862f6dbfbdda50e255d9ad3bb59ae8dfbbe3c99fd\", \"public_key\":\"03477fd4b6f3f06e92810eb4f2dbe1a851e92669c76099a68e90e84acadceb9fa3\"}, {\"tx_hash\":\"85a5b7ba4b8cbf31561251a1497a5ae87025be746d22f30a688e79820df64751\", \"recipient\":\"128q5ggsK1CKzJuypLwMZEcj4QwyAyYsb4\", \"status\":1, \"created_at\":\"2015-05-23T00:00:58.432Z\", \"updated_at\":\"2015-05-23T05:31:50.072Z\", \"private_key\":\"be818860297168ebb6d9b376f7b65e88b73763ef9b9dfae523598588b960dfe7\", \"public_key\":\"021d17b4cfb7227a53fcbd89c64504946ad819c4cea4295b4afccc5b68396471c7\"}, {\"tx_hash\":\"e31f22e1bbd2ba8fb9cfca379bf14d81e2a0e27404513fd627658c7afa128d84\", \"recipient\":\"1ASh51xLdLTY2Z2kXKNv4r1kN2a5Z14XL6\", \"status\":1, \"created_at\":\"2015-04-15T00:01:14.815Z\", \"updated_at\":\"2015-04-15T14:42:02.003Z\", \"private_key\":\"6e1662cc0e63c55672d277a15b9b9d1ebe0be755a7d617173c32a6a9d961c75a\", \"public_key\":\"02c836f0a5c5aa0ac4979cb7ece57357e0e351968b76ba7845498f9b3be8c6157b\"}, {\"tx_hash\":\"c6b2274f27896e417929ae81b1d8b726396d90bcb936779e5a6333ba644f4550\", \"recipient\":\"1K4o3My8VfAwzurMYt9FX1oCJiw2kS92iw\", \"status\":1, \"created_at\":\"2015-05-26T00:01:00.661Z\", \"updated_at\":\"2015-05-26T06:51:22.413Z\", \"private_key\":\"b9abb2181d70d4637e39f43081c01f80fa7732024d47daf3dc14a0771d9d48f1\", \"public_key\":\"03fd031351158d94ab243d96475344e87ef4705d4bc3c7f6a14b8f373b6464ecd6\"}, {\"tx_hash\":\"83343c039915885b1f4038527ff33931fc2c7c3e496a24a53377141313dd457b\", \"recipient\":\"1LjmYYrbPuoSmb7xdRsghZd8ws1trz6uYp\", \"status\":1, \"created_at\":\"2015-05-24T00:00:32.908Z\", \"updated_at\":\"2015-05-24T02:11:49.871Z\", \"private_key\":\"4dfce2005cc77bc5d1f31a74be715f65c398460e50dd14ed9869bf3e7833d673\", \"public_key\":\"03c111c14d15cfc305e53055640b9bdb1869cd1cc9108e3a9c492856bf0d1152f5\"}, {\"tx_hash\":\"1f4065055093d010042577f05747abc10824880242e7cf2c83aaa64c11fa4480\", \"recipient\":\"15gMq9qEyDWrdAvmMidaCLcvL1oxRpP2DF\", \"status\":1, \"created_at\":\"2015-05-25T00:00:48.974Z\", \"updated_at\":\"2015-05-25T06:51:33.537Z\", \"private_key\":\"62d45b39e228d1a95a4487bdc710bbe6e961a858c5bee4ca5b3d7b947d6c9d0f\", \"public_key\":\"03ed2af19cd3b3632d13cd103427eeb204fa67406b44a34866a7a5d93729d4af42\"}, {\"tx_hash\":\"4286ba63dbf5b0d8a5371e22e39fea93655f5f5df7c736ee90aa1efe5f88a1d6\", \"recipient\":\"1JenQeTcNfFn7Nak52PfMNiXUvJsMftHcD\", \"status\":1, \"created_at\":\"2015-05-29T00:00:26.911Z\", \"updated_at\":\"2015-05-29T14:03:00.926Z\", \"private_key\":\"074fcd7a780a7739fcdf6002c22f6288ab01487f525fdbd758d178f1e2a9a37e\", \"public_key\":\"023bc7c71d9573a9a8cc90baa45696d19a5f1c735ad6174b37b2e4647f9ec33825\"}, {\"tx_hash\":\"c34d5b08276f93a1c028f20664c052551700db7109433a9411eda12400c4cb39\", \"recipient\":\"1FdR2QGCLvZVcF26vArJRt3X1wpPyNJ6Ao\", \"status\":1, \"created_at\":\"2015-05-27T00:00:52.694Z\", \"updated_at\":\"2015-05-27T10:02:52.082Z\", \"private_key\":\"7680856b28d67c106f47cf60f4e2358add6f219c84a4112b04028406657468f4\", \"public_key\":\"02e41001d101a12923921ff3b056700e8ef5b1e38d68538f73108273adcc9f9aaa\"}, {\"tx_hash\":\"a7d4eb81767d73f97944fec27ca0034140370ffa5947ddae6df7a8102889d7bb\", \"recipient\":\"1EMD8PuWR74KASVpL8kLLj74iJGhcBWQK3\", \"status\":1, \"created_at\":\"2015-05-28T00:00:29.181Z\", \"updated_at\":\"2015-05-28T05:03:28.627Z\", \"private_key\":\"500c343ff9e75ed57e1c94d5137f56e5e84b69abebb737729786dd7c8d14e1c3\", \"public_key\":\"021eb0862c6d3380387654d43c4122a9516984343886f4099c0df3a16c92dcda22\"}, {\"tx_hash\":\"7fc82e3563429340e8404d1f4995503169e51d36eeaa957ffed5b93e09878de8\", \"recipient\":\"1NTjnNNzSeyys1Cgx3r3Es1fCFTHARjEW8\", \"status\":1, \"created_at\":\"2015-05-31T00:00:53.040Z\", \"updated_at\":\"2015-05-31T11:21:33.999Z\", \"private_key\":\"2e8b4e0c67e5780d475e1bbd052308743b05ba59dcbcbc4aa28f65b2cf22f8be\", \"public_key\":\"03fa110a3e3a2e982b0eb33d338c46c6b89fb8caf09580a2a9c05e102f2cd677c8\"}, {\"tx_hash\":\"de5f0b9034b658a24ac062d9a31c382cee30a8316781382321c5baa5298823ed\", \"recipient\":\"17fv7DkQCGEPeJPY92BpXQcEeugVKVUUWg\", \"status\":1, \"created_at\":\"2015-05-30T00:01:12.794Z\", \"updated_at\":\"2015-05-30T03:32:00.344Z\", \"private_key\":\"03da981ac54d847be21ab01b95a0c5527b4e071e8b1efdb6381bbd3fca5a8eb9\", \"public_key\":\"023ddd316d412ab15431f9c3e3819b7d810f3d006f7124b345211a9d8c342418ed\"}, {\"tx_hash\":\"f4e00063cd010063ef8ee04e192b609b5822f7ef296a59fd9ed31ed3a7cea3f6\", \"recipient\":\"1HqmRrfKtmLbfug9oTbXVsUUAqWgMxMHX9\", \"status\":1, \"created_at\":\"2015-04-16T00:01:19.301Z\", \"updated_at\":\"2015-04-16T04:03:16.440Z\", \"private_key\":\"14d3129bb9dc697fdebee99aceefd78d8f07858cc3b5451a28a705eb0a565ab6\", \"public_key\":\"0210bbb1bd44afba9a1d8a4e4324e7bb62a3dc1cf9ac9b7435efd7f8adef176815\"}, {\"tx_hash\":\"e4638d4474a25588230d6575e76300f813853283cfd473a5e290259651b85001\", \"recipient\":\"1Ga5W1Cwi6ss5cNzwJNyU1GHPkgj4NBgxe\", \"status\":1, \"created_at\":\"2015-06-01T00:01:18.431Z\", \"updated_at\":\"2015-06-01T07:51:32.206Z\", \"private_key\":\"1db5cf6bf3041069bf2ff478d6b6ddbcf20c4af40550c6f36bc2e441deeb9c99\", \"public_key\":\"0262ea29c8cdb20534882933d0c4590e5100c9c834cd8eec35a2c681a284d3938c\"}, {\"tx_hash\":\"f143abba8681b940a49039520290d2551dd4416770d2fa26ced8a5196c51fcb2\", \"recipient\":\"129wcuqbcxEcqUZNTjn2Xd5qEryvBda4AC\", \"status\":1, \"created_at\":\"2015-04-18T00:00:58.014Z\", \"updated_at\":\"2015-04-18T08:41:32.317Z\", \"private_key\":\"4085a150d3654c1eff2442a35ff631f778553b58a64ceff89eb9abf18b4333ff\", \"public_key\":\"036047ba8879f8defb4f841eb7deae9c5ba5f39f98389a1294eaad4cd2bfb03cb7\"}, {\"tx_hash\":\"243d27bcec12af06a1949493beaaff2976d4fc88757ca5a6bddb767ef9c7df95\", \"recipient\":\"1F9LAX1237fuGaYB6wuBDSsaqEFNFvyqLd\", \"status\":1, \"created_at\":\"2015-06-02T00:00:31.528Z\", \"updated_at\":\"2015-06-03T12:03:21.213Z\", \"private_key\":\"135a29ad06823fc5db01707ac379ad6a65e4f51d0caf170174470b19139edded\", \"public_key\":\"02d625b3c35a84c99f1e0d8a908f57b8512983bd6ced6a9e7ca6814b635d6725ba\"}, {\"tx_hash\":\"52da0fa05666543b5274488c20e69f668a7690b30db721a5a9a6702b833bf4e1\", \"recipient\":\"1NjEfap29LwbEq51DADiafWSK6eCkFhQ23\", \"status\":1, \"created_at\":\"2015-06-03T00:00:40.467Z\", \"updated_at\":\"2015-06-03T12:03:22.708Z\", \"private_key\":\"718890619ea3bb1cc5af74b0708e76ff60547d6ae995f359494fe2c4df958804\", \"public_key\":\"0267c022706a465a5ab8bb05da5df59e1cb97137ab43a9be214cd6ad967a51c67f\"}, {\"tx_hash\":\"df6cf8d16929c774087741f382af107cb235d97eac61e5833439a5e3afd3700d\", \"recipient\":\"18mpztXerZGxJGxBReAp2jEtN4FDxkm2DQ\", \"status\":1, \"created_at\":\"2015-06-04T00:01:15.261Z\", \"updated_at\":\"2015-06-04T16:21:45.524Z\", \"private_key\":\"a0451e50edbc88a0075561a57b6fedc5f0987ba2745f73f672baf28f0bca6127\", \"public_key\":\"036a0ce19c67d41faac969151323f105ef582abe1628a7c965dc79629a607c38f0\"}, {\"tx_hash\":\"4e8eb46448426032879947076c199bb11e4dd4460837d5a7c08ec16fb46271ff\", \"recipient\":\"1CRLSUTsof2gTdrH1hiQ9QB37YzXtkeKjQ\", \"status\":1, \"created_at\":\"2015-06-05T00:00:37.446Z\", \"updated_at\":\"2015-06-05T11:31:57.539Z\", \"private_key\":\"acf3dec09ef3c643b099d444a099b596daae40c34f6e52f9da0bf233dcc60272\", \"public_key\":\"02b578dd620e0384589f643d344af274b69b9da73bc4eb109eeea418a48a08bd70\"}, {\"tx_hash\":\"3abb61b9874c7cfccae4600afb118d5a27513a454bd7512fc25e6115b6281040\", \"recipient\":\"12t7uSvSyHxHxvFvtbJhAKdKusuhhjzzc6\", \"status\":1, \"created_at\":\"2015-04-20T00:01:15.302Z\", \"updated_at\":\"2015-04-20T09:41:54.346Z\", \"private_key\":\"60e3ee581c07bd3665239d24d3825b4b8bfb51abea5b8de969b29ac39a4245d5\", \"public_key\":\"035a60386823a62a83245d9a21065fbf50d7c9048d46e563a55761a4184a34bb2c\"}, {\"tx_hash\":\"8cd48be8895fd816d724fd940241f4317bedc09ca70dd99ea48e4a7be4bf95a0\", \"recipient\":\"15GAnzUpPZ214joynVfaiBStombZGJba53\", \"status\":1, \"created_at\":\"2015-06-06T00:01:03.073Z\", \"updated_at\":\"2015-06-06T05:40:52.213Z\", \"private_key\":\"b5363d7b7e427b6deae4b02b85e9af2ba93c8ca8f3bf9789366b7ee07577d77d\", \"public_key\":\"031c48a33176e9b693f5757dc6793cb9ec5030f950e3ba399473b7f53bd7549602\"}, {\"tx_hash\":\"c236a3e52c9001d605d053622d270229cfaa558a83b68e365dcfcf869d7f2a9d\", \"recipient\":\"1BibV4kKVNm18T8SXG6y37CkA7NXuiXTT9\", \"status\":1, \"created_at\":\"2015-04-22T00:01:26.706Z\", \"updated_at\":\"2015-04-22T08:41:53.733Z\", \"private_key\":\"e583eb42ac506a8fb94d40e3caf44995cbe063fc98c13d64de1503552f10f8aa\", \"public_key\":\"02abbbe3b368a9a5705cca1a983d794353ed8b8bc46bcee53f6f0876099f668839\"}, {\"tx_hash\":\"54a521b952245944108a36505046f8a05d7324dc2f8df6186946e0b511cfa5a8\", \"recipient\":\"18dsDDLaFNbVuypxtVBdFc3oQP9dmNYR7k\", \"status\":1, \"created_at\":\"2015-06-07T00:01:26.683Z\", \"updated_at\":\"2015-06-08T10:22:23.891Z\", \"private_key\":\"09e6480de5aa168281597b01c0e2781a927678e190ccaebee15671b81e4d083d\", \"public_key\":\"0304df49a999d7a158b018c789cbcb9f4210d66a431833d75ee0a0a6222eb382df\"}, {\"tx_hash\":\"1aef91a65dafac5d25a3b25e8318fd6334c55cc55ad14cd19f3daa573ad36e63\", \"recipient\":\"17kQ6XLqKC7S9GwZR2krqzPQypNacRhiZC\", \"status\":1, \"created_at\":\"2015-06-09T00:01:10.425Z\", \"updated_at\":\"2015-06-09T08:11:58.711Z\", \"private_key\":\"c4b9f5512529a17661922bfec3a9d6eb8c05f3a302ffe0fa735bb0516d9f40fe\", \"public_key\":\"03b28204242c47a50e0886d1a04eff6d44543786b5a4ea2cfbb062e1b7571d610f\"}, {\"tx_hash\":\"52d153459978f94e1ac50d794604af2559d388d096c467f6a43e095de071dd6e\", \"recipient\":\"18u3mWfLsxwLgtCc2ewQCKB9PsNY6XSR7c\", \"status\":1, \"created_at\":\"2015-06-08T00:00:44.298Z\", \"updated_at\":\"2015-06-09T23:11:42.877Z\", \"private_key\":\"917c0f46fc859ea1f57d7c57029c6e264a0bd254034cc822cceef1392358760b\", \"public_key\":\"03cda54bd6e22c7adc81f8a3c34f93bb6788c0727272952024e94bd7220aacdee2\"}, {\"tx_hash\":\"1add190c1855f385345fddb9b2a47c9b5ec770beca77dc29bbae3d41da0546af\", \"recipient\":\"1DBJ4TPhYronVs6XUHMz5aKbJPuaXs2caY\", \"status\":1, \"created_at\":\"2015-06-12T00:00:49.355Z\", \"updated_at\":\"2015-06-12T07:11:49.584Z\", \"private_key\":\"97725ded135c5adc8d0a72930dd4c8a3d4c355151a683aeb179943934b04652f\", \"public_key\":\"03ab09855ba1e170e4ba3dddf39a79590b4e2feb5a2bcff00d08b4062c08fcc59b\"}, {\"tx_hash\":\"6e7b11c90f4a1efe1f66ea101c1fe67cb6049b068ab82459ac081865c46626d9\", \"recipient\":\"1AHTtr569CuaGfntp2skwPXoSPfK6rCjEg\", \"status\":1, \"created_at\":\"2015-06-10T00:01:21.683Z\", \"updated_at\":\"2015-06-10T11:32:12.558Z\", \"private_key\":\"d73e22daf34675a1f6fbe447b32f3fe702b968ba748080654e683ef46a72a540\", \"public_key\":\"03edcead542cdef293cbb4dd855fec9a2c7056d06261d8e7826fc1f32c48f93811\"}, {\"tx_hash\":\"be685122eaf9a33de0b42469107be6420bfc98ad3ada7ab3683be5c10e121243\", \"recipient\":\"1AgQC8xCi3mVUwrqG6Yh5WCLb73DQ13Zrd\", \"status\":1, \"created_at\":\"2015-06-11T00:00:59.166Z\", \"updated_at\":\"2015-06-11T10:21:57.744Z\", \"private_key\":\"15c1240175cc20d63622f3a0483012ad36cb2414bf8c52387d2eb799ef763dac\", \"public_key\":\"0215d6a5f089644b65bb3dee39b4c0cf356094387742bc69569a9ad6c6f8e49590\"}, {\"tx_hash\":\"0591f38e4fa3ea24901ecef1f004a73952a95eecfde4b8f8956728ea37df9a7a\", \"recipient\":\"12B37YnjFK3zzFa4dScMGdrudAV7tTCTCC\", \"status\":1, \"created_at\":\"2015-06-16T00:01:29.196Z\", \"updated_at\":\"2015-06-16T09:03:09.965Z\", \"private_key\":\"f7dfbb08b629caa4020f6468bbfe9f1eb8f281aa5cb5a96480b03edd364bb3fa\", \"public_key\":\"0371d69f11146b9cfe8f38967f17502e6050868d4af7bdd21741c9b19a98179e86\"}, {\"tx_hash\":\"e6830222ea64aaffdf6bec6f939c67293caf1e0c4da9c263ad3261336d38244e\", \"recipient\":\"1LJTkkxAQ2Fo7t4KMX6TE5mWr9u1ZYRmy7\", \"status\":1, \"created_at\":\"2015-06-13T00:00:51.190Z\", \"updated_at\":\"2015-06-13T13:31:55.735Z\", \"private_key\":\"98794910d11ada9b81f8abc7d8e4d3d81a89d2f5fce556afe7b8551ffcf388bd\", \"public_key\":\"0306530d49e472a05b4c8d3427ee01ab19c5cfec4b9575f1533e90ab5897da0d5d\"}, {\"tx_hash\":\"2cf1696dffc4fd60815d4b9ec51e21ceec79ac74eb481c359aca501f4bc6cc3c\", \"recipient\":\"13EYhcrNJ3ypBiz1uZdUGYVw4CXxhsG4nV\", \"status\":1, \"created_at\":\"2015-06-14T00:01:25.168Z\", \"updated_at\":\"2015-06-14T03:51:39.522Z\", \"private_key\":\"df96369a0728578d32a08fa17a10f536c4a123488e46f23cfa43a2ea738793f7\", \"public_key\":\"02854aa07ec3d76329c37576a9aaca485481a768cf738fdc6189a4395c2a0ebb68\"}, {\"tx_hash\":\"ebd5df214591d2917a5bdc6f842d1e3e7a7359ffa9f89e06d37f0a939ef0afcb\", \"recipient\":\"16XyHmh7fHWcaSoyiDoDmbXvUprNEKXuUE\", \"status\":1, \"created_at\":\"2015-06-15T00:01:21.530Z\", \"updated_at\":\"2015-06-15T02:51:53.312Z\", \"private_key\":\"cf546d5e1abbc6e393b578e9a67bd5aed6cbc1ef74db30ed0cf2b396f1b7f956\", \"public_key\":\"03d79666b43d720fa55295a03c3e5c9d20cf3986ff537559583736ddbfc8542565\"}, {\"tx_hash\":\"9ecc5fb8218f44360626dd2be29d16693f4d46135892e578d03b6bcb50644737\", \"recipient\":\"13kL4ptfdLJCfdYHqKpmzHBdPfW3mDfDN6\", \"status\":1, \"created_at\":\"2015-06-18T00:00:28.166Z\", \"updated_at\":\"2015-06-18T00:51:41.767Z\", \"private_key\":\"37696e1dd63c24136689e9f07ce90e96359bc4ce9fd8b07380b3a129e61be106\", \"public_key\":\"0285c5a6c8c60431f508e809ed6d4ea185b4d59e62448b6e3f0dec007a04d78448\"}, {\"tx_hash\":\"7a4c8c771d9e7f86e1fd4cc9312b1f1565330ccfbff74556f2235a956c7c1afe\", \"recipient\":\"1QG1qg7dCNuBoFi9gEvwFdDheDnYfiQLVE\", \"status\":1, \"created_at\":\"2015-06-17T00:01:10.464Z\", \"updated_at\":\"2015-06-17T03:02:55.614Z\", \"private_key\":\"a10c48144d44ee4257fb6f17918fe5084cc627312cababc962b40c698b284d99\", \"public_key\":\"03b856f166c3829732e2e1ec03bb9af7458241e032923092b9492bf69341942258\"}, {\"tx_hash\":\"0251488c32a8f9689069d430905a29a82defd550c666a6e842c2ac45c4aafd4c\", \"recipient\":\"1EQm68Ab2TNNeUg1uGPicFtNAu3uuMmzFt\", \"status\":1, \"created_at\":\"2015-06-19T00:01:11.356Z\", \"updated_at\":\"2015-06-19T01:21:56.644Z\", \"private_key\":\"d3f9c365785be2e3086722fc17aee13bfa2bf14529b0f09c74997d8a27234114\", \"public_key\":\"02e85c8f5d1dd48051bef01f52760dca4c50855d4804926ca0cc2c36ad7f053951\"}, {\"tx_hash\":\"e5fe48f5866d164c22002519e0c2222e909ca20bd76fdec6aa6da498f7d74e28\", \"recipient\":\"17Nx5goCqUCTATy1rPkfNJNwNmVzWJBBsW\", \"status\":1, \"created_at\":\"2015-06-20T00:00:50.189Z\", \"updated_at\":\"2015-06-21T11:31:45.628Z\", \"private_key\":\"25f78b029ae4eba0c4d117ea296dc90079706e962e7d6a64c26585c373465bbb\", \"public_key\":\"03e5155e4f7b33200b604e678bbdbb375777e21029f1c1ecbb72c6d14f51ce73a3\"}, {\"tx_hash\":\"432085e2792541b3e3ed0f2754833af40ce12d89e00a1b1f3b4aff856206949b\", \"recipient\":\"14D2wKGeB85Z3uh1E41QxBiUuBaTmsiNGc\", \"status\":1, \"created_at\":\"2015-06-21T00:00:29.732Z\", \"updated_at\":\"2015-06-21T01:41:47.825Z\", \"private_key\":\"bb2c7b6847be74f2e0a21fa735196ddbd2bb6b41d571122c793fd79f6521198c\", \"public_key\":\"022eb92466d49adda605fa97d909f535403e712740748b489d7fcd86060b5278f8\"}, {\"tx_hash\":\"4970c8abdfb28495a96d211faace07aa78b0f7167bb939aa97f85d9ac3ad3e93\", \"recipient\":\"1PYgWKcShWALzGb1yd6zay2BzkoaCw5qeo\", \"status\":1, \"created_at\":\"2015-04-23T00:00:18.959Z\", \"updated_at\":\"2015-05-17T04:02:55.691Z\", \"private_key\":\"4ff93fd0dc509d99ab9dcfa43ebcd14587d4759629c5dd884285f4c601b01f46\", \"public_key\":\"0230c2ac584f1a35a35500fbfb8eaab37aa9d41a75da4f18f9f6d15bb51519bd50\"}, {\"tx_hash\":\"132e5f8e5f84d7520877cc0a85faaf9e433ba364990fd808b12b0e96b42b03fd\", \"recipient\":\"1BCrNrSMbs4k2TsCUq6csuWocajQLwW91z\", \"status\":1, \"created_at\":\"2015-06-22T00:00:49.615Z\", \"updated_at\":\"2015-06-22T01:03:10.433Z\", \"private_key\":\"798daf4c5bc92209525a6a829462168f601794b9083a65aea4c555e393ae3b24\", \"public_key\":\"034b19bfb3e3e1d1e9c4c6d8b0ca2f9c567962a7b2cfaa4ba120f99072d45ac92b\"}, {\"tx_hash\":\"8773ab632d07e73ead837a6972a446e551ddf027058ca34e11ee7ee9c248f3db\", \"recipient\":\"15C7eh7f3EQuyTKySTHwiUEu5xFaHmiNDp\", \"status\":1, \"created_at\":\"2015-06-23T00:01:02.441Z\", \"updated_at\":\"2015-06-23T04:03:04.737Z\", \"private_key\":\"78c500dd8e47960fe23c6b02da4ce8f9d817d200a555b51134db80a8a7fdca3f\", \"public_key\":\"03464ddda63d09b25af81106f76a420ad05badfaa0737f8a86bd2673560ca84fa1\"}, {\"tx_hash\":\"0a51ed48f6f07a1939007ded92c001dbdf2abbd3dec70d73310873396c0e637a\", \"recipient\":\"1N3G9NpX6Jo6xCRuHjHwnDUoexVNaY7tsa\", \"status\":1, \"created_at\":\"2015-06-28T00:01:12.828Z\", \"updated_at\":\"2015-06-29T02:04:21.779Z\", \"private_key\":\"eaf9fab37d3c7473d04f8129d3e71b23be2b1e08e6116e506683b8a86e0bcf99\", \"public_key\":\"038a7820684a32ed17a463595880c1d32d8cbeeed5fe66408d9b0864e9e751f8e9\"}, {\"tx_hash\":\"14b40e99a0b4095d1fa01797c00f20ebcbb78a3bf5e48f5e75380729c42bbfba\", \"recipient\":\"14b9ZWvzio8i2PfWd2BqgVYaRG8phPwqpD\", \"status\":1, \"created_at\":\"2015-06-24T00:01:03.390Z\", \"updated_at\":\"2015-06-24T03:11:52.700Z\", \"private_key\":\"138c5fae0132fcabdd9f541629a01dd4c4a2d6a86b2207651bd32c37b709798b\", \"public_key\":\"033f3d0439299c64704701d29d7f432c1a0e8b0ee0da3ab86e4a536007d8da8b98\"}, {\"tx_hash\":\"5a21c329e5b23ef62f4a16dc35d3692b69ae121b20d26f0a04b13f3e2a8dd913\", \"recipient\":\"196rYUxmgcrR1HAWnfofP2GxCc3QchrwZh\", \"status\":1, \"created_at\":\"2015-06-29T00:01:27.826Z\", \"updated_at\":\"2015-06-29T09:21:54.514Z\", \"private_key\":\"cf520b9b13f3da61fc4b9a7b360a068266c16c732ad3be78eeb2dc786c0ebaeb\", \"public_key\":\"022a3357d71cf7c57a79f3a61205fd2f1591bdfc0f5351a39f9d6ed86cd4084839\"}, {\"tx_hash\":\"f6866bdd5ed4615db6a97859c2f8e5fa04df394c8788ede58f334dfb0b822a07\", \"recipient\":\"1EBWYTQoaJHSSw3EQSAvamjo6Q4mNUZDzv\", \"status\":1, \"created_at\":\"2015-06-25T00:01:20.784Z\", \"updated_at\":\"2015-06-25T03:41:44.439Z\", \"private_key\":\"3ef242ebfccc2182734e92dffae246bd57d76333e3ca1cea64c04b53fc9d680f\", \"public_key\":\"034e532613c0f915927a5226e29cf1aebf5d20cde124820d3264f68e81acd2962b\"}, {\"tx_hash\":\"6a79539f070bdae09b72d9b082eca467b0ece599a1837bbbf78853cbe37ecdb6\", \"recipient\":\"1KiKKLD6BYWAqQy7ZVt5U2ZuGjAzDsx8PP\", \"status\":1, \"created_at\":\"2015-06-30T00:01:29.211Z\", \"updated_at\":\"2015-06-30T06:51:40.083Z\", \"private_key\":\"0932252b3d7f242516a8a93fbd5fdf0e19fec093b914561ab5771cd8a45715f6\", \"public_key\":\"03e719d42e9275d255bb8d7598e37ee967fdadb5c28a966034521590a70a22260b\"}, {\"tx_hash\":\"70d5d808ae48b52ca18684e6109a484c4bee331a8f07ecbf22cde012f640d50f\", \"recipient\":\"14PVNg2cPb1ioe1CT4zqEvFN1VVAURzDFG\", \"status\":1, \"created_at\":\"2015-06-26T00:01:23.088Z\", \"updated_at\":\"2015-06-27T05:41:55.735Z\", \"private_key\":\"9575a13ce0e4e9dc932a1054546d51c5a893decd4affcb095ad6021b40e2f125\", \"public_key\":\"0262165833accd3cc27e419787d61a0b3958d99e4aadae5a2d0148be3e31f6aaad\"}, {\"tx_hash\":\"abf23d913ebaba5b6cfe4ce380db2854b1ef0328af576238cd22e4d2de5dd0af\", \"recipient\":\"1Eq8w9xtRnh2ER7UAFMvFRs76N7cb5yQiB\", \"status\":1, \"created_at\":\"2015-06-27T00:01:23.378Z\", \"updated_at\":\"2015-06-27T05:41:56.162Z\", \"private_key\":\"f3366cd4a2e204ab4363c43bb7bb18148ef449a271022f575a59c3306493570f\", \"public_key\":\"0367dfa09a5f7ed0aa20893853db6297e67377e9291b5a6daff84e63a4e0b4159f\"}, {\"tx_hash\":\"a4744de93164483dce44c6c8410e6af938a15ffed084de50e3cc3bfa808684b1\", \"recipient\":\"1QFf89ekBj1KQCSii4U4RUV7djLJbNmwkT\", \"status\":1, \"created_at\":\"2015-07-01T00:00:55.764Z\", \"updated_at\":\"2015-07-01T01:32:29.865Z\", \"private_key\":\"025fa36a5104680922df2280c9d6cb006555c6bff91e50e79d75c101d88c6e7c\", \"public_key\":\"028abae5d67d726059915c874321ec57e679eadd7d9845e54044fcd5795e7a0e8b\"}, {\"tx_hash\":\"a5b28a937d054a6478d38693016045a08e3b042bdeeedda3681536480e1dbb80\", \"recipient\":\"1HxWSMNxG2KZWEUo4QsFKnji4rJXbGt7JM\", \"status\":1, \"created_at\":\"2015-07-02T00:01:14.866Z\", \"updated_at\":\"2015-07-02T08:03:21.668Z\", \"private_key\":\"f16e2cd4864226645b24fc319c5804914ab39c18f7302207659635e249948ed2\", \"public_key\":\"023252ba58cfa6372d31b72d58ea20120383ab219fc21b84150941d2c165f2411a\"}, {\"tx_hash\":\"f3274f2af4242950308efe62989c158d5892be3b91bcb5f37e6c96b1a777ce36\", \"recipient\":\"12yiPp8bnQA8z2DNtV7N9S99o8aD4rQFq3\", \"status\":1, \"created_at\":\"2015-07-04T00:00:36.834Z\", \"updated_at\":\"2015-07-04T06:41:30.502Z\", \"private_key\":\"4ac51c3aa0aa10e8dc93efe5aa2a4af464698acdfbd4e7cadc2d2c98c06ba82b\", \"public_key\":\"022935969ebef594626b2d8ae3e7a70db0030db4847d8ac0ef39c4d03b71c0d162\"}, {\"tx_hash\":\"dcb6fab66a34e3ed99401cf968a0b704dab5b6ca07928c547131f01e6fcfe6bb\", \"recipient\":\"1JzwQmgQYwy6nBjybKDvktE3jgYXkuRGmw\", \"status\":1, \"created_at\":\"2015-07-03T00:00:41.858Z\", \"updated_at\":\"2015-07-03T06:32:06.750Z\", \"private_key\":\"68dcae9e4bbcd61c2e36bed37b97306568cd753c9457c132136edf72027e3583\", \"public_key\":\"02593ae4d08912627d48042d71ba4b203399e315749388ea30034208f6d6888ae5\"}, {\"tx_hash\":\"cf76060ed1587fbc2fc30d09b973d0f7ecb5f2ebda05ae99c0b7691b238fb61d\", \"recipient\":\"1AMFTZhh5uMWvftbELU25CxAh7oxJXGrhE\", \"status\":1, \"created_at\":\"2015-07-05T00:00:46.597Z\", \"updated_at\":\"2015-07-05T06:21:41.284Z\", \"private_key\":\"c6cd7111a61ee0f5c3491cd7164a01c6900c4e7d812f900d147ec95646442711\", \"public_key\":\"029a9fcaa8d30e8fd02667107e82a482c577c7fe608784e4c7c76474452c455c36\"}, {\"tx_hash\":\"0b66e834d067c4a3335606dbf447ed306ea55f04e34acc9cda63ad8c2fe24e66\", \"recipient\":\"17v4aYJQpwxp2VajkePPk9JvnkZvUeYANG\", \"status\":1, \"created_at\":\"2015-07-06T00:00:32.598Z\", \"updated_at\":\"2015-07-06T14:11:51.991Z\", \"private_key\":\"3f7219a37c872a7e60f7b17767625cc5d9b36311b74b1875ca4ce3398e9b844b\", \"public_key\":\"02022f7f79d72614f907ed0d741697ac7c7819aca6648c14131bde36126bd532b3\"}, {\"tx_hash\":\"004643d1f77530586b0e30169663c9089d509d058e61b96a51e3751792300cf7\", \"recipient\":\"1BYB1FcC8YsPAuCyw9bBEP2EV2HkvpxrYp\", \"status\":1, \"created_at\":\"2015-07-07T00:54:05.481Z\", \"updated_at\":\"2015-07-07T12:11:25.844Z\", \"private_key\":\"8ad7a8f5dac447cdaab4025219640639c1d318339b594802967147aa62ecb9f1\", \"public_key\":\"027678351c8915ecf9f705bdf5aac3a435cbbde290015a85e0dffdf2bc3d95d87d\"}, {\"tx_hash\":\"54e41c4a8079f406d2c67678b251d2e06f631bca3c8da99f3f5cf0629bc27b9b\", \"recipient\":\"13w9hFbkEpsyhRPmfda4E2JQ8akE6PYxhT\", \"status\":1, \"created_at\":\"2015-07-09T00:00:38.578Z\", \"updated_at\":\"2015-07-09T02:51:31.994Z\", \"private_key\":\"72f50d42532585e478cffe216152317b5ff1f69ae3a308db69ff6f68f8a80253\", \"public_key\":\"0332dce354feb2cbcebf8181a7485806b7cb33afe669dccbef8e4bd01dcae28239\"}, {\"tx_hash\":\"c428c7960df93d59d0ca4178000561df5c8bef727f969e43dcf0d7ea45a82bcf\", \"recipient\":\"19mPk8uaMmMXfsDDxdTPG1PXLWun2pHPaK\", \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea\", \"public_key\":\"03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\"}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815\", \"public_key\":\"0311241d491539de3f622afe966e0377a2379997a00d06f0412661d2611c541978\"}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b\", \"public_key\":\"028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\"}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2\", \"public_key\":\"035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\"}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbcd2d5ae707\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984\", \"public_key\":\"037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\"}]" |# \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"91a00440ee07a06e1e28f070ec97f165cdd5066ab1c97ff38a48ac95a3e2baea\", \"public_key\":\"03a2d0121dd45ab8a2b0bec0ae8c1fdad78ccf3f3c7894c9e9ea17e48ccceed6c8\"}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"8dbc2c47088d64002a1020f415a8b995e8d408ea0fa87c114c8b117d45efd815\", \"public_key\":\"0311241d491539de3f622afe966e0377a2379997a00d06f0412661d2611c541978\"}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"6e83e1336a252a67bc15716ac143bd6b47ec7dff0ac6261aa00579b29a3f0f3b\", \"public_key\":\"028c2b3752cb51cd1ba30284ae3fca378768b2511f91e92f342728ce20f14591a8\"}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"1b4de613b393415422031dffa6f17b8701c9249bd1096625f12f5205820aefb2\", \"public_key\":\"035311a5c807df1835184077423b28c08c99c59dd9722b9e70de7297f4807e5ed5\"}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbcd2d5ae707\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"c885799eeb6a78c858c5dc039dcfbad50dd008ce4b8b51e8b56a1c2fcefa3984\", \"public_key\":\"037108b890b7b7d18d47652df4d0a047bd99839ebb96de2fdb79b029f54d1ea898\"}]" |#
49660
;; timestamps.lisp -- Verifiable time stamps using the Bitcoin chain ;; from www.originstmp.org ;; ;; DM/RAL 07/15 ;; ------------------------------------------------------------------- #| The MIT License Copyright (c) 2017-2018 Refined Audiometrics Laboratory, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |# (in-package :ecc-crypto-b571) (defun timestamp-file (&key fname title) (let* ((hashv (sha3-256-file fname)) (hashn (convert-bytes-to-int hashv))) (list hashn (timestamps :create-stamp :hash hashn :title title)))) (defun timestamps (op &key hash title) ;; hash - numeric, needed for op :create-stamp and :get-stamp ;; title - optional for op :create-stamp ;; auth code obtined from www.originstamp.org/developer ;; and needs to be renewed after every 1M creates ;; ;; Invocation: ;; (timestamps :get-all-stamps) ;; (timestamps :get-stamp :hash xxxxxx) ;; (timestamps :get-all-transactions) ;; (timestamps :create-stamp :hash xxxx [:title "your title"]) ;; (let* ((auth "<PASSWORD>") (auth-line (format nil "Authorization: Token token=\"~A\"" auth)) (host-line "Host: www.originstamp.org")) (with-open-stream (http (comm:open-tcp-stream ;; Lispworks specific "www.originstamp.org" 80)) ;; leave off the "http://" prefix (assert http) (flet ((crlf (&optional (str "")) (concatenate 'string str '(#\return #\newline)))) (dolist (line (case op (:create-stamp ;; create a new TS (let* ((data (concatenate 'string (format nil "{\"hash_sha256\":\"~64,'0X\"" hash) (if title (format nil ",\"title\":\"~A\"" title) "") "}")) (dlen (length data))) `("POST /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line "Content-Type: application/json" ,(format nil "Content-Length: ~D" dlen) ;; this line is needed "" ;; needs this blank line ahead of data ,data))) (:get-stamp ;; get one specific TS `(,(format nil "GET /api/stamps/~64,'0X HTTP/1.1" hash) ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-stamps ;; get all TS for the day `("GET /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-transactions ;; get all TS for the day `("GET /api/transactions HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) )) (princ (crlf line) http)) (princ (crlf) http) (force-output http)) (terpri) (write-string "Waiting for reply...") (loop for ch = (read-char-no-hang http nil :eof) until ch do (progn (write-char #\.) (force-output)) (sleep 0.25) finally (unless (eq ch :eof) (unread-char ch http))) (terpri) (let* ((okay-line "HTTP/1.1 200 OK") (nok (length okay-line)) (lines (loop for line = (read-line http nil nil) while (and line (> (length line) 1)) collect (write-line line)))) (unless (and (>= (length (first lines)) nok) (string-equal (subseq (first lines) 0 nok) okay-line)) (error "Can't get timestamp data")) (let* ((key "Content-Length:") (nkey (length key)) (line (member key lines :key (lambda (s) (subseq s 0 (min (length s) nkey))) :test #'string-equal))) (if line (let* ((ndata (parse-integer (car line) :start nkey)) (data (make-string ndata))) (read-sequence data http) data) lines)) )))) #| (timestamps :get-stamp :hash #xD633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227) "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-12T00:00:31.863Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\", \"transaction\":{\"tx_hash\":\"6ed05fd3cfdd58eab8c349a9a77f6782613f1edc304aa4de3f36ffbed09051ee\", \"recipient\":\"1JM3GCAc2gWKZ8C2PYk3f6yBB8ZFVj5htR\", \"status\":0, \"created_at\":\"2015-07-12T00:00:31.788Z\", \"updated_at\":\"2015-07-12T00:00:32.309Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>\", \"seed\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227 <<-- !! 050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1 23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885 640982b83bc1aa015d8f60b6ed5f0799fa<KEY>a51760313decc854a9b91840bbd8 ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4 4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f <<-- !! 7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530 3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4 7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0 abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92 23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27 3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\"}}" |# #| ;; :create-stamp ;; "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-11T23:30:27.273Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\"}" |# #| ;; :get-stamp ;; "{\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}" |# #| ;; :get-all-stamps "[ {\"hash_sha256\":\"3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4\", \"created_at\":\"2015-07-11T14:31:48.972Z\", \"updated_at\":\"2015-07-11T14:31:48.972Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530\", \"created_at\":\"2015-07-11T17:35:13.487Z\", \"updated_at\":\"2015-07-11T17:35:13.487Z\", \"submitted_at\":null, \"title\":\"testing\"}, {\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}, {\"hash_sha256\":\"ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4\", \"created_at\":\"2015-07-11T18:00:42.182Z\", \"updated_at\":\"2015-07-11T18:00:42.182Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"640982b83bc1aa015d8f60b6ed5f0799fa42a51760313decc854a9b91840bbd8\", \"created_at\":\"2015-07-11T18:01:04.967Z\", \"updated_at\":\"2015-07-11T18:01:04.967Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885\", \"created_at\":\"2015-07-11T18:01:38.495Z\", \"updated_at\":\"2015-07-11T18:01:38.495Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1\", \"created_at\":\"2015-07-11T19:01:22.027Z\", \"updated_at\":\"2015-07-11T19:01:22.027Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\", \"created_at\":\"2015-07-11T07:20:36.463Z\", \"updated_at\":\"2015-07-11T07:20:36.463Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27\", \"created_at\":\"2015-07-11T11:14:37.135Z\", \"updated_at\":\"2015-07-11T11:14:37.135Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92\", \"created_at\":\"2015-07-11T11:22:07.051Z\", \"updated_at\":\"2015-07-11T11:22:07.051Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0\", \"created_at\":\"2015-07-11T12:48:24.442Z\", \"updated_at\":\"2015-07-11T12:48:24.442Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"} ]" |# #| ;; :get-all-transactions "[ {\"tx_hash\":\"5cc6cd42202553b3b57ea5a250b394fec174c0bd610da2598fda03ede170f90f\", \"recipient\":\"17rYW4DofgBrV2k8k2ky7xLuzUwp5inoJa\", \"status\":1, \"created_at\":\"2015-01-12T00:01:11.800Z\", \"updated_at\":\"2015-01-12T04:21:30.983Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"bdc6244b11575e29329ca10a65e6b171b377e6574eb3d6f0cf524fbe054322cf\", \"recipient\":\"1Vant4CVGow6RvEcsPBgEmFCN5bBzkpen\", \"status\":1, \"created_at\":\"2014-06-06T00:05:07.709Z\", \"updated_at\":\"2014-11-05T02:01:52.887Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>1adbd4a94161\"}, {\"tx_hash\":\"b65f0530d2b56e1f30547f9e0046166a2ced52dbb082cbf4f6bf7bd452a5eec2\", \"recipient\":\"1NUiXjKtSzj6obrZY6VR1Uydd23R9Cc35E\", \"status\":1, \"created_at\":\"2014-05-19T00:01:19.640Z\", \"updated_at\":\"2014-11-05T02:01:52.906Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>\"}, {\"tx_hash\":\"a4f4d37ce4ae65b6403bdfb843879633baef5267486d936e6e2b1f75f0669a10\", \"recipient\":\"1CKKrtq5ur5ZFtQGwwZDBzuRRd1cswqNrs\", \"status\":1, \"created_at\":\"2014-03-20T18:32:24.377Z\", \"updated_at\":\"2014-11-05T02:01:52.923<KEY>\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f4ea6b84442ab6b72160f6633b7c43a6186c30e16c276da2bc8dc0f768ef1680\", \"recipient\":\"125Qkz8J4VdyoxVL2wQK3mdCkdzt8zfcKA\", \"status\":1, \"created_at\":\"2014-05-29T00:02:40.501Z\", \"updated_at\":\"2014-11-05T02:01:52.940Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3<KEY>8df1c0cfabef582608c4f399c934e52\"}, {\"tx_hash\":\"05a46466ae2021a0bce6d5329c7528ee9b3c1b2fdda67bf6a7c04b28f5c0bf52\", \"recipient\":\"18q4mRvakf9UJWQAqcmn8wWHYQ2NKwNjpX\", \"status\":1, \"created_at\":\"2014-05-30T00:02:38.551Z\", \"updated_at\":\"2014-11-05T02:01:53.516Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ed6a0c5266ef634d3ff70e8edea9eb48ec4dc659a32a1c2a3ec4e0bcecb31db9\", \"recipient\":\"1ESG8CkoREhCZYx4kB1UEBnhNtzSAvVPXm\", \"status\":1, \"created_at\":\"2014-05-17T00:01:16.285Z\", \"updated_at\":\"2014-11-05T02:01:53.546Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b31b5e20c24cdbd9effcaebd5fb2d13ff03a6ba5fca4a8b367e230dcae7f490e\", \"recipient\":\"13B1WpaQ3Tk4BqQ4LX3eysQwvSn5uHsgW8\", \"status\":1, \"created_at\":\"2014-08-22T00:02:02.373Z\", \"updated_at\":\"2014-11-05T02:01:53.761Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>a9bb74d9415f541dc4274c1\"}, {\"tx_hash\":\"9a33b45134905cc6877af56f52060480b389e3fa4ea759ae8c504aed5c503158\", \"recipient\":\"1FWwNFMeKtjrmXgwaYZE6hAodrM7ozDNt9\", \"status\":1, \"created_at\":\"2014-08-02T00:01:41.468Z\", \"updated_at\":\"2014-11-05T02:01:53.924Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0c0fcf84d098e9a66c0848e9fc00662a82203c700c408038665157670c4554e9\", \"recipient\":\"1AST2VqYHnrmjv86FiRepvTJBSrXomLjRF\", \"status\":1, \"created_at\":\"2015-01-14T00:01:22.624Z\", \"updated_at\":\"2015-01-14T01:21:27.230Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5633980ac2a46f7ade29eb20da90307402ce7dbbe8c3d6ee2af8494584200a60\", \"recipient\":\"1ESYYyMmngUUHZk2YTnFdxuw6ddV57CYSx\", \"status\":1, \"created_at\":\"2015-03-23T00:00:30.572Z\", \"updated_at\":\"2015-03-23T03:41:45.110Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d6e8a78c75cbae895ce35cac701e722f475fb11bc7759a690771d586d92868f3\", \"recipient\":\"1N7BuAVEMxt38jxcHzPusWX1DbRJ8wxWRE\", \"status\":1, \"created_at\":\"2015-01-15T00:01:20.165Z\", \"updated_at\":\"2015-01-15T02:21:43.280Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a82e164dc639f8c2427b6585135da31007b066862643c2e88286d2ecc85b23cd\", \"recipient\":\"1HBfuMBfsQBLAmTJjQf7VZtJqJ1G4j9FTR\", \"status\":1, \"created_at\":\"2015-05-05T15:27:32.230Z\", \"updated_at\":\"2015-05-06T06:11:57.254Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d6568ebd966d2cef00885e3460ca2025ba42fdb56f80b67f34730d84964b48b5\", \"recipient\":\"1QCRzwHxuK3AQcmjgiPCUHBsoy1hPkMmQv\", \"status\":1, \"created_at\":\"2014-03-08T18:34:02.426Z\", \"updated_at\":\"2014-11-05T02:01:52.951Z\", \"private_key\":\"<KEY> \"public_key\":\"<KEY>}, {\"tx_hash\":\"2831a771337e431791d1281992e20be6fba1bb12f154efce516a9c1da1c0c817\", \"recipient\":\"1P9y1ahAfqUWWAvWB6nvyfGJGkGgqkTGz4\", \"status\":1, \"created_at\":\"2014-05-15T00:01:07.853Z\", \"updated_at\":\"2014-11-05T02:01:52.961Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"85f5a8e7319a1ddc28fbf58e7f7f67b4b5441ed720bc82699d7f14037db4d039\", \"recipient\":\"1MmuY2ywp7Fort4CRAGhb9ap4jMNE2MZJZ\", \"status\":1, \"created_at\":\"2014-06-13T00:05:47.200Z\", \"updated_at\":\"2014-11-05T02:01:52.974Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9a33c1b174a8cad687e2081383c94db4dd601e58cf8df8e24baa493b2fda573d\", \"recipient\":\"14EoknsfxEvzNEXtqKz4hhfjB1Q6iUSqJW\", \"status\":1, \"created_at\":\"2014-07-01T00:02:12.587Z\", \"updated_at\":\"2014-11-05T02:01:54.167Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3bd108eff5534cbaf85747376118f5e834fef1fdd7b165d1db2f1d1d8ebb99ac\", \"recipient\":\"1DSFfRafiWZWyTnqiTaMy27HA1amfaK9sr\", \"status\":1, \"created_at\":\"2014-07-03T00:02:38.416Z\", \"updated_at\":\"2014-11-05T02:01:54.193Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"76846c2a77902e57ab1e75b3313394567e76ec31b90bbe0161cb7479d725f64c\", \"recipient\":\"1BTGAMpZ9e25y3tm3J5SnP9ugAz5Ktco7\", \"status\":1, \"created_at\":\"2014-07-26T00:03:34.143Z\", \"updated_at\":\"2014-11-05T02:01:54.384Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>\"}, {\"tx_hash\":\"6262b99f22bcce8bacad6c46211213731ce249392195b2f3d968ed060f4bf27e\", \"recipient\":\"15LyoqNbG5jox9Ve68ciUseW4Wm8bGbRNK\", \"status\":1, \"created_at\":\"2014-08-31T09:53:39.904Z\", \"updated_at\":\"2014-11-05T02:01:54.510Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"daf0600d1a28ae86882adc03b8f583462bbc8f0174f79a03058db9a8658a36bb\", \"recipient\":\"1EFiGL8eF7D3waeEskfdfsvMicVrUfBacc\", \"status\":1, \"created_at\":\"2015-02-12T00:01:25.830Z\", \"updated_at\":\"2015-02-12T07:41:56.531Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"052aab2bd27b31b81ac39bad164cd38a244dce6f43ae489cb2805c0367c2ccc2\", \"recipient\":\"1JF1Js5TY2uCH2Uqaqe5ksaWPtJeZnWEub\", \"status\":1, \"created_at\":\"2015-05-14T00:00:48.476Z\", \"updated_at\":\"2015-05-14T03:03:00.807Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b9d3496573b5d1e867d77315a2fd917e9b6b34f9ed917c4247e182f10ce82d17\", \"recipient\":\"1Gw4kbqa3rbKWc1GpRGQfMATqQkWg5vLi2\", \"status\":1, \"created_at\":\"2014-11-13T01:02:52.146Z\", \"updated_at\":\"2014-11-14T00:21:40.358Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"21e08bd07f30d6cd503e4ce64a0fdb786dc50e34cf488006c904b6b05963e687\", \"recipient\":\"15P6v2v7HsTmT9XU9Qxr7rQa1sQftHwzzp\", \"status\":1, \"created_at\":\"2015-03-17T00:01:09.998Z\", \"updated_at\":\"2015-03-17T09:03:29.537Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7561a3bf4a53fadca684639e877af39abdb1c77<KEY>04ba1f856476ba56ae72cb94\", \"recipient\":\"1G9RXzGyoqQfJHzoQkH9a2EPDNQ8bnb1mF\", \"status\":1, \"created_at\":\"2014-07-10T00:03:12.573Z\", \"updated_at\":\"2014-11-05T02:01:52.991Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>64<KEY>}, {\"tx_hash\":\"274b0e7143eee9a23d166f6d60c9f8d0af11ed655254285559ec2225971c3939\", \"recipient\":\"15StrEcsCmSNfktcfXBrato4VdaZCkbUAQ\", \"status\":1, \"created_at\":\"2014-06-26T00:02:37.128Z\", \"updated_at\":\"2014-11-05T02:01:53.001Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0c28e0f4ebe036df09ded5ee33323d9c5518d6a37dfa45964ae7ff7d1eda7050\", \"recipient\":\"13McrP98NcUniCecfGL6GpivHTRzoVChPX\", \"status\":1, \"created_at\":\"2014-09-12T00:00:18.694Z\", \"updated_at\":\"2014-11-05T02:01:54.536Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7334c1369680e4f999e97b3bd9315e3d<KEY>cf<KEY>c<KEY>2<KEY>\", \"recipient\":\"14RWr2qjHCgmPtet2BCeqRqTfnA9LfRc1R\", \"status\":1, \"created_at\":\"2014-10-21T00:03:54.249Z\", \"updated_at\":\"2014-11-05T02:01:54.615Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"15872e495968e5f68893d13a75c3101980d9b44104d2af509ff65e5c8ac448d5\", \"recipient\":\"1JhPmLzpUY5TwTggvzmV6Vve4NHPTDCopy\", \"status\":1, \"created_at\":\"2014-09-19T00:02:05.121Z\", \"updated_at\":\"2014-11-05T02:01:54.625Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"551131e5f5fc48b7816ff07acfeedc5c7fc55d66050145e58d5f3523ee75142f\", \"recipient\":\"1JU5XyFZTBh9w5simV6e8EzdCioNVTim1H\", \"status\":1, \"created_at\":\"2014-08-26T00:02:03.885Z\", \"updated_at\":\"2014-11-05T02:01:54.645Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4747e4c8524c82fc737caf89f9ad666<KEY>715cf<KEY>dd796c<KEY>ff<KEY>\", \"recipient\":\"1Kiwqx8Rrw8XafDNBnsrUX1j5ohy1Yn6oG\", \"status\":1, \"created_at\":\"2014-11-14T00:01:45.775Z\", \"updated_at\":\"2014-11-14T14:51:47.987Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4d10a835b5e9a974596755f95407c825d9249eda6feaf4305e1a7fc1119d43cc\", \"recipient\":\"13UCP7B7P9cG9NZAqykTSUfwZYi2x6XaiB\", \"status\":1, \"created_at\":\"2014-11-15T00:01:19.086Z\", \"updated_at\":\"2014-11-15T08:32:36.799Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3c893495a8eb51df1373e0ca8c\"}, {\"tx_hash\":\"b03cf3b1c193dc66800bf809f7ea3f853431f2fa94621b573b22e5fbcf71491b\", \"recipient\":\"1451zcXorHeHQ5tioGCRoMpSXqX2rezUHU\", \"status\":1, \"created_at\":\"2015-05-06T00:00:55.528Z\", \"updated_at\":\"2015-05-06T06:11:57.704Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d33c092e34a89d60dc718f22903735d053668b5414ed97089491e41608a0889f\", \"recipient\":\"13G6DWSFygS6kU6wq3nEehwTgqH4preN62\", \"status\":1, \"created_at\":\"2014-05-14T00:01:35.969Z\", \"updated_at\":\"2014-11-05T02:01:53.011Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"50d46c1696c07d2e4aed3f0f6b8ec365cdbab74a5e0c87c2470d208c842fb0f4\", \"recipient\":\"1DHnLfeb1hDakgk2fVcG6aDyMzK6Vgcynm\", \"status\":1, \"created_at\":\"2014-09-23T00:02:10.197Z\", \"updated_at\":\"2014-11-05T02:01:53.022Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c<KEY>b4bfdcf61b<KEY>0c1f6b<KEY>b<KEY>75<KEY>d21<KEY>0<KEY>14<KEY>a2<KEY>fb<KEY>\", \"recipient\":\"14gcu52GekwuQBwwto6RpbWQDgv3JhpaGu\", \"status\":1, \"created_at\":\"2014-10-11T00:00:55.209Z\", \"updated_at\":\"2014-11-05T02:01:53.046Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>\"}, {\"tx_hash\":\"04642f3f029eda2b48640642ca970ac2b190132876542d36918772ea5b7191ed\", \"recipient\":\"1LdBELrbXZbKedG5qKJwgA35Gep7RXKwk5\", \"status\":1, \"created_at\":\"2014-06-17T00:01:54.014Z\", \"updated_at\":\"2014-11-05T02:01:54.730Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d1d7623456bfe389152c7e5d7075728c1045c62b054022d7e9b95c5ef117e890\", \"recipient\":\"195mgMWrgSmjy2Ax3r1N3rvood3YN5wsLR\", \"status\":1, \"created_at\":\"2014-07-02T00:02:37.176Z\", \"updated_at\":\"2014-11-05T02:01:54.979Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>8d<KEY>160743ab\"}, {\"tx_hash\":\"b5175cd928c898cf3a9f3283666386c44dc6343db5ff788ddf597d13e4438e3b\", \"recipient\":\"18F4Anawmto2ypQW4xTMmCwJgQPvJSuBaL\", \"status\":1, \"created_at\":\"2014-07-09T00:00:28.290Z\", \"updated_at\":\"2014-11-05T02:01:55.102Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"44f2cf8058d4d5c1f7aaa019ba404c0726b187828726b598e4369be230387a25\", \"recipient\":\"1kynpGAAYNNGGBWakw1GXisuNWVa3Wiz3\", \"status\":1, \"created_at\":\"2014-11-16T00:01:16.227Z\", \"updated_at\":\"2014-11-16T03:51:50.052Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"eb5f0cef8a03ff68980d045e2c27689f130a043e8ece31a5b9c9fb4636f95002\", \"recipient\":\"14BfdJrP64JpWPQG58FUcJhM9AFTkDyKnC\", \"status\":1, \"created_at\":\"2015-01-17T00:23:37.472Z\", \"updated_at\":\"2015-01-17T04:11:33.558Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c205529af8313c48102dfa8cc78e309b9440cabb0eeb3f24e73d43dc22c7cf07\", \"recipient\":\"1EV7LBAXZEuw4mDfCR3FE8yJJT8cNqDp9L\", \"status\":1, \"created_at\":\"2015-02-13T00:00:48.588Z\", \"updated_at\":\"2015-02-13T05:32:20.428Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"15baee9509fa0e591634d5da7e3d540dd7a1d9c6a030c807b09b2351028d6abf\", \"recipient\":\"1PmAGdacqT3Hzr259qdVz85egChWfQphtv\", \"status\":1, \"created_at\":\"2015-05-07T00:00:52.308Z\", \"updated_at\":\"2015-05-07T04:21:52.571Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cb4cda0073b401d796e0f2c96e8f5a84fec1f506a07c40de2b634e4df9598266\", \"recipient\":\"19NSGsvtjMrgukZzUrd5uyNrJimunqF6G4\", \"status\":1, \"created_at\":\"2014-05-22T00:00:39.567Z\", \"updated_at\":\"2014-11-05T02:01:53.058Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f0dbb6df8156cc81cafa247814664d39c9d93537d5ddebef3b68367d7eb45f9a\", \"recipient\":\"12FuhxfFtx1trdppKajTUruc4xjVtMouLt\", \"status\":1, \"created_at\":\"2014-04-23T00:00:40.650Z\", \"updated_at\":\"2014-11-05T02:01:53.109Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"886b51655b0695ac6f1b8ea08847c5c427086177232636f4dfb4cc7556d99116\", \"recipient\":\"12Yu1gc4wy9PuSjmkQsBrb8Pc2Ptr3BaVm\", \"status\":1, \"created_at\":\"2014-04-24T00:01:43.397Z\", \"updated_at\":\"2014-11-05T02:01:53.119Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"66a5d6bd7f492a5ccfd86eba7f9e945854f0b3c41f30bd439bce76530bb89ac9\", \"recipient\":\"1P5RUSCntazC4sDSzXwEC7nJhy6EzSP7MA\", \"status\":1, \"created_at\":\"2014-07-31T00:01:58.647Z\", \"updated_at\":\"2014-11-05T02:01:55.258Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"576e4dd53fbab59178efb1bba3b9659c8596fa92178020a3e7dcf06c139e822e\", \"recipient\":\"1ByhvYLBaXUtgoVfAcWMp4bGfoueBpvmtP\", \"status\":1, \"created_at\":\"2014-10-22T00:03:29.755Z\", \"updated_at\":\"2014-11-05T02:01:55.445Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"43b51534677a771d3ef3236280cee0916f74b563a9c9004c94a2b0d1d711622c\", \"recipient\":\"17VE1uPUYpvCexRR9QmpuU6v5MAWYTra2W\", \"status\":1, \"created_at\":\"2014-11-17T00:01:53.251Z\", \"updated_at\":\"2014-11-17T14:21:47.075Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1f59e364b4fc3eaf62b77d458c2ce94445b349a323bb86170bf1fa9c99646868\", \"recipient\":\"19p2Zqgbs3wB399BENWA77K668rkHsuu2D\", \"status\":1, \"created_at\":\"2015-04-08T00:00:35.575Z\", \"updated_at\":\"2015-04-08T06:32:03.752Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2c813acaadd48e6552fa291aa72a01d9820b150975ffdd57285c7f4833fde4a3\", \"recipient\":\"1H7x369d3dh1MFVV6nn7MsNiNNtsHN5Q3B\", \"status\":1, \"created_at\":\"2014-11-18T00:01:53.635Z\", \"updated_at\":\"2014-11-18T00:41:49.817Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>c3b7cb220e5741bb56\"}, {\"tx_hash\":\"3bbff16458b61246a95bb1e17a3965d886222e56a9c22dc79bc733019a5b963a\", \"recipient\":\"1Pz6V2qChiufKqXGs2opZYvtTtVr8JuLKZ\", \"status\":1, \"created_at\":\"2014-11-19T00:01:23.886Z\", \"updated_at\":\"2014-11-19T01:32:58.124Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8ebe0d670073ba67c736f2920ee082c908c1f86d6b1ead5d3efe313d864de029\", \"recipient\":\"1H6Hv8pLzCUZ3ZjiH5tmajmjZX9auiea93\", \"status\":1, \"created_at\":\"2014-11-20T00:01:45.097Z\", \"updated_at\":\"2014-11-20T02:04:37.604Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"946f2b211b6741f2699f6c8f029caab2e97889b857bd0f8fe9c227575702a45c\", \"recipient\":\"15VRET362id6vRn6a2Zqn6vBrfSwAE6TK7\", \"status\":1, \"created_at\":\"2014-06-14T00:00:37.408Z\", \"updated_at\":\"2014-11-05T02:01:53.129Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"19c42ab5ec36db0d5127f82c5ae7ac96351fd071938ac40146a0713f8e4a8e11\", \"recipient\":\"12Tn73UVzb7fMVFQbJqgmzHBUD1YbmRiF9\", \"status\":1, \"created_at\":\"2014-11-21T00:01:12.416Z\", \"updated_at\":\"2014-11-21T02:03:45.847Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9466a3c8c7d333ffc72dfc16e1992cf1dca269d8c758da90050aebe7b9f22dea\", \"recipient\":\"18qtwsM6kqKNum4ic9fKDFAscAAt9HZM4r\", \"status\":1, \"created_at\":\"2015-01-18T00:00:55.356Z\", \"updated_at\":\"2015-01-27T09:39:31.697Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"440321c778c38f3c821a0664b3a52092aaed336df3e591bb1ac514f08a56333c\", \"recipient\":\"1FYdtZzuBusLmptCNHdLAKYEX76b3rEJvW\", \"status\":1, \"created_at\":\"2015-02-14T00:00:59.765Z\", \"updated_at\":\"2015-02-14T03:32:33.451Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6553bf0bdf60ae8cd779ccf35e40a730d5cd09bdd70e522de01831f5c9ebb9cd\", \"recipient\":\"12TEbw4Bd4V9ms4kuH1kC6Yaj2kuzcYJ1c\", \"status\":1, \"created_at\":\"2015-03-06T00:01:42.198Z\", \"updated_at\":\"2015-03-06T02:12:06.336Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>e2883f62a68a42e754d43645429d18223936ca19589\"}, {\"tx_hash\":\"69ab4452a2455324f089cd888e23cb93aaf9b4d40cecaff30a7375d0970545b9\", \"recipient\":\"1EkqZqmm9iECCJ9pwGrt3KhoaJ7qkFGn3K\", \"status\":1, \"created_at\":\"2015-03-16T00:01:11.445Z\", \"updated_at\":\"2015-03-16T01:51:28.986Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"99f5c46372957b146e5f644874c3359a40542302d960cda5dc65770b64d6235f\", \"recipient\":\"1Ccq5ZYou8qLjigYaTYbiisTKrVQJrCi7H\", \"status\":1, \"created_at\":\"2015-05-15T00:00:40.396Z\", \"updated_at\":\"2015-05-18T09:51:29.803Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e55d281e60d25023cb07adacc376c8f5285241625318661547832f965a8f12b6\", \"recipient\":\"1LnSbzpdzb6JAyWMXrWQCr8gGF1mUhhkAv\", \"status\":1, \"created_at\":\"2015-05-08T00:01:21.989Z\", \"updated_at\":\"2015-05-08T08:12:20.765Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"10417bfe88b10ca116cba61fca45788f2284a4e8cc57e75f79e85670447b3ffa\", \"recipient\":\"1Kbn3jYP1aiJW4CEP2wrt2z2qGCmvamQk4\", \"status\":1, \"created_at\":\"2014-07-08T16:09:30.595Z\", \"updated_at\":\"2014-11-05T02:01:53.152Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5f8768b7abd0cc28643c1aafaa691e0b93b7331a401d977d5898b35a5479a197\", \"recipient\":\"13eYJskv4gMUxjHFA6fnok3ihmhqoG3zRW\", \"status\":1, \"created_at\":\"2014-07-12T00:00:38.014Z\", \"updated_at\":\"2014-11-05T02:01:53.162Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>a223193fe6635ea4c581965279bbcc8954c8c8c6b405234c8337f472de4c3f5deef241f6138c3737cf01e220d3efd2f\"}, {\"tx_hash\":\"9509fc4f47f1404fd99f868c6ec9d486f35a079cbf8b49f10f98e77c3817669d\", \"recipient\":\"1ByDk6GFEvrB98xM81p6nrD4nVTsbKShFr\", \"status\":1, \"created_at\":\"2014-06-29T00:02:42.268Z\", \"updated_at\":\"2014-11-05T02:01:53.172Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"446a6b8f158e8755806b6672bf6acbc82b817ca5e405e940ae366847290e9d4e\", \"recipient\":\"1KT2Y2nY3pzuZoVX7XYDAGFBJD7oeckXPv\", \"status\":1, \"created_at\":\"2015-05-13T00:00:32.811Z\", \"updated_at\":\"2015-05-13T16:02:38.947Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e37f0a9c8f1b52fd8883cae81f41892c496fb1ab0676d913b72d2cbacb7ce3fa\", \"recipient\":\"1LFjG2Q4yiGNEXWoufmRCSSXc2yW9Ab4kL\", \"status\":1, \"created_at\":\"2015-05-09T00:00:40.427Z\", \"updated_at\":\"2015-05-09T02:22:06.134Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3c4\"}, {\"tx_hash\":\"2e088f04c5dc0324f16771a491df3ffadca947def262c8146c4020f4352ff100\", \"recipient\":\"1GJyjbuNUPGfDxe35x73na5weTLN7BUiDs\", \"status\":1, \"created_at\":\"2014-11-22T00:01:31.302Z\", \"updated_at\":\"2014-11-22T01:21:28.008Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7a97fbfe87a98cffe1a832a3244b1ac046af816313219adbe6d29b2c7786b3f9\", \"recipient\":\"1C6HmpjvvHk7kH7EFaBwnb3X22nEtxASu3\", \"status\":1, \"created_at\":\"2014-11-23T00:00:44.164Z\", \"updated_at\":\"2014-11-23T01:03:36.035Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d3419d432015929785e88d5dfc9f3e6e46509be12c1980935c9982eef399957f\", \"recipient\":\"13KPpnsDF7EZibdb9ggHALsmr16GogAUUZ\", \"status\":1, \"created_at\":\"2015-05-10T00:01:05.797Z\", \"updated_at\":\"2015-05-10T15:31:57.006Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2d9cdc612ed78cc0a0c02d4ab5df99a785c59110406357cb4147a1e3592661a6\", \"recipient\":\"15i2e32VvqKRqFiEEXno8We83KtABN5iT4\", \"status\":1, \"created_at\":\"2015-02-15T00:00:33.715Z\", \"updated_at\":\"2015-02-15T02:41:53.066Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b06394a816cf500167defc419064187a333f2fec63b9962da28031c5984dfe77\", \"recipient\":\"1J2v8YLu1gMgj5mCZFBsfUfusD8pszvgqr\", \"status\":1, \"created_at\":\"2015-02-16T00:00:57.522Z\", \"updated_at\":\"2015-02-16T13:03:24.902Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5df96fbce787ad35836a2eb7c0b3ab095cb43fd1e1cfbdcce1828d80ed2634f5\", \"recipient\":\"1EVWovQT8xr435oiEvcqW9awNgx7Gz1Bxr\", \"status\":1, \"created_at\":\"2015-02-17T00:01:10.722Z\", \"updated_at\":\"2015-02-17T09:32:14.650Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"80d790815a6ae2b4982989af7285562223b19e359f830bfa4fefd930840622bc\", \"recipient\":\"12NJQhG7xroqBCTH4v6EJ4WM85fhujQyxP\", \"status\":1, \"created_at\":\"2015-02-19T00:01:02.305Z\", \"updated_at\":\"2015-02-19T02:41:52.068Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ef50c29dccfa428d99a26d404acc7a80c0a299c4f80d0d5b0aee68b430b89a4e\", \"recipient\":\"1K3Rcr6sdkQsLSSDY2ujzQe9JGk7Q7EqT7\", \"status\":1, \"created_at\":\"2015-02-18T00:01:45.090Z\", \"updated_at\":\"2015-02-18T14:03:27.288Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"263d31cd4eb2d684dc0ab311112f5dc17b9c755431170e592e99703e58e5e62d\", \"recipient\":\"1BiqJri9R56QSv7jQs2KDYvT5KTLHGxEKC\", \"status\":1, \"created_at\":\"2014-07-16T17:33:17.581Z\", \"updated_at\":\"2014-11-05T02:01:53.187Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>edc137a245a65cc2f07d6d4ef1829bb5130d3a22ed3de04486621ac476e314b6380d515c300250bf66fb4983b23728d9a38d26<KEY>4<KEY>3\"}, {\"tx_hash\":\"c636d3b28f960236325d4c2638f82f429924c6c0cac4ac48b9e7fee8e53ff8d6\", \"recipient\":\"18K4M4qo5yymYFhbkmAriSFVfnpPP6uwSm\", \"status\":1, \"created_at\":\"2014-07-08T00:03:01.018Z\", \"updated_at\":\"2014-11-05T02:01:53.198Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ef9e6c1c337661b22ef1b508b917d0b4f23df98e107a556996e69dbdf3a79176\", \"recipient\":\"1F9bCHaCPa79fWiULnVPybY1W2H6gmvDyN\", \"status\":1, \"created_at\":\"2014-07-29T00:02:15.701Z\", \"updated_at\":\"2014-11-05T02:01:53.208Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3e53<KEY>b<KEY>b<KEY>}, {\"tx_hash\":\"cf815a603fb0d2348c786f219fc71a7ee222a161d713fb53d4fb1e084ae67232\", \"recipient\":\"1GpzYXKGXjnPxzMWdeSvNPpwC8CMumthNo\", \"status\":1, \"created_at\":\"2014-11-24T00:00:50.076Z\", \"updated_at\":\"2014-11-24T02:32:17.019Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4d8dfb4699b0d1ac7e438c1182a0cc4db2a85404d87e4e883d4746d78fbf4346\", \"recipient\":\"1HCTW9GnX1qa1h2q9RLBbMGFX4zDrj9h7G\", \"status\":1, \"created_at\":\"2015-03-21T00:01:02.326Z\", \"updated_at\":\"2015-03-22T21:51:31.967Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2f4d1c4640b86d094bb2d225a8a414ebbab8bf4c1356ac5e422618cece0b618b\", \"recipient\":\"126NsPsUqPVwoabfJoMK9uB6vh9p7wDfrC\", \"status\":1, \"created_at\":\"2015-02-20T00:01:18.581Z\", \"updated_at\":\"2015-02-20T02:03:39.623Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cc610efdac09b0dd95d0801eb589d66654f636dbc58fc10b7cfdad8aa9eb6d59\", \"recipient\":\"1HZC6Uzp3UtKgtWTvJjcvvXLNKN4EVHGyZ\", \"status\":1, \"created_at\":\"2015-03-07T00:00:44.051Z\", \"updated_at\":\"2015-03-08T17:03:36.014Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"97fd31ba4defc8344e4cfbb8df10c5a884a7a3790f71dac27d4ae19662d505d0\", \"recipient\":\"1JouHbiPyT4JB6UfHDokWqv4dMhrbuD6Zc\", \"status\":1, \"created_at\":\"2014-07-18T00:03:40.087Z\", \"updated_at\":\"2014-11-05T02:01:53.218Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a2d14ba75d34d95002f2d94acecf5791f82f576281ca69eee043d8fa04eb3953\", \"recipient\":\"1Cqzwjjta16HLPFmi43rqkuuRRGAroo1wd\", \"status\":1, \"created_at\":\"2014-07-24T00:03:35.045Z\", \"updated_at\":\"2014-11-05T02:01:53.228Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>285754882a4476beaf64e3ba1c883a17e9d907be20f12a2748ecc4a32004aff46041dc5a5d072648e10b44037a\"}, {\"tx_hash\":\"405e034591a7d1c978ca66b24b5cdc51dc4e326ebdec361e77a952ba28f1cd54\", \"recipient\":\"1rKydRpQNRoFymrCFdq4BDqC4GHJ4YBmn\", \"status\":1, \"created_at\":\"2014-07-23T00:03:47.019Z\", \"updated_at\":\"2014-11-05T02:01:53.242Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3b2b6ef09ee244411e9383ac42d82cf15b890a5ab5b1cf0201b1b829dd0f4a11\", \"recipient\":\"18WCREWiEE3qETHSNW4X2vnHuFgZaLf2q9\", \"status\":1, \"created_at\":\"2014-11-25T00:01:30.406Z\", \"updated_at\":\"2014-11-25T02:31:49.377Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"36741940f0a73484912a4b2aca38fb75f346bbcdde8e6ecd0ac5e7d97d9317c5\", \"recipient\":\"159984tsJx6V6godf1pdQd2j221bjShPev\", \"status\":1, \"created_at\":\"2015-01-19T00:01:05.848Z\", \"updated_at\":\"2015-01-27T09:39:32.317Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"24a8242ea0aabb23ffe395035ed0fbdac4c90031d233ec7b94f282ab097b38fc\", \"recipient\":\"1CMZh1o75M8pVV44e1ynr7QMgR3oxejQo7\", \"status\":1, \"created_at\":\"2015-01-20T00:01:05.066Z\", \"updated_at\":\"2015-01-27T09:39:32.791Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d23151f82e9b92e559a8092f79a57e6df23294163c33dad6be962b0c4aacf4c7\", \"recipient\":\"1JrbM1Fx95CNRSz138bC9USpCpYVHhs1qv\", \"status\":1, \"created_at\":\"2015-01-29T00:01:19.007Z\", \"updated_at\":\"2015-01-29T02:21:48.672Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>ec0ef60d3e408df38f265cb020cfabf06c7e9e0f1c2944d2\"}, {\"tx_hash\":\"04bd372bbcd317cad494f960a0b3f78e023fdf8aa62b976020797508e5ddf49f\", \"recipient\":\"1Jf7k1bmqG1x6TT7KhdCNi2iJMtpY5DTLJ\", \"status\":1, \"created_at\":\"2015-02-20T07:47:02.435Z\", \"updated_at\":\"2015-02-20T08:32:18.258Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"820810819ca30b3ba0b42509e64ee6a0cd270d633fa62e5afd0d2e49b7a7c056\", \"recipient\":\"129KNMKCkx7WcyYHS83uAddf3A6c6QBdfS\", \"status\":1, \"created_at\":\"2015-01-28T00:00:59.364Z\", \"updated_at\":\"2015-02-01T09:11:38.062Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f1844287d3de2fb8e5ba2524f0d543e9aa354e53a90fe13a5b90d087e94d7c1c\", \"recipient\":\"1FS7WwQpgAAHuiceKgNY57WZwWHE1V4XsW\", \"status\":1, \"created_at\":\"2015-02-22T00:00:54.359Z\", \"updated_at\":\"2015-02-22T06:41:36.344Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"119f044d51c887a18bc0aa6bc31dff70beb18348a6d3ee1efc044a3185f6c4b9\", \"recipient\":\"1HhzMeiFhtwxy5bsq8e1uLe4MM569ru8ar\", \"status\":1, \"created_at\":\"2015-03-08T00:01:35.284Z\", \"updated_at\":\"2015-03-08T17:03:36.683Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d1b8c561fb07e6bc0162e1a35c090e9811a7eac8ba8f28f49451ded4d97a646e\", \"recipient\":\"1Fnqr2gpQ6u2jsj45JStrVicX5mZtPVQG3\", \"status\":1, \"created_at\":\"2014-03-19T18:33:04.956Z\", \"updated_at\":\"2014-11-05T02:01:53.252Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>75<KEY>5<KEY>5d9df<KEY>8410447280a6eb7838a38d6e9704bd58fbe\"}, {\"tx_hash\":\"4028f8e6e85378d7bda36539b58159b22d0fcf658e5cba84ff3c3bd6cd1fcdf3\", \"recipient\":\"1HA1cai9V1uzCT62tWuSfydbgtLgyt8bTy\", \"status\":1, \"created_at\":\"2014-03-21T18:30:23.280Z\", \"updated_at\":\"2014-11-05T02:01:53.261Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e96df52be3a2b2560dcf8967a629fa21a3567b86dfda8e2960557945574d1759\", \"recipient\":\"17apfom6T4LZEKd9XtC1yxAsRiCMx65hZr\", \"status\":1, \"created_at\":\"2014-04-10T00:01:30.432Z\", \"updated_at\":\"2014-11-05T02:01:53.271Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3fba2e0fe527f85fa90da49fef624714099cb6c37ab206278fea54e01b85ea60\", \"recipient\":\"16K3cnJZbE72eRnowCEmgR5CSTzvkKKVyq\", \"status\":1, \"created_at\":\"2014-04-19T00:01:48.161Z\", \"updated_at\":\"2014-11-05T02:01:53.280Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>a<KEY>3bcf<KEY>16754cc350f65d813825a4804597d811e9d\"}, {\"tx_hash\":\"a0f39b6c1489b99c3641fc98833d3c6816668b0925735af6381fed990a5fda45\", \"recipient\":\"1ArhbdchmwQXHd8SwymQsQJkdjFURXz7ao\", \"status\":1, \"created_at\":\"2014-06-07T00:04:15.129Z\", \"updated_at\":\"2014-11-05T02:01:53.289Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4e9c565741cdc89df91406b17605ff014a896917b6b531d248d24c898cff1c28\", \"recipient\":\"1A19BhZBV4EstbyWAPaXjnM2K1y5rhhpAm\", \"status\":1, \"created_at\":\"2014-06-08T00:00:28.939<KEY>\", \"updated_at\":\"2014-11-05T02:01:53.299Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"638825d12cecdcd45100de8364da6cd62350bc0851cba288613583ee6b8f9871\", \"recipient\":\"1LayyTVH9XLo5SC48fwQ6sQS8uH94HzeVM\", \"status\":1, \"created_at\":\"2014-11-26T00:01:03.506Z\", \"updated_at\":\"2014-11-26T02:41:13.596Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"af1370ba00198de53709e1db13245a2651078bfc91b6720c9c9f8c44087144e9\", \"recipient\":\"176XGqHurSCZwTB5KtM2A65oCHicRjkPUm\", \"status\":1, \"created_at\":\"2015-01-30T00:00:52.768Z\", \"updated_at\":\"2015-02-01T08:32:00.780Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4e0e85de3430e92744c5db1bd8424f63146d85ae1d3735beb51d10bc6ff5e598\", \"recipient\":\"1DKH1SfrZ4J92D2DFnUfLXLPmYpYr38fUS\", \"status\":1, \"created_at\":\"2015-01-23T00:01:53.137Z\", \"updated_at\":\"2015-02-01T09:11:38.573Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a38fdad21e38e56dafbf2c12da1552d19181356d807c80bf3b542be88a9edae3\", \"recipient\":\"1FdDPvRK7ZdTu2yJLUxKcdVWvycq9X4FAD\", \"status\":1, \"created_at\":\"2015-01-21T00:01:05.382Z\", \"updated_at\":\"2015-02-01T09:11:39.068Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f155d9e6f0e63848112fdd4ee56b0b3583b69a8085a83e3857258522c50a33bf\", \"recipient\":\"185ZkrVnneUkhzmAjzXRm9Eq1htKsmHeCz\", \"status\":1, \"created_at\":\"2015-04-12T00:01:12.172Z\", \"updated_at\":\"2015-04-13T03:32:15.143Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"940b1c299bc80d09db22878e96589f8181a0ce4bce8df5f6a26e65fdd7538360\", \"recipient\":\"1CpuH9WNK5Mw4ZqCjVy9AKjHZkDosJDwXA\", \"status\":1, \"created_at\":\"2014-09-27T00:03:57.190Z\", \"updated_at\":\"2014-11-05T02:01:53.308Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3bda48eaa0d8a65b722dc323e8403a0a269323c4731cd9ee3f2947c1b02f4d4e\", \"recipient\":\"1PPavrDe6vdr7efY4YyJqipTmcZnosULN\", \"status\":1, \"created_at\":\"2014-08-29T00:04:03.885Z\", \"updated_at\":\"2014-11-05T02:01:53.318Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"006d98d7cc04610e99e26064ca341f8e1e03ad3b488137a63dcb9c52090fe221\", \"recipient\":\"1FiYmARFCDRhoQYdwHBWKSnogFZdqT1VRc\", \"status\":1, \"created_at\":\"2014-11-27T00:01:26.805Z\", \"updated_at\":\"2014-11-27T08:31:38.423Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6ac17d327a1af6d4c23d4df61e6c8ec7ffd19582f4417b749d6066384cee1643\", \"recipient\":\"1AihosgYQiPPwnttgo8xm1n81e8J7h2xCq\", \"status\":1, \"created_at\":\"2014-11-28T00:00:42.741Z\", \"updated_at\":\"2014-11-28T01:31:35.785Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9d5fbf9b2a08ab1fa138e4e186c9ebd8c1d0e93b43b94ebd356723f555bf083e\", \"recipient\":\"18Ptciey75pUzyRWZGyqvwvsrGX87tAtbm\", \"status\":1, \"created_at\":\"2014-11-29T00:01:35.977Z\", \"updated_at\":\"2014-11-29T14:02:32.236Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a0565e9c65c5e6521fc808edd311456912dbd1ef4d1953563b744130febbe397\", \"recipient\":\"12oje7qNQMu3W7kwp4nAuP6aQPAidw83tt\", \"status\":1, \"created_at\":\"2014-11-30T00:01:06.188Z\", \"updated_at\":\"2014-11-30T03:41:26.418Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"788901fe347df34bbba5b0b811b7dcb40adc9336b8869e3f26225d102832927c\", \"recipient\":\"13GP9Bv9kegfFauVeqKWHcvqCYCFWVWVxe\", \"status\":1, \"created_at\":\"2014-12-01T00:00:53.067Z\", \"updated_at\":\"2014-12-01T01:02:20.176Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"62e612858a11f764d6de72da806540d088e8aa7ac225142178122350c76f2c40\", \"recipient\":\"1MSn81x2n5bPk5rATRvbjMwGnX2tyEzuUU\", \"status\":1, \"created_at\":\"2014-12-02T00:00:42.038Z\", \"updated_at\":\"2014-12-02T10:31:40.609Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a740c53413f576cc6774c5e0e5e577e395a4f7df50fd5bf4676fb9f0c650a8d7\", \"recipient\":\"18ahpKZ7b6n9kCGXyL3yk3J1KANSEUNbbf\", \"status\":1, \"created_at\":\"2014-12-04T00:00:49.839Z\", \"updated_at\":\"2014-12-04T05:21:26.521Z\", \"private_key\":\"<KEY> \"public_key\":\"<KEY>}, {\"tx_hash\":\"1596943406db888462b84b833319044a41a5f2639a2c972cd420ed0d2c95d786\", \"recipient\":\"1D6brAwYaq3DifUbNBPqLMi1ZZgsGaRbsx\", \"status\":1, \"created_at\":\"2014-12-05T00:01:39.128Z\", \"updated_at\":\"2014-12-05T04:41:18.769Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8fd29553b5dcbbee3f9f2348cc44fddd72f29da252df8a23bdf99b98c8a3a8e0\", \"recipient\":\"1Ezjd74wFjwn94y8uGrU4VzgbD5MnAYm3u\", \"status\":1, \"created_at\":\"2014-12-06T00:00:48.354Z\", \"updated_at\":\"2014-12-06T03:31:32.361Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"32240fc3fdbd0584dbe3cfd219c8991e50ff7c7277cbb08ef8a9a4972326d8c7\", \"recipient\":\"1Aj9bFfaXKsXoJF2Ksnu7ALFSLow5kPrX4\", \"status\":1, \"created_at\":\"2014-12-07T00:01:17.515Z\", \"updated_at\":\"2014-12-07T01:03:04.602Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cc6fb0bda4f2e417df47924453e28a64600699d544f6485b3e00b2dd5ffdec45\", \"recipient\":\"1KkFSNDPzBKbd6ASjU8JuX5RTM58XbWJmt\", \"status\":1, \"created_at\":\"2014-12-08T00:00:57.494Z\", \"updated_at\":\"2014-12-08T06:21:25.426Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ff889c510fb6c7f3f3461b29d8ed4e07166e4096f6880828abadbc5196fc4521\", \"recipient\":\"1LpqkAAE1YbZbNKP242xSevL5vxum8jVjs\", \"status\":1, \"created_at\":\"2014-12-09T00:00:27.922Z\", \"updated_at\":\"2014-12-09T21:31:35.358Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d2c9f2e2744e13456bf403d6e7ee88e48d34680aa6fd3a5f77b095e5d93e5c81\", \"recipient\":\"1FendAsmKLEbDYuRDdeit9t4dsjd1RRxUs\", \"status\":1, \"created_at\":\"2014-12-10T00:01:05.687Z\", \"updated_at\":\"2014-12-10T01:11:25.531Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e82455ed<KEY>cda5baf8<KEY>3790701f8ecb7f08cbad38c69cc4d2941d891c8f25f\", \"recipient\":\"1HfUEjA2i1F7w8RVchpo17Sezij6CQoCkd\", \"status\":1, \"created_at\":\"2014-12-12T00:00:34.338Z\", \"updated_at\":\"2014-12-15T07:11:58.195Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9bc74c1389e34c836e4b66b8106bb1f3506e1b77bc639ffdeecdbfb71c52e566\", \"recipient\":\"1PSyeNNXJu6jGbQh8LFRem8erokxyiQfue\", \"status\":1, \"created_at\":\"2014-06-10T00:02:54.117Z\", \"updated_at\":\"2014-11-05T02:01:53.328Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>c0182d8e79c33479c5510411a888efff992c8d218be3ec5a721ade2ab9718e4707992afe8e4099e2b2b2e45b6daca8f09ac5690c9110589<KEY>a64c71a64aa463\"}, {\"tx_hash\":\"4e3f39c404deeee1ea63393a5cb789374896f320f2f5322830a1297ea6f3db52\", \"recipient\":\"1PZFokPxzHYgAukejrVNjF43L4re3FyRsj\", \"status\":1, \"created_at\":\"2014-06-20T20:23:21.378Z\", \"updated_at\":\"2014-11-05T02:01:53.344Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7729867b65e959d3ca78eb27428b8a9a4b446a8868383e8fe9853f93409e6d08\", \"recipient\":\"16fGJQsyyzJRvA7EUyEUpnWKG9MXGHYKkW\", \"status\":1, \"created_at\":\"2014-03-22T18:30:07.901Z\", \"updated_at\":\"2014-11-05T02:01:53.353Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>b<KEY>ee<KEY>}, {\"tx_hash\":\"c62c201342aa9f5bdc0bf22e075dac5d70057a939be3176800f574ad87739c6b\", \"recipient\":\"1EcwbLEhkqrYcpHBkmGD9wktwbo6vxccmx\", \"status\":1, \"created_at\":\"2014-05-16T00:02:21.191Z\", \"updated_at\":\"2014-11-05T02:01:53.363Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d14350bae9ebfd6d5fd1d1a14260725c523a2418acc9452a67699354987bdb70\", \"recipient\":\"1KazxQSy9NJ5iGJkn55BJGT7nKAkt4nGqi\", \"status\":1, \"created_at\":\"2014-10-03T00:02:30.353Z\", \"updated_at\":\"2014-11-05T02:01:53.372Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f19de2eda6ceb4465f0f2f6e51699b7e34d374c8<KEY>\", \"recipient\":\"15DA5aCRy12vvMZ7MYsd8y6UmXBvxFNie2\", \"status\":1, \"created_at\":\"2014-10-04T00:01:16.836Z\", \"updated_at\":\"2014-11-05T02:01:53.382Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"955fce669b8e39ae8019c252d8b87fd5e54d62c9f5257dc8c1df2286a7731625\", \"recipient\":\"1Lo6YAJP1aChnPQ41LRVyiwyr9T6PUiUoo\", \"status\":1, \"created_at\":\"2014-09-29T00:00:58.816Z\", \"updated_at\":\"2014-11-05T02:01:53.410Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"eb2f56a706f8695c21866542c6fee70fe4c0f6e4b84e1402fe1d6701d0d40cef\", \"recipient\":\"1A6ZjoJe4hdMj7AMCdpWuYtLqBjVbqvoWq\", \"status\":1, \"created_at\":\"2015-02-21T00:01:32.561Z\", \"updated_at\":\"2015-02-21T23:51:38.171Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7f8d7ef78b392baa65b3564ca4c2af9dc1505f2fb9bced620de471097d85dfc7\", \"recipient\":\"16vStVunYSJLab2nYWojf5239YvztKZrHV\", \"status\":1, \"created_at\":\"2014-12-03T00:10:56.380Z\", \"updated_at\":\"2014-12-03T03:21:12.903Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ac053b59823bb9fc4f466ccebad61c126f5f5b87c721819438e43b9423fa459e\", \"recipient\":\"137QUkdudDw1R86va7c2o7xkFVrPeB4TGS\", \"status\":1, \"created_at\":\"2014-12-11T00:00:41.846Z\", \"updated_at\":\"2014-12-12T03:03:00.623Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6d61fbd4c7c7cb957ba9bad778f688<KEY>f7a4b6fa586c2b49<KEY>860ade584ced4bf\", \"recipient\":\"1DruqemSaF2WiaUMVCC8VEeEVXP5rkBjrW\", \"status\":1, \"created_at\":\"2015-03-09T00:01:22.368Z\", \"updated_at\":\"2015-03-09T02:51:37.961Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"110f9cc7eed95cdab83a75159dc80ce98c5fa6e1ac9809444fafaad9dbf9af76\", \"recipient\":\"18XsBQ1mkRo34Uwd8jGyXTo8cqNL4sSCWz\", \"status\":1, \"created_at\":\"2014-10-08T00:03:09.097Z\", \"updated_at\":\"2014-11-05T02:01:53.420Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>0f81419<KEY>9<KEY>e3d919<KEY>2cf586<KEY>1a91<KEY>0<KEY>02733b7<KEY>70fd9030603f765497ab2a01d082af67a18bb3273d0\"}, {\"tx_hash\":\"c35a6d329334d51d8131c9b2d90b5539f6473bc04ad0ee1ee5a9701b824106fd\", \"recipient\":\"1FddQAF7Ekad3ZbCPvjDa7mJCKLJoRWq53\", \"status\":1, \"created_at\":\"2014-09-06T00:01:48.575Z\", \"updated_at\":\"2014-11-05T02:01:53.430Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0cdee6fec1e8fcfeef6877a3eb3755ca90874afe13fd3371e1041fb0d824507d\", \"recipient\":\"1Q6EwC7CpCMa9wfe<KEY>\", \"status\":1, \"created_at\":\"2014-10-10T00:04:43.291Z\", \"updated_at\":\"2014-11-05T02:01:53.447Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e5f2600d775cce0ffaad0d49e17268da513ead7a7ceb1feb7f6c24d3883c9a68\", \"recipient\":\"1L5nvobdgFUGkoV9DFqmeNW4hHMogDPRQE\", \"status\":1, \"created_at\":\"2014-12-16T00:01:32.944Z\", \"updated_at\":\"2014-12-16T02:11:47.375Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>49d311c399fff1d5434ab698a047b5c17bf5a45\"}, {\"tx_hash\":\"4a59a8642442e211c434124a361d857cc6b7eee4ff62ba578b9b7e4ad6a879e9\", \"recipient\":\"1McvkcqHXrHAiJTzFwjLMTVNpAMATGstnQ\", \"status\":1, \"created_at\":\"2014-12-13T00:02:00.649Z\", \"updated_at\":\"2014-12-13T01:51:27.991Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"da504ee3868a3b33a17c1046107b374051759c2534fbca7d7303fc029b62a2a3\", \"recipient\":\"1PAqJm6XMcDkbxahziREZA5cLZHJpB37pv\", \"status\":1, \"created_at\":\"2015-05-16T00:01:20.924Z\", \"updated_at\":\"2015-05-18T09:51:31.248Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2b60edaf17da94fd876eb298ec76cfc871e1b277a257a4af8ab409dc1d36715c\", \"recipient\":\"19TBcRdoZkGTXozqYQxCJhw6dudmzNbApg\", \"status\":1, \"created_at\":\"2014-12-14T00:01:20.919Z\", \"updated_at\":\"2014-12-14T01:21:22.291Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ad9d0483ef79b303615d1a78d09846ad164e75785fac6e898441b025b81aade9\", \"recipient\":\"1KyDvfF9KixQpVU6GPU7HWDh7646TZNQbp\", \"status\":1, \"created_at\":\"2014-12-15T00:01:18.403Z\", \"updated_at\":\"2014-12-15T01:41:27.818Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"257f8e66371e728160d020a90299c5aaf5532816cb6adbb14bedc7608273c3eb\", \"recipient\":\"1DJjj57xGxVm6oM69hEs9FyLvAjKEZ8U3Q\", \"status\":1, \"created_at\":\"2015-02-03T08:25:13.022Z\", \"updated_at\":\"2015-02-03T18:11:44.812Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"14c9813897febd3ce406717b010bb2e2c78afe584099d050b1b10f5699c14f62\", \"recipient\":\"1FP4VeiaEPon1ibJTqGaZu7TLj6hkTjWr2\", \"status\":1, \"created_at\":\"2014-12-17T00:01:29.311Z\", \"updated_at\":\"2014-12-17T08:04:36.447Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4ea030d2b5f63ac3a4fb39b4cd14e9071d46d7d07051c3a0d5f3fb086ea65013\", \"recipient\":\"1HfLpsy6B6uSRcepq18m2cMfwJETjEXTnp\", \"status\":1, \"created_at\":\"2015-02-24T00:00:37.074Z\", \"updated_at\":\"2015-02-24T04:21:53.109Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>8f739f48cda369d8\"}, {\"tx_hash\":\"85d6f06fabb725147f196ff23ecca82bb1e22ea651630023bb30ae9e9e73175f\", \"recipient\":\"1JhwSqmqdyXT32ZKnLMJYcwjqxpLbW16Ln\", \"status\":1, \"created_at\":\"2015-04-18T18:38:35.335Z\", \"updated_at\":\"2015-04-19T05:51:45.524Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"fc3282c0ba4c0858091ba7ac8486cd9d0fd65d8f17ec52ac1aafdcbfb4a87608\", \"recipient\":\"1NeNjHBHBZTWJxwBrVgiS5Qwhm5v1ybU82\", \"status\":1, \"created_at\":\"2014-12-19T00:01:33.692Z\", \"updated_at\":\"2014-12-26T15:02:35.179Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5ef24006465b48e339ce3d7ae5af6da353cfc37af0a502711f02acfaaf518a99\", \"recipient\":\"16KYScxfa8xaXLuvJ7yRshhhrG7NBy9ZxT\", \"status\":1, \"created_at\":\"2014-07-07T00:03:23.585Z\", \"updated_at\":\"2014-11-05T02:01:53.456Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ba88a190f4c65b3a069e74b04580c32351dcb76286c87bed6809cd4f966cf315\", \"recipient\":\"1EHe5Fw8K7Q5TtxaWbLodznj97FFFPAVjX\", \"status\":1, \"created_at\":\"2014-03-24T18:30:49.312Z\", \"updated_at\":\"2014-11-05T02:01:53.466Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"09088155124078b04884d8dea35fa262dea21ca50dfce2a4e29e1b4244b4cd1f\", \"recipient\":\"1APCpFuFrd5uk5PM6NsbcTavcYnSvoCDSz\", \"status\":1, \"created_at\":\"2014-06-03T00:01:18.232Z\", \"updated_at\":\"2014-11-05T02:01:53.485Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>9c473c8c8cfe1cfb07b01746dfaed83745f00283f63791d52764fc4872a7954f\"}, {\"tx_hash\":\"8955284fb0cdddd166c10c66f1dbd15e82313aa0fcbb23bcdb800a3c7ef74d75\", \"recipient\":\"17GZiqkCqJ5gkn9QefEZeZ3XsHPQcdQoKH\", \"status\":1, \"created_at\":\"2014-06-28T00:02:58.649Z\", \"updated_at\":\"2014-11-05T02:01:53.494Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"708f1c7125cfc80ae6f5504f349d02d93ebd77ec8d75e7c5491de7145e64a3f1\", \"recipient\":\"1Q8dVs8WpKsB6ej3hHCqs9i3WDJmWp1Z8u\", \"status\":1, \"created_at\":\"2015-02-04T00:00:52.844Z\", \"updated_at\":\"2015-02-04T02:02:40.718Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6c81aee4f3a1c06a98dd7be17d08435693f0744dc1a915194d0b721077e61cff\", \"recipient\":\"1FoHf6ZfSJxXxYNxUJyiqWJgWGRabxM6Jk\", \"status\":1, \"created_at\":\"2014-12-21T00:01:30.330Z\", \"updated_at\":\"2014-12-26T08:20:35.137Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c169fbead005637c6506e47c6298334e86943c711d9cf7672d45f9ba4ce<KEY>\", \"recipient\":\"13WcphmngCvPaG5hrp622DH9iKXZzp6QTD\", \"status\":1, \"created_at\":\"2015-02-23T00:00:33.304Z\", \"updated_at\":\"2015-02-23T09:03:46.995Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"04fd971aff7716594dad0dd659e76b0508c0aea08f7f4b2ca65cbefbdfcf08ba\", \"recipient\":\"12ws8wHDrKDiq9J6YnPwbn7TzxXuyPEE3a\", \"status\":1, \"created_at\":\"2015-02-25T00:01:13.418Z\", \"updated_at\":\"2015-02-25T02:32:01.536Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>f197c087c<KEY>\"}, {\"tx_hash\":\"acd740897db33b8fe5f136c0e7bb6dbe8250c34a450385a96f5aafa1fb6876f3\", \"recipient\":\"1LP7rnZ9XVsdRzSZpcwtrtZYi7yGtPc6R8\", \"status\":1, \"created_at\":\"2015-05-17T00:00:47.271Z\", \"updated_at\":\"2015-05-17T18:02:55.407Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ffba72b4b4ad75be9f99d70d7400137de02d319813d48c43e632ac65428e62f5\", \"recipient\":\"18aW1v7jWJqPB26oZv5BdtSYbwJyZowmBB\", \"status\":1, \"created_at\":\"2014-12-23T00:01:30.832Z\", \"updated_at\":\"2014-12-26T08:20:35.902Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"02bb58e93fad82be2181a9df61e0c6b18bd3bad7c485f7fdfda3b3e28ef538d4\", \"recipient\":\"19kH2E8187iQhY1cfhsrCEYxKM7mDwmfKo\", \"status\":1, \"created_at\":\"2014-12-22T00:01:15.052Z\", \"updated_at\":\"2014-12-26T08:20:36.257Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"61ce589b5c7bf41a7faa951fc61ae33870740a513b21d64dedba6057a4f35918\", \"recipient\":\"1Km8AHFos4KyNN6ugKjnNxg8E9LjXrY4X3\", \"status\":1, \"created_at\":\"2014-12-24T00:01:18.656Z\", \"updated_at\":\"2014-12-26T08:20:36.599Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0db2399293136f4269af3365e5abe3b55b0ec87ae40de82c37de6078c8b53fcc\", \"recipient\":\"1NB822hbEk2xW7RVDukH6NBCZfA3PAULsq\", \"status\":1, \"created_at\":\"2015-02-23T09:29:40.970Z\", \"updated_at\":\"2015-02-23T11:32:12.414Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0269c5bfa1a3772836a48fc03f6f9c24448aa1de73c06b10cd50db81c4f0f35e\", \"recipient\":\"1PhoU2YpwwsdGgzxMLZQtnChL9vNW3L2tb\", \"status\":1, \"created_at\":\"2014-12-20T00:01:31.878Z\", \"updated_at\":\"2014-12-26T08:20:36.999Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7e0724c204189970d7597b4d54b6f4eda90d229251f240dce8fca03adfab0a2e\", \"recipient\":\"1FwfcMq3t1rPxr98vqX1nKLZex3iVhmHbV\", \"status\":1, \"created_at\":\"2014-12-26T00:01:24.323Z\", \"updated_at\":\"2014-12-26T08:20:37.294Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a0330747df03510406923c21bfeb097d751e8b4771147a296b9e04347e667d17\", \"recipient\":\"13SXAQxZYFoAcpoNuMaktRmf5YzAY6garW\", \"status\":1, \"created_at\":\"2014-12-26T08:19:28.404Z\", \"updated_at\":\"2014-12-26T15:02:35.691Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7e31fb18377e5799a96b1c973eebc9c076ad3d6bf79679cfa642d0bb1aaa29ff\", \"recipient\":\"1GJmoifR2xG3fyjWUFhU6sawrze9cD3TuE\", \"status\":1, \"created_at\":\"2014-12-25T00:01:46.938Z\", \"updated_at\":\"2014-12-26T15:02:36.335Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2e9f04c056b71a8c1a1aa6fbb19382268ed43dc3d8ff540d16c717b0a09d1915\", \"recipient\":\"1BUUyEebCA8u5dtrEjUXtFNDy9XPCrAjMb\", \"status\":1, \"created_at\":\"2014-12-27T00:00:50.433Z\", \"updated_at\":\"2014-12-27T01:11:40.472Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"bf8334fd848413ff2e5de56a7ab2fd0d66a5313c259a2f759bc124293510020a\", \"recipient\":\"198LNYTZimueegcUkkZJwhm8kNAsneEzLf\", \"status\":1, \"created_at\":\"2014-12-28T00:01:08.816Z\", \"updated_at\":\"2014-12-28T03:02:55.1<KEY>\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ffa5713c36e3323697503c224f9162daf1fcc649488f8e8a999487b533df4c2c\", \"recipient\":\"1KswqBC8LhYioAFmpvnBTxhVpEaBNemNAX\", \"status\":1, \"created_at\":\"2014-12-29T00:00:53.795Z\", \"updated_at\":\"2014-12-29T01:02:54.033Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3fee60b09cc02aa7b6bbc7c4dd4118ec290aa2d4f43c2583c66f3363187c4e44\", \"recipient\":\"19SfasMJXPr3JiZceesi9t67qq1FfN7xKF\", \"status\":1, \"created_at\":\"2014-12-30T00:14:55.489Z\", \"updated_at\":\"2014-12-30T13:31:37.244Z\", \"private_key\":\"<KEY> \"public_key\":\"<KEY>}, {\"tx_hash\":\"f464b79ade56edc9d7f8bbb6c3d63f800e4bd2decbf0705e30610a70193ad797\", \"recipient\":\"1JTgD9GW1SAcAii6BoyaFCDdjgxtC7xJ1n\", \"status\":1, \"created_at\":\"2015-02-05T00:01:13.704Z\", \"updated_at\":\"2015-02-05T12:12:12.061Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"77509145bed99546b2182b5d587bd00519bd6b102b8b93e64040e903d8ebd501\", \"recipient\":\"1HrrMHEodPsFBPwHEZi2ufpF6bT6mcS9DB\", \"status\":1, \"created_at\":\"2015-02-26T00:01:10.617Z\", \"updated_at\":\"2015-02-26T05:42:36.352Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"16b023d73816bf57d476ada2ed857e9c6ac892630306115dcdbfe2e2f9b9adf1\", \"recipient\":\"1B3x9F5uGFFZfNZkTJxDsi4mJ8r2x1oGgq\", \"status\":1, \"created_at\":\"2015-04-06T00:01:26.334Z\", \"updated_at\":\"2015-04-06T03:21:37.565Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>0c86995b6b4b787bacc1d3f4eff6827d9aaf95a6be5\"}, {\"tx_hash\":\"04f07eaedb3a19de552c10a4178a9ca291449fc43dd64f530f1a04aed0e2824d\", \"recipient\":\"1Nu9pBXYk5J1eQWhxxx4YTauXxdYCaHdGp\", \"status\":1, \"created_at\":\"2015-04-05T08:32:01.354Z\", \"updated_at\":\"2015-04-05T10:12:02.208Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"47389bb2838241eca93235f00211b7518ab7aeffd8300f02c981c92bccdcfe36\", \"recipient\":\"1Atm6DgJN8VA7N5LVtYHqC2joxefhenp3A\", \"status\":1, \"created_at\":\"2015-04-07T00:01:05.058Z\", \"updated_at\":\"2015-04-07T13:03:15.670Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1780f4b7edc3ceffb85cf853d864461f8564c4a1d4dcfc8a7e40808aa2eb417a\", \"recipient\":\"15CoibLa7ZtkEXVjBcbe7pVR9KvaxkL72u\", \"status\":1, \"created_at\":\"2015-04-13T00:00:46.102Z\", \"updated_at\":\"2015-04-13T03:32:15.501Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d3eb9cd216da609b9cc29258aab0cea8852ebd46cf26ea0e0ba36f6a43d7b9b2\", \"recipient\":\"18xoaDAM4WRammpNaDLbkDczxPauHS4C61\", \"status\":1, \"created_at\":\"2015-04-17T00:01:20.730Z\", \"updated_at\":\"2015-04-18T08:41:32.039Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7b00e00558dbe54e07687e966fbf76711ad99d61f3f63c220da5fae0780c72aa\", \"recipient\":\"13VYpPMgWij54Q8ayvQ2PGQ8EgQxCbvuvf\", \"status\":1, \"created_at\":\"2015-04-18T18:31:13.174Z\", \"updated_at\":\"2015-04-18T19:11:52.573Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"bda2605ebd825142d4e78dc58522aad5524ca5bf7ea1f1d5f95ebb7d488191f1\", \"recipient\":\"1AFseaQSqi2aU9JvfCpst34pe3CMs5J5S\", \"status\":1, \"created_at\":\"2015-04-21T00:01:39.586Z\", \"updated_at\":\"2015-04-21T08:51:37.763Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cb18d149f57c62f5cdd9e74937df1c2d3603201ca546448476a167045d7f587b\", \"recipient\":\"1GmkofsaApUKUg2XWFK54NSkQXmPMCvmCX\", \"status\":1, \"created_at\":\"2014-08-20T00:01:21.131Z\", \"updated_at\":\"2014-11-05T02:01:53.507Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>2<KEY>67<KEY>87c7d22910e3ecd42e07b5bc82f14b2be2f<KEY>dbe662474229f5ea7\"}, {\"tx_hash\":\"b4d902789d21c7108e28ce0612225eb3655f3afbb4532b65beb981c66ff06293\", \"recipient\":\"1Mn8aEDGiJTVsdX8XXyxHgQvCbptutvC9X\", \"status\":1, \"created_at\":\"2015-01-03T00:01:02.526Z\", \"updated_at\":\"2015-01-03T19:02:35.343Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4a6851a492d1e56b9b1b9ba4fa277aaea526799e8eed0edb5f497aaa2ccd6900\", \"recipient\":\"184A4UWM9ivKTXfvt2iM4RNFfZhekTA8Qm\", \"status\":1, \"created_at\":\"2014-12-31T00:01:17.007Z\", \"updated_at\":\"2014-12-31T15:21:27.404Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"182ab2e142833d58a844be450b0f480aa2f3be2493da19c32dfff7eff09e5854\", \"recipient\":\"1FvuMPjGzNEUrMjqqXqNyVg7NuLPs4aBf3\", \"status\":1, \"created_at\":\"2015-01-01T00:00:24.765Z\", \"updated_at\":\"2015-01-01T04:31:34.367Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0412d45d4e794d781a326a606a4824084d2661d2f3a884bc3f9e163ae9ff5122\", \"recipient\":\"1MMvuNXHRHAVWFZp73ucF8xi2pJK8Fg76J\", \"status\":1, \"created_at\":\"2015-01-02T00:01:00.556Z\", \"updated_at\":\"2015-01-02T11:41:39.408Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1a0fc9688bd38866c7f3abb5b35bd8509f57439d7910e96327fa6c56f1a34d2c\", \"recipient\":\"1JzVYgQean3sdpnBvivV9F8Cq1g6vZ6c9o\", \"status\":1, \"created_at\":\"2015-01-04T00:01:25.742Z\", \"updated_at\":\"2015-01-04T09:51:38.685Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0bc8b895e90f140900914892e656dd7b19f94d64087f2a50c67dd88e47a9b8a1\", \"recipient\":\"1Joj67nyw3nQJ1ySzALRx5CB2ZTCfi4Y1a\", \"status\":1, \"created_at\":\"2015-01-07T00:01:32.764Z\", \"updated_at\":\"2015-01-07T06:11:30.856Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"51d5ab218951cd8ad36c22c90e9b2ad72bd13c3e762dae3d37287204c766a640\", \"recipient\":\"1QBt3BVddLe65A6Kbau9e3LRWwFowj5EVk\", \"status\":1, \"created_at\":\"2015-01-05T00:00:52.961Z\", \"updated_at\":\"2015-01-05T07:02:51.195Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>f7923f2ebcce85083ea8ba4bc306ae0bf955fdbd9c\"}, {\"tx_hash\":\"9de1fecd8f4155859710d8502941f940b46c542b5710723cee1213f350f51697\", \"recipient\":\"1MUEjrGUMaxCyJ2Mhz8Wda9Bq4HwusP7ze\", \"status\":1, \"created_at\":\"2015-01-06T00:01:33.365Z\", \"updated_at\":\"2015-01-06T05:21:35.194Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"fc77ed3cc859b6ea0d52444492203c913351519685578f810af34ac7a928abf8\", \"recipient\":\"17fU1Z87HxJAbW2tQYd9TUKTbS5EBJukCV\", \"status\":1, \"created_at\":\"2015-01-09T00:01:20.374Z\", \"updated_at\":\"2015-01-09T02:31:37.362Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d948f615c9c8ac456573839b7a7e91127ab1df19b8f122d7f79659e167ae324b\", \"recipient\":\"1J2pJm19owYLgi368QQa4T7xskPrMQv4Lp\", \"status\":1, \"created_at\":\"2015-01-08T00:01:27.134Z\", \"updated_at\":\"2015-01-08T02:21:36.417Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"269b902c36787deb2541e1596d7a70102fd20afecd3b4ce29a86a2d82d0d01f0\", \"recipient\":\"1FmpRoghBZStYAFid53nwV3BG5cWCZYXdN\", \"status\":1, \"created_at\":\"2015-01-10T00:00:58.092Z\", \"updated_at\":\"2015-01-10T08:11:48.324Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cfeec1dcec94c588483a0f25a63aa6eed71c4895d8e4be8a5105085506717cb1\", \"recipient\":\"1B8RVypPq5kMJHYqW6tqRNzpxfCK2wFZj7\", \"status\":1, \"created_at\":\"2015-01-11T00:05:00.799Z\", \"updated_at\":\"2015-01-11T09:02:32.880Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9e412776afc88a91f0dc0921b2d0533afc75f66ac4db988205ca0de1c28af5ef\", \"recipient\":\"169pNiqDKiQpRXfZCDe64yuukUCnBPpjCg\", \"status\":1, \"created_at\":\"2014-05-20T00:01:28.933Z\", \"updated_at\":\"2014-11-05T02:01:53.527Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>1<KEY>a5d03d0<KEY>344380b3<KEY>}, {\"tx_hash\":\"959730b5fd7ff6df09f8e971c80806b68a0376bdc7dc2f994e1350c7c5211723\", \"recipient\":\"1B5KeyLZUxavyVC8W1Xf7zsKTmUZbVPauF\", \"status\":1, \"created_at\":\"2014-06-02T00:04:04.653Z\", \"updated_at\":\"2014-11-05T02:01:53.537Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c00940fe6d0976db9e53a5f41505ccea920846bcb459c1fcc06f46202657d79b\", \"recipient\":\"1L6eng3JME8eCnVFKDZdpjy2FfygoQwjhL\", \"status\":1, \"created_at\":\"2014-05-18T00:00:25.190Z\", \"updated_at\":\"2014-11-05T02:01:53.556Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3b42e20f69db1ad6f00ca56a0b2ae7c483c4f2733be759bdbc69b49feb3187<KEY>\", \"recipient\":\"1QKkr49YoLFo6Z6inHiPhfhAYFxWj9K7Hy\", \"status\":1, \"created_at\":\"2014-04-18T13:22:49.602Z\", \"updated_at\":\"2014-11-05T02:01:53.565Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"36330ecb94f53ef7502618885e4ee1eee0a1cf8b13ba4bfa1041a1f75ad85b31\", \"recipient\":\"12JYZfZp1MeB1HhmNAnYenFw26GW5oHomv\", \"status\":1, \"created_at\":\"2014-05-31T00:00:16.891Z\", \"updated_at\":\"2014-11-05T02:01:53.590Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b83800314a4c8bd79393fac714eea04a7b5d7df75d1d3c3331fb9b6c0c529d69\", \"recipient\":\"1L7rfCAkY5EDCEGwuZEuwJtccrxGN7BZMn\", \"status\":1, \"created_at\":\"2014-07-25T00:04:29.040Z\", \"updated_at\":\"2014-11-05T02:01:53.601Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"23d03659209b3c6fa8ea08cee15e4bb6a76bbd33212d1764baf0b1a21e41a72a\", \"recipient\":\"13RQZEUPLLTUJZ4DxTG3ffRqoSwZuWqyS4\", \"status\":1, \"created_at\":\"2014-08-01T00:01:40.493Z\", \"updated_at\":\"2014-11-05T02:01:53.619Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3<KEY>3<KEY>bf<KEY>c6<KEY>}, {\"tx_hash\":\"3661ef8aa0cdabf903e6ff9ea240b485655e8d0a42275e9e52a42122a32f9ccf\", \"recipient\":\"1wy2p4BV8MfPnMQMRNiNqYQEhEB7LgQYj\", \"status\":1, \"created_at\":\"2014-08-14T00:02:18.460Z\", \"updated_at\":\"2014-11-05T02:01:53.628Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8bc4889e0134508b4cdec5cd972fcfc7ceecb4e02dd1c79c714992c9fbc0271a\", \"recipient\":\"1Ee8boWJvKykTevPbsnUVXwBtwXfmEcArm\", \"status\":1, \"created_at\":\"2014-07-21T00:03:33.063Z\", \"updated_at\":\"2014-11-05T02:01:53.638Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ffcdf1aae1acb22d9c81641e545ba20918a65eff2458c3e2c473dd27b6c63927\", \"recipient\":\"19sAkdCSQPPXfieXbYtDsoRAY8iWeerxBb\", \"status\":1, \"created_at\":\"2014-07-28T00:04:33.768Z\", \"updated_at\":\"2014-11-05T02:01:53.647Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>1d371a<KEY>b2b276<KEY>}, {\"tx_hash\":\"e4b2966b3f9c99ba188d3667cbc32b476745bb7f2bc7d40f7ea333aab9312323\", \"recipient\":\"1Nsd7DeFSfgWPmscYx9VEj9ZbPHvs3mE2f\", \"status\":1, \"created_at\":\"2014-08-10T00:01:44.536Z\", \"updated_at\":\"2014-11-05T02:01:53.656Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"025e34722395211a0f05847679334a66b36d5da52e974fb4ce1ebae62df0e7ed\", \"recipient\":\"1KbD8WUePmwXmpAMrH1jmws9aLxa3tLRL2\", \"status\":1, \"created_at\":\"2014-07-16T20:37:30.619Z\", \"updated_at\":\"2014-11-05T02:01:53.675Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"51f87059c234fb2ff758895c8e7c990059bf46a5d54a1aa31c32f27641b20a2<KEY>\", \"recipient\":\"1F1M4K4KfGq5qtzB4CsXBjdHriYufu85Ah\", \"status\":1, \"created_at\":\"2014-07-16T20:53:56.446Z\", \"updated_at\":\"2014-11-05T02:01:53.685Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4e468ff7adbb480a6020188ed6c5103582f17673a2c297cec5fc0c5e3b80e98e\", \"recipient\":\"14habrH2ScUbrWcWy5NpaXuoefQ2CnpNLe\", \"status\":1, \"created_at\":\"2014-09-08T00:02:04.828Z\", \"updated_at\":\"2014-11-05T02:01:53.703Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ee1b6b5b44cc6926aa7c4a76a82fed0966ecf20160d2c5d127a8f993ca0f5459\", \"recipient\":\"14jqg33KWdjJqq5ExtudvsepTMdT5j3aeR\", \"status\":1, \"created_at\":\"2014-09-24T00:01:07.631Z\", \"updated_at\":\"2014-11-05T02:01:53.724Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4ec4374f1caa4646199806f21645052c8540ac060974c3fb143dc8a1289718fc\", \"recipient\":\"161mmBrmvm9K7S6sgCFmC2h4NJ77aAPAkJ\", \"status\":1, \"created_at\":\"2014-09-14T00:01:40.268Z\", \"updated_at\":\"2014-11-05T02:01:53.735Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"10fcab160176e81e8df317706742da904d9128040c0a84ac00d91845e5b05be1\", \"recipient\":\"18GFJ5Um4ictjRcPg1Utpi5Kvk585dW7zV\", \"status\":1, \"created_at\":\"2014-09-16T00:02:37.395Z\", \"updated_at\":\"2014-11-05T02:01:53.745Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0684e3a180763c820330628a2173f54961120ac0f0921f49b93117ff965a8a77\", \"recipient\":\"1BLEAyLhuDjHyRweJH4ntnFC98CiA71hLo\", \"status\":1, \"created_at\":\"2014-08-23T00:01:03.235Z\", \"updated_at\":\"2014-11-05T02:01:53.784Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"98cfc06713213692a745a3d10e992dac492ecb178345d6370509cd039e5a1422\", \"recipient\":\"1CK6H3xA5w44XwFMRmeFbAv7fjZ8YZMapr\", \"status\":1, \"created_at\":\"2014-10-20T00:03:25.551Z\", \"updated_at\":\"2014-11-05T02:01:53.800Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>\"}, {\"tx_hash\":\"155411ca3c5dac0298dff2ace9e3b855609645365c00e744e830d8a0c8ebccca\", \"recipient\":\"18EgiSrkM48ZWB8CiQtVVVPPyDWitatto6\", \"status\":1, \"created_at\":\"2014-10-02T00:01:06.472Z\", \"updated_at\":\"2014-11-05T02:01:53.811Z\", \"private_key\":\"bf2ed9a7659ea3c3819fd6c8f40927fe0db3dca050820f8ce234ecdf81f97946\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7b8ba249ca64b3900aa6c08d929a94c60c446a5ca33d19e54744b4cf0f43c525\", \"recipient\":\"1FDVeHvKAmgryxuJ3tNJYsnPpLuvYWufG6\", \"status\":1, \"created_at\":\"2014-10-05T00:00:46.280Z\", \"updated_at\":\"2014-11-05T02:01:53.828Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>8<KEY>182d222efacc\"}, {\"tx_hash\":\"a578adb058de0aa8ab5c122ed9a7396018e611aac7751f37cacdc46e7ebdfb77\", \"recipient\":\"14WKY4JEEG8jXRTtdHm24NMJgae1kbJtU5\", \"status\":1, \"created_at\":\"2014-10-15T00:02:07.663Z\", \"updated_at\":\"2014-11-05T02:01:53.844Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f111ee1d4f16fddf35a5634a2fe5fa6e6b68240f2156d5a1f6e236ff9ee57f1b\", \"recipient\":\"1Nizee17zZ4Dhk5gysqBnCeLPSJXY6pqLR\", \"status\":1, \"created_at\":\"2014-05-25T00:00:59.698Z\", \"updated_at\":\"2014-11-05T02:01:53.853Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9181cd4434d9bb2ba6a840b4161334cd519b47de81efab3d3b9db3f262065b2a\", \"recipient\":\"1KNMWBTfJZaZEvok96hLrDwpStKQHFvJtC\", \"status\":1, \"created_at\":\"2014-06-05T00:03:47.226Z\", \"updated_at\":\"2014-11-05T02:01:53.863Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>db722f98df\"}, {\"tx_hash\":\"3d0e2a091327adf984350745f7c66dcb7875c03855a083978ac7d5c6af3c936f\", \"recipient\":\"1JpEtyrKVnjKctfEZLt4dTfGEPJT4RuSgX\", \"status\":1, \"created_at\":\"2014-05-27T00:03:38.266Z\", \"updated_at\":\"2014-11-05T02:01:53.879Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"76a88d221e6c8748027642db86c76a6179fd7c9e67e9b8462626ad9ec2785be0\", \"recipient\":\"12H9khkAqWA4E1Qum2FCwYRaQT8ozt9foL\", \"status\":1, \"created_at\":\"2014-10-29T21:55:10.444Z\", \"updated_at\":\"2014-11-05T02:01:53.<KEY>\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"00558a6bf42975bc24ad0c46951ac4d36b284b7d2f8869798de217e67326aef7\", \"recipient\":\"1C2kUE3cHanHaPCogP14tR7h5V876zXwSx\", \"status\":1, \"created_at\":\"2014-09-15T00:01:20.644Z\", \"updated_at\":\"2014-11-05T02:01:53.905Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>7<KEY>f45b25608400917abba92b2827af6\"}, {\"tx_hash\":\"7d170a86f561701d9b3fe793f1ab5c27c3b08fdafd1a037cb0a6facf07d70a43\", \"recipient\":\"1GSSHwJNz9ZWczwb5cDECK9DhoJTym6itU\", \"status\":1, \"created_at\":\"2014-05-08T00:02:24.003Z\", \"updated_at\":\"2014-11-05T02:01:53.915Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4c7994c370b0b7a58f3df65e0fcc5223cd57b2ffd3548a6395f0424be5306d46\", \"recipient\":\"145fVeQPhJGJf6Jq5UhbJw7UVpnopbCBqh\", \"status\":1, \"created_at\":\"2015-05-18T00:00:58.730Z\", \"updated_at\":\"2015-05-18T09:51:31.657Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b1b35b093ffb7ba24155cbbb211041377f3a2c44be0d4a376860024ba2331602\", \"recipient\":\"1E2ZWykKZUP11yo4YS8vyFXLWAJeYKPbrx\", \"status\":1, \"created_at\":\"2014-10-26T00:00:55.447Z\", \"updated_at\":\"2014-11-05T02:01:53.934Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1552390c50242cddb935f58c88f3c12dd189a55fd661b864764792d689f68f35\", \"recipient\":\"1JrKRhniUKoTsUSZsui8zDTaGGKfqAo7Ub\", \"status\":1, \"created_at\":\"2014-06-18T00:04:04.229Z\", \"updated_at\":\"2014-11-05T02:01:53.946Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"364cfa51f9dd1a3f66d1997d3dfc14097aa2c4f302543996304a386452127148\", \"recipient\":\"1HqhqeHDwfvqUV6s2d6oWA6rBfwxmvuu8Y\", \"status\":1, \"created_at\":\"2014-06-16T00:00:46.148Z\", \"updated_at\":\"2014-11-05T02:01:54.054Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e7380c96301a7c5644f6064cc1000db9d863a36722f0b9eb5ac4fee8250ccbeb\", \"recipient\":\"16X7Z3WkAwgZdtRc67BjzJaaAyVGC9XvVw\", \"status\":1, \"created_at\":\"2014-06-21T00:03:29.175Z\", \"updated_at\":\"2014-11-05T02:01:54.084Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e4aad1c75c097eac80e68c2df0db1870c0abb3c9a0ed3ac2b2d06feb88cd0bcb\", \"recipient\":\"19TyvYS74Ho6RDUyoDNZaS9sVTYJdvjcKn\", \"status\":1, \"created_at\":\"2014-06-22T00:02:54.977Z\", \"updated_at\":\"2014-11-05T02:01:54.095Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c533d2f3b74b6e53fd69e0d284779158c91d17bc05f0856c1d4a0a5d8f8d18c4\", \"recipient\":\"15qyS9x5RYnaKodT5gYjrhTLA1qw9jfsdo\", \"status\":1, \"created_at\":\"2014-06-24T00:03:43.006Z\", \"updated_at\":\"2014-11-05T02:01:54.110Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c5735f619ea9450afba8a3c39654f5acf60d1ffbc6135ea77703d5216342917f\", \"recipient\":\"154uJzLAiosPPiRD3QLEh1nEk3iZjVu5gk\", \"status\":1, \"created_at\":\"2014-06-25T00:03:27.933Z\", \"updated_at\":\"2014-11-05T02:01:54.120Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>488843909\"}, {\"tx_hash\":\"daf1a9dd37cfa364750ad4623f9494f9180f4a6c0d6c7820075ca907e9181d6a\", \"recipient\":\"1Bn1CULrCZqwH3sPMVBvP7Jo1z5U9DRL6G\", \"status\":1, \"created_at\":\"2014-06-27T00:02:00.853Z\", \"updated_at\":\"2014-11-05T02:01:54.130Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"918f4636b7da99f39ef93395e618fb8150fb99b5822c2bef9bda681ad0653229\", \"recipient\":\"1Q9oX1DrVd39UVx39vV8CxSXyJTXUhnzia\", \"status\":1, \"created_at\":\"2014-07-05T00:00:23.364Z\", \"updated_at\":\"2014-11-05T02:01:54.147<KEY>\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f3bcd428858081ff82f64a583c347aa714b1c1394b8757f2944f9848d1f6724d\", \"recipient\":\"17Tqrjw1BvscnyobeiPAH8Nqxf1TQD44x2\", \"status\":1, \"created_at\":\"2014-06-30T00:01:35.126Z\", \"updated_at\":\"2014-11-05T02:01:54.157Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>2<KEY>27<KEY>27d036813c922cbc5388c152cc6627b\"}, {\"tx_hash\":\"1daaf9ec98513538ff85f476c801cab0736428ccc786f8221c68f84e9e432764\", \"recipient\":\"138PyficovYkH7Ut9oRjxTMyJRiWyf8XRG\", \"status\":1, \"created_at\":\"2014-07-15T00:03:11.112Z\", \"updated_at\":\"2014-11-05T02:01:54.179Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"adf352f73e98f56ed55e1c4fe9f46d406b4686b4162ab66f5fc7246f5d8313d2\", \"recipient\":\"18Rigxnx6D9aCgJfrbNu8stUihJio7zhuK\", \"status\":1, \"created_at\":\"2014-07-16T00:02:59.233Z\", \"updated_at\":\"2014-11-05T02:01:54.211Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6ea75d536848f9a1dc8d0e04510767d2e2fb34055605fd52a1b2a3a2c4cece04\", \"recipient\":\"1DQUJ4Z6ygitDpopQskPRCuQwm9Ez8ajdM\", \"status\":1, \"created_at\":\"2014-07-17T00:01:57.057Z\", \"updated_at\":\"2014-11-05T02:01:54.313Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>1<KEY>1639a88d0b41ef88d1c61c74725\"}, {\"tx_hash\":\"623cd0dccd6281011ccf7935f69e261e6ffa267d0d229d6f7d9cbe8decc89b11\", \"recipient\":\"1QCuZWoH5xCTgQbfxH7uzxNo3FtxDAxNdq\", \"status\":1, \"created_at\":\"2014-08-07T00:01:52.728Z\", \"updated_at\":\"2014-11-05T02:01:54.331Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cd86d40b2707dee5e3edff0cf2c5ecba63bfd969b501190ec7c311130f084285\", \"recipient\":\"1479tCiLWz5aKvM8SKxko9uiTrX8K2HwpG\", \"status\":1, \"created_at\":\"2014-07-30T00:04:26.693Z\", \"updated_at\":\"2014-11-05T02:01:54.341Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f8e2eed5464b174d25cc7d48836f6683cbee14080a191dd81f2ec7979b8bd4c4\", \"recipient\":\"12rB5WuthGjSCgJ4tzw9gHrLmoHYTqUQqQ\", \"status\":1, \"created_at\":\"2014-08-06T00:00:39.527Z\", \"updated_at\":\"2014-11-05T02:01:54.357Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>8<KEY>49<KEY>109a0ae95f3d82b167658cc1fb684645\"}, {\"tx_hash\":\"8ee99265fb77f830ba79759d509ce585196e2c6623c99866aa3e19a2dbc43066\", \"recipient\":\"1YYekbc3L3cM2Fq2UE1fnxxK1TBfjxPhX\", \"status\":1, \"created_at\":\"2014-07-19T00:03:31.239Z\", \"updated_at\":\"2014-11-05T02:01:54.374Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2e83d98c31147546570bb123716cf7359ece3d3eb342adf4fb4c5a3db211d68f\", \"recipient\":\"1EWrwRRuPeFZqtuupHKXfFJVsVNyxwdGYg\", \"status\":1, \"created_at\":\"2015-02-28T00:01:10.314Z\", \"updated_at\":\"2015-02-28T02:51:43.930Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8905d041a4fe8903ba16f4880f43dba84ee8e4eb1fb57a7ada22a5eb00406050\", \"recipient\":\"1NEVG8nLCVfdsBe2pJTxFEzvvKnh3AA5qV\", \"status\":1, \"created_at\":\"2015-03-13T00:00:58.406Z\", \"updated_at\":\"2015-03-14T03:22:00.346Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e9b5dfe44174ccd94fd6ede31da13fe9608d2ed9addbf81b93ac7bf7bd8ac4ae\", \"recipient\":\"18c8SznKPzHihmrbcM5wYdGSUHPzGuH<KEY>\", \"status\":1, \"created_at\":\"2015-05-19T00:00:42.053Z\", \"updated_at\":\"2015-05-19T13:21:42.197Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a5490f9df9b4d5f11e6c0a33cbce388d37176ecc988594daaa1a752bd029f01c\", \"recipient\":\"1EyRXrtiGcsVDAPv5WacybHY4SvbzVeaJk\", \"status\":1, \"created_at\":\"2015-02-27T00:01:33.835Z\", \"updated_at\":\"2015-02-27T00:53:05.189Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2c056935b77b9644684f7dcd7d0b679fe8fc8e02aae314ba0d03cc40043db054\", \"recipient\":\"19WDbpqrZttg4uG3L3Jj1UHWEGCnSbT73s\", \"status\":1, \"created_at\":\"2014-07-22T00:03:43.152Z\", \"updated_at\":\"2014-11-05T02:01:54.395Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"39db27fa5adcaf0b828d5037a882a4a5efcf6bd3551fefe171a339d3fa418c86\", \"recipient\":\"1Kyh12UYzPeLygRc73UMDUTydREBJLSnTx\", \"status\":1, \"created_at\":\"2014-08-08T00:00:57.109Z\", \"updated_at\":\"2014-11-05T02:01:54.408Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7e2f10ee736048c19c19c1a7202b11a7a438ba7e7bba7128f559bf9c8c463eab\", \"recipient\":\"12M3XZJf9pppmVHidyxJSXi9Xo3ei5ZXun\", \"status\":1, \"created_at\":\"2014-09-21T00:01:02.250Z\", \"updated_at\":\"2014-11-05T02:01:54.418Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"35189b74ac7e0cd8fb723b450f8d63f9b52b628dc5dd3599eadde8d1bbd2a332\", \"recipient\":\"13MePxVWGvK2qxd3vhef2Wf79zYQiGNwQL\", \"status\":1, \"created_at\":\"2014-08-13T00:02:04.590Z\", \"updated_at\":\"2014-11-05T02:01:54.427Z\", \"private_key\":\"<KEY> \"public_key\":\"<KEY>}, {\"tx_hash\":\"eb286633e29904901ca2ae4df5bbaf14aa25e4c8387d985adc4873dceba9798b\", \"recipient\":\"19pR3kzPsghsaXsgBXHHoF4zzjXKDvf3AF\", \"status\":1, \"created_at\":\"2014-08-16T00:03:17.308Z\", \"updated_at\":\"2014-11-05T02:01:54.444Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"b4b82100bc96cb2531b11a228cebe6e81871d919219aae23d0cff67b9103a3bd\", \"recipient\":\"15amQEzENHMw1Cgd6dawfU1Mceh695453a\", \"status\":1, \"created_at\":\"2014-08-19T00:02:33.963Z\", \"updated_at\":\"2014-11-05T02:01:54.460Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"633e453ecbc79bff9260bd1e2ae6fde79199871e8817b27664e389801ca27b95\", \"recipient\":\"17H66Co6zon2Lm83SCdLfGwn4LgGiyAJkf\", \"status\":1, \"created_at\":\"2014-08-15T00:01:15.375Z\", \"updated_at\":\"2014-11-05T02:01:54.470Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"14ac6a2f3eabde6d34518e6b45a4b611029b71d43b12d4547b2be076486230dc\", \"recipient\":\"1GqJQ3CB3QQSqfx7n5YMMWiXZpCzCm8v7N\", \"status\":1, \"created_at\":\"2014-09-03T00:01:25.216Z\", \"updated_at\":\"2014-11-05T02:01:54.490Z\", \"private_key\":\"<KEY>759<KEY>1<KEY>2e4<KEY>3582ffff973085ec56f18be6f8618ece2a94579edb771c62\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ce9a86fffc98ee5581d0afcc7e2c31b3629425821edb1f340da71cfc5bc67815\", \"recipient\":\"13KLTTQASP88L6p12ELqJy4bjnDSEwozCz\", \"status\":1, \"created_at\":\"2014-08-27T00:00:50.518Z\", \"updated_at\":\"2014-11-05T02:01:54.499Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>8af6ff9\"}, {\"tx_hash\":\"a58ab327b123f52cfb4dcf55ab20f370b64c216c46225e0fda9daa463485caf1\", \"recipient\":\"13pj86PtizzrVsWBK67xrVsit4fcFxoboX\", \"status\":1, \"created_at\":\"2015-04-09T00:01:17.301Z\", \"updated_at\":\"2015-04-09T03:41:32.631Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f349f7a051bdccbdaaa8a8aa6f4e1d7c1e525fcad210503f968881b9ca3f3953\", \"recipient\":\"1FDYRCzyrBxtPQEUcYtPn31Z57sEWdSZ77\", \"status\":1, \"created_at\":\"2014-09-11T00:00:58.352Z\", \"updated_at\":\"2014-11-05T02:01:54.520Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1be02fd5d8ff79ff476c98e8579c03df39f86d4c84728a5dfbc16cdc970ec15f\", \"recipient\":\"18zCuxKJB3BrFuxneGZvqXuCK6ePn5uxJx\", \"status\":1, \"created_at\":\"2014-09-13T00:01:26.758Z\", \"updated_at\":\"2014-11-05T02:01:54.546Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d7f8eaa6c629835573b2ea32c2fff12e716f7ee715c93d758d7054bc4ee1856e\", \"recipient\":\"17kK2Yjiyx45UFcegEjoJGL6AbP8bNnHRQ\", \"status\":1, \"created_at\":\"2014-08-28T00:01:40.142Z\", \"updated_at\":\"2014-11-05T02:01:54.556Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>d<KEY>63217<KEY>22bf<KEY>07d<KEY>3<KEY>8<KEY>}, {\"tx_hash\":\"f912b95edf2f3c27222e7bf5fcd16bc289e703332374bc6c06494806bb19721c\", \"recipient\":\"1EymstwppqpjDLnppAzzkaP4oRewC2WtFL\", \"status\":1, \"created_at\":\"2014-10-17T00:02:39.244Z\", \"updated_at\":\"2014-11-05T02:01:54.570Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"030c377b490360e39c8bb321d235ce04bce32a930d844033989c17607c1fa545\", \"recipient\":\"1BdRoLwdDTyg5pwi9t1S2kFova32Yzr2ux\", \"status\":1, \"created_at\":\"2014-08-21T00:01:45.354Z\", \"updated_at\":\"2014-11-05T02:01:54.580Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a7d0a02d81ce67e33b948b22618358527a9286073bf0e9cf46e1c80865ebdaec\", \"recipient\":\"1NvZdFo4sfTGd2g6MEo3mwwWD9psA6DNQ7\", \"status\":1, \"created_at\":\"2014-09-30T00:02:40.948Z\", \"updated_at\":\"2014-11-05T02:01:54.594Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>b<KEY>}, {\"tx_hash\":\"1cfe6f32d9ecd8467da2ef350cc12355744f3394b7263f1438fb0a0348261f9f\", \"recipient\":\"1JwkcQiauoeuRoAw3tAV8NsHox46zavWxL\", \"status\":1, \"created_at\":\"2014-10-18T00:04:07.895Z\", \"updated_at\":\"2014-11-05T02:01:54.604Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7351a3ecbf091b4bd26879f682cdd3e9a0d6dcf03046d006bbe955f0d7328cb5\", \"recipient\":\"17w1KLLKTRELdWjUTG3PhJh5ZNP9faNwHg\", \"status\":1, \"created_at\":\"2015-03-01T00:02:10.733Z\", \"updated_at\":\"2015-03-01T03:32:15.363Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f97397d2ec383e005bd9eb92a7537f188fc6c35ca851d791beaca510275d3c9e\", \"recipient\":\"1Fzbp3xAjvLW3rsis7tBdhUHYhk62my6qJ\", \"status\":1, \"created_at\":\"2015-05-19T17:36:52.626Z\", \"updated_at\":\"2015-05-19T18:12:12.879Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8801507b6464f0c271b6dda43fd46c306bafe1e96b1e026ff3dc702916484ce8\", \"recipient\":\"1CXMpUCwgXsFv3kVuCWNKndLxdkPucgMXg\", \"status\":1, \"created_at\":\"2015-02-06T00:00:50.455Z\", \"updated_at\":\"2015-02-06T01:12:09.129Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"09ddafe9b2a44217c28b88c4b2b0b7a2fd5b058ccd4423e2c533f267fca34f55\", \"recipient\":\"19zViZWqcAk9hZ4FkvSgXTQ36TrMM29gdX\", \"status\":1, \"created_at\":\"2015-04-11T00:01:10.824Z\", \"updated_at\":\"2015-04-11T04:03:53.529Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"97dc3f7272e00a2adbc36134861ad20f0c39a099b794781a896c585d66cc2994\", \"recipient\":\"1DJew7kboAeRf9ZvZsXkr7CdhNBs3mxuNb\", \"status\":1, \"created_at\":\"2014-09-20T00:02:49.930Z\", \"updated_at\":\"2014-11-05T02:01:54.635Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3dd943557ace2a9889317a3d3a32c59c3973f635c29bb5c470ae3d9ad32371f7374f1df14004553d65011643\"}, {\"tx_hash\":\"6e77511b73eb74999f1baa1da4c01f05da61362dcbb2a5b92cf2bfc9ba80a833\", \"recipient\":\"1HJdTKwaMiJTJg2qSWkAaR6VLAoQfZFo4j\", \"status\":1, \"created_at\":\"2014-10-19T00:03:29.701Z\", \"updated_at\":\"2014-11-05T02:01:54.664Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d10225248e5742e0001196eefef871e2abc6ec682bbb547449278c053e87f4eb\", \"recipient\":\"1GscL6FtdwR8HCGtntanruiUgx7WyaEKR<KEY>\", \"status\":1, \"created_at\":\"2014-08-09T00:02:52.005Z\", \"updated_at\":\"2014-11-05T02:01:54.674Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5f8636d47e297945df2152d366f4addffbf59a1f34ed23599509af5918e7c8d6\", \"recipient\":\"19cEFAbviq8Jn8wnkhC66RfVypq21QmBL2\", \"status\":1, \"created_at\":\"2014-09-04T00:01:21.963Z\", \"updated_at\":\"2014-11-05T02:01:54.684Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>dd<KEY>bcc<KEY>27b<KEY>ddd4<KEY>\"}, {\"tx_hash\":\"87dc93e880ef54fd656d393b071de5ae248f7d6d16dfc64ab681d76a3a51637e\", \"recipient\":\"1KX1Uj6wZ3XvbVQ8JZuERwjNTPdQV1NA9A\", \"status\":1, \"created_at\":\"2014-09-09T00:02:16.514Z\", \"updated_at\":\"2014-11-05T02:01:54.694Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4da9a8e99bd107aef496ef7d6a082ad6f0ad40ff3555ac79c7e88b4513e38dba\", \"recipient\":\"183RdFzvnR4iDTYxfDCmu<KEY>\", \"status\":1, \"created_at\":\"2014-10-24T00:03:15.523Z\", \"updated_at\":\"2014-11-05T02:01:54.704Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"49f2c9c84e1176113b6e5a8072c26a664eae697155b059bf5b0369823bf6d59d\", \"recipient\":\"129FhScAaPJrMhRVDQR6gUj8mQLYrH6u9r\", \"status\":1, \"created_at\":\"2014-10-25T00:02:36.246Z\", \"updated_at\":\"2014-11-05T02:01:54.720Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>b3c4c1df0282c25145312ea4<KEY>14<KEY>2<KEY>6<KEY>02<KEY>02<KEY>0<KEY>26991a<KEY>2<KEY>6<KEY>1<KEY>7<KEY>1e4<KEY>9<KEY>0af<KEY>c84d<KEY>d29<KEY>2d4c6058bb723cd4d770421c34a4ee281694159ee6d7ed\"}, {\"tx_hash\":\"8be98aeda1900f4c0dad61489aefc1319d6739213a82af48c46152aa8a1748b9\", \"recipient\":\"14csJV8qA2JxqqycQRsGWEipak8QyGpsyE\", \"status\":1, \"created_at\":\"2015-05-20T00:01:16.616Z\", \"updated_at\":\"2015-05-20T02:41:24.667Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"09aff87f6f8470af69fa7999fe1c8c57ac3bbcb27632201de4fb4d47b01cf434\", \"recipient\":\"17w55VgkraGP7ePuoi8R51VGXUz6N2VrMr\", \"status\":1, \"created_at\":\"2014-07-13T00:03:11.848Z\", \"updated_at\":\"2014-11-05T02:01:54.741Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5faa33de1954e3d3e7a86dc2b3382cc4bb34467397bb1fb42ea6607a6eccd985\", \"recipient\":\"1Jhh1fiPXujNKyQXx4Hp8HdrjUvNJNrsPw\", \"status\":1, \"created_at\":\"2014-07-04T00:02:40.993Z\", \"updated_at\":\"2014-11-05T02:01:54.758Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>c25<KEY>ff<KEY>f<KEY>0bf6<KEY>9<KEY>e<KEY>1<KEY>ae<KEY>\"}, {\"tx_hash\":\"62e706ab68ed837ad1bcf46af3bef4332317e4d207a8e3baeac281a64e964094\", \"recipient\":\"15nW73dJdqnJKyhwF2kT74631LxGMtxrws\", \"status\":1, \"created_at\":\"2014-09-22T00:01:16.469Z\", \"updated_at\":\"2014-11-05T02:01:54.776Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"bf63f9301f6c44b64b37bbb1f688d7e9e6dbdd0aeac00acc3416d75248d25d84\", \"recipient\":\"1Gu89n93x7ejfcFaEzqqcnSSv74dqfATJ2\", \"status\":1, \"created_at\":\"2014-09-18T00:01:30.745Z\", \"updated_at\":\"2014-11-05T02:01:54.800Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0a4c0eedc64788e0bd7bc5b6f904db320ccee05bab4bfc7e3768ada9c65db7b8\", \"recipient\":\"1K626vn2b75F7E6ga4BT6NGfBJLgRy4b2a\", \"status\":1, \"created_at\":\"2014-03-06T18:12:18.631Z\", \"updated_at\":\"2014-11-05T02:01:54.811Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>365234c6a7378def8ebb5ed860864c04a939b702235011b7b38db4472209a8779aef7e41a8af6d89caf614dd9\"}, {\"tx_hash\":\"f2dd148488005569176b02106d53800921a45b253b85b3266584e791e7ce8dab\", \"recipient\":\"18qJB63Fu25HDJEnPhvyJoHzV95q44tawR\", \"status\":1, \"created_at\":\"2014-06-20T00:02:59.970Z\", \"updated_at\":\"2014-11-05T02:01:54.824Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"22d7711d3700984fe0f9a4b24ed6d9f0002d92e186ed70a004c03eee4a0d8878\", \"recipient\":\"1HSrRGG3xTTgXSSGs<KEY>\", \"status\":1, \"created_at\":\"2014-06-19T00:03:08.596Z\", \"updated_at\":\"2014-11-05T02:01:54.834Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7e8a9612907c313ecf112d77c8728e7454809f74db005a5d95f01a699c2a2244\", \"recipient\":\"1Mbrt1KyLjjNbfht8uHvgZCRBAwBmeHRYz\", \"status\":1, \"created_at\":\"2014-07-11T00:02:53.893Z\", \"updated_at\":\"2014-11-05T02:01:54.882Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>37d8e0a0720b7eb43465f0eb880538e2b46ef4379661<KEY>849650de02bc9d80a3ebd20aba8e478fb93381451fa839afb37c6b4083e681e97bc42d25f\"}, {\"tx_hash\":\"1ced7a8bb16d007989137638f80c2e7e98f3693792fdf6ba10f67fc5800d66b9\", \"recipient\":\"1k8ZH4KMF8jjNhiZqpH1dAc3TCdPoWtFz\", \"status\":1, \"created_at\":\"2014-07-06T00:03:46.146Z\", \"updated_at\":\"2014-11-05T02:01:55.071Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1820a8227530e2de48b6f8901239ab9bfb2bef14ce8e82c32650236b197fb5c7\", \"recipient\":\"13sQenmSSWutGBf531Vfo6qihS3VgyHx6s\", \"status\":1, \"created_at\":\"2015-03-02T00:01:18.650Z\", \"updated_at\":\"2015-03-02T04:21:43.443Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6833db89c0603cff2ff8ee9b3cf4a1cb0274566b8c432fb79b16eeebcb3741f6\", \"recipient\":\"1JwjA5kbMBHw94vBRib2cSu6TNcYh8UQfC\", \"status\":1, \"created_at\":\"2015-03-15T00:01:12.338Z\", \"updated_at\":\"2015-03-15T23:11:50.287Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>bc66f669b\"}, {\"tx_hash\":\"f1b9e9017b97007f4fcffa3b7704da134d62c2db6d53f0b3ba236bd88c599a76\", \"recipient\":\"1FQ4TEV3482bmV5dysx4fBbkMhF34mMvzN\", \"status\":1, \"created_at\":\"2015-05-21T00:00:34.812Z\", \"updated_at\":\"2015-05-21T04:51:34.994Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d9341c7ae399a33f05f3c2061fdcd1674857bd244aede6aba86b00b202b30b6c\", \"recipient\":\"1BTq9R1V4txJzDHAAcSifDM4FopS4MNmos\", \"status\":1, \"created_at\":\"2015-02-07T00:00:26.651Z\", \"updated_at\":\"2015-02-07T02:03:43.065Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"d6c6ddcb450e1434dfdc4717b771d25c0c0efad04e7ab6946cadae496942c445\", \"recipient\":\"1PF4wiajPbdfQAwFs3qn1YAXNAtXiWdc4R\", \"status\":1, \"created_at\":\"2014-08-05T00:01:02.573Z\", \"updated_at\":\"2014-11-05T02:01:55.138Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a648ca92a6a620cbda3e7dc59c4542269a8c0895a3ce52443c445ca507ee702a\", \"recipient\":\"17wUqNtW71HeJ<KEY>\", \"status\":1, \"created_at\":\"2014-08-12T00:02:02.109Z\", \"updated_at\":\"2014-11-05T02:01:55.288Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7825d568ec2485d01bb0a857e91fa49c849d0f14bf3ba00033eed9c52347959b\", \"recipient\":\"1JEvnUs6xYdSFszAfypnRFmCTqvarUHmyb\", \"status\":1, \"created_at\":\"2014-09-05T00:01:10.782Z\", \"updated_at\":\"2014-11-05T02:01:55.307Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>113bd8787fd8ca8938d15549f0833cf7bd386db7c5a69b3007c74eaac1fc99f6132b468f1b90bd078ad375e4ed75e0572c28d8e1305ad9710dc4e87\"}, {\"tx_hash\":\"63186ca40ef1330ddfd4c8b2c283a25726b6122e78810e4d28fa6702939e63cf\", \"recipient\":\"15VzZi3gFGLMxfFUvq7YtAD94sYWb2ppmh\", \"status\":1, \"created_at\":\"2014-10-07T00:04:18.578Z\", \"updated_at\":\"2014-11-05T02:01:55.318Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4219480d1f44541eede61328b015740d4c197d6b798581455612af034171f5f8\", \"recipient\":\"1Jiz6h7uZBf7qNim8gsqR77jSxT6fPRJAQ\", \"status\":1, \"created_at\":\"2014-09-10T00:02:07.158Z\", \"updated_at\":\"2014-11-05T02:01:55.328Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>2a0<KEY>a<KEY>57684<KEY>\"}, {\"tx_hash\":\"c8d18a04fe3986a2f67df0a59a92870931cd83a5e804cb743db25008de95f13e\", \"recipient\":\"134Yg6CsVgwXvHYuRrFn4HutxHPutVdDew\", \"status\":1, \"created_at\":\"2015-03-03T00:02:14.707Z\", \"updated_at\":\"2015-03-03T05:12:59.529Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c859873bd52b52b4f2e1e33eada6c5695a23ad1d2812966e17bea24e27a4e1d6\", \"recipient\":\"1N7zsioZcNvYV8fEuZgqoZgp4sBKaCmK8F\", \"status\":1, \"created_at\":\"2015-03-04T00:01:27.787Z\", \"updated_at\":\"2015-03-04T03:03:56.466Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4aa383e4de6f7953fd0034f7c3d4b8560b3d4413830ca9c3951be7148f474bfa\", \"recipient\":\"1NP6YELeLM8rAvcaTdWd488zGxcKMdu8HB\", \"status\":1, \"created_at\":\"2015-03-05T00:01:23.190Z\", \"updated_at\":\"2015-03-05T01:32:01.215Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"df0044bd6404470a20248f7c324865abae7cf55203329e96fa8d38a40704d40e\", \"recipient\":\"15vNTK3VGHmNh4ZXKxGcJtW4RL7HwrW3hm\", \"status\":1, \"created_at\":\"2015-03-05T07:01:23.044Z\", \"updated_at\":\"2015-03-05T09:21:32.063Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ccedc74c3489c0943e0de27d7fc969e736fadd748b91b9c30874be10abbe8031\", \"recipient\":\"1JFNFsMNmPKXyGvzkcmfgEhAgeB59cPre3\", \"status\":1, \"created_at\":\"2015-05-05T00:01:01.506Z\", \"updated_at\":\"2015-05-05T13:02:49.422Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"610008c9614a4e60bf0e13649e67a0160faaf2fdace74db1d58e34d8069cf7fd\", \"recipient\":\"14CvSMCLEqcEJXfyxQ15qP4NHPQEsuTEyc\", \"status\":1, \"created_at\":\"2014-09-17T00:01:45.324Z\", \"updated_at\":\"2014-11-05T02:01:55.413Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>dfd5c10fa4889<KEY>6aca3b190ce9b146e8ddf893006bbcba020ec47\"}, {\"tx_hash\":\"60ed5cf4eb7df8fd5440253b6ac9f38ee475b613350b849a1b84f79e2c7a3be5\", \"recipient\":\"1HdE74JRCoRtvabShnrVR6W33g7n7kN5bm\", \"status\":1, \"created_at\":\"2014-09-25T00:02:36.163Z\", \"updated_at\":\"2014-11-05T02:01:55.424Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5b1cfb278417b9ecca5c0abff5d82559d68cac6b3c0957ed4662fcde49e9bb79\", \"recipient\":\"1LTLoErGNyJftJiKNhx7f65yeP6GDe2C8i\", \"status\":1, \"created_at\":\"2014-10-23T00:03:01.135Z\", \"updated_at\":\"2014-11-05T02:01:55.435Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c37c292036ac8e53f45df7b1d579c991a14d71dda38e3cda127f3b9e6bc5dd28\", \"recipient\":\"13MAP4k1pemMJSy37Gs1bDkuXebQzBHDft\", \"status\":1, \"created_at\":\"2015-02-09T00:00:31.189Z\", \"updated_at\":\"2015-02-09T13:03:50.510Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"00e4789a46c033dae3037037<KEY>bc1f0dd2f93c05<KEY>cdbcd8787cb11<KEY>ede56f\", \"recipient\":\"1KuNUh1cZvYpmj5S4SRAVSPWT27jUfybvE\", \"status\":1, \"created_at\":\"2015-02-08T00:00:40.432Z\", \"updated_at\":\"2015-02-08T01:12:05.179Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"da52e261090e4fb2cd27a4b3a03ee3f5405439ed6c9c879a6adf6547dd30fe39\", \"recipient\":\"17xca7Da51PXG1R3Nn3nodKvWxC6HUEmwb\", \"status\":1, \"created_at\":\"2015-05-22T00:00:51.136Z\", \"updated_at\":\"2015-05-22T02:31:58.591Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>1044fcdee10d430a33dedf552fdbce9436314\"}, {\"tx_hash\":\"e6f168271eb096f8531eeeb8a7ad7f7013c5aa0b1a67c811530e9ea9ce46dfbb\", \"recipient\":\"1NgeXp6dcody7TmUJGdMJ8yV6bAZZwNp7o\", \"status\":1, \"created_at\":\"2015-02-10T00:01:15.427Z\", \"updated_at\":\"2015-02-11T00:32:22.795Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2ffed5570f19bffb44893b93b29d5e83dd123ca2867bd7aae3437a66b8315d6c\", \"recipient\":\"14ek3CPMHb1J5nAWcWhGxjWNqehd11Pun8\", \"status\":1, \"created_at\":\"2015-02-11T00:01:12.172Z\", \"updated_at\":\"2015-02-11T00:32:22.423Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"fce90aaef1c40c8af54806e65521c1394d2ff2b132e1e03b1ab89f87cce9ba89\", \"recipient\":\"1EETrb2TDoHFYUKZn7vBfC7mgfVReN8szA\", \"status\":1, \"created_at\":\"2015-02-11T22:29:03.282Z\", \"updated_at\":\"2015-02-11T23:22:08.636Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7ba5c520cd592957a5fbee281b640b26a1ba0ab87110c7a575690a0a7169e2ad\", \"recipient\":\"1P19fwU71UiP6UdYrhqXpXgKK9uZ7U2KUi\", \"status\":1, \"created_at\":\"2015-03-17T20:21:18.737Z\", \"updated_at\":\"2015-03-22T18:25:58.264Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"69637167f28291d8aa121614a47e82437fbe61c1c789b07566cd7e89cb53bbe5\", \"recipient\":\"192FGXVbLFXyHL5x7nYakAP2e1Rs5f3nWt\", \"status\":1, \"created_at\":\"2015-04-14T00:00:26.323Z\", \"updated_at\":\"2015-04-14T14:32:22.890Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"85a5b7ba4b8cbf31561251a1497a5ae87025be746d22f30a688e79820df64751\", \"recipient\":\"128q5ggsK1CKzJuypLwMZEcj4QwyAyYsb4\", \"status\":1, \"created_at\":\"2015-05-23T00:00:58.432Z\", \"updated_at\":\"2015-05-23T05:31:50.072Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e31f22e1bbd2ba8fb9cfca379bf14d81e2a0e27404513fd627658c7afa128d84\", \"recipient\":\"1ASh51xLdLTY2Z2kXKNv4r1kN2a5Z14XL6\", \"status\":1, \"created_at\":\"2015-04-15T00:01:14.815Z\", \"updated_at\":\"2015-04-15T14:42:02.003Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c6b2274f27896e417929ae81b1d8b726396d90bcb936779e5a6333ba644f4550\", \"recipient\":\"1K4o3My8VfAwzurMYt9FX1oCJiw2kS92iw\", \"status\":1, \"created_at\":\"2015-05-26T00:01:00.661Z\", \"updated_at\":\"2015-05-26T06:51:22.413Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"83343c039915885b1f4038527ff33931fc2c7c3e496a24a53377141313dd457b\", \"recipient\":\"1LjmYYrbPuoSmb7xdRsghZd8ws1trz6uYp\", \"status\":1, \"created_at\":\"2015-05-24T00:00:32.908Z\", \"updated_at\":\"2015-05-24T02:11:49.871Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1f4065055093d010042577f05747abc10824880242e7cf2c83aaa64c11fa4480\", \"recipient\":\"15gMq9qEyDWrdAvmMidaCLcvL1oxRpP2DF\", \"status\":1, \"created_at\":\"2015-05-25T00:00:48.974Z\", \"updated_at\":\"2015-05-25T06:51:33.537Z\", \"private_key\":\"<KEY> \"public_key\":\"<KEY>}, {\"tx_hash\":\"4286ba63dbf5b0d8a5371e22e39fea93655f5f5df7c736ee90aa1efe5f88a1d6\", \"recipient\":\"1JenQeTcNfFn7Nak52PfMNiXUvJsMftHcD\", \"status\":1, \"created_at\":\"2015-05-29T00:00:26.911Z\", \"updated_at\":\"2015-05-29T14:03:00.926Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c34d5b08276f93a1c028f20664c052551700db7109433a9411eda12400c4cb39\", \"recipient\":\"1FdR2QGCLvZVcF26vArJRt3X1wpPyNJ6Ao\", \"status\":1, \"created_at\":\"2015-05-27T00:00:52.694Z\", \"updated_at\":\"2015-05-27T10:02:52.082Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a7d4eb81767d73f97944fec27ca0034140370ffa5947ddae6df7a8102889d<KEY>bb\", \"recipient\":\"1EMD8PuWR74KASVpL8kLLj74iJGhcBWQK3\", \"status\":1, \"created_at\":\"2015-05-28T00:00:29.181Z\", \"updated_at\":\"2015-05-28T05:03:28.627Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7fc82e3563429340e8404d1f4995503169e51d36eeaa957ffed5b93e09878de8\", \"recipient\":\"1NTjnNNzSeyys1Cgx3r3Es1fCFTHARjEW8\", \"status\":1, \"created_at\":\"2015-05-31T00:00:53.040Z\", \"updated_at\":\"2015-05-31T11:21:33.999Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>05e102f2cd677c8\"}, {\"tx_hash\":\"de5f0b9034b658a24ac062d9a31c382cee30a8316781382321c5baa5298823ed\", \"recipient\":\"17fv7DkQCGEPeJPY92BpXQcEeugVKVUUWg\", \"status\":1, \"created_at\":\"2015-05-30T00:01:12.794Z\", \"updated_at\":\"2015-05-30T03:32:00.344Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f4e00063cd010063ef8ee04e192b609b5822f7ef296a59fd9ed31ed3a7cea3f6\", \"recipient\":\"1HqmRrfKtmLbfug9oTbXVsUUAqWgMxMHX9\", \"status\":1, \"created_at\":\"2015-04-16T00:01:19.301Z\", \"updated_at\":\"2015-04-16T04:03:16.440Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e4638d4474a25588230d6575e76300f813853283cfd473a5e290259651b85001\", \"recipient\":\"1Ga5W1Cwi6ss5cNzwJNyU1GHPkgj4NBgxe\", \"status\":1, \"created_at\":\"2015-06-01T00:01:18.431Z\", \"updated_at\":\"2015-06-01T07:51:32.206Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f143abba8681b940a49039520290d2551dd4416770d2fa26ced8a5196c51fcb2\", \"recipient\":\"129wcuqbcxEcqUZNTjn2Xd5qEryvBda4AC\", \"status\":1, \"created_at\":\"2015-04-18T00:00:58.014Z\", \"updated_at\":\"2015-04-18T08:41:32.317Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"243d27bcec12af06a1949493beaaff2976d4fc88757ca5a6bddb767ef9c7df95\", \"recipient\":\"1F9LAX1237fuGaYB6wuBDSsaqEFNFvyqLd\", \"status\":1, \"created_at\":\"2015-06-02T00:00:31.528Z\", \"updated_at\":\"2015-06-03T12:03:21.213Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"52da0fa05666543b5274488c20e69f668a7690b30db721a5a9a6702b833bf4e1\", \"recipient\":\"1NjEfap29LwbEq51DADiafWSK6eCkFhQ23\", \"status\":1, \"created_at\":\"2015-06-03T00:00:40.467Z\", \"updated_at\":\"2015-06-03T12:03:22.708Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"df6cf8d16929c774087741f382af107cb235d97eac61e5833439a5e3afd3700d\", \"recipient\":\"18mpztXerZGxJGxBReAp2jEtN4FDxkm2DQ\", \"status\":1, \"created_at\":\"2015-06-04T00:01:15.261Z\", \"updated_at\":\"2015-06-04T16:21:45.524Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4e8eb46448426032879947076c199bb11e4dd4460837d5a7c08ec16fb46271ff\", \"recipient\":\"1CRLSUTsof2gTdrH1hiQ9QB37YzXtkeKjQ\", \"status\":1, \"created_at\":\"2015-06-05T00:00:37.446Z\", \"updated_at\":\"2015-06-05T11:31:57.539Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3abb61b9874c7cfccae4600afb118d5a27513a454bd7512fc25e6115b6281040\", \"recipient\":\"12t7uSvSyHxHxvFvtbJhAKdKusuhhjzzc6\", \"status\":1, \"created_at\":\"2015-04-20T00:01:15.302Z\", \"updated_at\":\"2015-04-20T09:41:54.346Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>3245d9a21065fbf50d7c9048d46e563a55761a4184a34bb2c\"}, {\"tx_hash\":\"8cd48be8895fd816d724fd940241f4317bedc09ca70dd99ea48e4a7be4bf95a0\", \"recipient\":\"15GAnzUpPZ214joynVfaiBStombZGJba53\", \"status\":1, \"created_at\":\"2015-06-06T00:01:03.073Z\", \"updated_at\":\"2015-06-06T05:40:52.213Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c236a3e52c9001d605d053622d270229cfaa558a83b68e365dcfcf869d7f2a9d\", \"recipient\":\"1BibV4kKVNm18T8SXG6y37CkA7NXuiXTT9\", \"status\":1, \"created_at\":\"2015-04-22T00:01:26.706Z\", \"updated_at\":\"2015-04-22T08:41:53.733Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"54a521b952245944108a36505046f8a05d7324dc2f8df6186946e0b511cfa5a8\", \"recipient\":\"18dsDDLaFNbVuypxtVBdFc3oQP9dmNYR7k\", \"status\":1, \"created_at\":\"2015-06-07T00:01:26.683Z\", \"updated_at\":\"2015-06-08T10:22:23.891Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1aef91a65dafac5d25a3b25e8318fd6334c55cc55ad14cd19f3daa573ad36e63\", \"recipient\":\"17kQ6XLqKC7S9GwZR2krqzPQypNacRhiZC\", \"status\":1, \"created_at\":\"2015-06-09T00:01:10.425Z\", \"updated_at\":\"2015-06-09T08:11:58.711Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"52d153459978f94e1ac50d794604af2559d388d096c467f6a43e095de071dd6e\", \"recipient\":\"18u3mWfLsxwLgtCc2ewQCKB9PsNY6XSR7c\", \"status\":1, \"created_at\":\"2015-06-08T00:00:44.298Z\", \"updated_at\":\"2015-06-09T23:11:42.877Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"1add190c1855f385345fddb9b2a47c9b5ec770beca77dc29bbae3d41da0546af\", \"recipient\":\"1DBJ4TPhYronVs6XUHMz5aKbJPuaXs2caY\", \"status\":1, \"created_at\":\"2015-06-12T00:00:49.355Z\", \"updated_at\":\"2015-06-12T07:11:49.584Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6e7b11c90f4a1efe1f66ea101c1fe67cb6049b068ab82459ac081865c46626d9\", \"recipient\":\"1AHTtr569CuaGfntp2skwPXoSPfK6rCjEg\", \"status\":1, \"created_at\":\"2015-06-10T00:01:21.683Z\", \"updated_at\":\"2015-06-10T11:32:12.558Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>6d06261d8e7826fc1f32c48f93811\"}, {\"tx_hash\":\"be685122eaf9a33de0b42469107be6420bfc98ad3ada7ab3683be5c10e121243\", \"recipient\":\"1AgQC8xCi3mVUwrqG6Yh5WCLb73DQ13Zrd\", \"status\":1, \"created_at\":\"2015-06-11T00:00:59.166Z\", \"updated_at\":\"2015-06-11T10:21:57.744Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0591f38e4fa3ea24901ecef1f004a73952a95eecfde4b8f8956728ea37df9a7a\", \"recipient\":\"12B37YnjFK3zzFa4dScMGdrudAV7tTCTCC\", \"status\":1, \"created_at\":\"2015-06-16T00:01:29.196Z\", \"updated_at\":\"2015-06-16T09:03:09.965Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e6830222ea64aaffdf6bec6f939c67293caf1e0c4da9c263ad3261336d38244e\", \"recipient\":\"1LJTkkxAQ2Fo7t4KMX6TE5mWr9u1ZYRmy7\", \"status\":1, \"created_at\":\"2015-06-13T00:00:51.190Z\", \"updated_at\":\"2015-06-13T13:31:55.735Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"2cf1696dffc4fd60815d4b9ec51e21ceec79ac74eb481c359aca501f4bc6cc3c\", \"recipient\":\"13EYhcrNJ3ypBiz1uZdUGYVw4CXxhsG4nV\", \"status\":1, \"created_at\":\"2015-06-14T00:01:25.168Z\", \"updated_at\":\"2015-06-14T03:51:39.522Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"ebd5df214591d2917a5bdc6f842d1e3e7a7359ffa9f89e06d37f0a939ef0afcb\", \"recipient\":\"16XyHmh7fHWcaSoyiDoDmbXvUprNEKXuUE\", \"status\":1, \"created_at\":\"2015-06-15T00:01:21.530Z\", \"updated_at\":\"2015-06-15T02:51:53.312Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"9ecc5fb8218f44360626dd2be29d16693f4d46135892e578d03b6bcb50644737\", \"recipient\":\"13kL4ptfdLJCfdYHqKpmzHBdPfW3mDfDN6\", \"status\":1, \"created_at\":\"2015-06-18T00:00:28.166Z\", \"updated_at\":\"2015-06-18T00:51:41.767Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"7a4c8c771d9e7f86e1fd4cc9312b1f1565330ccfbff74556f2235a956c7c1afe\", \"recipient\":\"1QG1qg7dCNuBoFi9gEvwFdDheDnYfiQLVE\", \"status\":1, \"created_at\":\"2015-06-17T00:01:10.464Z\", \"updated_at\":\"2015-06-17T03:02:55.614Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>2258\"}, {\"tx_hash\":\"0251488c32a8f9689069d430905a29a82defd550c666a6e842c2ac45c4aafd4c\", \"recipient\":\"1EQm68Ab2TNNeUg1uGPicFtNAu3uuMmzFt\", \"status\":1, \"created_at\":\"2015-06-19T00:01:11.356Z\", \"updated_at\":\"2015-06-19T01:21:56.644Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"e5fe48f5866d164c22002519e0c2222e909ca20bd76fdec6aa6da498f7d74e28\", \"recipient\":\"17Nx5goCqUCTATy1rPkfNJNwNmVzWJBBsW\", \"status\":1, \"created_at\":\"2015-06-20T00:00:50.189Z\", \"updated_at\":\"2015-06-21T11:31:45.628Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"432085e2792541b3e3ed0f2754833af40ce12d89e00a1b1f3b4aff856206949b\", \"recipient\":\"14D2wKGeB85Z3uh1E41QxBiUuBaTmsiNGc\", \"status\":1, \"created_at\":\"2015-06-21T00:00:29.732Z\", \"updated_at\":\"2015-06-21T01:41:47.825Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"4970c8abdfb28495a96d211faace07aa78b0f7167bb939aa97f85d9ac3ad3e93\", \"recipient\":\"1PYgWKcShWALzGb1yd6zay2BzkoaCw5qeo\", \"status\":1, \"created_at\":\"2015-04-23T00:00:18.959Z\", \"updated_at\":\"2015-05-17T04:02:55.691Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"132e5f8e5f84d7520877cc0a85faaf9e433ba364990fd808b12b0e96b42b03fd\", \"recipient\":\"1BCrNrSMbs4k2TsCUq6csuWocajQLwW91z\", \"status\":1, \"created_at\":\"2015-06-22T00:00:49.615Z\", \"updated_at\":\"2015-06-22T01:03:10.433Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"8773ab632d07e73ead837a6972a446e551ddf027058ca34e11ee7ee9c248f3db\", \"recipient\":\"15C7eh7f3EQuyTKySTHwiUEu5xFaHmiNDp\", \"status\":1, \"created_at\":\"2015-06-23T00:01:02.441Z\", \"updated_at\":\"2015-06-23T04:03:04.737Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0a51ed48f6f07a1939007ded92c001dbdf2abbd3dec70d73310873396c0e637a\", \"recipient\":\"1N3G9NpX6Jo6xCRuHjHwnDUoexVNaY7tsa\", \"status\":1, \"created_at\":\"2015-06-28T00:01:12.828Z\", \"updated_at\":\"2015-06-29T02:04:21.779Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"14b40e99a0b4095d1fa01797c00f20ebcbb78a3bf5e48f5e75380729c42bbfba\", \"recipient\":\"14b9ZWvzio8i2PfWd2BqgVYaRG8phPwqpD\", \"status\":1, \"created_at\":\"2015-06-24T00:01:03.390Z\", \"updated_at\":\"2015-06-24T03:11:52.700Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"5a21c329e5b23ef62f4a16dc35d3692b69ae121b20d26f0a04b13f3e2a8dd913\", \"recipient\":\"196rYUxmgcrR1HAWnfofP2GxCc3QchrwZh\", \"status\":1, \"created_at\":\"2015-06-29T00:01:27.826Z\", \"updated_at\":\"2015-06-29T09:21:54.514Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f6866bdd5ed4615db6a97859c2f8e5fa04df394c8788ede58f334dfb0b822a07\", \"recipient\":\"1EBWYTQoaJHSSw3EQSAvamjo6Q4mNUZDzv\", \"status\":1, \"created_at\":\"2015-06-25T00:01:20.784Z\", \"updated_at\":\"2015-06-25T03:41:44.439Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"6a79539f070bdae09b72d9b082eca467b0ece599a1837bbbf78853cbe37ecdb6\", \"recipient\":\"1KiKKLD6BYWAqQy7ZVt5U2ZuGjAzDsx8PP\", \"status\":1, \"created_at\":\"2015-06-30T00:01:29.211Z\", \"updated_at\":\"2015-06-30T06:51:40.083Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"70d5d808ae48b52ca18684e6109a484c4bee331a8f07ecbf22cde012f640d50f\", \"recipient\":\"14PVNg2cPb1ioe1CT4zqEvFN1VVAURzDFG\", \"status\":1, \"created_at\":\"2015-06-26T00:01:23.088Z\", \"updated_at\":\"2015-06-27T05:41:55.735Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"abf23d913ebaba5b6cfe4ce380db2854b1ef0328af576238cd22e4d2de5dd0af\", \"recipient\":\"1Eq8w9xtRnh2ER7UAFMvFRs76N7cb5yQiB\", \"status\":1, \"created_at\":\"2015-06-27T00:01:23.378Z\", \"updated_at\":\"2015-06-27T05:41:56.162Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a4744de93164483dce44c6c8410e6af938a15ffed084de50e3cc3bfa808684b1\", \"recipient\":\"1QFf89ekBj1KQCSii4U4RUV7djLJbNmwkT\", \"status\":1, \"created_at\":\"2015-07-01T00:00:55.764Z\", \"updated_at\":\"2015-07-01T01:32:29.865Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"a5b28a937d054a6478d38693016045a08e3b042bdeeedda3681536480e1dbb80\", \"recipient\":\"1HxWSMNxG2KZWEUo4QsFKnji4rJXbGt7JM\", \"status\":1, \"created_at\":\"2015-07-02T00:01:14.866Z\", \"updated_at\":\"2015-07-02T08:03:21.668Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"f3274f2af4242950308efe62989c158d5892be3b91bcb5f37e6c96b1a777ce36\", \"recipient\":\"12yiPp8bnQA8z2DNtV7N9S99o8aD4rQFq3\", \"status\":1, \"created_at\":\"2015-07-04T00:00:36.834Z\", \"updated_at\":\"2015-07-04T06:41:30.502Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>94626b2d8ae3e7a70db0030db4847d8ac0ef39c4d03b71c0d162\"}, {\"tx_hash\":\"dcb6fab66a34e3ed99401cf968a0b704dab5b6ca07928c547131f01e6fcfe6bb\", \"recipient\":\"1JzwQmgQYwy6nBjybKDvktE3jgYXkuRGmw\", \"status\":1, \"created_at\":\"2015-07-03T00:00:41.858Z\", \"updated_at\":\"2015-07-03T06:32:06.750Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"cf76060ed1587fbc2fc30d09b973d0f7ecb5f2ebda05ae99c0b7691b238fb61d\", \"recipient\":\"1AMFTZhh5uMWvftbELU25CxAh7oxJXGrhE\", \"status\":1, \"created_at\":\"2015-07-05T00:00:46.597Z\", \"updated_at\":\"2015-07-05T06:21:41.284Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"0b66e834d067c4a3335606dbf447ed306ea55f04e34acc9cda63ad8c2fe24e66\", \"recipient\":\"17v4aYJQpwxp2VajkePPk9JvnkZvUeYANG\", \"status\":1, \"created_at\":\"2015-07-06T00:00:32.598Z\", \"updated_at\":\"2015-07-06T14:11:51.991Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"004643d1f77530586b0e30169663c9089d509d058e61b96a51e3751792300cf7\", \"recipient\":\"1BYB1FcC8YsPAuCyw9bBEP2EV2HkvpxrYp\", \"status\":1, \"created_at\":\"2015-07-07T00:54:05.481Z\", \"updated_at\":\"2015-07-07T12:11:25.844Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"54e41c4a8079f406d2c67678b251d2e06f631bca3c8da99f3f5cf0629bc27b9b\", \"recipient\":\"13w9hFbkEpsyhRPmfda4E2JQ8akE6PYxhT\", \"status\":1, \"created_at\":\"2015-07-09T00:00:38.578Z\", \"updated_at\":\"2015-07-09T02:51:31.994Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"c428c7960df93d59d0ca4178000561df5c8bef727f969e43dcf0d7ea45a82bcf\", \"recipient\":\"19mPk8uaMmMXfsDDxdTPG1PXLWun2pHPaK\", \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>a00d06f0412661d2611c541978\"}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbcd2d5ae707\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}]" |# \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9db<KEY>\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"<KEY>\", \"public_key\":\"<KEY>}]" |#
true
;; timestamps.lisp -- Verifiable time stamps using the Bitcoin chain ;; from www.originstmp.org ;; ;; DM/RAL 07/15 ;; ------------------------------------------------------------------- #| The MIT License Copyright (c) 2017-2018 Refined Audiometrics Laboratory, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |# (in-package :ecc-crypto-b571) (defun timestamp-file (&key fname title) (let* ((hashv (sha3-256-file fname)) (hashn (convert-bytes-to-int hashv))) (list hashn (timestamps :create-stamp :hash hashn :title title)))) (defun timestamps (op &key hash title) ;; hash - numeric, needed for op :create-stamp and :get-stamp ;; title - optional for op :create-stamp ;; auth code obtined from www.originstamp.org/developer ;; and needs to be renewed after every 1M creates ;; ;; Invocation: ;; (timestamps :get-all-stamps) ;; (timestamps :get-stamp :hash xxxxxx) ;; (timestamps :get-all-transactions) ;; (timestamps :create-stamp :hash xxxx [:title "your title"]) ;; (let* ((auth "PI:PASSWORD:<PASSWORD>END_PI") (auth-line (format nil "Authorization: Token token=\"~A\"" auth)) (host-line "Host: www.originstamp.org")) (with-open-stream (http (comm:open-tcp-stream ;; Lispworks specific "www.originstamp.org" 80)) ;; leave off the "http://" prefix (assert http) (flet ((crlf (&optional (str "")) (concatenate 'string str '(#\return #\newline)))) (dolist (line (case op (:create-stamp ;; create a new TS (let* ((data (concatenate 'string (format nil "{\"hash_sha256\":\"~64,'0X\"" hash) (if title (format nil ",\"title\":\"~A\"" title) "") "}")) (dlen (length data))) `("POST /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line "Content-Type: application/json" ,(format nil "Content-Length: ~D" dlen) ;; this line is needed "" ;; needs this blank line ahead of data ,data))) (:get-stamp ;; get one specific TS `(,(format nil "GET /api/stamps/~64,'0X HTTP/1.1" hash) ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-stamps ;; get all TS for the day `("GET /api/stamps HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) (:get-all-transactions ;; get all TS for the day `("GET /api/transactions HTTP/1.1" ,host-line ;; mandatory field in HTTP-1.1 ,auth-line)) )) (princ (crlf line) http)) (princ (crlf) http) (force-output http)) (terpri) (write-string "Waiting for reply...") (loop for ch = (read-char-no-hang http nil :eof) until ch do (progn (write-char #\.) (force-output)) (sleep 0.25) finally (unless (eq ch :eof) (unread-char ch http))) (terpri) (let* ((okay-line "HTTP/1.1 200 OK") (nok (length okay-line)) (lines (loop for line = (read-line http nil nil) while (and line (> (length line) 1)) collect (write-line line)))) (unless (and (>= (length (first lines)) nok) (string-equal (subseq (first lines) 0 nok) okay-line)) (error "Can't get timestamp data")) (let* ((key "Content-Length:") (nkey (length key)) (line (member key lines :key (lambda (s) (subseq s 0 (min (length s) nkey))) :test #'string-equal))) (if line (let* ((ndata (parse-integer (car line) :start nkey)) (data (make-string ndata))) (read-sequence data http) data) lines)) )))) #| (timestamps :get-stamp :hash #xD633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227) "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-12T00:00:31.863Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\", \"transaction\":{\"tx_hash\":\"6ed05fd3cfdd58eab8c349a9a77f6782613f1edc304aa4de3f36ffbed09051ee\", \"recipient\":\"1JM3GCAc2gWKZ8C2PYk3f6yBB8ZFVj5htR\", \"status\":0, \"created_at\":\"2015-07-12T00:00:31.788Z\", \"updated_at\":\"2015-07-12T00:00:32.309Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI\", \"seed\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227 <<-- !! 050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1 23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885 640982b83bc1aa015d8f60b6ed5f0799faPI:KEY:<KEY>END_PIa51760313decc854a9b91840bbd8 ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4 4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f <<-- !! 7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530 3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4 7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0 abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92 23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27 3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\"}}" |# #| ;; :create-stamp ;; "{\"hash_sha256\":\"D633B44BB5ED5C970489904F4A508F0EC4F97A91D3C4E70491DD20C6B2AD3227\", \"created_at\":\"2015-07-11T23:30:27.273Z\", \"updated_at\":\"2015-07-11T23:30:27.273Z\", \"submitted_at\":null, \"title\":\"DBM/RAL\"}" |# #| ;; :get-stamp ;; "{\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}" |# #| ;; :get-all-stamps "[ {\"hash_sha256\":\"3c4c5e72e9fb7e01cb44045be8a7cea824ab2e55c0ad231cb604846457d38aa4\", \"created_at\":\"2015-07-11T14:31:48.972Z\", \"updated_at\":\"2015-07-11T14:31:48.972Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"7a47cd1b54f45e543a060365ef87d47e3e741e6f5535051158651d9966c9f530\", \"created_at\":\"2015-07-11T17:35:13.487Z\", \"updated_at\":\"2015-07-11T17:35:13.487Z\", \"submitted_at\":null, \"title\":\"testing\"}, {\"hash_sha256\":\"4196ace26f985f66e3efb457dc8e2ac0797714d0cd395d13dcfc0a0bc31ce54f\", \"created_at\":\"2015-07-11T17:55:37.657Z\", \"updated_at\":\"2015-07-11T17:55:37.657Z\", \"submitted_at\":null, \"title\":\"Edwards Curves in Lisp\"}, {\"hash_sha256\":\"ee4879292feb11c0ee97f2156f6206c62d2f0cedc24a8de6a11e797d0a9621b4\", \"created_at\":\"2015-07-11T18:00:42.182Z\", \"updated_at\":\"2015-07-11T18:00:42.182Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"640982b83bc1aa015d8f60b6ed5f0799fa42a51760313decc854a9b91840bbd8\", \"created_at\":\"2015-07-11T18:01:04.967Z\", \"updated_at\":\"2015-07-11T18:01:04.967Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"23b1d37c0f6aaea977c9900432f23ca018a25b89d4eef50b28863e1b11582885\", \"created_at\":\"2015-07-11T18:01:38.495Z\", \"updated_at\":\"2015-07-11T18:01:38.495Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"050adf52e82d2137c003892077c3d80ea0b903b671c9145e1de4d3bf12fd9bb1\", \"created_at\":\"2015-07-11T19:01:22.027Z\", \"updated_at\":\"2015-07-11T19:01:22.027Z\", \"submitted_at\":null, \"title\":null}, {\"hash_sha256\":\"3efd8291fcfb627216e8af91588525be8704d70b419dd1d31837a4b8d5d6bed6\", \"created_at\":\"2015-07-11T07:20:36.463Z\", \"updated_at\":\"2015-07-11T07:20:36.463Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"23dd1c1594bfd7b2b6ca38520d381cdc587d679496f6f9853e74f0b347dc6f27\", \"created_at\":\"2015-07-11T11:14:37.135Z\", \"updated_at\":\"2015-07-11T11:14:37.135Z\", \"submitted_at\":null, \"title\":\"\"}, {\"hash_sha256\":\"abb3739c02f5131f3da37a11892ad91089a797f70fffc0a42a4c264556bd8c92\", \"created_at\":\"2015-07-11T11:22:07.051Z\", \"updated_at\":\"2015-07-11T11:22:07.051Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"}, {\"hash_sha256\":\"7d07735c2d0d3e4d4961a7e95ab225e286b2d239c3d5562c8c54513d106d30b0\", \"created_at\":\"2015-07-11T12:48:24.442Z\", \"updated_at\":\"2015-07-11T12:48:24.442Z\", \"submitted_at\":null, \"title\":\"Signature Integrity\"} ]" |# #| ;; :get-all-transactions "[ {\"tx_hash\":\"5cc6cd42202553b3b57ea5a250b394fec174c0bd610da2598fda03ede170f90f\", \"recipient\":\"17rYW4DofgBrV2k8k2ky7xLuzUwp5inoJa\", \"status\":1, \"created_at\":\"2015-01-12T00:01:11.800Z\", \"updated_at\":\"2015-01-12T04:21:30.983Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"bdc6244b11575e29329ca10a65e6b171b377e6574eb3d6f0cf524fbe054322cf\", \"recipient\":\"1Vant4CVGow6RvEcsPBgEmFCN5bBzkpen\", \"status\":1, \"created_at\":\"2014-06-06T00:05:07.709Z\", \"updated_at\":\"2014-11-05T02:01:52.887Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI1adbd4a94161\"}, {\"tx_hash\":\"b65f0530d2b56e1f30547f9e0046166a2ced52dbb082cbf4f6bf7bd452a5eec2\", \"recipient\":\"1NUiXjKtSzj6obrZY6VR1Uydd23R9Cc35E\", \"status\":1, \"created_at\":\"2014-05-19T00:01:19.640Z\", \"updated_at\":\"2014-11-05T02:01:52.906Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"a4f4d37ce4ae65b6403bdfb843879633baef5267486d936e6e2b1f75f0669a10\", \"recipient\":\"1CKKrtq5ur5ZFtQGwwZDBzuRRd1cswqNrs\", \"status\":1, \"created_at\":\"2014-03-20T18:32:24.377Z\", \"updated_at\":\"2014-11-05T02:01:52.923PI:KEY:<KEY>END_PI\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f4ea6b84442ab6b72160f6633b7c43a6186c30e16c276da2bc8dc0f768ef1680\", \"recipient\":\"125Qkz8J4VdyoxVL2wQK3mdCkdzt8zfcKA\", \"status\":1, \"created_at\":\"2014-05-29T00:02:40.501Z\", \"updated_at\":\"2014-11-05T02:01:52.940Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3PI:KEY:<KEY>END_PI8df1c0cfabef582608c4f399c934e52\"}, {\"tx_hash\":\"05a46466ae2021a0bce6d5329c7528ee9b3c1b2fdda67bf6a7c04b28f5c0bf52\", \"recipient\":\"18q4mRvakf9UJWQAqcmn8wWHYQ2NKwNjpX\", \"status\":1, \"created_at\":\"2014-05-30T00:02:38.551Z\", \"updated_at\":\"2014-11-05T02:01:53.516Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ed6a0c5266ef634d3ff70e8edea9eb48ec4dc659a32a1c2a3ec4e0bcecb31db9\", \"recipient\":\"1ESG8CkoREhCZYx4kB1UEBnhNtzSAvVPXm\", \"status\":1, \"created_at\":\"2014-05-17T00:01:16.285Z\", \"updated_at\":\"2014-11-05T02:01:53.546Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b31b5e20c24cdbd9effcaebd5fb2d13ff03a6ba5fca4a8b367e230dcae7f490e\", \"recipient\":\"13B1WpaQ3Tk4BqQ4LX3eysQwvSn5uHsgW8\", \"status\":1, \"created_at\":\"2014-08-22T00:02:02.373Z\", \"updated_at\":\"2014-11-05T02:01:53.761Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIa9bb74d9415f541dc4274c1\"}, {\"tx_hash\":\"9a33b45134905cc6877af56f52060480b389e3fa4ea759ae8c504aed5c503158\", \"recipient\":\"1FWwNFMeKtjrmXgwaYZE6hAodrM7ozDNt9\", \"status\":1, \"created_at\":\"2014-08-02T00:01:41.468Z\", \"updated_at\":\"2014-11-05T02:01:53.924Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0c0fcf84d098e9a66c0848e9fc00662a82203c700c408038665157670c4554e9\", \"recipient\":\"1AST2VqYHnrmjv86FiRepvTJBSrXomLjRF\", \"status\":1, \"created_at\":\"2015-01-14T00:01:22.624Z\", \"updated_at\":\"2015-01-14T01:21:27.230Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5633980ac2a46f7ade29eb20da90307402ce7dbbe8c3d6ee2af8494584200a60\", \"recipient\":\"1ESYYyMmngUUHZk2YTnFdxuw6ddV57CYSx\", \"status\":1, \"created_at\":\"2015-03-23T00:00:30.572Z\", \"updated_at\":\"2015-03-23T03:41:45.110Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d6e8a78c75cbae895ce35cac701e722f475fb11bc7759a690771d586d92868f3\", \"recipient\":\"1N7BuAVEMxt38jxcHzPusWX1DbRJ8wxWRE\", \"status\":1, \"created_at\":\"2015-01-15T00:01:20.165Z\", \"updated_at\":\"2015-01-15T02:21:43.280Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a82e164dc639f8c2427b6585135da31007b066862643c2e88286d2ecc85b23cd\", \"recipient\":\"1HBfuMBfsQBLAmTJjQf7VZtJqJ1G4j9FTR\", \"status\":1, \"created_at\":\"2015-05-05T15:27:32.230Z\", \"updated_at\":\"2015-05-06T06:11:57.254Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d6568ebd966d2cef00885e3460ca2025ba42fdb56f80b67f34730d84964b48b5\", \"recipient\":\"1QCRzwHxuK3AQcmjgiPCUHBsoy1hPkMmQv\", \"status\":1, \"created_at\":\"2014-03-08T18:34:02.426Z\", \"updated_at\":\"2014-11-05T02:01:52.951Z\", \"private_key\":\"PI:KEY:<KEY>END_PI \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2831a771337e431791d1281992e20be6fba1bb12f154efce516a9c1da1c0c817\", \"recipient\":\"1P9y1ahAfqUWWAvWB6nvyfGJGkGgqkTGz4\", \"status\":1, \"created_at\":\"2014-05-15T00:01:07.853Z\", \"updated_at\":\"2014-11-05T02:01:52.961Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"85f5a8e7319a1ddc28fbf58e7f7f67b4b5441ed720bc82699d7f14037db4d039\", \"recipient\":\"1MmuY2ywp7Fort4CRAGhb9ap4jMNE2MZJZ\", \"status\":1, \"created_at\":\"2014-06-13T00:05:47.200Z\", \"updated_at\":\"2014-11-05T02:01:52.974Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9a33c1b174a8cad687e2081383c94db4dd601e58cf8df8e24baa493b2fda573d\", \"recipient\":\"14EoknsfxEvzNEXtqKz4hhfjB1Q6iUSqJW\", \"status\":1, \"created_at\":\"2014-07-01T00:02:12.587Z\", \"updated_at\":\"2014-11-05T02:01:54.167Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3bd108eff5534cbaf85747376118f5e834fef1fdd7b165d1db2f1d1d8ebb99ac\", \"recipient\":\"1DSFfRafiWZWyTnqiTaMy27HA1amfaK9sr\", \"status\":1, \"created_at\":\"2014-07-03T00:02:38.416Z\", \"updated_at\":\"2014-11-05T02:01:54.193Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"76846c2a77902e57ab1e75b3313394567e76ec31b90bbe0161cb7479d725f64c\", \"recipient\":\"1BTGAMpZ9e25y3tm3J5SnP9ugAz5Ktco7\", \"status\":1, \"created_at\":\"2014-07-26T00:03:34.143Z\", \"updated_at\":\"2014-11-05T02:01:54.384Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"6262b99f22bcce8bacad6c46211213731ce249392195b2f3d968ed060f4bf27e\", \"recipient\":\"15LyoqNbG5jox9Ve68ciUseW4Wm8bGbRNK\", \"status\":1, \"created_at\":\"2014-08-31T09:53:39.904Z\", \"updated_at\":\"2014-11-05T02:01:54.510Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"daf0600d1a28ae86882adc03b8f583462bbc8f0174f79a03058db9a8658a36bb\", \"recipient\":\"1EFiGL8eF7D3waeEskfdfsvMicVrUfBacc\", \"status\":1, \"created_at\":\"2015-02-12T00:01:25.830Z\", \"updated_at\":\"2015-02-12T07:41:56.531Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"052aab2bd27b31b81ac39bad164cd38a244dce6f43ae489cb2805c0367c2ccc2\", \"recipient\":\"1JF1Js5TY2uCH2Uqaqe5ksaWPtJeZnWEub\", \"status\":1, \"created_at\":\"2015-05-14T00:00:48.476Z\", \"updated_at\":\"2015-05-14T03:03:00.807Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b9d3496573b5d1e867d77315a2fd917e9b6b34f9ed917c4247e182f10ce82d17\", \"recipient\":\"1Gw4kbqa3rbKWc1GpRGQfMATqQkWg5vLi2\", \"status\":1, \"created_at\":\"2014-11-13T01:02:52.146Z\", \"updated_at\":\"2014-11-14T00:21:40.358Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"21e08bd07f30d6cd503e4ce64a0fdb786dc50e34cf488006c904b6b05963e687\", \"recipient\":\"15P6v2v7HsTmT9XU9Qxr7rQa1sQftHwzzp\", \"status\":1, \"created_at\":\"2015-03-17T00:01:09.998Z\", \"updated_at\":\"2015-03-17T09:03:29.537Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7561a3bf4a53fadca684639e877af39abdb1c77PI:KEY:<KEY>END_PI04ba1f856476ba56ae72cb94\", \"recipient\":\"1G9RXzGyoqQfJHzoQkH9a2EPDNQ8bnb1mF\", \"status\":1, \"created_at\":\"2014-07-10T00:03:12.573Z\", \"updated_at\":\"2014-11-05T02:01:52.991Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI64PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"274b0e7143eee9a23d166f6d60c9f8d0af11ed655254285559ec2225971c3939\", \"recipient\":\"15StrEcsCmSNfktcfXBrato4VdaZCkbUAQ\", \"status\":1, \"created_at\":\"2014-06-26T00:02:37.128Z\", \"updated_at\":\"2014-11-05T02:01:53.001Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0c28e0f4ebe036df09ded5ee33323d9c5518d6a37dfa45964ae7ff7d1eda7050\", \"recipient\":\"13McrP98NcUniCecfGL6GpivHTRzoVChPX\", \"status\":1, \"created_at\":\"2014-09-12T00:00:18.694Z\", \"updated_at\":\"2014-11-05T02:01:54.536Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7334c1369680e4f999e97b3bd9315e3dPI:KEY:<KEY>END_PIcfPI:KEY:<KEY>END_PIcPI:KEY:<KEY>END_PI2PI:KEY:<KEY>END_PI\", \"recipient\":\"14RWr2qjHCgmPtet2BCeqRqTfnA9LfRc1R\", \"status\":1, \"created_at\":\"2014-10-21T00:03:54.249Z\", \"updated_at\":\"2014-11-05T02:01:54.615Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"15872e495968e5f68893d13a75c3101980d9b44104d2af509ff65e5c8ac448d5\", \"recipient\":\"1JhPmLzpUY5TwTggvzmV6Vve4NHPTDCopy\", \"status\":1, \"created_at\":\"2014-09-19T00:02:05.121Z\", \"updated_at\":\"2014-11-05T02:01:54.625Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"551131e5f5fc48b7816ff07acfeedc5c7fc55d66050145e58d5f3523ee75142f\", \"recipient\":\"1JU5XyFZTBh9w5simV6e8EzdCioNVTim1H\", \"status\":1, \"created_at\":\"2014-08-26T00:02:03.885Z\", \"updated_at\":\"2014-11-05T02:01:54.645Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4747e4c8524c82fc737caf89f9ad666PI:KEY:<KEY>END_PI715cfPI:KEY:<KEY>END_PIdd796cPI:KEY:<KEY>END_PIffPI:KEY:<KEY>END_PI\", \"recipient\":\"1Kiwqx8Rrw8XafDNBnsrUX1j5ohy1Yn6oG\", \"status\":1, \"created_at\":\"2014-11-14T00:01:45.775Z\", \"updated_at\":\"2014-11-14T14:51:47.987Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4d10a835b5e9a974596755f95407c825d9249eda6feaf4305e1a7fc1119d43cc\", \"recipient\":\"13UCP7B7P9cG9NZAqykTSUfwZYi2x6XaiB\", \"status\":1, \"created_at\":\"2014-11-15T00:01:19.086Z\", \"updated_at\":\"2014-11-15T08:32:36.799Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3c893495a8eb51df1373e0ca8c\"}, {\"tx_hash\":\"b03cf3b1c193dc66800bf809f7ea3f853431f2fa94621b573b22e5fbcf71491b\", \"recipient\":\"1451zcXorHeHQ5tioGCRoMpSXqX2rezUHU\", \"status\":1, \"created_at\":\"2015-05-06T00:00:55.528Z\", \"updated_at\":\"2015-05-06T06:11:57.704Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d33c092e34a89d60dc718f22903735d053668b5414ed97089491e41608a0889f\", \"recipient\":\"13G6DWSFygS6kU6wq3nEehwTgqH4preN62\", \"status\":1, \"created_at\":\"2014-05-14T00:01:35.969Z\", \"updated_at\":\"2014-11-05T02:01:53.011Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"50d46c1696c07d2e4aed3f0f6b8ec365cdbab74a5e0c87c2470d208c842fb0f4\", \"recipient\":\"1DHnLfeb1hDakgk2fVcG6aDyMzK6Vgcynm\", \"status\":1, \"created_at\":\"2014-09-23T00:02:10.197Z\", \"updated_at\":\"2014-11-05T02:01:53.022Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cPI:KEY:<KEY>END_PIb4bfdcf61bPI:KEY:<KEY>END_PI0c1f6bPI:KEY:<KEY>END_PIbPI:KEY:<KEY>END_PI75PI:KEY:<KEY>END_PId21PI:KEY:<KEY>END_PI0PI:KEY:<KEY>END_PI14PI:KEY:<KEY>END_PIa2PI:KEY:<KEY>END_PIfbPI:KEY:<KEY>END_PI\", \"recipient\":\"14gcu52GekwuQBwwto6RpbWQDgv3JhpaGu\", \"status\":1, \"created_at\":\"2014-10-11T00:00:55.209Z\", \"updated_at\":\"2014-11-05T02:01:53.046Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"04642f3f029eda2b48640642ca970ac2b190132876542d36918772ea5b7191ed\", \"recipient\":\"1LdBELrbXZbKedG5qKJwgA35Gep7RXKwk5\", \"status\":1, \"created_at\":\"2014-06-17T00:01:54.014Z\", \"updated_at\":\"2014-11-05T02:01:54.730Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d1d7623456bfe389152c7e5d7075728c1045c62b054022d7e9b95c5ef117e890\", \"recipient\":\"195mgMWrgSmjy2Ax3r1N3rvood3YN5wsLR\", \"status\":1, \"created_at\":\"2014-07-02T00:02:37.176Z\", \"updated_at\":\"2014-11-05T02:01:54.979Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI8dPI:KEY:<KEY>END_PI160743ab\"}, {\"tx_hash\":\"b5175cd928c898cf3a9f3283666386c44dc6343db5ff788ddf597d13e4438e3b\", \"recipient\":\"18F4Anawmto2ypQW4xTMmCwJgQPvJSuBaL\", \"status\":1, \"created_at\":\"2014-07-09T00:00:28.290Z\", \"updated_at\":\"2014-11-05T02:01:55.102Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"44f2cf8058d4d5c1f7aaa019ba404c0726b187828726b598e4369be230387a25\", \"recipient\":\"1kynpGAAYNNGGBWakw1GXisuNWVa3Wiz3\", \"status\":1, \"created_at\":\"2014-11-16T00:01:16.227Z\", \"updated_at\":\"2014-11-16T03:51:50.052Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"eb5f0cef8a03ff68980d045e2c27689f130a043e8ece31a5b9c9fb4636f95002\", \"recipient\":\"14BfdJrP64JpWPQG58FUcJhM9AFTkDyKnC\", \"status\":1, \"created_at\":\"2015-01-17T00:23:37.472Z\", \"updated_at\":\"2015-01-17T04:11:33.558Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c205529af8313c48102dfa8cc78e309b9440cabb0eeb3f24e73d43dc22c7cf07\", \"recipient\":\"1EV7LBAXZEuw4mDfCR3FE8yJJT8cNqDp9L\", \"status\":1, \"created_at\":\"2015-02-13T00:00:48.588Z\", \"updated_at\":\"2015-02-13T05:32:20.428Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"15baee9509fa0e591634d5da7e3d540dd7a1d9c6a030c807b09b2351028d6abf\", \"recipient\":\"1PmAGdacqT3Hzr259qdVz85egChWfQphtv\", \"status\":1, \"created_at\":\"2015-05-07T00:00:52.308Z\", \"updated_at\":\"2015-05-07T04:21:52.571Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cb4cda0073b401d796e0f2c96e8f5a84fec1f506a07c40de2b634e4df9598266\", \"recipient\":\"19NSGsvtjMrgukZzUrd5uyNrJimunqF6G4\", \"status\":1, \"created_at\":\"2014-05-22T00:00:39.567Z\", \"updated_at\":\"2014-11-05T02:01:53.058Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f0dbb6df8156cc81cafa247814664d39c9d93537d5ddebef3b68367d7eb45f9a\", \"recipient\":\"12FuhxfFtx1trdppKajTUruc4xjVtMouLt\", \"status\":1, \"created_at\":\"2014-04-23T00:00:40.650Z\", \"updated_at\":\"2014-11-05T02:01:53.109Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"886b51655b0695ac6f1b8ea08847c5c427086177232636f4dfb4cc7556d99116\", \"recipient\":\"12Yu1gc4wy9PuSjmkQsBrb8Pc2Ptr3BaVm\", \"status\":1, \"created_at\":\"2014-04-24T00:01:43.397Z\", \"updated_at\":\"2014-11-05T02:01:53.119Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"66a5d6bd7f492a5ccfd86eba7f9e945854f0b3c41f30bd439bce76530bb89ac9\", \"recipient\":\"1P5RUSCntazC4sDSzXwEC7nJhy6EzSP7MA\", \"status\":1, \"created_at\":\"2014-07-31T00:01:58.647Z\", \"updated_at\":\"2014-11-05T02:01:55.258Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"576e4dd53fbab59178efb1bba3b9659c8596fa92178020a3e7dcf06c139e822e\", \"recipient\":\"1ByhvYLBaXUtgoVfAcWMp4bGfoueBpvmtP\", \"status\":1, \"created_at\":\"2014-10-22T00:03:29.755Z\", \"updated_at\":\"2014-11-05T02:01:55.445Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"43b51534677a771d3ef3236280cee0916f74b563a9c9004c94a2b0d1d711622c\", \"recipient\":\"17VE1uPUYpvCexRR9QmpuU6v5MAWYTra2W\", \"status\":1, \"created_at\":\"2014-11-17T00:01:53.251Z\", \"updated_at\":\"2014-11-17T14:21:47.075Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1f59e364b4fc3eaf62b77d458c2ce94445b349a323bb86170bf1fa9c99646868\", \"recipient\":\"19p2Zqgbs3wB399BENWA77K668rkHsuu2D\", \"status\":1, \"created_at\":\"2015-04-08T00:00:35.575Z\", \"updated_at\":\"2015-04-08T06:32:03.752Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2c813acaadd48e6552fa291aa72a01d9820b150975ffdd57285c7f4833fde4a3\", \"recipient\":\"1H7x369d3dh1MFVV6nn7MsNiNNtsHN5Q3B\", \"status\":1, \"created_at\":\"2014-11-18T00:01:53.635Z\", \"updated_at\":\"2014-11-18T00:41:49.817Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIc3b7cb220e5741bb56\"}, {\"tx_hash\":\"3bbff16458b61246a95bb1e17a3965d886222e56a9c22dc79bc733019a5b963a\", \"recipient\":\"1Pz6V2qChiufKqXGs2opZYvtTtVr8JuLKZ\", \"status\":1, \"created_at\":\"2014-11-19T00:01:23.886Z\", \"updated_at\":\"2014-11-19T01:32:58.124Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8ebe0d670073ba67c736f2920ee082c908c1f86d6b1ead5d3efe313d864de029\", \"recipient\":\"1H6Hv8pLzCUZ3ZjiH5tmajmjZX9auiea93\", \"status\":1, \"created_at\":\"2014-11-20T00:01:45.097Z\", \"updated_at\":\"2014-11-20T02:04:37.604Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"946f2b211b6741f2699f6c8f029caab2e97889b857bd0f8fe9c227575702a45c\", \"recipient\":\"15VRET362id6vRn6a2Zqn6vBrfSwAE6TK7\", \"status\":1, \"created_at\":\"2014-06-14T00:00:37.408Z\", \"updated_at\":\"2014-11-05T02:01:53.129Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"19c42ab5ec36db0d5127f82c5ae7ac96351fd071938ac40146a0713f8e4a8e11\", \"recipient\":\"12Tn73UVzb7fMVFQbJqgmzHBUD1YbmRiF9\", \"status\":1, \"created_at\":\"2014-11-21T00:01:12.416Z\", \"updated_at\":\"2014-11-21T02:03:45.847Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9466a3c8c7d333ffc72dfc16e1992cf1dca269d8c758da90050aebe7b9f22dea\", \"recipient\":\"18qtwsM6kqKNum4ic9fKDFAscAAt9HZM4r\", \"status\":1, \"created_at\":\"2015-01-18T00:00:55.356Z\", \"updated_at\":\"2015-01-27T09:39:31.697Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"440321c778c38f3c821a0664b3a52092aaed336df3e591bb1ac514f08a56333c\", \"recipient\":\"1FYdtZzuBusLmptCNHdLAKYEX76b3rEJvW\", \"status\":1, \"created_at\":\"2015-02-14T00:00:59.765Z\", \"updated_at\":\"2015-02-14T03:32:33.451Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6553bf0bdf60ae8cd779ccf35e40a730d5cd09bdd70e522de01831f5c9ebb9cd\", \"recipient\":\"12TEbw4Bd4V9ms4kuH1kC6Yaj2kuzcYJ1c\", \"status\":1, \"created_at\":\"2015-03-06T00:01:42.198Z\", \"updated_at\":\"2015-03-06T02:12:06.336Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIe2883f62a68a42e754d43645429d18223936ca19589\"}, {\"tx_hash\":\"69ab4452a2455324f089cd888e23cb93aaf9b4d40cecaff30a7375d0970545b9\", \"recipient\":\"1EkqZqmm9iECCJ9pwGrt3KhoaJ7qkFGn3K\", \"status\":1, \"created_at\":\"2015-03-16T00:01:11.445Z\", \"updated_at\":\"2015-03-16T01:51:28.986Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"99f5c46372957b146e5f644874c3359a40542302d960cda5dc65770b64d6235f\", \"recipient\":\"1Ccq5ZYou8qLjigYaTYbiisTKrVQJrCi7H\", \"status\":1, \"created_at\":\"2015-05-15T00:00:40.396Z\", \"updated_at\":\"2015-05-18T09:51:29.803Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e55d281e60d25023cb07adacc376c8f5285241625318661547832f965a8f12b6\", \"recipient\":\"1LnSbzpdzb6JAyWMXrWQCr8gGF1mUhhkAv\", \"status\":1, \"created_at\":\"2015-05-08T00:01:21.989Z\", \"updated_at\":\"2015-05-08T08:12:20.765Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"10417bfe88b10ca116cba61fca45788f2284a4e8cc57e75f79e85670447b3ffa\", \"recipient\":\"1Kbn3jYP1aiJW4CEP2wrt2z2qGCmvamQk4\", \"status\":1, \"created_at\":\"2014-07-08T16:09:30.595Z\", \"updated_at\":\"2014-11-05T02:01:53.152Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5f8768b7abd0cc28643c1aafaa691e0b93b7331a401d977d5898b35a5479a197\", \"recipient\":\"13eYJskv4gMUxjHFA6fnok3ihmhqoG3zRW\", \"status\":1, \"created_at\":\"2014-07-12T00:00:38.014Z\", \"updated_at\":\"2014-11-05T02:01:53.162Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIa223193fe6635ea4c581965279bbcc8954c8c8c6b405234c8337f472de4c3f5deef241f6138c3737cf01e220d3efd2f\"}, {\"tx_hash\":\"9509fc4f47f1404fd99f868c6ec9d486f35a079cbf8b49f10f98e77c3817669d\", \"recipient\":\"1ByDk6GFEvrB98xM81p6nrD4nVTsbKShFr\", \"status\":1, \"created_at\":\"2014-06-29T00:02:42.268Z\", \"updated_at\":\"2014-11-05T02:01:53.172Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"446a6b8f158e8755806b6672bf6acbc82b817ca5e405e940ae366847290e9d4e\", \"recipient\":\"1KT2Y2nY3pzuZoVX7XYDAGFBJD7oeckXPv\", \"status\":1, \"created_at\":\"2015-05-13T00:00:32.811Z\", \"updated_at\":\"2015-05-13T16:02:38.947Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e37f0a9c8f1b52fd8883cae81f41892c496fb1ab0676d913b72d2cbacb7ce3fa\", \"recipient\":\"1LFjG2Q4yiGNEXWoufmRCSSXc2yW9Ab4kL\", \"status\":1, \"created_at\":\"2015-05-09T00:00:40.427Z\", \"updated_at\":\"2015-05-09T02:22:06.134Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3c4\"}, {\"tx_hash\":\"2e088f04c5dc0324f16771a491df3ffadca947def262c8146c4020f4352ff100\", \"recipient\":\"1GJyjbuNUPGfDxe35x73na5weTLN7BUiDs\", \"status\":1, \"created_at\":\"2014-11-22T00:01:31.302Z\", \"updated_at\":\"2014-11-22T01:21:28.008Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7a97fbfe87a98cffe1a832a3244b1ac046af816313219adbe6d29b2c7786b3f9\", \"recipient\":\"1C6HmpjvvHk7kH7EFaBwnb3X22nEtxASu3\", \"status\":1, \"created_at\":\"2014-11-23T00:00:44.164Z\", \"updated_at\":\"2014-11-23T01:03:36.035Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d3419d432015929785e88d5dfc9f3e6e46509be12c1980935c9982eef399957f\", \"recipient\":\"13KPpnsDF7EZibdb9ggHALsmr16GogAUUZ\", \"status\":1, \"created_at\":\"2015-05-10T00:01:05.797Z\", \"updated_at\":\"2015-05-10T15:31:57.006Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2d9cdc612ed78cc0a0c02d4ab5df99a785c59110406357cb4147a1e3592661a6\", \"recipient\":\"15i2e32VvqKRqFiEEXno8We83KtABN5iT4\", \"status\":1, \"created_at\":\"2015-02-15T00:00:33.715Z\", \"updated_at\":\"2015-02-15T02:41:53.066Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b06394a816cf500167defc419064187a333f2fec63b9962da28031c5984dfe77\", \"recipient\":\"1J2v8YLu1gMgj5mCZFBsfUfusD8pszvgqr\", \"status\":1, \"created_at\":\"2015-02-16T00:00:57.522Z\", \"updated_at\":\"2015-02-16T13:03:24.902Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5df96fbce787ad35836a2eb7c0b3ab095cb43fd1e1cfbdcce1828d80ed2634f5\", \"recipient\":\"1EVWovQT8xr435oiEvcqW9awNgx7Gz1Bxr\", \"status\":1, \"created_at\":\"2015-02-17T00:01:10.722Z\", \"updated_at\":\"2015-02-17T09:32:14.650Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"80d790815a6ae2b4982989af7285562223b19e359f830bfa4fefd930840622bc\", \"recipient\":\"12NJQhG7xroqBCTH4v6EJ4WM85fhujQyxP\", \"status\":1, \"created_at\":\"2015-02-19T00:01:02.305Z\", \"updated_at\":\"2015-02-19T02:41:52.068Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ef50c29dccfa428d99a26d404acc7a80c0a299c4f80d0d5b0aee68b430b89a4e\", \"recipient\":\"1K3Rcr6sdkQsLSSDY2ujzQe9JGk7Q7EqT7\", \"status\":1, \"created_at\":\"2015-02-18T00:01:45.090Z\", \"updated_at\":\"2015-02-18T14:03:27.288Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"263d31cd4eb2d684dc0ab311112f5dc17b9c755431170e592e99703e58e5e62d\", \"recipient\":\"1BiqJri9R56QSv7jQs2KDYvT5KTLHGxEKC\", \"status\":1, \"created_at\":\"2014-07-16T17:33:17.581Z\", \"updated_at\":\"2014-11-05T02:01:53.187Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIedc137a245a65cc2f07d6d4ef1829bb5130d3a22ed3de04486621ac476e314b6380d515c300250bf66fb4983b23728d9a38d26PI:KEY:<KEY>END_PI4PI:KEY:<KEY>END_PI3\"}, {\"tx_hash\":\"c636d3b28f960236325d4c2638f82f429924c6c0cac4ac48b9e7fee8e53ff8d6\", \"recipient\":\"18K4M4qo5yymYFhbkmAriSFVfnpPP6uwSm\", \"status\":1, \"created_at\":\"2014-07-08T00:03:01.018Z\", \"updated_at\":\"2014-11-05T02:01:53.198Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ef9e6c1c337661b22ef1b508b917d0b4f23df98e107a556996e69dbdf3a79176\", \"recipient\":\"1F9bCHaCPa79fWiULnVPybY1W2H6gmvDyN\", \"status\":1, \"created_at\":\"2014-07-29T00:02:15.701Z\", \"updated_at\":\"2014-11-05T02:01:53.208Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3e53PI:KEY:<KEY>END_PIbPI:KEY:<KEY>END_PIbPI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cf815a603fb0d2348c786f219fc71a7ee222a161d713fb53d4fb1e084ae67232\", \"recipient\":\"1GpzYXKGXjnPxzMWdeSvNPpwC8CMumthNo\", \"status\":1, \"created_at\":\"2014-11-24T00:00:50.076Z\", \"updated_at\":\"2014-11-24T02:32:17.019Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4d8dfb4699b0d1ac7e438c1182a0cc4db2a85404d87e4e883d4746d78fbf4346\", \"recipient\":\"1HCTW9GnX1qa1h2q9RLBbMGFX4zDrj9h7G\", \"status\":1, \"created_at\":\"2015-03-21T00:01:02.326Z\", \"updated_at\":\"2015-03-22T21:51:31.967Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2f4d1c4640b86d094bb2d225a8a414ebbab8bf4c1356ac5e422618cece0b618b\", \"recipient\":\"126NsPsUqPVwoabfJoMK9uB6vh9p7wDfrC\", \"status\":1, \"created_at\":\"2015-02-20T00:01:18.581Z\", \"updated_at\":\"2015-02-20T02:03:39.623Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cc610efdac09b0dd95d0801eb589d66654f636dbc58fc10b7cfdad8aa9eb6d59\", \"recipient\":\"1HZC6Uzp3UtKgtWTvJjcvvXLNKN4EVHGyZ\", \"status\":1, \"created_at\":\"2015-03-07T00:00:44.051Z\", \"updated_at\":\"2015-03-08T17:03:36.014Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"97fd31ba4defc8344e4cfbb8df10c5a884a7a3790f71dac27d4ae19662d505d0\", \"recipient\":\"1JouHbiPyT4JB6UfHDokWqv4dMhrbuD6Zc\", \"status\":1, \"created_at\":\"2014-07-18T00:03:40.087Z\", \"updated_at\":\"2014-11-05T02:01:53.218Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a2d14ba75d34d95002f2d94acecf5791f82f576281ca69eee043d8fa04eb3953\", \"recipient\":\"1Cqzwjjta16HLPFmi43rqkuuRRGAroo1wd\", \"status\":1, \"created_at\":\"2014-07-24T00:03:35.045Z\", \"updated_at\":\"2014-11-05T02:01:53.228Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI285754882a4476beaf64e3ba1c883a17e9d907be20f12a2748ecc4a32004aff46041dc5a5d072648e10b44037a\"}, {\"tx_hash\":\"405e034591a7d1c978ca66b24b5cdc51dc4e326ebdec361e77a952ba28f1cd54\", \"recipient\":\"1rKydRpQNRoFymrCFdq4BDqC4GHJ4YBmn\", \"status\":1, \"created_at\":\"2014-07-23T00:03:47.019Z\", \"updated_at\":\"2014-11-05T02:01:53.242Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3b2b6ef09ee244411e9383ac42d82cf15b890a5ab5b1cf0201b1b829dd0f4a11\", \"recipient\":\"18WCREWiEE3qETHSNW4X2vnHuFgZaLf2q9\", \"status\":1, \"created_at\":\"2014-11-25T00:01:30.406Z\", \"updated_at\":\"2014-11-25T02:31:49.377Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"36741940f0a73484912a4b2aca38fb75f346bbcdde8e6ecd0ac5e7d97d9317c5\", \"recipient\":\"159984tsJx6V6godf1pdQd2j221bjShPev\", \"status\":1, \"created_at\":\"2015-01-19T00:01:05.848Z\", \"updated_at\":\"2015-01-27T09:39:32.317Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"24a8242ea0aabb23ffe395035ed0fbdac4c90031d233ec7b94f282ab097b38fc\", \"recipient\":\"1CMZh1o75M8pVV44e1ynr7QMgR3oxejQo7\", \"status\":1, \"created_at\":\"2015-01-20T00:01:05.066Z\", \"updated_at\":\"2015-01-27T09:39:32.791Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d23151f82e9b92e559a8092f79a57e6df23294163c33dad6be962b0c4aacf4c7\", \"recipient\":\"1JrbM1Fx95CNRSz138bC9USpCpYVHhs1qv\", \"status\":1, \"created_at\":\"2015-01-29T00:01:19.007Z\", \"updated_at\":\"2015-01-29T02:21:48.672Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIec0ef60d3e408df38f265cb020cfabf06c7e9e0f1c2944d2\"}, {\"tx_hash\":\"04bd372bbcd317cad494f960a0b3f78e023fdf8aa62b976020797508e5ddf49f\", \"recipient\":\"1Jf7k1bmqG1x6TT7KhdCNi2iJMtpY5DTLJ\", \"status\":1, \"created_at\":\"2015-02-20T07:47:02.435Z\", \"updated_at\":\"2015-02-20T08:32:18.258Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"820810819ca30b3ba0b42509e64ee6a0cd270d633fa62e5afd0d2e49b7a7c056\", \"recipient\":\"129KNMKCkx7WcyYHS83uAddf3A6c6QBdfS\", \"status\":1, \"created_at\":\"2015-01-28T00:00:59.364Z\", \"updated_at\":\"2015-02-01T09:11:38.062Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f1844287d3de2fb8e5ba2524f0d543e9aa354e53a90fe13a5b90d087e94d7c1c\", \"recipient\":\"1FS7WwQpgAAHuiceKgNY57WZwWHE1V4XsW\", \"status\":1, \"created_at\":\"2015-02-22T00:00:54.359Z\", \"updated_at\":\"2015-02-22T06:41:36.344Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"119f044d51c887a18bc0aa6bc31dff70beb18348a6d3ee1efc044a3185f6c4b9\", \"recipient\":\"1HhzMeiFhtwxy5bsq8e1uLe4MM569ru8ar\", \"status\":1, \"created_at\":\"2015-03-08T00:01:35.284Z\", \"updated_at\":\"2015-03-08T17:03:36.683Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d1b8c561fb07e6bc0162e1a35c090e9811a7eac8ba8f28f49451ded4d97a646e\", \"recipient\":\"1Fnqr2gpQ6u2jsj45JStrVicX5mZtPVQG3\", \"status\":1, \"created_at\":\"2014-03-19T18:33:04.956Z\", \"updated_at\":\"2014-11-05T02:01:53.252Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI75PI:KEY:<KEY>END_PI5PI:KEY:<KEY>END_PI5d9dfPI:KEY:<KEY>END_PI8410447280a6eb7838a38d6e9704bd58fbe\"}, {\"tx_hash\":\"4028f8e6e85378d7bda36539b58159b22d0fcf658e5cba84ff3c3bd6cd1fcdf3\", \"recipient\":\"1HA1cai9V1uzCT62tWuSfydbgtLgyt8bTy\", \"status\":1, \"created_at\":\"2014-03-21T18:30:23.280Z\", \"updated_at\":\"2014-11-05T02:01:53.261Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e96df52be3a2b2560dcf8967a629fa21a3567b86dfda8e2960557945574d1759\", \"recipient\":\"17apfom6T4LZEKd9XtC1yxAsRiCMx65hZr\", \"status\":1, \"created_at\":\"2014-04-10T00:01:30.432Z\", \"updated_at\":\"2014-11-05T02:01:53.271Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3fba2e0fe527f85fa90da49fef624714099cb6c37ab206278fea54e01b85ea60\", \"recipient\":\"16K3cnJZbE72eRnowCEmgR5CSTzvkKKVyq\", \"status\":1, \"created_at\":\"2014-04-19T00:01:48.161Z\", \"updated_at\":\"2014-11-05T02:01:53.280Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIaPI:KEY:<KEY>END_PI3bcfPI:KEY:<KEY>END_PI16754cc350f65d813825a4804597d811e9d\"}, {\"tx_hash\":\"a0f39b6c1489b99c3641fc98833d3c6816668b0925735af6381fed990a5fda45\", \"recipient\":\"1ArhbdchmwQXHd8SwymQsQJkdjFURXz7ao\", \"status\":1, \"created_at\":\"2014-06-07T00:04:15.129Z\", \"updated_at\":\"2014-11-05T02:01:53.289Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4e9c565741cdc89df91406b17605ff014a896917b6b531d248d24c898cff1c28\", \"recipient\":\"1A19BhZBV4EstbyWAPaXjnM2K1y5rhhpAm\", \"status\":1, \"created_at\":\"2014-06-08T00:00:28.939PI:KEY:<KEY>END_PI\", \"updated_at\":\"2014-11-05T02:01:53.299Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"638825d12cecdcd45100de8364da6cd62350bc0851cba288613583ee6b8f9871\", \"recipient\":\"1LayyTVH9XLo5SC48fwQ6sQS8uH94HzeVM\", \"status\":1, \"created_at\":\"2014-11-26T00:01:03.506Z\", \"updated_at\":\"2014-11-26T02:41:13.596Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"af1370ba00198de53709e1db13245a2651078bfc91b6720c9c9f8c44087144e9\", \"recipient\":\"176XGqHurSCZwTB5KtM2A65oCHicRjkPUm\", \"status\":1, \"created_at\":\"2015-01-30T00:00:52.768Z\", \"updated_at\":\"2015-02-01T08:32:00.780Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4e0e85de3430e92744c5db1bd8424f63146d85ae1d3735beb51d10bc6ff5e598\", \"recipient\":\"1DKH1SfrZ4J92D2DFnUfLXLPmYpYr38fUS\", \"status\":1, \"created_at\":\"2015-01-23T00:01:53.137Z\", \"updated_at\":\"2015-02-01T09:11:38.573Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a38fdad21e38e56dafbf2c12da1552d19181356d807c80bf3b542be88a9edae3\", \"recipient\":\"1FdDPvRK7ZdTu2yJLUxKcdVWvycq9X4FAD\", \"status\":1, \"created_at\":\"2015-01-21T00:01:05.382Z\", \"updated_at\":\"2015-02-01T09:11:39.068Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f155d9e6f0e63848112fdd4ee56b0b3583b69a8085a83e3857258522c50a33bf\", \"recipient\":\"185ZkrVnneUkhzmAjzXRm9Eq1htKsmHeCz\", \"status\":1, \"created_at\":\"2015-04-12T00:01:12.172Z\", \"updated_at\":\"2015-04-13T03:32:15.143Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"940b1c299bc80d09db22878e96589f8181a0ce4bce8df5f6a26e65fdd7538360\", \"recipient\":\"1CpuH9WNK5Mw4ZqCjVy9AKjHZkDosJDwXA\", \"status\":1, \"created_at\":\"2014-09-27T00:03:57.190Z\", \"updated_at\":\"2014-11-05T02:01:53.308Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3bda48eaa0d8a65b722dc323e8403a0a269323c4731cd9ee3f2947c1b02f4d4e\", \"recipient\":\"1PPavrDe6vdr7efY4YyJqipTmcZnosULN\", \"status\":1, \"created_at\":\"2014-08-29T00:04:03.885Z\", \"updated_at\":\"2014-11-05T02:01:53.318Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"006d98d7cc04610e99e26064ca341f8e1e03ad3b488137a63dcb9c52090fe221\", \"recipient\":\"1FiYmARFCDRhoQYdwHBWKSnogFZdqT1VRc\", \"status\":1, \"created_at\":\"2014-11-27T00:01:26.805Z\", \"updated_at\":\"2014-11-27T08:31:38.423Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6ac17d327a1af6d4c23d4df61e6c8ec7ffd19582f4417b749d6066384cee1643\", \"recipient\":\"1AihosgYQiPPwnttgo8xm1n81e8J7h2xCq\", \"status\":1, \"created_at\":\"2014-11-28T00:00:42.741Z\", \"updated_at\":\"2014-11-28T01:31:35.785Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9d5fbf9b2a08ab1fa138e4e186c9ebd8c1d0e93b43b94ebd356723f555bf083e\", \"recipient\":\"18Ptciey75pUzyRWZGyqvwvsrGX87tAtbm\", \"status\":1, \"created_at\":\"2014-11-29T00:01:35.977Z\", \"updated_at\":\"2014-11-29T14:02:32.236Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a0565e9c65c5e6521fc808edd311456912dbd1ef4d1953563b744130febbe397\", \"recipient\":\"12oje7qNQMu3W7kwp4nAuP6aQPAidw83tt\", \"status\":1, \"created_at\":\"2014-11-30T00:01:06.188Z\", \"updated_at\":\"2014-11-30T03:41:26.418Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"788901fe347df34bbba5b0b811b7dcb40adc9336b8869e3f26225d102832927c\", \"recipient\":\"13GP9Bv9kegfFauVeqKWHcvqCYCFWVWVxe\", \"status\":1, \"created_at\":\"2014-12-01T00:00:53.067Z\", \"updated_at\":\"2014-12-01T01:02:20.176Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"62e612858a11f764d6de72da806540d088e8aa7ac225142178122350c76f2c40\", \"recipient\":\"1MSn81x2n5bPk5rATRvbjMwGnX2tyEzuUU\", \"status\":1, \"created_at\":\"2014-12-02T00:00:42.038Z\", \"updated_at\":\"2014-12-02T10:31:40.609Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a740c53413f576cc6774c5e0e5e577e395a4f7df50fd5bf4676fb9f0c650a8d7\", \"recipient\":\"18ahpKZ7b6n9kCGXyL3yk3J1KANSEUNbbf\", \"status\":1, \"created_at\":\"2014-12-04T00:00:49.839Z\", \"updated_at\":\"2014-12-04T05:21:26.521Z\", \"private_key\":\"PI:KEY:<KEY>END_PI \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1596943406db888462b84b833319044a41a5f2639a2c972cd420ed0d2c95d786\", \"recipient\":\"1D6brAwYaq3DifUbNBPqLMi1ZZgsGaRbsx\", \"status\":1, \"created_at\":\"2014-12-05T00:01:39.128Z\", \"updated_at\":\"2014-12-05T04:41:18.769Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8fd29553b5dcbbee3f9f2348cc44fddd72f29da252df8a23bdf99b98c8a3a8e0\", \"recipient\":\"1Ezjd74wFjwn94y8uGrU4VzgbD5MnAYm3u\", \"status\":1, \"created_at\":\"2014-12-06T00:00:48.354Z\", \"updated_at\":\"2014-12-06T03:31:32.361Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"32240fc3fdbd0584dbe3cfd219c8991e50ff7c7277cbb08ef8a9a4972326d8c7\", \"recipient\":\"1Aj9bFfaXKsXoJF2Ksnu7ALFSLow5kPrX4\", \"status\":1, \"created_at\":\"2014-12-07T00:01:17.515Z\", \"updated_at\":\"2014-12-07T01:03:04.602Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cc6fb0bda4f2e417df47924453e28a64600699d544f6485b3e00b2dd5ffdec45\", \"recipient\":\"1KkFSNDPzBKbd6ASjU8JuX5RTM58XbWJmt\", \"status\":1, \"created_at\":\"2014-12-08T00:00:57.494Z\", \"updated_at\":\"2014-12-08T06:21:25.426Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ff889c510fb6c7f3f3461b29d8ed4e07166e4096f6880828abadbc5196fc4521\", \"recipient\":\"1LpqkAAE1YbZbNKP242xSevL5vxum8jVjs\", \"status\":1, \"created_at\":\"2014-12-09T00:00:27.922Z\", \"updated_at\":\"2014-12-09T21:31:35.358Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d2c9f2e2744e13456bf403d6e7ee88e48d34680aa6fd3a5f77b095e5d93e5c81\", \"recipient\":\"1FendAsmKLEbDYuRDdeit9t4dsjd1RRxUs\", \"status\":1, \"created_at\":\"2014-12-10T00:01:05.687Z\", \"updated_at\":\"2014-12-10T01:11:25.531Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e82455edPI:KEY:<KEY>END_PIcda5baf8PI:KEY:<KEY>END_PI3790701f8ecb7f08cbad38c69cc4d2941d891c8f25f\", \"recipient\":\"1HfUEjA2i1F7w8RVchpo17Sezij6CQoCkd\", \"status\":1, \"created_at\":\"2014-12-12T00:00:34.338Z\", \"updated_at\":\"2014-12-15T07:11:58.195Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9bc74c1389e34c836e4b66b8106bb1f3506e1b77bc639ffdeecdbfb71c52e566\", \"recipient\":\"1PSyeNNXJu6jGbQh8LFRem8erokxyiQfue\", \"status\":1, \"created_at\":\"2014-06-10T00:02:54.117Z\", \"updated_at\":\"2014-11-05T02:01:53.328Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIc0182d8e79c33479c5510411a888efff992c8d218be3ec5a721ade2ab9718e4707992afe8e4099e2b2b2e45b6daca8f09ac5690c9110589PI:KEY:<KEY>END_PIa64c71a64aa463\"}, {\"tx_hash\":\"4e3f39c404deeee1ea63393a5cb789374896f320f2f5322830a1297ea6f3db52\", \"recipient\":\"1PZFokPxzHYgAukejrVNjF43L4re3FyRsj\", \"status\":1, \"created_at\":\"2014-06-20T20:23:21.378Z\", \"updated_at\":\"2014-11-05T02:01:53.344Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7729867b65e959d3ca78eb27428b8a9a4b446a8868383e8fe9853f93409e6d08\", \"recipient\":\"16fGJQsyyzJRvA7EUyEUpnWKG9MXGHYKkW\", \"status\":1, \"created_at\":\"2014-03-22T18:30:07.901Z\", \"updated_at\":\"2014-11-05T02:01:53.353Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIbPI:KEY:<KEY>END_PIeePI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c62c201342aa9f5bdc0bf22e075dac5d70057a939be3176800f574ad87739c6b\", \"recipient\":\"1EcwbLEhkqrYcpHBkmGD9wktwbo6vxccmx\", \"status\":1, \"created_at\":\"2014-05-16T00:02:21.191Z\", \"updated_at\":\"2014-11-05T02:01:53.363Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d14350bae9ebfd6d5fd1d1a14260725c523a2418acc9452a67699354987bdb70\", \"recipient\":\"1KazxQSy9NJ5iGJkn55BJGT7nKAkt4nGqi\", \"status\":1, \"created_at\":\"2014-10-03T00:02:30.353Z\", \"updated_at\":\"2014-11-05T02:01:53.372Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f19de2eda6ceb4465f0f2f6e51699b7e34d374c8PI:KEY:<KEY>END_PI\", \"recipient\":\"15DA5aCRy12vvMZ7MYsd8y6UmXBvxFNie2\", \"status\":1, \"created_at\":\"2014-10-04T00:01:16.836Z\", \"updated_at\":\"2014-11-05T02:01:53.382Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"955fce669b8e39ae8019c252d8b87fd5e54d62c9f5257dc8c1df2286a7731625\", \"recipient\":\"1Lo6YAJP1aChnPQ41LRVyiwyr9T6PUiUoo\", \"status\":1, \"created_at\":\"2014-09-29T00:00:58.816Z\", \"updated_at\":\"2014-11-05T02:01:53.410Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"eb2f56a706f8695c21866542c6fee70fe4c0f6e4b84e1402fe1d6701d0d40cef\", \"recipient\":\"1A6ZjoJe4hdMj7AMCdpWuYtLqBjVbqvoWq\", \"status\":1, \"created_at\":\"2015-02-21T00:01:32.561Z\", \"updated_at\":\"2015-02-21T23:51:38.171Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7f8d7ef78b392baa65b3564ca4c2af9dc1505f2fb9bced620de471097d85dfc7\", \"recipient\":\"16vStVunYSJLab2nYWojf5239YvztKZrHV\", \"status\":1, \"created_at\":\"2014-12-03T00:10:56.380Z\", \"updated_at\":\"2014-12-03T03:21:12.903Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ac053b59823bb9fc4f466ccebad61c126f5f5b87c721819438e43b9423fa459e\", \"recipient\":\"137QUkdudDw1R86va7c2o7xkFVrPeB4TGS\", \"status\":1, \"created_at\":\"2014-12-11T00:00:41.846Z\", \"updated_at\":\"2014-12-12T03:03:00.623Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6d61fbd4c7c7cb957ba9bad778f688PI:KEY:<KEY>END_PIf7a4b6fa586c2b49PI:KEY:<KEY>END_PI860ade584ced4bf\", \"recipient\":\"1DruqemSaF2WiaUMVCC8VEeEVXP5rkBjrW\", \"status\":1, \"created_at\":\"2015-03-09T00:01:22.368Z\", \"updated_at\":\"2015-03-09T02:51:37.961Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"110f9cc7eed95cdab83a75159dc80ce98c5fa6e1ac9809444fafaad9dbf9af76\", \"recipient\":\"18XsBQ1mkRo34Uwd8jGyXTo8cqNL4sSCWz\", \"status\":1, \"created_at\":\"2014-10-08T00:03:09.097Z\", \"updated_at\":\"2014-11-05T02:01:53.420Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI0f81419PI:KEY:<KEY>END_PI9PI:KEY:<KEY>END_PIe3d919PI:KEY:<KEY>END_PI2cf586PI:KEY:<KEY>END_PI1a91PI:KEY:<KEY>END_PI0PI:KEY:<KEY>END_PI02733b7PI:KEY:<KEY>END_PI70fd9030603f765497ab2a01d082af67a18bb3273d0\"}, {\"tx_hash\":\"c35a6d329334d51d8131c9b2d90b5539f6473bc04ad0ee1ee5a9701b824106fd\", \"recipient\":\"1FddQAF7Ekad3ZbCPvjDa7mJCKLJoRWq53\", \"status\":1, \"created_at\":\"2014-09-06T00:01:48.575Z\", \"updated_at\":\"2014-11-05T02:01:53.430Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0cdee6fec1e8fcfeef6877a3eb3755ca90874afe13fd3371e1041fb0d824507d\", \"recipient\":\"1Q6EwC7CpCMa9wfePI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2014-10-10T00:04:43.291Z\", \"updated_at\":\"2014-11-05T02:01:53.447Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e5f2600d775cce0ffaad0d49e17268da513ead7a7ceb1feb7f6c24d3883c9a68\", \"recipient\":\"1L5nvobdgFUGkoV9DFqmeNW4hHMogDPRQE\", \"status\":1, \"created_at\":\"2014-12-16T00:01:32.944Z\", \"updated_at\":\"2014-12-16T02:11:47.375Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI49d311c399fff1d5434ab698a047b5c17bf5a45\"}, {\"tx_hash\":\"4a59a8642442e211c434124a361d857cc6b7eee4ff62ba578b9b7e4ad6a879e9\", \"recipient\":\"1McvkcqHXrHAiJTzFwjLMTVNpAMATGstnQ\", \"status\":1, \"created_at\":\"2014-12-13T00:02:00.649Z\", \"updated_at\":\"2014-12-13T01:51:27.991Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"da504ee3868a3b33a17c1046107b374051759c2534fbca7d7303fc029b62a2a3\", \"recipient\":\"1PAqJm6XMcDkbxahziREZA5cLZHJpB37pv\", \"status\":1, \"created_at\":\"2015-05-16T00:01:20.924Z\", \"updated_at\":\"2015-05-18T09:51:31.248Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2b60edaf17da94fd876eb298ec76cfc871e1b277a257a4af8ab409dc1d36715c\", \"recipient\":\"19TBcRdoZkGTXozqYQxCJhw6dudmzNbApg\", \"status\":1, \"created_at\":\"2014-12-14T00:01:20.919Z\", \"updated_at\":\"2014-12-14T01:21:22.291Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ad9d0483ef79b303615d1a78d09846ad164e75785fac6e898441b025b81aade9\", \"recipient\":\"1KyDvfF9KixQpVU6GPU7HWDh7646TZNQbp\", \"status\":1, \"created_at\":\"2014-12-15T00:01:18.403Z\", \"updated_at\":\"2014-12-15T01:41:27.818Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"257f8e66371e728160d020a90299c5aaf5532816cb6adbb14bedc7608273c3eb\", \"recipient\":\"1DJjj57xGxVm6oM69hEs9FyLvAjKEZ8U3Q\", \"status\":1, \"created_at\":\"2015-02-03T08:25:13.022Z\", \"updated_at\":\"2015-02-03T18:11:44.812Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"14c9813897febd3ce406717b010bb2e2c78afe584099d050b1b10f5699c14f62\", \"recipient\":\"1FP4VeiaEPon1ibJTqGaZu7TLj6hkTjWr2\", \"status\":1, \"created_at\":\"2014-12-17T00:01:29.311Z\", \"updated_at\":\"2014-12-17T08:04:36.447Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4ea030d2b5f63ac3a4fb39b4cd14e9071d46d7d07051c3a0d5f3fb086ea65013\", \"recipient\":\"1HfLpsy6B6uSRcepq18m2cMfwJETjEXTnp\", \"status\":1, \"created_at\":\"2015-02-24T00:00:37.074Z\", \"updated_at\":\"2015-02-24T04:21:53.109Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI8f739f48cda369d8\"}, {\"tx_hash\":\"85d6f06fabb725147f196ff23ecca82bb1e22ea651630023bb30ae9e9e73175f\", \"recipient\":\"1JhwSqmqdyXT32ZKnLMJYcwjqxpLbW16Ln\", \"status\":1, \"created_at\":\"2015-04-18T18:38:35.335Z\", \"updated_at\":\"2015-04-19T05:51:45.524Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"fc3282c0ba4c0858091ba7ac8486cd9d0fd65d8f17ec52ac1aafdcbfb4a87608\", \"recipient\":\"1NeNjHBHBZTWJxwBrVgiS5Qwhm5v1ybU82\", \"status\":1, \"created_at\":\"2014-12-19T00:01:33.692Z\", \"updated_at\":\"2014-12-26T15:02:35.179Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5ef24006465b48e339ce3d7ae5af6da353cfc37af0a502711f02acfaaf518a99\", \"recipient\":\"16KYScxfa8xaXLuvJ7yRshhhrG7NBy9ZxT\", \"status\":1, \"created_at\":\"2014-07-07T00:03:23.585Z\", \"updated_at\":\"2014-11-05T02:01:53.456Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ba88a190f4c65b3a069e74b04580c32351dcb76286c87bed6809cd4f966cf315\", \"recipient\":\"1EHe5Fw8K7Q5TtxaWbLodznj97FFFPAVjX\", \"status\":1, \"created_at\":\"2014-03-24T18:30:49.312Z\", \"updated_at\":\"2014-11-05T02:01:53.466Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"09088155124078b04884d8dea35fa262dea21ca50dfce2a4e29e1b4244b4cd1f\", \"recipient\":\"1APCpFuFrd5uk5PM6NsbcTavcYnSvoCDSz\", \"status\":1, \"created_at\":\"2014-06-03T00:01:18.232Z\", \"updated_at\":\"2014-11-05T02:01:53.485Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI9c473c8c8cfe1cfb07b01746dfaed83745f00283f63791d52764fc4872a7954f\"}, {\"tx_hash\":\"8955284fb0cdddd166c10c66f1dbd15e82313aa0fcbb23bcdb800a3c7ef74d75\", \"recipient\":\"17GZiqkCqJ5gkn9QefEZeZ3XsHPQcdQoKH\", \"status\":1, \"created_at\":\"2014-06-28T00:02:58.649Z\", \"updated_at\":\"2014-11-05T02:01:53.494Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"708f1c7125cfc80ae6f5504f349d02d93ebd77ec8d75e7c5491de7145e64a3f1\", \"recipient\":\"1Q8dVs8WpKsB6ej3hHCqs9i3WDJmWp1Z8u\", \"status\":1, \"created_at\":\"2015-02-04T00:00:52.844Z\", \"updated_at\":\"2015-02-04T02:02:40.718Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6c81aee4f3a1c06a98dd7be17d08435693f0744dc1a915194d0b721077e61cff\", \"recipient\":\"1FoHf6ZfSJxXxYNxUJyiqWJgWGRabxM6Jk\", \"status\":1, \"created_at\":\"2014-12-21T00:01:30.330Z\", \"updated_at\":\"2014-12-26T08:20:35.137Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c169fbead005637c6506e47c6298334e86943c711d9cf7672d45f9ba4cePI:KEY:<KEY>END_PI\", \"recipient\":\"13WcphmngCvPaG5hrp622DH9iKXZzp6QTD\", \"status\":1, \"created_at\":\"2015-02-23T00:00:33.304Z\", \"updated_at\":\"2015-02-23T09:03:46.995Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"04fd971aff7716594dad0dd659e76b0508c0aea08f7f4b2ca65cbefbdfcf08ba\", \"recipient\":\"12ws8wHDrKDiq9J6YnPwbn7TzxXuyPEE3a\", \"status\":1, \"created_at\":\"2015-02-25T00:01:13.418Z\", \"updated_at\":\"2015-02-25T02:32:01.536Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIf197c087cPI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"acd740897db33b8fe5f136c0e7bb6dbe8250c34a450385a96f5aafa1fb6876f3\", \"recipient\":\"1LP7rnZ9XVsdRzSZpcwtrtZYi7yGtPc6R8\", \"status\":1, \"created_at\":\"2015-05-17T00:00:47.271Z\", \"updated_at\":\"2015-05-17T18:02:55.407Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ffba72b4b4ad75be9f99d70d7400137de02d319813d48c43e632ac65428e62f5\", \"recipient\":\"18aW1v7jWJqPB26oZv5BdtSYbwJyZowmBB\", \"status\":1, \"created_at\":\"2014-12-23T00:01:30.832Z\", \"updated_at\":\"2014-12-26T08:20:35.902Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"02bb58e93fad82be2181a9df61e0c6b18bd3bad7c485f7fdfda3b3e28ef538d4\", \"recipient\":\"19kH2E8187iQhY1cfhsrCEYxKM7mDwmfKo\", \"status\":1, \"created_at\":\"2014-12-22T00:01:15.052Z\", \"updated_at\":\"2014-12-26T08:20:36.257Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"61ce589b5c7bf41a7faa951fc61ae33870740a513b21d64dedba6057a4f35918\", \"recipient\":\"1Km8AHFos4KyNN6ugKjnNxg8E9LjXrY4X3\", \"status\":1, \"created_at\":\"2014-12-24T00:01:18.656Z\", \"updated_at\":\"2014-12-26T08:20:36.599Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0db2399293136f4269af3365e5abe3b55b0ec87ae40de82c37de6078c8b53fcc\", \"recipient\":\"1NB822hbEk2xW7RVDukH6NBCZfA3PAULsq\", \"status\":1, \"created_at\":\"2015-02-23T09:29:40.970Z\", \"updated_at\":\"2015-02-23T11:32:12.414Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0269c5bfa1a3772836a48fc03f6f9c24448aa1de73c06b10cd50db81c4f0f35e\", \"recipient\":\"1PhoU2YpwwsdGgzxMLZQtnChL9vNW3L2tb\", \"status\":1, \"created_at\":\"2014-12-20T00:01:31.878Z\", \"updated_at\":\"2014-12-26T08:20:36.999Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7e0724c204189970d7597b4d54b6f4eda90d229251f240dce8fca03adfab0a2e\", \"recipient\":\"1FwfcMq3t1rPxr98vqX1nKLZex3iVhmHbV\", \"status\":1, \"created_at\":\"2014-12-26T00:01:24.323Z\", \"updated_at\":\"2014-12-26T08:20:37.294Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a0330747df03510406923c21bfeb097d751e8b4771147a296b9e04347e667d17\", \"recipient\":\"13SXAQxZYFoAcpoNuMaktRmf5YzAY6garW\", \"status\":1, \"created_at\":\"2014-12-26T08:19:28.404Z\", \"updated_at\":\"2014-12-26T15:02:35.691Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7e31fb18377e5799a96b1c973eebc9c076ad3d6bf79679cfa642d0bb1aaa29ff\", \"recipient\":\"1GJmoifR2xG3fyjWUFhU6sawrze9cD3TuE\", \"status\":1, \"created_at\":\"2014-12-25T00:01:46.938Z\", \"updated_at\":\"2014-12-26T15:02:36.335Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2e9f04c056b71a8c1a1aa6fbb19382268ed43dc3d8ff540d16c717b0a09d1915\", \"recipient\":\"1BUUyEebCA8u5dtrEjUXtFNDy9XPCrAjMb\", \"status\":1, \"created_at\":\"2014-12-27T00:00:50.433Z\", \"updated_at\":\"2014-12-27T01:11:40.472Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"bf8334fd848413ff2e5de56a7ab2fd0d66a5313c259a2f759bc124293510020a\", \"recipient\":\"198LNYTZimueegcUkkZJwhm8kNAsneEzLf\", \"status\":1, \"created_at\":\"2014-12-28T00:01:08.816Z\", \"updated_at\":\"2014-12-28T03:02:55.1PI:KEY:<KEY>END_PI\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ffa5713c36e3323697503c224f9162daf1fcc649488f8e8a999487b533df4c2c\", \"recipient\":\"1KswqBC8LhYioAFmpvnBTxhVpEaBNemNAX\", \"status\":1, \"created_at\":\"2014-12-29T00:00:53.795Z\", \"updated_at\":\"2014-12-29T01:02:54.033Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3fee60b09cc02aa7b6bbc7c4dd4118ec290aa2d4f43c2583c66f3363187c4e44\", \"recipient\":\"19SfasMJXPr3JiZceesi9t67qq1FfN7xKF\", \"status\":1, \"created_at\":\"2014-12-30T00:14:55.489Z\", \"updated_at\":\"2014-12-30T13:31:37.244Z\", \"private_key\":\"PI:KEY:<KEY>END_PI \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f464b79ade56edc9d7f8bbb6c3d63f800e4bd2decbf0705e30610a70193ad797\", \"recipient\":\"1JTgD9GW1SAcAii6BoyaFCDdjgxtC7xJ1n\", \"status\":1, \"created_at\":\"2015-02-05T00:01:13.704Z\", \"updated_at\":\"2015-02-05T12:12:12.061Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"77509145bed99546b2182b5d587bd00519bd6b102b8b93e64040e903d8ebd501\", \"recipient\":\"1HrrMHEodPsFBPwHEZi2ufpF6bT6mcS9DB\", \"status\":1, \"created_at\":\"2015-02-26T00:01:10.617Z\", \"updated_at\":\"2015-02-26T05:42:36.352Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"16b023d73816bf57d476ada2ed857e9c6ac892630306115dcdbfe2e2f9b9adf1\", \"recipient\":\"1B3x9F5uGFFZfNZkTJxDsi4mJ8r2x1oGgq\", \"status\":1, \"created_at\":\"2015-04-06T00:01:26.334Z\", \"updated_at\":\"2015-04-06T03:21:37.565Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI0c86995b6b4b787bacc1d3f4eff6827d9aaf95a6be5\"}, {\"tx_hash\":\"04f07eaedb3a19de552c10a4178a9ca291449fc43dd64f530f1a04aed0e2824d\", \"recipient\":\"1Nu9pBXYk5J1eQWhxxx4YTauXxdYCaHdGp\", \"status\":1, \"created_at\":\"2015-04-05T08:32:01.354Z\", \"updated_at\":\"2015-04-05T10:12:02.208Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"47389bb2838241eca93235f00211b7518ab7aeffd8300f02c981c92bccdcfe36\", \"recipient\":\"1Atm6DgJN8VA7N5LVtYHqC2joxefhenp3A\", \"status\":1, \"created_at\":\"2015-04-07T00:01:05.058Z\", \"updated_at\":\"2015-04-07T13:03:15.670Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1780f4b7edc3ceffb85cf853d864461f8564c4a1d4dcfc8a7e40808aa2eb417a\", \"recipient\":\"15CoibLa7ZtkEXVjBcbe7pVR9KvaxkL72u\", \"status\":1, \"created_at\":\"2015-04-13T00:00:46.102Z\", \"updated_at\":\"2015-04-13T03:32:15.501Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d3eb9cd216da609b9cc29258aab0cea8852ebd46cf26ea0e0ba36f6a43d7b9b2\", \"recipient\":\"18xoaDAM4WRammpNaDLbkDczxPauHS4C61\", \"status\":1, \"created_at\":\"2015-04-17T00:01:20.730Z\", \"updated_at\":\"2015-04-18T08:41:32.039Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7b00e00558dbe54e07687e966fbf76711ad99d61f3f63c220da5fae0780c72aa\", \"recipient\":\"13VYpPMgWij54Q8ayvQ2PGQ8EgQxCbvuvf\", \"status\":1, \"created_at\":\"2015-04-18T18:31:13.174Z\", \"updated_at\":\"2015-04-18T19:11:52.573Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"bda2605ebd825142d4e78dc58522aad5524ca5bf7ea1f1d5f95ebb7d488191f1\", \"recipient\":\"1AFseaQSqi2aU9JvfCpst34pe3CMs5J5S\", \"status\":1, \"created_at\":\"2015-04-21T00:01:39.586Z\", \"updated_at\":\"2015-04-21T08:51:37.763Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cb18d149f57c62f5cdd9e74937df1c2d3603201ca546448476a167045d7f587b\", \"recipient\":\"1GmkofsaApUKUg2XWFK54NSkQXmPMCvmCX\", \"status\":1, \"created_at\":\"2014-08-20T00:01:21.131Z\", \"updated_at\":\"2014-11-05T02:01:53.507Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI2PI:KEY:<KEY>END_PI67PI:KEY:<KEY>END_PI87c7d22910e3ecd42e07b5bc82f14b2be2fPI:KEY:<KEY>END_PIdbe662474229f5ea7\"}, {\"tx_hash\":\"b4d902789d21c7108e28ce0612225eb3655f3afbb4532b65beb981c66ff06293\", \"recipient\":\"1Mn8aEDGiJTVsdX8XXyxHgQvCbptutvC9X\", \"status\":1, \"created_at\":\"2015-01-03T00:01:02.526Z\", \"updated_at\":\"2015-01-03T19:02:35.343Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4a6851a492d1e56b9b1b9ba4fa277aaea526799e8eed0edb5f497aaa2ccd6900\", \"recipient\":\"184A4UWM9ivKTXfvt2iM4RNFfZhekTA8Qm\", \"status\":1, \"created_at\":\"2014-12-31T00:01:17.007Z\", \"updated_at\":\"2014-12-31T15:21:27.404Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"182ab2e142833d58a844be450b0f480aa2f3be2493da19c32dfff7eff09e5854\", \"recipient\":\"1FvuMPjGzNEUrMjqqXqNyVg7NuLPs4aBf3\", \"status\":1, \"created_at\":\"2015-01-01T00:00:24.765Z\", \"updated_at\":\"2015-01-01T04:31:34.367Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0412d45d4e794d781a326a606a4824084d2661d2f3a884bc3f9e163ae9ff5122\", \"recipient\":\"1MMvuNXHRHAVWFZp73ucF8xi2pJK8Fg76J\", \"status\":1, \"created_at\":\"2015-01-02T00:01:00.556Z\", \"updated_at\":\"2015-01-02T11:41:39.408Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1a0fc9688bd38866c7f3abb5b35bd8509f57439d7910e96327fa6c56f1a34d2c\", \"recipient\":\"1JzVYgQean3sdpnBvivV9F8Cq1g6vZ6c9o\", \"status\":1, \"created_at\":\"2015-01-04T00:01:25.742Z\", \"updated_at\":\"2015-01-04T09:51:38.685Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0bc8b895e90f140900914892e656dd7b19f94d64087f2a50c67dd88e47a9b8a1\", \"recipient\":\"1Joj67nyw3nQJ1ySzALRx5CB2ZTCfi4Y1a\", \"status\":1, \"created_at\":\"2015-01-07T00:01:32.764Z\", \"updated_at\":\"2015-01-07T06:11:30.856Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"51d5ab218951cd8ad36c22c90e9b2ad72bd13c3e762dae3d37287204c766a640\", \"recipient\":\"1QBt3BVddLe65A6Kbau9e3LRWwFowj5EVk\", \"status\":1, \"created_at\":\"2015-01-05T00:00:52.961Z\", \"updated_at\":\"2015-01-05T07:02:51.195Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIf7923f2ebcce85083ea8ba4bc306ae0bf955fdbd9c\"}, {\"tx_hash\":\"9de1fecd8f4155859710d8502941f940b46c542b5710723cee1213f350f51697\", \"recipient\":\"1MUEjrGUMaxCyJ2Mhz8Wda9Bq4HwusP7ze\", \"status\":1, \"created_at\":\"2015-01-06T00:01:33.365Z\", \"updated_at\":\"2015-01-06T05:21:35.194Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"fc77ed3cc859b6ea0d52444492203c913351519685578f810af34ac7a928abf8\", \"recipient\":\"17fU1Z87HxJAbW2tQYd9TUKTbS5EBJukCV\", \"status\":1, \"created_at\":\"2015-01-09T00:01:20.374Z\", \"updated_at\":\"2015-01-09T02:31:37.362Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d948f615c9c8ac456573839b7a7e91127ab1df19b8f122d7f79659e167ae324b\", \"recipient\":\"1J2pJm19owYLgi368QQa4T7xskPrMQv4Lp\", \"status\":1, \"created_at\":\"2015-01-08T00:01:27.134Z\", \"updated_at\":\"2015-01-08T02:21:36.417Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"269b902c36787deb2541e1596d7a70102fd20afecd3b4ce29a86a2d82d0d01f0\", \"recipient\":\"1FmpRoghBZStYAFid53nwV3BG5cWCZYXdN\", \"status\":1, \"created_at\":\"2015-01-10T00:00:58.092Z\", \"updated_at\":\"2015-01-10T08:11:48.324Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cfeec1dcec94c588483a0f25a63aa6eed71c4895d8e4be8a5105085506717cb1\", \"recipient\":\"1B8RVypPq5kMJHYqW6tqRNzpxfCK2wFZj7\", \"status\":1, \"created_at\":\"2015-01-11T00:05:00.799Z\", \"updated_at\":\"2015-01-11T09:02:32.880Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9e412776afc88a91f0dc0921b2d0533afc75f66ac4db988205ca0de1c28af5ef\", \"recipient\":\"169pNiqDKiQpRXfZCDe64yuukUCnBPpjCg\", \"status\":1, \"created_at\":\"2014-05-20T00:01:28.933Z\", \"updated_at\":\"2014-11-05T02:01:53.527Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI1PI:KEY:<KEY>END_PIa5d03d0PI:KEY:<KEY>END_PI344380b3PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"959730b5fd7ff6df09f8e971c80806b68a0376bdc7dc2f994e1350c7c5211723\", \"recipient\":\"1B5KeyLZUxavyVC8W1Xf7zsKTmUZbVPauF\", \"status\":1, \"created_at\":\"2014-06-02T00:04:04.653Z\", \"updated_at\":\"2014-11-05T02:01:53.537Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c00940fe6d0976db9e53a5f41505ccea920846bcb459c1fcc06f46202657d79b\", \"recipient\":\"1L6eng3JME8eCnVFKDZdpjy2FfygoQwjhL\", \"status\":1, \"created_at\":\"2014-05-18T00:00:25.190Z\", \"updated_at\":\"2014-11-05T02:01:53.556Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3b42e20f69db1ad6f00ca56a0b2ae7c483c4f2733be759bdbc69b49feb3187PI:KEY:<KEY>END_PI\", \"recipient\":\"1QKkr49YoLFo6Z6inHiPhfhAYFxWj9K7Hy\", \"status\":1, \"created_at\":\"2014-04-18T13:22:49.602Z\", \"updated_at\":\"2014-11-05T02:01:53.565Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"36330ecb94f53ef7502618885e4ee1eee0a1cf8b13ba4bfa1041a1f75ad85b31\", \"recipient\":\"12JYZfZp1MeB1HhmNAnYenFw26GW5oHomv\", \"status\":1, \"created_at\":\"2014-05-31T00:00:16.891Z\", \"updated_at\":\"2014-11-05T02:01:53.590Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b83800314a4c8bd79393fac714eea04a7b5d7df75d1d3c3331fb9b6c0c529d69\", \"recipient\":\"1L7rfCAkY5EDCEGwuZEuwJtccrxGN7BZMn\", \"status\":1, \"created_at\":\"2014-07-25T00:04:29.040Z\", \"updated_at\":\"2014-11-05T02:01:53.601Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"23d03659209b3c6fa8ea08cee15e4bb6a76bbd33212d1764baf0b1a21e41a72a\", \"recipient\":\"13RQZEUPLLTUJZ4DxTG3ffRqoSwZuWqyS4\", \"status\":1, \"created_at\":\"2014-08-01T00:01:40.493Z\", \"updated_at\":\"2014-11-05T02:01:53.619Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3PI:KEY:<KEY>END_PI3PI:KEY:<KEY>END_PIbfPI:KEY:<KEY>END_PIc6PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3661ef8aa0cdabf903e6ff9ea240b485655e8d0a42275e9e52a42122a32f9ccf\", \"recipient\":\"1wy2p4BV8MfPnMQMRNiNqYQEhEB7LgQYj\", \"status\":1, \"created_at\":\"2014-08-14T00:02:18.460Z\", \"updated_at\":\"2014-11-05T02:01:53.628Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8bc4889e0134508b4cdec5cd972fcfc7ceecb4e02dd1c79c714992c9fbc0271a\", \"recipient\":\"1Ee8boWJvKykTevPbsnUVXwBtwXfmEcArm\", \"status\":1, \"created_at\":\"2014-07-21T00:03:33.063Z\", \"updated_at\":\"2014-11-05T02:01:53.638Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ffcdf1aae1acb22d9c81641e545ba20918a65eff2458c3e2c473dd27b6c63927\", \"recipient\":\"19sAkdCSQPPXfieXbYtDsoRAY8iWeerxBb\", \"status\":1, \"created_at\":\"2014-07-28T00:04:33.768Z\", \"updated_at\":\"2014-11-05T02:01:53.647Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI1d371aPI:KEY:<KEY>END_PIb2b276PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e4b2966b3f9c99ba188d3667cbc32b476745bb7f2bc7d40f7ea333aab9312323\", \"recipient\":\"1Nsd7DeFSfgWPmscYx9VEj9ZbPHvs3mE2f\", \"status\":1, \"created_at\":\"2014-08-10T00:01:44.536Z\", \"updated_at\":\"2014-11-05T02:01:53.656Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"025e34722395211a0f05847679334a66b36d5da52e974fb4ce1ebae62df0e7ed\", \"recipient\":\"1KbD8WUePmwXmpAMrH1jmws9aLxa3tLRL2\", \"status\":1, \"created_at\":\"2014-07-16T20:37:30.619Z\", \"updated_at\":\"2014-11-05T02:01:53.675Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"51f87059c234fb2ff758895c8e7c990059bf46a5d54a1aa31c32f27641b20a2PI:KEY:<KEY>END_PI\", \"recipient\":\"1F1M4K4KfGq5qtzB4CsXBjdHriYufu85Ah\", \"status\":1, \"created_at\":\"2014-07-16T20:53:56.446Z\", \"updated_at\":\"2014-11-05T02:01:53.685Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4e468ff7adbb480a6020188ed6c5103582f17673a2c297cec5fc0c5e3b80e98e\", \"recipient\":\"14habrH2ScUbrWcWy5NpaXuoefQ2CnpNLe\", \"status\":1, \"created_at\":\"2014-09-08T00:02:04.828Z\", \"updated_at\":\"2014-11-05T02:01:53.703Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ee1b6b5b44cc6926aa7c4a76a82fed0966ecf20160d2c5d127a8f993ca0f5459\", \"recipient\":\"14jqg33KWdjJqq5ExtudvsepTMdT5j3aeR\", \"status\":1, \"created_at\":\"2014-09-24T00:01:07.631Z\", \"updated_at\":\"2014-11-05T02:01:53.724Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4ec4374f1caa4646199806f21645052c8540ac060974c3fb143dc8a1289718fc\", \"recipient\":\"161mmBrmvm9K7S6sgCFmC2h4NJ77aAPAkJ\", \"status\":1, \"created_at\":\"2014-09-14T00:01:40.268Z\", \"updated_at\":\"2014-11-05T02:01:53.735Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"10fcab160176e81e8df317706742da904d9128040c0a84ac00d91845e5b05be1\", \"recipient\":\"18GFJ5Um4ictjRcPg1Utpi5Kvk585dW7zV\", \"status\":1, \"created_at\":\"2014-09-16T00:02:37.395Z\", \"updated_at\":\"2014-11-05T02:01:53.745Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0684e3a180763c820330628a2173f54961120ac0f0921f49b93117ff965a8a77\", \"recipient\":\"1BLEAyLhuDjHyRweJH4ntnFC98CiA71hLo\", \"status\":1, \"created_at\":\"2014-08-23T00:01:03.235Z\", \"updated_at\":\"2014-11-05T02:01:53.784Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"98cfc06713213692a745a3d10e992dac492ecb178345d6370509cd039e5a1422\", \"recipient\":\"1CK6H3xA5w44XwFMRmeFbAv7fjZ8YZMapr\", \"status\":1, \"created_at\":\"2014-10-20T00:03:25.551Z\", \"updated_at\":\"2014-11-05T02:01:53.800Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"155411ca3c5dac0298dff2ace9e3b855609645365c00e744e830d8a0c8ebccca\", \"recipient\":\"18EgiSrkM48ZWB8CiQtVVVPPyDWitatto6\", \"status\":1, \"created_at\":\"2014-10-02T00:01:06.472Z\", \"updated_at\":\"2014-11-05T02:01:53.811Z\", \"private_key\":\"bf2ed9a7659ea3c3819fd6c8f40927fe0db3dca050820f8ce234ecdf81f97946\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7b8ba249ca64b3900aa6c08d929a94c60c446a5ca33d19e54744b4cf0f43c525\", \"recipient\":\"1FDVeHvKAmgryxuJ3tNJYsnPpLuvYWufG6\", \"status\":1, \"created_at\":\"2014-10-05T00:00:46.280Z\", \"updated_at\":\"2014-11-05T02:01:53.828Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI8PI:KEY:<KEY>END_PI182d222efacc\"}, {\"tx_hash\":\"a578adb058de0aa8ab5c122ed9a7396018e611aac7751f37cacdc46e7ebdfb77\", \"recipient\":\"14WKY4JEEG8jXRTtdHm24NMJgae1kbJtU5\", \"status\":1, \"created_at\":\"2014-10-15T00:02:07.663Z\", \"updated_at\":\"2014-11-05T02:01:53.844Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f111ee1d4f16fddf35a5634a2fe5fa6e6b68240f2156d5a1f6e236ff9ee57f1b\", \"recipient\":\"1Nizee17zZ4Dhk5gysqBnCeLPSJXY6pqLR\", \"status\":1, \"created_at\":\"2014-05-25T00:00:59.698Z\", \"updated_at\":\"2014-11-05T02:01:53.853Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9181cd4434d9bb2ba6a840b4161334cd519b47de81efab3d3b9db3f262065b2a\", \"recipient\":\"1KNMWBTfJZaZEvok96hLrDwpStKQHFvJtC\", \"status\":1, \"created_at\":\"2014-06-05T00:03:47.226Z\", \"updated_at\":\"2014-11-05T02:01:53.863Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIdb722f98df\"}, {\"tx_hash\":\"3d0e2a091327adf984350745f7c66dcb7875c03855a083978ac7d5c6af3c936f\", \"recipient\":\"1JpEtyrKVnjKctfEZLt4dTfGEPJT4RuSgX\", \"status\":1, \"created_at\":\"2014-05-27T00:03:38.266Z\", \"updated_at\":\"2014-11-05T02:01:53.879Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"76a88d221e6c8748027642db86c76a6179fd7c9e67e9b8462626ad9ec2785be0\", \"recipient\":\"12H9khkAqWA4E1Qum2FCwYRaQT8ozt9foL\", \"status\":1, \"created_at\":\"2014-10-29T21:55:10.444Z\", \"updated_at\":\"2014-11-05T02:01:53.PI:KEY:<KEY>END_PI\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"00558a6bf42975bc24ad0c46951ac4d36b284b7d2f8869798de217e67326aef7\", \"recipient\":\"1C2kUE3cHanHaPCogP14tR7h5V876zXwSx\", \"status\":1, \"created_at\":\"2014-09-15T00:01:20.644Z\", \"updated_at\":\"2014-11-05T02:01:53.905Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI7PI:KEY:<KEY>END_PIf45b25608400917abba92b2827af6\"}, {\"tx_hash\":\"7d170a86f561701d9b3fe793f1ab5c27c3b08fdafd1a037cb0a6facf07d70a43\", \"recipient\":\"1GSSHwJNz9ZWczwb5cDECK9DhoJTym6itU\", \"status\":1, \"created_at\":\"2014-05-08T00:02:24.003Z\", \"updated_at\":\"2014-11-05T02:01:53.915Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4c7994c370b0b7a58f3df65e0fcc5223cd57b2ffd3548a6395f0424be5306d46\", \"recipient\":\"145fVeQPhJGJf6Jq5UhbJw7UVpnopbCBqh\", \"status\":1, \"created_at\":\"2015-05-18T00:00:58.730Z\", \"updated_at\":\"2015-05-18T09:51:31.657Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b1b35b093ffb7ba24155cbbb211041377f3a2c44be0d4a376860024ba2331602\", \"recipient\":\"1E2ZWykKZUP11yo4YS8vyFXLWAJeYKPbrx\", \"status\":1, \"created_at\":\"2014-10-26T00:00:55.447Z\", \"updated_at\":\"2014-11-05T02:01:53.934Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1552390c50242cddb935f58c88f3c12dd189a55fd661b864764792d689f68f35\", \"recipient\":\"1JrKRhniUKoTsUSZsui8zDTaGGKfqAo7Ub\", \"status\":1, \"created_at\":\"2014-06-18T00:04:04.229Z\", \"updated_at\":\"2014-11-05T02:01:53.946Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"364cfa51f9dd1a3f66d1997d3dfc14097aa2c4f302543996304a386452127148\", \"recipient\":\"1HqhqeHDwfvqUV6s2d6oWA6rBfwxmvuu8Y\", \"status\":1, \"created_at\":\"2014-06-16T00:00:46.148Z\", \"updated_at\":\"2014-11-05T02:01:54.054Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e7380c96301a7c5644f6064cc1000db9d863a36722f0b9eb5ac4fee8250ccbeb\", \"recipient\":\"16X7Z3WkAwgZdtRc67BjzJaaAyVGC9XvVw\", \"status\":1, \"created_at\":\"2014-06-21T00:03:29.175Z\", \"updated_at\":\"2014-11-05T02:01:54.084Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e4aad1c75c097eac80e68c2df0db1870c0abb3c9a0ed3ac2b2d06feb88cd0bcb\", \"recipient\":\"19TyvYS74Ho6RDUyoDNZaS9sVTYJdvjcKn\", \"status\":1, \"created_at\":\"2014-06-22T00:02:54.977Z\", \"updated_at\":\"2014-11-05T02:01:54.095Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c533d2f3b74b6e53fd69e0d284779158c91d17bc05f0856c1d4a0a5d8f8d18c4\", \"recipient\":\"15qyS9x5RYnaKodT5gYjrhTLA1qw9jfsdo\", \"status\":1, \"created_at\":\"2014-06-24T00:03:43.006Z\", \"updated_at\":\"2014-11-05T02:01:54.110Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c5735f619ea9450afba8a3c39654f5acf60d1ffbc6135ea77703d5216342917f\", \"recipient\":\"154uJzLAiosPPiRD3QLEh1nEk3iZjVu5gk\", \"status\":1, \"created_at\":\"2014-06-25T00:03:27.933Z\", \"updated_at\":\"2014-11-05T02:01:54.120Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI488843909\"}, {\"tx_hash\":\"daf1a9dd37cfa364750ad4623f9494f9180f4a6c0d6c7820075ca907e9181d6a\", \"recipient\":\"1Bn1CULrCZqwH3sPMVBvP7Jo1z5U9DRL6G\", \"status\":1, \"created_at\":\"2014-06-27T00:02:00.853Z\", \"updated_at\":\"2014-11-05T02:01:54.130Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"918f4636b7da99f39ef93395e618fb8150fb99b5822c2bef9bda681ad0653229\", \"recipient\":\"1Q9oX1DrVd39UVx39vV8CxSXyJTXUhnzia\", \"status\":1, \"created_at\":\"2014-07-05T00:00:23.364Z\", \"updated_at\":\"2014-11-05T02:01:54.147PI:KEY:<KEY>END_PI\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f3bcd428858081ff82f64a583c347aa714b1c1394b8757f2944f9848d1f6724d\", \"recipient\":\"17Tqrjw1BvscnyobeiPAH8Nqxf1TQD44x2\", \"status\":1, \"created_at\":\"2014-06-30T00:01:35.126Z\", \"updated_at\":\"2014-11-05T02:01:54.157Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI2PI:KEY:<KEY>END_PI27PI:KEY:<KEY>END_PI27d036813c922cbc5388c152cc6627b\"}, {\"tx_hash\":\"1daaf9ec98513538ff85f476c801cab0736428ccc786f8221c68f84e9e432764\", \"recipient\":\"138PyficovYkH7Ut9oRjxTMyJRiWyf8XRG\", \"status\":1, \"created_at\":\"2014-07-15T00:03:11.112Z\", \"updated_at\":\"2014-11-05T02:01:54.179Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"adf352f73e98f56ed55e1c4fe9f46d406b4686b4162ab66f5fc7246f5d8313d2\", \"recipient\":\"18Rigxnx6D9aCgJfrbNu8stUihJio7zhuK\", \"status\":1, \"created_at\":\"2014-07-16T00:02:59.233Z\", \"updated_at\":\"2014-11-05T02:01:54.211Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6ea75d536848f9a1dc8d0e04510767d2e2fb34055605fd52a1b2a3a2c4cece04\", \"recipient\":\"1DQUJ4Z6ygitDpopQskPRCuQwm9Ez8ajdM\", \"status\":1, \"created_at\":\"2014-07-17T00:01:57.057Z\", \"updated_at\":\"2014-11-05T02:01:54.313Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI1PI:KEY:<KEY>END_PI1639a88d0b41ef88d1c61c74725\"}, {\"tx_hash\":\"623cd0dccd6281011ccf7935f69e261e6ffa267d0d229d6f7d9cbe8decc89b11\", \"recipient\":\"1QCuZWoH5xCTgQbfxH7uzxNo3FtxDAxNdq\", \"status\":1, \"created_at\":\"2014-08-07T00:01:52.728Z\", \"updated_at\":\"2014-11-05T02:01:54.331Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cd86d40b2707dee5e3edff0cf2c5ecba63bfd969b501190ec7c311130f084285\", \"recipient\":\"1479tCiLWz5aKvM8SKxko9uiTrX8K2HwpG\", \"status\":1, \"created_at\":\"2014-07-30T00:04:26.693Z\", \"updated_at\":\"2014-11-05T02:01:54.341Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f8e2eed5464b174d25cc7d48836f6683cbee14080a191dd81f2ec7979b8bd4c4\", \"recipient\":\"12rB5WuthGjSCgJ4tzw9gHrLmoHYTqUQqQ\", \"status\":1, \"created_at\":\"2014-08-06T00:00:39.527Z\", \"updated_at\":\"2014-11-05T02:01:54.357Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI8PI:KEY:<KEY>END_PI49PI:KEY:<KEY>END_PI109a0ae95f3d82b167658cc1fb684645\"}, {\"tx_hash\":\"8ee99265fb77f830ba79759d509ce585196e2c6623c99866aa3e19a2dbc43066\", \"recipient\":\"1YYekbc3L3cM2Fq2UE1fnxxK1TBfjxPhX\", \"status\":1, \"created_at\":\"2014-07-19T00:03:31.239Z\", \"updated_at\":\"2014-11-05T02:01:54.374Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2e83d98c31147546570bb123716cf7359ece3d3eb342adf4fb4c5a3db211d68f\", \"recipient\":\"1EWrwRRuPeFZqtuupHKXfFJVsVNyxwdGYg\", \"status\":1, \"created_at\":\"2015-02-28T00:01:10.314Z\", \"updated_at\":\"2015-02-28T02:51:43.930Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8905d041a4fe8903ba16f4880f43dba84ee8e4eb1fb57a7ada22a5eb00406050\", \"recipient\":\"1NEVG8nLCVfdsBe2pJTxFEzvvKnh3AA5qV\", \"status\":1, \"created_at\":\"2015-03-13T00:00:58.406Z\", \"updated_at\":\"2015-03-14T03:22:00.346Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e9b5dfe44174ccd94fd6ede31da13fe9608d2ed9addbf81b93ac7bf7bd8ac4ae\", \"recipient\":\"18c8SznKPzHihmrbcM5wYdGSUHPzGuHPI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2015-05-19T00:00:42.053Z\", \"updated_at\":\"2015-05-19T13:21:42.197Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a5490f9df9b4d5f11e6c0a33cbce388d37176ecc988594daaa1a752bd029f01c\", \"recipient\":\"1EyRXrtiGcsVDAPv5WacybHY4SvbzVeaJk\", \"status\":1, \"created_at\":\"2015-02-27T00:01:33.835Z\", \"updated_at\":\"2015-02-27T00:53:05.189Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2c056935b77b9644684f7dcd7d0b679fe8fc8e02aae314ba0d03cc40043db054\", \"recipient\":\"19WDbpqrZttg4uG3L3Jj1UHWEGCnSbT73s\", \"status\":1, \"created_at\":\"2014-07-22T00:03:43.152Z\", \"updated_at\":\"2014-11-05T02:01:54.395Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"39db27fa5adcaf0b828d5037a882a4a5efcf6bd3551fefe171a339d3fa418c86\", \"recipient\":\"1Kyh12UYzPeLygRc73UMDUTydREBJLSnTx\", \"status\":1, \"created_at\":\"2014-08-08T00:00:57.109Z\", \"updated_at\":\"2014-11-05T02:01:54.408Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7e2f10ee736048c19c19c1a7202b11a7a438ba7e7bba7128f559bf9c8c463eab\", \"recipient\":\"12M3XZJf9pppmVHidyxJSXi9Xo3ei5ZXun\", \"status\":1, \"created_at\":\"2014-09-21T00:01:02.250Z\", \"updated_at\":\"2014-11-05T02:01:54.418Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"35189b74ac7e0cd8fb723b450f8d63f9b52b628dc5dd3599eadde8d1bbd2a332\", \"recipient\":\"13MePxVWGvK2qxd3vhef2Wf79zYQiGNwQL\", \"status\":1, \"created_at\":\"2014-08-13T00:02:04.590Z\", \"updated_at\":\"2014-11-05T02:01:54.427Z\", \"private_key\":\"PI:KEY:<KEY>END_PI \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"eb286633e29904901ca2ae4df5bbaf14aa25e4c8387d985adc4873dceba9798b\", \"recipient\":\"19pR3kzPsghsaXsgBXHHoF4zzjXKDvf3AF\", \"status\":1, \"created_at\":\"2014-08-16T00:03:17.308Z\", \"updated_at\":\"2014-11-05T02:01:54.444Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"b4b82100bc96cb2531b11a228cebe6e81871d919219aae23d0cff67b9103a3bd\", \"recipient\":\"15amQEzENHMw1Cgd6dawfU1Mceh695453a\", \"status\":1, \"created_at\":\"2014-08-19T00:02:33.963Z\", \"updated_at\":\"2014-11-05T02:01:54.460Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"633e453ecbc79bff9260bd1e2ae6fde79199871e8817b27664e389801ca27b95\", \"recipient\":\"17H66Co6zon2Lm83SCdLfGwn4LgGiyAJkf\", \"status\":1, \"created_at\":\"2014-08-15T00:01:15.375Z\", \"updated_at\":\"2014-11-05T02:01:54.470Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"14ac6a2f3eabde6d34518e6b45a4b611029b71d43b12d4547b2be076486230dc\", \"recipient\":\"1GqJQ3CB3QQSqfx7n5YMMWiXZpCzCm8v7N\", \"status\":1, \"created_at\":\"2014-09-03T00:01:25.216Z\", \"updated_at\":\"2014-11-05T02:01:54.490Z\", \"private_key\":\"PI:KEY:<KEY>END_PI759PI:KEY:<KEY>END_PI1PI:KEY:<KEY>END_PI2e4PI:KEY:<KEY>END_PI3582ffff973085ec56f18be6f8618ece2a94579edb771c62\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ce9a86fffc98ee5581d0afcc7e2c31b3629425821edb1f340da71cfc5bc67815\", \"recipient\":\"13KLTTQASP88L6p12ELqJy4bjnDSEwozCz\", \"status\":1, \"created_at\":\"2014-08-27T00:00:50.518Z\", \"updated_at\":\"2014-11-05T02:01:54.499Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI8af6ff9\"}, {\"tx_hash\":\"a58ab327b123f52cfb4dcf55ab20f370b64c216c46225e0fda9daa463485caf1\", \"recipient\":\"13pj86PtizzrVsWBK67xrVsit4fcFxoboX\", \"status\":1, \"created_at\":\"2015-04-09T00:01:17.301Z\", \"updated_at\":\"2015-04-09T03:41:32.631Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f349f7a051bdccbdaaa8a8aa6f4e1d7c1e525fcad210503f968881b9ca3f3953\", \"recipient\":\"1FDYRCzyrBxtPQEUcYtPn31Z57sEWdSZ77\", \"status\":1, \"created_at\":\"2014-09-11T00:00:58.352Z\", \"updated_at\":\"2014-11-05T02:01:54.520Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1be02fd5d8ff79ff476c98e8579c03df39f86d4c84728a5dfbc16cdc970ec15f\", \"recipient\":\"18zCuxKJB3BrFuxneGZvqXuCK6ePn5uxJx\", \"status\":1, \"created_at\":\"2014-09-13T00:01:26.758Z\", \"updated_at\":\"2014-11-05T02:01:54.546Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d7f8eaa6c629835573b2ea32c2fff12e716f7ee715c93d758d7054bc4ee1856e\", \"recipient\":\"17kK2Yjiyx45UFcegEjoJGL6AbP8bNnHRQ\", \"status\":1, \"created_at\":\"2014-08-28T00:01:40.142Z\", \"updated_at\":\"2014-11-05T02:01:54.556Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIdPI:KEY:<KEY>END_PI63217PI:KEY:<KEY>END_PI22bfPI:KEY:<KEY>END_PI07dPI:KEY:<KEY>END_PI3PI:KEY:<KEY>END_PI8PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f912b95edf2f3c27222e7bf5fcd16bc289e703332374bc6c06494806bb19721c\", \"recipient\":\"1EymstwppqpjDLnppAzzkaP4oRewC2WtFL\", \"status\":1, \"created_at\":\"2014-10-17T00:02:39.244Z\", \"updated_at\":\"2014-11-05T02:01:54.570Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"030c377b490360e39c8bb321d235ce04bce32a930d844033989c17607c1fa545\", \"recipient\":\"1BdRoLwdDTyg5pwi9t1S2kFova32Yzr2ux\", \"status\":1, \"created_at\":\"2014-08-21T00:01:45.354Z\", \"updated_at\":\"2014-11-05T02:01:54.580Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a7d0a02d81ce67e33b948b22618358527a9286073bf0e9cf46e1c80865ebdaec\", \"recipient\":\"1NvZdFo4sfTGd2g6MEo3mwwWD9psA6DNQ7\", \"status\":1, \"created_at\":\"2014-09-30T00:02:40.948Z\", \"updated_at\":\"2014-11-05T02:01:54.594Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIbPI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1cfe6f32d9ecd8467da2ef350cc12355744f3394b7263f1438fb0a0348261f9f\", \"recipient\":\"1JwkcQiauoeuRoAw3tAV8NsHox46zavWxL\", \"status\":1, \"created_at\":\"2014-10-18T00:04:07.895Z\", \"updated_at\":\"2014-11-05T02:01:54.604Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7351a3ecbf091b4bd26879f682cdd3e9a0d6dcf03046d006bbe955f0d7328cb5\", \"recipient\":\"17w1KLLKTRELdWjUTG3PhJh5ZNP9faNwHg\", \"status\":1, \"created_at\":\"2015-03-01T00:02:10.733Z\", \"updated_at\":\"2015-03-01T03:32:15.363Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f97397d2ec383e005bd9eb92a7537f188fc6c35ca851d791beaca510275d3c9e\", \"recipient\":\"1Fzbp3xAjvLW3rsis7tBdhUHYhk62my6qJ\", \"status\":1, \"created_at\":\"2015-05-19T17:36:52.626Z\", \"updated_at\":\"2015-05-19T18:12:12.879Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8801507b6464f0c271b6dda43fd46c306bafe1e96b1e026ff3dc702916484ce8\", \"recipient\":\"1CXMpUCwgXsFv3kVuCWNKndLxdkPucgMXg\", \"status\":1, \"created_at\":\"2015-02-06T00:00:50.455Z\", \"updated_at\":\"2015-02-06T01:12:09.129Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"09ddafe9b2a44217c28b88c4b2b0b7a2fd5b058ccd4423e2c533f267fca34f55\", \"recipient\":\"19zViZWqcAk9hZ4FkvSgXTQ36TrMM29gdX\", \"status\":1, \"created_at\":\"2015-04-11T00:01:10.824Z\", \"updated_at\":\"2015-04-11T04:03:53.529Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"97dc3f7272e00a2adbc36134861ad20f0c39a099b794781a896c585d66cc2994\", \"recipient\":\"1DJew7kboAeRf9ZvZsXkr7CdhNBs3mxuNb\", \"status\":1, \"created_at\":\"2014-09-20T00:02:49.930Z\", \"updated_at\":\"2014-11-05T02:01:54.635Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3dd943557ace2a9889317a3d3a32c59c3973f635c29bb5c470ae3d9ad32371f7374f1df14004553d65011643\"}, {\"tx_hash\":\"6e77511b73eb74999f1baa1da4c01f05da61362dcbb2a5b92cf2bfc9ba80a833\", \"recipient\":\"1HJdTKwaMiJTJg2qSWkAaR6VLAoQfZFo4j\", \"status\":1, \"created_at\":\"2014-10-19T00:03:29.701Z\", \"updated_at\":\"2014-11-05T02:01:54.664Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d10225248e5742e0001196eefef871e2abc6ec682bbb547449278c053e87f4eb\", \"recipient\":\"1GscL6FtdwR8HCGtntanruiUgx7WyaEKRPI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2014-08-09T00:02:52.005Z\", \"updated_at\":\"2014-11-05T02:01:54.674Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5f8636d47e297945df2152d366f4addffbf59a1f34ed23599509af5918e7c8d6\", \"recipient\":\"19cEFAbviq8Jn8wnkhC66RfVypq21QmBL2\", \"status\":1, \"created_at\":\"2014-09-04T00:01:21.963Z\", \"updated_at\":\"2014-11-05T02:01:54.684Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIddPI:KEY:<KEY>END_PIbccPI:KEY:<KEY>END_PI27bPI:KEY:<KEY>END_PIddd4PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"87dc93e880ef54fd656d393b071de5ae248f7d6d16dfc64ab681d76a3a51637e\", \"recipient\":\"1KX1Uj6wZ3XvbVQ8JZuERwjNTPdQV1NA9A\", \"status\":1, \"created_at\":\"2014-09-09T00:02:16.514Z\", \"updated_at\":\"2014-11-05T02:01:54.694Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4da9a8e99bd107aef496ef7d6a082ad6f0ad40ff3555ac79c7e88b4513e38dba\", \"recipient\":\"183RdFzvnR4iDTYxfDCmuPI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2014-10-24T00:03:15.523Z\", \"updated_at\":\"2014-11-05T02:01:54.704Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"49f2c9c84e1176113b6e5a8072c26a664eae697155b059bf5b0369823bf6d59d\", \"recipient\":\"129FhScAaPJrMhRVDQR6gUj8mQLYrH6u9r\", \"status\":1, \"created_at\":\"2014-10-25T00:02:36.246Z\", \"updated_at\":\"2014-11-05T02:01:54.720Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIb3c4c1df0282c25145312ea4PI:KEY:<KEY>END_PI14PI:KEY:<KEY>END_PI2PI:KEY:<KEY>END_PI6PI:KEY:<KEY>END_PI02PI:KEY:<KEY>END_PI02PI:KEY:<KEY>END_PI0PI:KEY:<KEY>END_PI26991aPI:KEY:<KEY>END_PI2PI:KEY:<KEY>END_PI6PI:KEY:<KEY>END_PI1PI:KEY:<KEY>END_PI7PI:KEY:<KEY>END_PI1e4PI:KEY:<KEY>END_PI9PI:KEY:<KEY>END_PI0afPI:KEY:<KEY>END_PIc84dPI:KEY:<KEY>END_PId29PI:KEY:<KEY>END_PI2d4c6058bb723cd4d770421c34a4ee281694159ee6d7ed\"}, {\"tx_hash\":\"8be98aeda1900f4c0dad61489aefc1319d6739213a82af48c46152aa8a1748b9\", \"recipient\":\"14csJV8qA2JxqqycQRsGWEipak8QyGpsyE\", \"status\":1, \"created_at\":\"2015-05-20T00:01:16.616Z\", \"updated_at\":\"2015-05-20T02:41:24.667Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"09aff87f6f8470af69fa7999fe1c8c57ac3bbcb27632201de4fb4d47b01cf434\", \"recipient\":\"17w55VgkraGP7ePuoi8R51VGXUz6N2VrMr\", \"status\":1, \"created_at\":\"2014-07-13T00:03:11.848Z\", \"updated_at\":\"2014-11-05T02:01:54.741Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5faa33de1954e3d3e7a86dc2b3382cc4bb34467397bb1fb42ea6607a6eccd985\", \"recipient\":\"1Jhh1fiPXujNKyQXx4Hp8HdrjUvNJNrsPw\", \"status\":1, \"created_at\":\"2014-07-04T00:02:40.993Z\", \"updated_at\":\"2014-11-05T02:01:54.758Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIc25PI:KEY:<KEY>END_PIffPI:KEY:<KEY>END_PIfPI:KEY:<KEY>END_PI0bf6PI:KEY:<KEY>END_PI9PI:KEY:<KEY>END_PIePI:KEY:<KEY>END_PI1PI:KEY:<KEY>END_PIaePI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"62e706ab68ed837ad1bcf46af3bef4332317e4d207a8e3baeac281a64e964094\", \"recipient\":\"15nW73dJdqnJKyhwF2kT74631LxGMtxrws\", \"status\":1, \"created_at\":\"2014-09-22T00:01:16.469Z\", \"updated_at\":\"2014-11-05T02:01:54.776Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"bf63f9301f6c44b64b37bbb1f688d7e9e6dbdd0aeac00acc3416d75248d25d84\", \"recipient\":\"1Gu89n93x7ejfcFaEzqqcnSSv74dqfATJ2\", \"status\":1, \"created_at\":\"2014-09-18T00:01:30.745Z\", \"updated_at\":\"2014-11-05T02:01:54.800Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0a4c0eedc64788e0bd7bc5b6f904db320ccee05bab4bfc7e3768ada9c65db7b8\", \"recipient\":\"1K626vn2b75F7E6ga4BT6NGfBJLgRy4b2a\", \"status\":1, \"created_at\":\"2014-03-06T18:12:18.631Z\", \"updated_at\":\"2014-11-05T02:01:54.811Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI365234c6a7378def8ebb5ed860864c04a939b702235011b7b38db4472209a8779aef7e41a8af6d89caf614dd9\"}, {\"tx_hash\":\"f2dd148488005569176b02106d53800921a45b253b85b3266584e791e7ce8dab\", \"recipient\":\"18qJB63Fu25HDJEnPhvyJoHzV95q44tawR\", \"status\":1, \"created_at\":\"2014-06-20T00:02:59.970Z\", \"updated_at\":\"2014-11-05T02:01:54.824Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"22d7711d3700984fe0f9a4b24ed6d9f0002d92e186ed70a004c03eee4a0d8878\", \"recipient\":\"1HSrRGG3xTTgXSSGsPI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2014-06-19T00:03:08.596Z\", \"updated_at\":\"2014-11-05T02:01:54.834Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7e8a9612907c313ecf112d77c8728e7454809f74db005a5d95f01a699c2a2244\", \"recipient\":\"1Mbrt1KyLjjNbfht8uHvgZCRBAwBmeHRYz\", \"status\":1, \"created_at\":\"2014-07-11T00:02:53.893Z\", \"updated_at\":\"2014-11-05T02:01:54.882Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI37d8e0a0720b7eb43465f0eb880538e2b46ef4379661PI:KEY:<KEY>END_PI849650de02bc9d80a3ebd20aba8e478fb93381451fa839afb37c6b4083e681e97bc42d25f\"}, {\"tx_hash\":\"1ced7a8bb16d007989137638f80c2e7e98f3693792fdf6ba10f67fc5800d66b9\", \"recipient\":\"1k8ZH4KMF8jjNhiZqpH1dAc3TCdPoWtFz\", \"status\":1, \"created_at\":\"2014-07-06T00:03:46.146Z\", \"updated_at\":\"2014-11-05T02:01:55.071Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1820a8227530e2de48b6f8901239ab9bfb2bef14ce8e82c32650236b197fb5c7\", \"recipient\":\"13sQenmSSWutGBf531Vfo6qihS3VgyHx6s\", \"status\":1, \"created_at\":\"2015-03-02T00:01:18.650Z\", \"updated_at\":\"2015-03-02T04:21:43.443Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6833db89c0603cff2ff8ee9b3cf4a1cb0274566b8c432fb79b16eeebcb3741f6\", \"recipient\":\"1JwjA5kbMBHw94vBRib2cSu6TNcYh8UQfC\", \"status\":1, \"created_at\":\"2015-03-15T00:01:12.338Z\", \"updated_at\":\"2015-03-15T23:11:50.287Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIbc66f669b\"}, {\"tx_hash\":\"f1b9e9017b97007f4fcffa3b7704da134d62c2db6d53f0b3ba236bd88c599a76\", \"recipient\":\"1FQ4TEV3482bmV5dysx4fBbkMhF34mMvzN\", \"status\":1, \"created_at\":\"2015-05-21T00:00:34.812Z\", \"updated_at\":\"2015-05-21T04:51:34.994Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d9341c7ae399a33f05f3c2061fdcd1674857bd244aede6aba86b00b202b30b6c\", \"recipient\":\"1BTq9R1V4txJzDHAAcSifDM4FopS4MNmos\", \"status\":1, \"created_at\":\"2015-02-07T00:00:26.651Z\", \"updated_at\":\"2015-02-07T02:03:43.065Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"d6c6ddcb450e1434dfdc4717b771d25c0c0efad04e7ab6946cadae496942c445\", \"recipient\":\"1PF4wiajPbdfQAwFs3qn1YAXNAtXiWdc4R\", \"status\":1, \"created_at\":\"2014-08-05T00:01:02.573Z\", \"updated_at\":\"2014-11-05T02:01:55.138Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a648ca92a6a620cbda3e7dc59c4542269a8c0895a3ce52443c445ca507ee702a\", \"recipient\":\"17wUqNtW71HeJPI:KEY:<KEY>END_PI\", \"status\":1, \"created_at\":\"2014-08-12T00:02:02.109Z\", \"updated_at\":\"2014-11-05T02:01:55.288Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7825d568ec2485d01bb0a857e91fa49c849d0f14bf3ba00033eed9c52347959b\", \"recipient\":\"1JEvnUs6xYdSFszAfypnRFmCTqvarUHmyb\", \"status\":1, \"created_at\":\"2014-09-05T00:01:10.782Z\", \"updated_at\":\"2014-11-05T02:01:55.307Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI113bd8787fd8ca8938d15549f0833cf7bd386db7c5a69b3007c74eaac1fc99f6132b468f1b90bd078ad375e4ed75e0572c28d8e1305ad9710dc4e87\"}, {\"tx_hash\":\"63186ca40ef1330ddfd4c8b2c283a25726b6122e78810e4d28fa6702939e63cf\", \"recipient\":\"15VzZi3gFGLMxfFUvq7YtAD94sYWb2ppmh\", \"status\":1, \"created_at\":\"2014-10-07T00:04:18.578Z\", \"updated_at\":\"2014-11-05T02:01:55.318Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4219480d1f44541eede61328b015740d4c197d6b798581455612af034171f5f8\", \"recipient\":\"1Jiz6h7uZBf7qNim8gsqR77jSxT6fPRJAQ\", \"status\":1, \"created_at\":\"2014-09-10T00:02:07.158Z\", \"updated_at\":\"2014-11-05T02:01:55.328Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI2a0PI:KEY:<KEY>END_PIaPI:KEY:<KEY>END_PI57684PI:KEY:<KEY>END_PI\"}, {\"tx_hash\":\"c8d18a04fe3986a2f67df0a59a92870931cd83a5e804cb743db25008de95f13e\", \"recipient\":\"134Yg6CsVgwXvHYuRrFn4HutxHPutVdDew\", \"status\":1, \"created_at\":\"2015-03-03T00:02:14.707Z\", \"updated_at\":\"2015-03-03T05:12:59.529Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c859873bd52b52b4f2e1e33eada6c5695a23ad1d2812966e17bea24e27a4e1d6\", \"recipient\":\"1N7zsioZcNvYV8fEuZgqoZgp4sBKaCmK8F\", \"status\":1, \"created_at\":\"2015-03-04T00:01:27.787Z\", \"updated_at\":\"2015-03-04T03:03:56.466Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4aa383e4de6f7953fd0034f7c3d4b8560b3d4413830ca9c3951be7148f474bfa\", \"recipient\":\"1NP6YELeLM8rAvcaTdWd488zGxcKMdu8HB\", \"status\":1, \"created_at\":\"2015-03-05T00:01:23.190Z\", \"updated_at\":\"2015-03-05T01:32:01.215Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"df0044bd6404470a20248f7c324865abae7cf55203329e96fa8d38a40704d40e\", \"recipient\":\"15vNTK3VGHmNh4ZXKxGcJtW4RL7HwrW3hm\", \"status\":1, \"created_at\":\"2015-03-05T07:01:23.044Z\", \"updated_at\":\"2015-03-05T09:21:32.063Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ccedc74c3489c0943e0de27d7fc969e736fadd748b91b9c30874be10abbe8031\", \"recipient\":\"1JFNFsMNmPKXyGvzkcmfgEhAgeB59cPre3\", \"status\":1, \"created_at\":\"2015-05-05T00:01:01.506Z\", \"updated_at\":\"2015-05-05T13:02:49.422Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"610008c9614a4e60bf0e13649e67a0160faaf2fdace74db1d58e34d8069cf7fd\", \"recipient\":\"14CvSMCLEqcEJXfyxQ15qP4NHPQEsuTEyc\", \"status\":1, \"created_at\":\"2014-09-17T00:01:45.324Z\", \"updated_at\":\"2014-11-05T02:01:55.413Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIdfd5c10fa4889PI:KEY:<KEY>END_PI6aca3b190ce9b146e8ddf893006bbcba020ec47\"}, {\"tx_hash\":\"60ed5cf4eb7df8fd5440253b6ac9f38ee475b613350b849a1b84f79e2c7a3be5\", \"recipient\":\"1HdE74JRCoRtvabShnrVR6W33g7n7kN5bm\", \"status\":1, \"created_at\":\"2014-09-25T00:02:36.163Z\", \"updated_at\":\"2014-11-05T02:01:55.424Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5b1cfb278417b9ecca5c0abff5d82559d68cac6b3c0957ed4662fcde49e9bb79\", \"recipient\":\"1LTLoErGNyJftJiKNhx7f65yeP6GDe2C8i\", \"status\":1, \"created_at\":\"2014-10-23T00:03:01.135Z\", \"updated_at\":\"2014-11-05T02:01:55.435Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c37c292036ac8e53f45df7b1d579c991a14d71dda38e3cda127f3b9e6bc5dd28\", \"recipient\":\"13MAP4k1pemMJSy37Gs1bDkuXebQzBHDft\", \"status\":1, \"created_at\":\"2015-02-09T00:00:31.189Z\", \"updated_at\":\"2015-02-09T13:03:50.510Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"00e4789a46c033dae3037037PI:KEY:<KEY>END_PIbc1f0dd2f93c05PI:KEY:<KEY>END_PIcdbcd8787cb11PI:KEY:<KEY>END_PIede56f\", \"recipient\":\"1KuNUh1cZvYpmj5S4SRAVSPWT27jUfybvE\", \"status\":1, \"created_at\":\"2015-02-08T00:00:40.432Z\", \"updated_at\":\"2015-02-08T01:12:05.179Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"da52e261090e4fb2cd27a4b3a03ee3f5405439ed6c9c879a6adf6547dd30fe39\", \"recipient\":\"17xca7Da51PXG1R3Nn3nodKvWxC6HUEmwb\", \"status\":1, \"created_at\":\"2015-05-22T00:00:51.136Z\", \"updated_at\":\"2015-05-22T02:31:58.591Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI1044fcdee10d430a33dedf552fdbce9436314\"}, {\"tx_hash\":\"e6f168271eb096f8531eeeb8a7ad7f7013c5aa0b1a67c811530e9ea9ce46dfbb\", \"recipient\":\"1NgeXp6dcody7TmUJGdMJ8yV6bAZZwNp7o\", \"status\":1, \"created_at\":\"2015-02-10T00:01:15.427Z\", \"updated_at\":\"2015-02-11T00:32:22.795Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2ffed5570f19bffb44893b93b29d5e83dd123ca2867bd7aae3437a66b8315d6c\", \"recipient\":\"14ek3CPMHb1J5nAWcWhGxjWNqehd11Pun8\", \"status\":1, \"created_at\":\"2015-02-11T00:01:12.172Z\", \"updated_at\":\"2015-02-11T00:32:22.423Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"fce90aaef1c40c8af54806e65521c1394d2ff2b132e1e03b1ab89f87cce9ba89\", \"recipient\":\"1EETrb2TDoHFYUKZn7vBfC7mgfVReN8szA\", \"status\":1, \"created_at\":\"2015-02-11T22:29:03.282Z\", \"updated_at\":\"2015-02-11T23:22:08.636Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7ba5c520cd592957a5fbee281b640b26a1ba0ab87110c7a575690a0a7169e2ad\", \"recipient\":\"1P19fwU71UiP6UdYrhqXpXgKK9uZ7U2KUi\", \"status\":1, \"created_at\":\"2015-03-17T20:21:18.737Z\", \"updated_at\":\"2015-03-22T18:25:58.264Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"69637167f28291d8aa121614a47e82437fbe61c1c789b07566cd7e89cb53bbe5\", \"recipient\":\"192FGXVbLFXyHL5x7nYakAP2e1Rs5f3nWt\", \"status\":1, \"created_at\":\"2015-04-14T00:00:26.323Z\", \"updated_at\":\"2015-04-14T14:32:22.890Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"85a5b7ba4b8cbf31561251a1497a5ae87025be746d22f30a688e79820df64751\", \"recipient\":\"128q5ggsK1CKzJuypLwMZEcj4QwyAyYsb4\", \"status\":1, \"created_at\":\"2015-05-23T00:00:58.432Z\", \"updated_at\":\"2015-05-23T05:31:50.072Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e31f22e1bbd2ba8fb9cfca379bf14d81e2a0e27404513fd627658c7afa128d84\", \"recipient\":\"1ASh51xLdLTY2Z2kXKNv4r1kN2a5Z14XL6\", \"status\":1, \"created_at\":\"2015-04-15T00:01:14.815Z\", \"updated_at\":\"2015-04-15T14:42:02.003Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c6b2274f27896e417929ae81b1d8b726396d90bcb936779e5a6333ba644f4550\", \"recipient\":\"1K4o3My8VfAwzurMYt9FX1oCJiw2kS92iw\", \"status\":1, \"created_at\":\"2015-05-26T00:01:00.661Z\", \"updated_at\":\"2015-05-26T06:51:22.413Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"83343c039915885b1f4038527ff33931fc2c7c3e496a24a53377141313dd457b\", \"recipient\":\"1LjmYYrbPuoSmb7xdRsghZd8ws1trz6uYp\", \"status\":1, \"created_at\":\"2015-05-24T00:00:32.908Z\", \"updated_at\":\"2015-05-24T02:11:49.871Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1f4065055093d010042577f05747abc10824880242e7cf2c83aaa64c11fa4480\", \"recipient\":\"15gMq9qEyDWrdAvmMidaCLcvL1oxRpP2DF\", \"status\":1, \"created_at\":\"2015-05-25T00:00:48.974Z\", \"updated_at\":\"2015-05-25T06:51:33.537Z\", \"private_key\":\"PI:KEY:<KEY>END_PI \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4286ba63dbf5b0d8a5371e22e39fea93655f5f5df7c736ee90aa1efe5f88a1d6\", \"recipient\":\"1JenQeTcNfFn7Nak52PfMNiXUvJsMftHcD\", \"status\":1, \"created_at\":\"2015-05-29T00:00:26.911Z\", \"updated_at\":\"2015-05-29T14:03:00.926Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c34d5b08276f93a1c028f20664c052551700db7109433a9411eda12400c4cb39\", \"recipient\":\"1FdR2QGCLvZVcF26vArJRt3X1wpPyNJ6Ao\", \"status\":1, \"created_at\":\"2015-05-27T00:00:52.694Z\", \"updated_at\":\"2015-05-27T10:02:52.082Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a7d4eb81767d73f97944fec27ca0034140370ffa5947ddae6df7a8102889dPI:KEY:<KEY>END_PIbb\", \"recipient\":\"1EMD8PuWR74KASVpL8kLLj74iJGhcBWQK3\", \"status\":1, \"created_at\":\"2015-05-28T00:00:29.181Z\", \"updated_at\":\"2015-05-28T05:03:28.627Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7fc82e3563429340e8404d1f4995503169e51d36eeaa957ffed5b93e09878de8\", \"recipient\":\"1NTjnNNzSeyys1Cgx3r3Es1fCFTHARjEW8\", \"status\":1, \"created_at\":\"2015-05-31T00:00:53.040Z\", \"updated_at\":\"2015-05-31T11:21:33.999Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI05e102f2cd677c8\"}, {\"tx_hash\":\"de5f0b9034b658a24ac062d9a31c382cee30a8316781382321c5baa5298823ed\", \"recipient\":\"17fv7DkQCGEPeJPY92BpXQcEeugVKVUUWg\", \"status\":1, \"created_at\":\"2015-05-30T00:01:12.794Z\", \"updated_at\":\"2015-05-30T03:32:00.344Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f4e00063cd010063ef8ee04e192b609b5822f7ef296a59fd9ed31ed3a7cea3f6\", \"recipient\":\"1HqmRrfKtmLbfug9oTbXVsUUAqWgMxMHX9\", \"status\":1, \"created_at\":\"2015-04-16T00:01:19.301Z\", \"updated_at\":\"2015-04-16T04:03:16.440Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e4638d4474a25588230d6575e76300f813853283cfd473a5e290259651b85001\", \"recipient\":\"1Ga5W1Cwi6ss5cNzwJNyU1GHPkgj4NBgxe\", \"status\":1, \"created_at\":\"2015-06-01T00:01:18.431Z\", \"updated_at\":\"2015-06-01T07:51:32.206Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f143abba8681b940a49039520290d2551dd4416770d2fa26ced8a5196c51fcb2\", \"recipient\":\"129wcuqbcxEcqUZNTjn2Xd5qEryvBda4AC\", \"status\":1, \"created_at\":\"2015-04-18T00:00:58.014Z\", \"updated_at\":\"2015-04-18T08:41:32.317Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"243d27bcec12af06a1949493beaaff2976d4fc88757ca5a6bddb767ef9c7df95\", \"recipient\":\"1F9LAX1237fuGaYB6wuBDSsaqEFNFvyqLd\", \"status\":1, \"created_at\":\"2015-06-02T00:00:31.528Z\", \"updated_at\":\"2015-06-03T12:03:21.213Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"52da0fa05666543b5274488c20e69f668a7690b30db721a5a9a6702b833bf4e1\", \"recipient\":\"1NjEfap29LwbEq51DADiafWSK6eCkFhQ23\", \"status\":1, \"created_at\":\"2015-06-03T00:00:40.467Z\", \"updated_at\":\"2015-06-03T12:03:22.708Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"df6cf8d16929c774087741f382af107cb235d97eac61e5833439a5e3afd3700d\", \"recipient\":\"18mpztXerZGxJGxBReAp2jEtN4FDxkm2DQ\", \"status\":1, \"created_at\":\"2015-06-04T00:01:15.261Z\", \"updated_at\":\"2015-06-04T16:21:45.524Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4e8eb46448426032879947076c199bb11e4dd4460837d5a7c08ec16fb46271ff\", \"recipient\":\"1CRLSUTsof2gTdrH1hiQ9QB37YzXtkeKjQ\", \"status\":1, \"created_at\":\"2015-06-05T00:00:37.446Z\", \"updated_at\":\"2015-06-05T11:31:57.539Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3abb61b9874c7cfccae4600afb118d5a27513a454bd7512fc25e6115b6281040\", \"recipient\":\"12t7uSvSyHxHxvFvtbJhAKdKusuhhjzzc6\", \"status\":1, \"created_at\":\"2015-04-20T00:01:15.302Z\", \"updated_at\":\"2015-04-20T09:41:54.346Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI3245d9a21065fbf50d7c9048d46e563a55761a4184a34bb2c\"}, {\"tx_hash\":\"8cd48be8895fd816d724fd940241f4317bedc09ca70dd99ea48e4a7be4bf95a0\", \"recipient\":\"15GAnzUpPZ214joynVfaiBStombZGJba53\", \"status\":1, \"created_at\":\"2015-06-06T00:01:03.073Z\", \"updated_at\":\"2015-06-06T05:40:52.213Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c236a3e52c9001d605d053622d270229cfaa558a83b68e365dcfcf869d7f2a9d\", \"recipient\":\"1BibV4kKVNm18T8SXG6y37CkA7NXuiXTT9\", \"status\":1, \"created_at\":\"2015-04-22T00:01:26.706Z\", \"updated_at\":\"2015-04-22T08:41:53.733Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"54a521b952245944108a36505046f8a05d7324dc2f8df6186946e0b511cfa5a8\", \"recipient\":\"18dsDDLaFNbVuypxtVBdFc3oQP9dmNYR7k\", \"status\":1, \"created_at\":\"2015-06-07T00:01:26.683Z\", \"updated_at\":\"2015-06-08T10:22:23.891Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1aef91a65dafac5d25a3b25e8318fd6334c55cc55ad14cd19f3daa573ad36e63\", \"recipient\":\"17kQ6XLqKC7S9GwZR2krqzPQypNacRhiZC\", \"status\":1, \"created_at\":\"2015-06-09T00:01:10.425Z\", \"updated_at\":\"2015-06-09T08:11:58.711Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"52d153459978f94e1ac50d794604af2559d388d096c467f6a43e095de071dd6e\", \"recipient\":\"18u3mWfLsxwLgtCc2ewQCKB9PsNY6XSR7c\", \"status\":1, \"created_at\":\"2015-06-08T00:00:44.298Z\", \"updated_at\":\"2015-06-09T23:11:42.877Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"1add190c1855f385345fddb9b2a47c9b5ec770beca77dc29bbae3d41da0546af\", \"recipient\":\"1DBJ4TPhYronVs6XUHMz5aKbJPuaXs2caY\", \"status\":1, \"created_at\":\"2015-06-12T00:00:49.355Z\", \"updated_at\":\"2015-06-12T07:11:49.584Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6e7b11c90f4a1efe1f66ea101c1fe67cb6049b068ab82459ac081865c46626d9\", \"recipient\":\"1AHTtr569CuaGfntp2skwPXoSPfK6rCjEg\", \"status\":1, \"created_at\":\"2015-06-10T00:01:21.683Z\", \"updated_at\":\"2015-06-10T11:32:12.558Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI6d06261d8e7826fc1f32c48f93811\"}, {\"tx_hash\":\"be685122eaf9a33de0b42469107be6420bfc98ad3ada7ab3683be5c10e121243\", \"recipient\":\"1AgQC8xCi3mVUwrqG6Yh5WCLb73DQ13Zrd\", \"status\":1, \"created_at\":\"2015-06-11T00:00:59.166Z\", \"updated_at\":\"2015-06-11T10:21:57.744Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0591f38e4fa3ea24901ecef1f004a73952a95eecfde4b8f8956728ea37df9a7a\", \"recipient\":\"12B37YnjFK3zzFa4dScMGdrudAV7tTCTCC\", \"status\":1, \"created_at\":\"2015-06-16T00:01:29.196Z\", \"updated_at\":\"2015-06-16T09:03:09.965Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e6830222ea64aaffdf6bec6f939c67293caf1e0c4da9c263ad3261336d38244e\", \"recipient\":\"1LJTkkxAQ2Fo7t4KMX6TE5mWr9u1ZYRmy7\", \"status\":1, \"created_at\":\"2015-06-13T00:00:51.190Z\", \"updated_at\":\"2015-06-13T13:31:55.735Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"2cf1696dffc4fd60815d4b9ec51e21ceec79ac74eb481c359aca501f4bc6cc3c\", \"recipient\":\"13EYhcrNJ3ypBiz1uZdUGYVw4CXxhsG4nV\", \"status\":1, \"created_at\":\"2015-06-14T00:01:25.168Z\", \"updated_at\":\"2015-06-14T03:51:39.522Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"ebd5df214591d2917a5bdc6f842d1e3e7a7359ffa9f89e06d37f0a939ef0afcb\", \"recipient\":\"16XyHmh7fHWcaSoyiDoDmbXvUprNEKXuUE\", \"status\":1, \"created_at\":\"2015-06-15T00:01:21.530Z\", \"updated_at\":\"2015-06-15T02:51:53.312Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"9ecc5fb8218f44360626dd2be29d16693f4d46135892e578d03b6bcb50644737\", \"recipient\":\"13kL4ptfdLJCfdYHqKpmzHBdPfW3mDfDN6\", \"status\":1, \"created_at\":\"2015-06-18T00:00:28.166Z\", \"updated_at\":\"2015-06-18T00:51:41.767Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"7a4c8c771d9e7f86e1fd4cc9312b1f1565330ccfbff74556f2235a956c7c1afe\", \"recipient\":\"1QG1qg7dCNuBoFi9gEvwFdDheDnYfiQLVE\", \"status\":1, \"created_at\":\"2015-06-17T00:01:10.464Z\", \"updated_at\":\"2015-06-17T03:02:55.614Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI2258\"}, {\"tx_hash\":\"0251488c32a8f9689069d430905a29a82defd550c666a6e842c2ac45c4aafd4c\", \"recipient\":\"1EQm68Ab2TNNeUg1uGPicFtNAu3uuMmzFt\", \"status\":1, \"created_at\":\"2015-06-19T00:01:11.356Z\", \"updated_at\":\"2015-06-19T01:21:56.644Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"e5fe48f5866d164c22002519e0c2222e909ca20bd76fdec6aa6da498f7d74e28\", \"recipient\":\"17Nx5goCqUCTATy1rPkfNJNwNmVzWJBBsW\", \"status\":1, \"created_at\":\"2015-06-20T00:00:50.189Z\", \"updated_at\":\"2015-06-21T11:31:45.628Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"432085e2792541b3e3ed0f2754833af40ce12d89e00a1b1f3b4aff856206949b\", \"recipient\":\"14D2wKGeB85Z3uh1E41QxBiUuBaTmsiNGc\", \"status\":1, \"created_at\":\"2015-06-21T00:00:29.732Z\", \"updated_at\":\"2015-06-21T01:41:47.825Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"4970c8abdfb28495a96d211faace07aa78b0f7167bb939aa97f85d9ac3ad3e93\", \"recipient\":\"1PYgWKcShWALzGb1yd6zay2BzkoaCw5qeo\", \"status\":1, \"created_at\":\"2015-04-23T00:00:18.959Z\", \"updated_at\":\"2015-05-17T04:02:55.691Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"132e5f8e5f84d7520877cc0a85faaf9e433ba364990fd808b12b0e96b42b03fd\", \"recipient\":\"1BCrNrSMbs4k2TsCUq6csuWocajQLwW91z\", \"status\":1, \"created_at\":\"2015-06-22T00:00:49.615Z\", \"updated_at\":\"2015-06-22T01:03:10.433Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"8773ab632d07e73ead837a6972a446e551ddf027058ca34e11ee7ee9c248f3db\", \"recipient\":\"15C7eh7f3EQuyTKySTHwiUEu5xFaHmiNDp\", \"status\":1, \"created_at\":\"2015-06-23T00:01:02.441Z\", \"updated_at\":\"2015-06-23T04:03:04.737Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0a51ed48f6f07a1939007ded92c001dbdf2abbd3dec70d73310873396c0e637a\", \"recipient\":\"1N3G9NpX6Jo6xCRuHjHwnDUoexVNaY7tsa\", \"status\":1, \"created_at\":\"2015-06-28T00:01:12.828Z\", \"updated_at\":\"2015-06-29T02:04:21.779Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"14b40e99a0b4095d1fa01797c00f20ebcbb78a3bf5e48f5e75380729c42bbfba\", \"recipient\":\"14b9ZWvzio8i2PfWd2BqgVYaRG8phPwqpD\", \"status\":1, \"created_at\":\"2015-06-24T00:01:03.390Z\", \"updated_at\":\"2015-06-24T03:11:52.700Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"5a21c329e5b23ef62f4a16dc35d3692b69ae121b20d26f0a04b13f3e2a8dd913\", \"recipient\":\"196rYUxmgcrR1HAWnfofP2GxCc3QchrwZh\", \"status\":1, \"created_at\":\"2015-06-29T00:01:27.826Z\", \"updated_at\":\"2015-06-29T09:21:54.514Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f6866bdd5ed4615db6a97859c2f8e5fa04df394c8788ede58f334dfb0b822a07\", \"recipient\":\"1EBWYTQoaJHSSw3EQSAvamjo6Q4mNUZDzv\", \"status\":1, \"created_at\":\"2015-06-25T00:01:20.784Z\", \"updated_at\":\"2015-06-25T03:41:44.439Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"6a79539f070bdae09b72d9b082eca467b0ece599a1837bbbf78853cbe37ecdb6\", \"recipient\":\"1KiKKLD6BYWAqQy7ZVt5U2ZuGjAzDsx8PP\", \"status\":1, \"created_at\":\"2015-06-30T00:01:29.211Z\", \"updated_at\":\"2015-06-30T06:51:40.083Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"70d5d808ae48b52ca18684e6109a484c4bee331a8f07ecbf22cde012f640d50f\", \"recipient\":\"14PVNg2cPb1ioe1CT4zqEvFN1VVAURzDFG\", \"status\":1, \"created_at\":\"2015-06-26T00:01:23.088Z\", \"updated_at\":\"2015-06-27T05:41:55.735Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"abf23d913ebaba5b6cfe4ce380db2854b1ef0328af576238cd22e4d2de5dd0af\", \"recipient\":\"1Eq8w9xtRnh2ER7UAFMvFRs76N7cb5yQiB\", \"status\":1, \"created_at\":\"2015-06-27T00:01:23.378Z\", \"updated_at\":\"2015-06-27T05:41:56.162Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a4744de93164483dce44c6c8410e6af938a15ffed084de50e3cc3bfa808684b1\", \"recipient\":\"1QFf89ekBj1KQCSii4U4RUV7djLJbNmwkT\", \"status\":1, \"created_at\":\"2015-07-01T00:00:55.764Z\", \"updated_at\":\"2015-07-01T01:32:29.865Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"a5b28a937d054a6478d38693016045a08e3b042bdeeedda3681536480e1dbb80\", \"recipient\":\"1HxWSMNxG2KZWEUo4QsFKnji4rJXbGt7JM\", \"status\":1, \"created_at\":\"2015-07-02T00:01:14.866Z\", \"updated_at\":\"2015-07-02T08:03:21.668Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"f3274f2af4242950308efe62989c158d5892be3b91bcb5f37e6c96b1a777ce36\", \"recipient\":\"12yiPp8bnQA8z2DNtV7N9S99o8aD4rQFq3\", \"status\":1, \"created_at\":\"2015-07-04T00:00:36.834Z\", \"updated_at\":\"2015-07-04T06:41:30.502Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI94626b2d8ae3e7a70db0030db4847d8ac0ef39c4d03b71c0d162\"}, {\"tx_hash\":\"dcb6fab66a34e3ed99401cf968a0b704dab5b6ca07928c547131f01e6fcfe6bb\", \"recipient\":\"1JzwQmgQYwy6nBjybKDvktE3jgYXkuRGmw\", \"status\":1, \"created_at\":\"2015-07-03T00:00:41.858Z\", \"updated_at\":\"2015-07-03T06:32:06.750Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"cf76060ed1587fbc2fc30d09b973d0f7ecb5f2ebda05ae99c0b7691b238fb61d\", \"recipient\":\"1AMFTZhh5uMWvftbELU25CxAh7oxJXGrhE\", \"status\":1, \"created_at\":\"2015-07-05T00:00:46.597Z\", \"updated_at\":\"2015-07-05T06:21:41.284Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"0b66e834d067c4a3335606dbf447ed306ea55f04e34acc9cda63ad8c2fe24e66\", \"recipient\":\"17v4aYJQpwxp2VajkePPk9JvnkZvUeYANG\", \"status\":1, \"created_at\":\"2015-07-06T00:00:32.598Z\", \"updated_at\":\"2015-07-06T14:11:51.991Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"004643d1f77530586b0e30169663c9089d509d058e61b96a51e3751792300cf7\", \"recipient\":\"1BYB1FcC8YsPAuCyw9bBEP2EV2HkvpxrYp\", \"status\":1, \"created_at\":\"2015-07-07T00:54:05.481Z\", \"updated_at\":\"2015-07-07T12:11:25.844Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"54e41c4a8079f406d2c67678b251d2e06f631bca3c8da99f3f5cf0629bc27b9b\", \"recipient\":\"13w9hFbkEpsyhRPmfda4E2JQ8akE6PYxhT\", \"status\":1, \"created_at\":\"2015-07-09T00:00:38.578Z\", \"updated_at\":\"2015-07-09T02:51:31.994Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"c428c7960df93d59d0ca4178000561df5c8bef727f969e43dcf0d7ea45a82bcf\", \"recipient\":\"19mPk8uaMmMXfsDDxdTPG1PXLWun2pHPaK\", \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PIa00d06f0412661d2611c541978\"}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbcd2d5ae707\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}]" |# \"status\":1, \"created_at\":\"2015-07-10T00:00:58.275Z\", \"updated_at\":\"2015-07-10T04:11:23.760Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"de4f6c1f419c02b72d7ace7543193c35ab0733cf2aadccdbb8284543ee619ed4\", \"recipient\":\"1GinZ15SfJHyLg62KrX615GykUC4ZaV8hp\", \"status\":0, \"created_at\":\"2015-07-11T00:00:37.720Z\", \"updated_at\":\"2015-07-11T00:00:38.774Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"3e24e38058cbd1f39d2f510de1bd39e82f61390750dce6517bc346ff00f60be9\", \"recipient\":\"1Q97qMnwdgUNvhTveTBy8F9Q4GQsbN8kTa\", \"status\":1, \"created_at\":\"2015-07-08T00:00:48.714Z\", \"updated_at\":\"2015-07-08T05:02:14.659Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"52f3a8cd1d346efd018f8de36078e1615c7b20489fbead8052194b1686dcc9d5\", \"recipient\":\"1DsRASAzeh94FwGHQutKgsbgogSfeGfrCV\", \"status\":1, \"created_at\":\"2015-05-11T00:01:07.658Z\", \"updated_at\":\"2015-05-11T17:11:41.661Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}, {\"tx_hash\":\"de7614884e8e6a02c79357f4d54d12fcf1ca6b2f05910c4099f9dbPI:KEY:<KEY>END_PI\", \"recipient\":\"1CvynMV8j7MaMSpK822sFQcu1h5QP7L2QT\", \"status\":1, \"created_at\":\"2015-05-12T00:00:55.493Z\", \"updated_at\":\"2015-05-12T11:02:43.981Z\", \"private_key\":\"PI:KEY:<KEY>END_PI\", \"public_key\":\"PI:KEY:<KEY>END_PI}]" |#
[ { "context": ";;;; spellcheck.lisp\n;;;;\n;;;; Copyright (c) 2018 Robert Smith\n\n(eval-when (:compile-toplevel :load-toplevel :ex", "end": 62, "score": 0.9996868371963501, "start": 50, "tag": "NAME", "value": "Robert Smith" } ]
spellcheck.lisp
stylewarning/lisp-random
56
;;;; spellcheck.lisp ;;;; ;;;; Copyright (c) 2018 Robert Smith (eval-when (:compile-toplevel :load-toplevel :execute) (defun split (string) (loop :for beg := (position #\Newline string :test #'char/=) :then (position #\Newline string :start (1+ end) :test #'char/=) :for end := (and beg (position #\Newline string :start beg :test #'char=)) :when beg :collect (subseq string beg end) :while end)) (defun misspelled-words (string) "Identify the list of misspelled words in the string STRING." (split (with-input-from-string (*standard-input* string) (uiop:run-program '("aspell" "list") :input t :output '(:string :stripped t)))))) (defmacro spellchecked (string &key ignore) "Check the string STRING for misspelled words. Warn, at compile time, about possibly misspellt words." (check-type string string) (when (stringp ignore) (setf ignore (list ignore))) (let ((words (set-difference (misspelled-words string) ignore :test #'string=))) (unless (endp words) (warn "You may have misspelled the following word~P: ~{~S~^, ~}." (length words) words))) string)
88136
;;;; spellcheck.lisp ;;;; ;;;; Copyright (c) 2018 <NAME> (eval-when (:compile-toplevel :load-toplevel :execute) (defun split (string) (loop :for beg := (position #\Newline string :test #'char/=) :then (position #\Newline string :start (1+ end) :test #'char/=) :for end := (and beg (position #\Newline string :start beg :test #'char=)) :when beg :collect (subseq string beg end) :while end)) (defun misspelled-words (string) "Identify the list of misspelled words in the string STRING." (split (with-input-from-string (*standard-input* string) (uiop:run-program '("aspell" "list") :input t :output '(:string :stripped t)))))) (defmacro spellchecked (string &key ignore) "Check the string STRING for misspelled words. Warn, at compile time, about possibly misspellt words." (check-type string string) (when (stringp ignore) (setf ignore (list ignore))) (let ((words (set-difference (misspelled-words string) ignore :test #'string=))) (unless (endp words) (warn "You may have misspelled the following word~P: ~{~S~^, ~}." (length words) words))) string)
true
;;;; spellcheck.lisp ;;;; ;;;; Copyright (c) 2018 PI:NAME:<NAME>END_PI (eval-when (:compile-toplevel :load-toplevel :execute) (defun split (string) (loop :for beg := (position #\Newline string :test #'char/=) :then (position #\Newline string :start (1+ end) :test #'char/=) :for end := (and beg (position #\Newline string :start beg :test #'char=)) :when beg :collect (subseq string beg end) :while end)) (defun misspelled-words (string) "Identify the list of misspelled words in the string STRING." (split (with-input-from-string (*standard-input* string) (uiop:run-program '("aspell" "list") :input t :output '(:string :stripped t)))))) (defmacro spellchecked (string &key ignore) "Check the string STRING for misspelled words. Warn, at compile time, about possibly misspellt words." (check-type string string) (when (stringp ignore) (setf ignore (list ignore))) (let ((words (set-difference (misspelled-words string) ignore :test #'string=))) (unless (endp words) (warn "You may have misspelled the following word~P: ~{~S~^, ~}." (length words) words))) string)
[ { "context": "ches/basic-tests-p001.lisp *-*\n;;;; *-* Edited-By: cork *-*\n;;;; *-* Last-Edit: Wed Apr 7 10:23:10 2010 ", "end": 184, "score": 0.9694879055023193, "start": 180, "tag": "USERNAME", "value": "cork" }, { "context": "******************************\n;;;\n;;; Written by: Dan Corkill\n;;;\n;;; Copyright (C) 2008, Dan Corkill <corkill@", "end": 711, "score": 0.9998844861984253, "start": 700, "tag": "NAME", "value": "Dan Corkill" }, { "context": "ritten by: Dan Corkill\n;;;\n;;; Copyright (C) 2008, Dan Corkill <[email protected]>\n;;; Part of the GBBopen Pro", "end": 751, "score": 0.999873697757721, "start": 740, "tag": "NAME", "value": "Dan Corkill" }, { "context": " Corkill\n;;;\n;;; Copyright (C) 2008, Dan Corkill <[email protected]>\n;;; Part of the GBBopen Project.\n;;; Licensed un", "end": 772, "score": 0.9999340772628784, "start": 753, "tag": "EMAIL", "value": "[email protected]" }, { "context": "-user)\n\n(patch (1 \"06-22-08\" \n :author \"Corkill\"\n :description \"A simple example patch\")", "end": 1172, "score": 0.8307586908340454, "start": 1166, "tag": "NAME", "value": "orkill" } ]
source/gbbopen/test/patches/basic-tests-p001.lisp
earl-ducaine/gbbopen
3
;;;; -*- Mode:Common-Lisp; Package:GBBOPEN-USER; Syntax:common-lisp -*- ;;;; *-* File: /usr/local/gbbopen/source/gbbopen/test/patches/basic-tests-p001.lisp *-* ;;;; *-* Edited-By: cork *-* ;;;; *-* Last-Edit: Wed Apr 7 10:23:10 2010 *-* ;;;; *-* Machine: cyclone.cs.umass.edu *-* ;;;; ************************************************************************** ;;;; ************************************************************************** ;;;; * ;;;; * Simple Patch Test for GBBopen Trip-Test ;;;; * ;;;; ************************************************************************** ;;;; ************************************************************************** ;;; ;;; Written by: Dan Corkill ;;; ;;; Copyright (C) 2008, Dan Corkill <[email protected]> ;;; Part of the GBBopen Project. ;;; Licensed under Apache License 2.0 (see LICENSE for license information). ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;;; ;;; 06-22-08 File created. (Corkill) ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (in-package :gbbopen-user) (patch (1 "06-22-08" :author "Corkill" :description "A simple example patch") (printv "Simple example patch loaded!")) ;;; =========================================================================== ;;; End of File ;;; ===========================================================================
1404
;;;; -*- Mode:Common-Lisp; Package:GBBOPEN-USER; Syntax:common-lisp -*- ;;;; *-* File: /usr/local/gbbopen/source/gbbopen/test/patches/basic-tests-p001.lisp *-* ;;;; *-* Edited-By: cork *-* ;;;; *-* Last-Edit: Wed Apr 7 10:23:10 2010 *-* ;;;; *-* Machine: cyclone.cs.umass.edu *-* ;;;; ************************************************************************** ;;;; ************************************************************************** ;;;; * ;;;; * Simple Patch Test for GBBopen Trip-Test ;;;; * ;;;; ************************************************************************** ;;;; ************************************************************************** ;;; ;;; Written by: <NAME> ;;; ;;; Copyright (C) 2008, <NAME> <<EMAIL>> ;;; Part of the GBBopen Project. ;;; Licensed under Apache License 2.0 (see LICENSE for license information). ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;;; ;;; 06-22-08 File created. (Corkill) ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (in-package :gbbopen-user) (patch (1 "06-22-08" :author "C<NAME>" :description "A simple example patch") (printv "Simple example patch loaded!")) ;;; =========================================================================== ;;; End of File ;;; ===========================================================================
true
;;;; -*- Mode:Common-Lisp; Package:GBBOPEN-USER; Syntax:common-lisp -*- ;;;; *-* File: /usr/local/gbbopen/source/gbbopen/test/patches/basic-tests-p001.lisp *-* ;;;; *-* Edited-By: cork *-* ;;;; *-* Last-Edit: Wed Apr 7 10:23:10 2010 *-* ;;;; *-* Machine: cyclone.cs.umass.edu *-* ;;;; ************************************************************************** ;;;; ************************************************************************** ;;;; * ;;;; * Simple Patch Test for GBBopen Trip-Test ;;;; * ;;;; ************************************************************************** ;;;; ************************************************************************** ;;; ;;; Written by: PI:NAME:<NAME>END_PI ;;; ;;; Copyright (C) 2008, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; Part of the GBBopen Project. ;;; Licensed under Apache License 2.0 (see LICENSE for license information). ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;;; ;;; 06-22-08 File created. (Corkill) ;;; ;;; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (in-package :gbbopen-user) (patch (1 "06-22-08" :author "CPI:NAME:<NAME>END_PI" :description "A simple example patch") (printv "Simple example patch loaded!")) ;;; =========================================================================== ;;; End of File ;;; ===========================================================================
[ { "context": "t of Qtools\n (c) 2014 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 90, "score": 0.9999179840087891, "start": 72, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 115, "score": 0.9998934864997864, "start": 101, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.form-fiddle)\n\n(d", "end": 135, "score": 0.9999242424964905, "start": 117, "tag": "EMAIL", "value": "[email protected]" } ]
form-fiddle.lisp
Shinmera/form-fiddle
2
#| This file is a part of Qtools (c) 2014 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.form-fiddle) (defun declaration-p (form) (and (listp form) (eql 'declare (first form)))) (defun docstring-p (form) (stringp form)) (defun lambda-function (lambda-form) (first lambda-form)) (defun lambda-name (lambda-form) (unless (listp (second lambda-form)) (second lambda-form))) (defun lambda-qualifiers (lambda-form) (unless (listp (second lambda-form)) (loop for item in (cddr lambda-form) until (listp item) collect item))) (defun lambda-lambda-list (lambda-form) (loop for item in lambda-form when (listp item) do (return item))) (defun lambda-body (lambda-form) (loop for body on lambda-form ;; Once we encounter the lambda-list, return the following. when (listp (first body)) do (return (cdr body)))) (defun lambda-docstring (lambda-form) (let ((body (lambda-body lambda-form))) (loop ;; The last expression in a form cannot be a docstring. ;; (lambda (foo) "bar") => no docstring, returns "bar". for i from 0 below (1- (length body)) for form in body while (declaration-p form) finally (when (stringp form) (return form))))) (defun lambda-declarations (lambda-form) (let ((body (lambda-body lambda-form))) (when (stringp (first body)) (setf body (cdr body))) (loop for form in body while (or (declaration-p form) (docstring-p form)) when (declaration-p form) collect form))) (defun lambda-forms (lambda-form) (let* ((body (lambda-body lambda-form))) (loop for forms on body for form = (car body) for i from 0 below (1- (length body)) while (or (declaration-p form) (docstring-p form)) finally (return (if (declaration-p (car forms)) (cdr forms) forms))))) (defun split-lambda-form (lambda-form) (let ((body lambda-form) (lambda-p (eql (first lambda-form) 'lambda))) (append (list (pop body)) ;; First is name, rest are qualifiers ;; until we reach a list, which must be ;; the lambda-list of the form. (if lambda-p (list NIL) (list (pop body))) (loop for form = (pop body) until (listp form) collect form into qualifiers finally (return (list qualifiers form))) ;; Now we go on to parsing the body we reached. ;; This is annoying because of the interleaving ;; of docstrings and declarations. ;; F.e. the following is a body with two ;; declarations, a docstring and a form: ;; ;; (declare) "foo" (declare) "bar" ;; ;; And this is a body with one declaration, a ;; docstring and a form: ;; ;; (declare) "foo" "bar" ;; ;; But this is only a declaration and a form: ;; ;; (declare) "foo" ;; ;; To make matters even more complicated, the ;; following has three decls, one docstring, and ;; a form. The consequences of multiple docstrings ;; like this are undefined as per the hyperspec, ;; but it seems allowed so we have to deal. ;; ;; (declare) "foo" (declare) "bar" (declare) "baz" ;; ;; On the other hand, something like this has ;; one decl, one docstring and three forms. ;; ;; (declare) "foo" "bar" (declare) "baz" ;; ;; Or at least that's what I'm guessing is the ;; intended behaviour suggested by 3.4.11 . ;; ;; We opt to choose the first occurring docstring. (loop with docstring = NIL for forms on body for form = (car forms) for i from 0 below (1- (length body)) while (or (and (docstring-p form) (or (not docstring) (not (docstring-p (car (cdr forms)))))) (declaration-p form)) if (docstring-p form) do (setf docstring (or docstring form)) else collect form into declarations finally (return (if (declaration-p (car forms)) (list docstring (append declarations (list (car forms))) (cdr forms)) (list docstring declarations forms))))))) (defmacro with-destructured-lambda-form ((&key function name qualifiers lambda-list docstring declarations forms) expression &body body) (let ((bindings (list (or function (gensym "FUNCTION")) (or name (gensym "NAME")) (or qualifiers (gensym "QUALIFIERS")) (or lambda-list (gensym "LAMBDA-LIST")) (or docstring (gensym "DOCSTRING")) (or declarations (gensym "DECLARATIONS")) (or forms (gensym "FORMS"))))) `(destructuring-bind ,bindings (split-lambda-form ,expression) (declare (ignore ,@(loop for symb in bindings unless (symbol-package symb) collect symb))) ,@body))) (defun split-body-options (body) (values (loop for list = body then rest for (key val . rest) = list while (and (cdr list) (keywordp key)) collect key collect val finally (setf body list)) body)) (defun removef (plist &rest args) (loop for (key val) on plist by #'cddr unless (find key args) collect key unless (find key args) collect val)) (defmacro with-body-options ((body other-options &rest options) form &body body-forms) (flet ((unlist (opt) (if (listp opt) (first opt) opt)) (kw (opt) (intern (string opt) "KEYWORD"))) (let ((all-options (gensym "OPTIONS")) (option-keywords (loop for opt in options collect (kw (unlist opt))))) `(multiple-value-bind (,all-options ,body) (split-body-options ,form) (destructuring-bind (&key ,@options &allow-other-keys) ,all-options (let ((,other-options (removef ,all-options ,@option-keywords))) ,@body-forms))))))
29802
#| This file is a part of Qtools (c) 2014 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.form-fiddle) (defun declaration-p (form) (and (listp form) (eql 'declare (first form)))) (defun docstring-p (form) (stringp form)) (defun lambda-function (lambda-form) (first lambda-form)) (defun lambda-name (lambda-form) (unless (listp (second lambda-form)) (second lambda-form))) (defun lambda-qualifiers (lambda-form) (unless (listp (second lambda-form)) (loop for item in (cddr lambda-form) until (listp item) collect item))) (defun lambda-lambda-list (lambda-form) (loop for item in lambda-form when (listp item) do (return item))) (defun lambda-body (lambda-form) (loop for body on lambda-form ;; Once we encounter the lambda-list, return the following. when (listp (first body)) do (return (cdr body)))) (defun lambda-docstring (lambda-form) (let ((body (lambda-body lambda-form))) (loop ;; The last expression in a form cannot be a docstring. ;; (lambda (foo) "bar") => no docstring, returns "bar". for i from 0 below (1- (length body)) for form in body while (declaration-p form) finally (when (stringp form) (return form))))) (defun lambda-declarations (lambda-form) (let ((body (lambda-body lambda-form))) (when (stringp (first body)) (setf body (cdr body))) (loop for form in body while (or (declaration-p form) (docstring-p form)) when (declaration-p form) collect form))) (defun lambda-forms (lambda-form) (let* ((body (lambda-body lambda-form))) (loop for forms on body for form = (car body) for i from 0 below (1- (length body)) while (or (declaration-p form) (docstring-p form)) finally (return (if (declaration-p (car forms)) (cdr forms) forms))))) (defun split-lambda-form (lambda-form) (let ((body lambda-form) (lambda-p (eql (first lambda-form) 'lambda))) (append (list (pop body)) ;; First is name, rest are qualifiers ;; until we reach a list, which must be ;; the lambda-list of the form. (if lambda-p (list NIL) (list (pop body))) (loop for form = (pop body) until (listp form) collect form into qualifiers finally (return (list qualifiers form))) ;; Now we go on to parsing the body we reached. ;; This is annoying because of the interleaving ;; of docstrings and declarations. ;; F.e. the following is a body with two ;; declarations, a docstring and a form: ;; ;; (declare) "foo" (declare) "bar" ;; ;; And this is a body with one declaration, a ;; docstring and a form: ;; ;; (declare) "foo" "bar" ;; ;; But this is only a declaration and a form: ;; ;; (declare) "foo" ;; ;; To make matters even more complicated, the ;; following has three decls, one docstring, and ;; a form. The consequences of multiple docstrings ;; like this are undefined as per the hyperspec, ;; but it seems allowed so we have to deal. ;; ;; (declare) "foo" (declare) "bar" (declare) "baz" ;; ;; On the other hand, something like this has ;; one decl, one docstring and three forms. ;; ;; (declare) "foo" "bar" (declare) "baz" ;; ;; Or at least that's what I'm guessing is the ;; intended behaviour suggested by 3.4.11 . ;; ;; We opt to choose the first occurring docstring. (loop with docstring = NIL for forms on body for form = (car forms) for i from 0 below (1- (length body)) while (or (and (docstring-p form) (or (not docstring) (not (docstring-p (car (cdr forms)))))) (declaration-p form)) if (docstring-p form) do (setf docstring (or docstring form)) else collect form into declarations finally (return (if (declaration-p (car forms)) (list docstring (append declarations (list (car forms))) (cdr forms)) (list docstring declarations forms))))))) (defmacro with-destructured-lambda-form ((&key function name qualifiers lambda-list docstring declarations forms) expression &body body) (let ((bindings (list (or function (gensym "FUNCTION")) (or name (gensym "NAME")) (or qualifiers (gensym "QUALIFIERS")) (or lambda-list (gensym "LAMBDA-LIST")) (or docstring (gensym "DOCSTRING")) (or declarations (gensym "DECLARATIONS")) (or forms (gensym "FORMS"))))) `(destructuring-bind ,bindings (split-lambda-form ,expression) (declare (ignore ,@(loop for symb in bindings unless (symbol-package symb) collect symb))) ,@body))) (defun split-body-options (body) (values (loop for list = body then rest for (key val . rest) = list while (and (cdr list) (keywordp key)) collect key collect val finally (setf body list)) body)) (defun removef (plist &rest args) (loop for (key val) on plist by #'cddr unless (find key args) collect key unless (find key args) collect val)) (defmacro with-body-options ((body other-options &rest options) form &body body-forms) (flet ((unlist (opt) (if (listp opt) (first opt) opt)) (kw (opt) (intern (string opt) "KEYWORD"))) (let ((all-options (gensym "OPTIONS")) (option-keywords (loop for opt in options collect (kw (unlist opt))))) `(multiple-value-bind (,all-options ,body) (split-body-options ,form) (destructuring-bind (&key ,@options &allow-other-keys) ,all-options (let ((,other-options (removef ,all-options ,@option-keywords))) ,@body-forms))))))
true
#| This file is a part of Qtools (c) 2014 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.form-fiddle) (defun declaration-p (form) (and (listp form) (eql 'declare (first form)))) (defun docstring-p (form) (stringp form)) (defun lambda-function (lambda-form) (first lambda-form)) (defun lambda-name (lambda-form) (unless (listp (second lambda-form)) (second lambda-form))) (defun lambda-qualifiers (lambda-form) (unless (listp (second lambda-form)) (loop for item in (cddr lambda-form) until (listp item) collect item))) (defun lambda-lambda-list (lambda-form) (loop for item in lambda-form when (listp item) do (return item))) (defun lambda-body (lambda-form) (loop for body on lambda-form ;; Once we encounter the lambda-list, return the following. when (listp (first body)) do (return (cdr body)))) (defun lambda-docstring (lambda-form) (let ((body (lambda-body lambda-form))) (loop ;; The last expression in a form cannot be a docstring. ;; (lambda (foo) "bar") => no docstring, returns "bar". for i from 0 below (1- (length body)) for form in body while (declaration-p form) finally (when (stringp form) (return form))))) (defun lambda-declarations (lambda-form) (let ((body (lambda-body lambda-form))) (when (stringp (first body)) (setf body (cdr body))) (loop for form in body while (or (declaration-p form) (docstring-p form)) when (declaration-p form) collect form))) (defun lambda-forms (lambda-form) (let* ((body (lambda-body lambda-form))) (loop for forms on body for form = (car body) for i from 0 below (1- (length body)) while (or (declaration-p form) (docstring-p form)) finally (return (if (declaration-p (car forms)) (cdr forms) forms))))) (defun split-lambda-form (lambda-form) (let ((body lambda-form) (lambda-p (eql (first lambda-form) 'lambda))) (append (list (pop body)) ;; First is name, rest are qualifiers ;; until we reach a list, which must be ;; the lambda-list of the form. (if lambda-p (list NIL) (list (pop body))) (loop for form = (pop body) until (listp form) collect form into qualifiers finally (return (list qualifiers form))) ;; Now we go on to parsing the body we reached. ;; This is annoying because of the interleaving ;; of docstrings and declarations. ;; F.e. the following is a body with two ;; declarations, a docstring and a form: ;; ;; (declare) "foo" (declare) "bar" ;; ;; And this is a body with one declaration, a ;; docstring and a form: ;; ;; (declare) "foo" "bar" ;; ;; But this is only a declaration and a form: ;; ;; (declare) "foo" ;; ;; To make matters even more complicated, the ;; following has three decls, one docstring, and ;; a form. The consequences of multiple docstrings ;; like this are undefined as per the hyperspec, ;; but it seems allowed so we have to deal. ;; ;; (declare) "foo" (declare) "bar" (declare) "baz" ;; ;; On the other hand, something like this has ;; one decl, one docstring and three forms. ;; ;; (declare) "foo" "bar" (declare) "baz" ;; ;; Or at least that's what I'm guessing is the ;; intended behaviour suggested by 3.4.11 . ;; ;; We opt to choose the first occurring docstring. (loop with docstring = NIL for forms on body for form = (car forms) for i from 0 below (1- (length body)) while (or (and (docstring-p form) (or (not docstring) (not (docstring-p (car (cdr forms)))))) (declaration-p form)) if (docstring-p form) do (setf docstring (or docstring form)) else collect form into declarations finally (return (if (declaration-p (car forms)) (list docstring (append declarations (list (car forms))) (cdr forms)) (list docstring declarations forms))))))) (defmacro with-destructured-lambda-form ((&key function name qualifiers lambda-list docstring declarations forms) expression &body body) (let ((bindings (list (or function (gensym "FUNCTION")) (or name (gensym "NAME")) (or qualifiers (gensym "QUALIFIERS")) (or lambda-list (gensym "LAMBDA-LIST")) (or docstring (gensym "DOCSTRING")) (or declarations (gensym "DECLARATIONS")) (or forms (gensym "FORMS"))))) `(destructuring-bind ,bindings (split-lambda-form ,expression) (declare (ignore ,@(loop for symb in bindings unless (symbol-package symb) collect symb))) ,@body))) (defun split-body-options (body) (values (loop for list = body then rest for (key val . rest) = list while (and (cdr list) (keywordp key)) collect key collect val finally (setf body list)) body)) (defun removef (plist &rest args) (loop for (key val) on plist by #'cddr unless (find key args) collect key unless (find key args) collect val)) (defmacro with-body-options ((body other-options &rest options) form &body body-forms) (flet ((unlist (opt) (if (listp opt) (first opt) opt)) (kw (opt) (intern (string opt) "KEYWORD"))) (let ((all-options (gensym "OPTIONS")) (option-keywords (loop for opt in options collect (kw (unlist opt))))) `(multiple-value-bind (,all-options ,body) (split-body-options ,form) (destructuring-bind (&key ,@options &allow-other-keys) ,all-options (let ((,other-options (removef ,all-options ,@option-keywords))) ,@body-forms))))))
[ { "context": " of UAX-14\n (c) 20114 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 91, "score": 0.9999194741249084, "start": 73, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(defpackage #:org.shirak", "end": 116, "score": 0.999884307384491, "start": 102, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(defpackage #:org.shirakumo.alloy.uax-9.comp", "end": 136, "score": 0.9999261498451233, "start": 118, "tag": "EMAIL", "value": "[email protected]" } ]
compile.lisp
Shinmera/uax-9
4
#| This file is a part of UAX-14 (c) 20114 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (defpackage #:org.shirakumo.alloy.uax-9.compiler (:use #:cl) (:local-nicknames (#:uax-9 #:org.shirakumo.alloy.uax-9)) (:export #:compile-databases)) (in-package #:org.shirakumo.alloy.uax-9.compiler) (defun set-line-class (data line) (let* ((end (or (position #\# line) (length line))) (sep (position #\; line)) (dot (position #\. line)) (class (string-upcase (string-trim " " (subseq line (1+ sep) end)))) (value (uax-9::class-id (find-symbol class "KEYWORD"))) (start (parse-integer line :radix 16 :start 0 :end (or dot sep))) (end (if dot (parse-integer line :radix 16 :start (+ 2 dot) :end sep) start))) (loop for i from start to end do (setf (aref data i) value)))) (defun compile-bidi-class-database (&key (source (make-pathname :name "DerivedBidiClass" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-class-database-file*)) (let ((data uax-9::+bidi-class-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-line-class data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-sequence data stream)) target)) (defun write-u32le (int stream) (write-byte (ldb (byte 8 0) int) stream) (write-byte (ldb (byte 8 8) int) stream) (write-byte (ldb (byte 8 16) int) stream) (write-byte (ldb (byte 8 24) int) stream)) (defun set-bracket-pair (data line) (let* ((from (position #\; line)) (to (position #\; line :start (1+ from)))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ from 2) :end to :radix 16)) (type (ecase (char line (+ to 2)) (#\n 0) (#\o 1) (#\c 2)))) (setf (gethash from data) (logior to (ash type 25)))))) (defun compile-bidi-brackets-table (&key (source (make-pathname :name "BidiBrackets" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-brackets-table-file*)) (let ((data uax-9::+bidi-brackets-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-bracket-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun set-mirror-pair (data line) (let ((from (position #\; line)) (to (position #\# line))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ 2 from) :end to :radix 16))) (setf (gethash from data) to)))) (defun set-mirror-empty-pair (data line) (let* ((line (string-left-trim "# " line)) (from (position #\; line))) (let* ((from (parse-integer line :end from :radix 16)) (to from)) (setf (ldb (byte 1 31) to) 1) (setf (gethash from data) to)))) (defun compile-bidi-mirror-table (&key (source (make-pathname :name "BidiMirroring" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-mirroring-table-file*)) (let ((data uax-9::+bidi-mirroring-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (< 0 (length line)) (char/= #\# (char line 0))) (set-mirror-pair data line)) (when (and (< 6 (length line)) (loop for i from 2 below 6 always (find (char line i) "0123456789ABCDEF"))) (set-mirror-empty-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun compile-databases () (compile-bidi-class-database) (compile-bidi-brackets-table) (compile-bidi-mirror-table))
51278
#| This file is a part of UAX-14 (c) 20114 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (defpackage #:org.shirakumo.alloy.uax-9.compiler (:use #:cl) (:local-nicknames (#:uax-9 #:org.shirakumo.alloy.uax-9)) (:export #:compile-databases)) (in-package #:org.shirakumo.alloy.uax-9.compiler) (defun set-line-class (data line) (let* ((end (or (position #\# line) (length line))) (sep (position #\; line)) (dot (position #\. line)) (class (string-upcase (string-trim " " (subseq line (1+ sep) end)))) (value (uax-9::class-id (find-symbol class "KEYWORD"))) (start (parse-integer line :radix 16 :start 0 :end (or dot sep))) (end (if dot (parse-integer line :radix 16 :start (+ 2 dot) :end sep) start))) (loop for i from start to end do (setf (aref data i) value)))) (defun compile-bidi-class-database (&key (source (make-pathname :name "DerivedBidiClass" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-class-database-file*)) (let ((data uax-9::+bidi-class-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-line-class data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-sequence data stream)) target)) (defun write-u32le (int stream) (write-byte (ldb (byte 8 0) int) stream) (write-byte (ldb (byte 8 8) int) stream) (write-byte (ldb (byte 8 16) int) stream) (write-byte (ldb (byte 8 24) int) stream)) (defun set-bracket-pair (data line) (let* ((from (position #\; line)) (to (position #\; line :start (1+ from)))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ from 2) :end to :radix 16)) (type (ecase (char line (+ to 2)) (#\n 0) (#\o 1) (#\c 2)))) (setf (gethash from data) (logior to (ash type 25)))))) (defun compile-bidi-brackets-table (&key (source (make-pathname :name "BidiBrackets" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-brackets-table-file*)) (let ((data uax-9::+bidi-brackets-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-bracket-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun set-mirror-pair (data line) (let ((from (position #\; line)) (to (position #\# line))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ 2 from) :end to :radix 16))) (setf (gethash from data) to)))) (defun set-mirror-empty-pair (data line) (let* ((line (string-left-trim "# " line)) (from (position #\; line))) (let* ((from (parse-integer line :end from :radix 16)) (to from)) (setf (ldb (byte 1 31) to) 1) (setf (gethash from data) to)))) (defun compile-bidi-mirror-table (&key (source (make-pathname :name "BidiMirroring" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-mirroring-table-file*)) (let ((data uax-9::+bidi-mirroring-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (< 0 (length line)) (char/= #\# (char line 0))) (set-mirror-pair data line)) (when (and (< 6 (length line)) (loop for i from 2 below 6 always (find (char line i) "0123456789ABCDEF"))) (set-mirror-empty-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun compile-databases () (compile-bidi-class-database) (compile-bidi-brackets-table) (compile-bidi-mirror-table))
true
#| This file is a part of UAX-14 (c) 20114 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (defpackage #:org.shirakumo.alloy.uax-9.compiler (:use #:cl) (:local-nicknames (#:uax-9 #:org.shirakumo.alloy.uax-9)) (:export #:compile-databases)) (in-package #:org.shirakumo.alloy.uax-9.compiler) (defun set-line-class (data line) (let* ((end (or (position #\# line) (length line))) (sep (position #\; line)) (dot (position #\. line)) (class (string-upcase (string-trim " " (subseq line (1+ sep) end)))) (value (uax-9::class-id (find-symbol class "KEYWORD"))) (start (parse-integer line :radix 16 :start 0 :end (or dot sep))) (end (if dot (parse-integer line :radix 16 :start (+ 2 dot) :end sep) start))) (loop for i from start to end do (setf (aref data i) value)))) (defun compile-bidi-class-database (&key (source (make-pathname :name "DerivedBidiClass" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-class-database-file*)) (let ((data uax-9::+bidi-class-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-line-class data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-sequence data stream)) target)) (defun write-u32le (int stream) (write-byte (ldb (byte 8 0) int) stream) (write-byte (ldb (byte 8 8) int) stream) (write-byte (ldb (byte 8 16) int) stream) (write-byte (ldb (byte 8 24) int) stream)) (defun set-bracket-pair (data line) (let* ((from (position #\; line)) (to (position #\; line :start (1+ from)))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ from 2) :end to :radix 16)) (type (ecase (char line (+ to 2)) (#\n 0) (#\o 1) (#\c 2)))) (setf (gethash from data) (logior to (ash type 25)))))) (defun compile-bidi-brackets-table (&key (source (make-pathname :name "BidiBrackets" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-brackets-table-file*)) (let ((data uax-9::+bidi-brackets-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (string/= "" line) (char/= #\# (char line 0))) (set-bracket-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun set-mirror-pair (data line) (let ((from (position #\; line)) (to (position #\# line))) (let ((from (parse-integer line :end from :radix 16)) (to (parse-integer line :start (+ 2 from) :end to :radix 16))) (setf (gethash from data) to)))) (defun set-mirror-empty-pair (data line) (let* ((line (string-left-trim "# " line)) (from (position #\; line))) (let* ((from (parse-integer line :end from :radix 16)) (to from)) (setf (ldb (byte 1 31) to) 1) (setf (gethash from data) to)))) (defun compile-bidi-mirror-table (&key (source (make-pathname :name "BidiMirroring" :type "txt" :defaults uax-9::*here*)) (target uax-9:*bidi-mirroring-table-file*)) (let ((data uax-9::+bidi-mirroring-map+)) (with-open-file (stream source :direction :input :element-type 'character :external-format :utf-8) (loop for line = (read-line stream NIL) while line do (when (and (< 0 (length line)) (char/= #\# (char line 0))) (set-mirror-pair data line)) (when (and (< 6 (length line)) (loop for i from 2 below 6 always (find (char line i) "0123456789ABCDEF"))) (set-mirror-empty-pair data line)))) (with-open-file (stream target :direction :output :element-type '(unsigned-byte 8) :if-exists :supersede) (write-u32le (hash-table-count data) stream) (loop for key being the hash-keys of data for val being the hash-values of data do (write-u32le key stream) (write-u32le val stream))) target)) (defun compile-databases () (compile-bidi-class-database) (compile-bidi-brackets-table) (compile-bidi-mirror-table))
[ { "context": " ;;;;;\n;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;\n;;; All rights re", "end": 356, "score": 0.9998831748962402, "start": 340, "tag": "NAME", "value": "William Schelter" } ]
maxima/src/maxima/src/askp.lisp
nilqed/spadlib
1
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ** (c) Copyright 1981 Massachusetts Institute of Technology ** ;;; ;;; Toplevel Functions: ($ASKINTEGER EXP <OPTIONAL-ARG>) ;;; ;;; EXP -> any Macsyma expression. ;;; <OPTIONAL-ARG> -> $EVEN, $ODD, $INTEGER. ;;; If not given, defaults to $INTEGER. ;;; ;;; returns -> $YES, $NO, $UNKNOWN. ;;; ;;; If LIMITP is non-NIL the facts collected will be consed onto the list ;;; INTEGER-INFO. ;;; ;;; Implementors Functions: (ASK-INTEGER <EXP> <WHAT-KIND>) ;;; same as $ASKINTEGER with less error checking and ;;; requires two arguments. ;;; ;;; Support Functions: ASK-EVOD -> is a symbol an even or odd number? ;;; ASK-INTEGERP -> is a symbol an integer? ;;; ASK-PROP -> ask the user a question about a symbol. ;;; (in-package :maxima) (macsyma-module askp) (declare-top (special limitp integer-info)) (defmfun $askinteger (x &optional (mode '$integer)) (if (member mode '($even $odd $integer) :test #'eq) (ask-integer x mode) (improper-arg-err mode '$askinteger))) (defun ask-integer (x even-odd) (setq x (sratsimp (sublis '((z** . 0) (*z* . 0)) x))) (cond ((ratnump x) '$no) ((eq even-odd '$integer) (ask-integerp x)) (t (ask-evod x even-odd)))) (defun ask-evod (x even-odd) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (let ((evod-ans (evod x)) (is-integer (maxima-integerp x))) (cond ((equal evod-ans even-odd) '$yes) ((and ($numberp x) (not is-integer)) '$no) ((and is-integer evod-ans) '$no) ((eq (setq evod-ans (ask-prop x (if (eq even-odd '$even) 'even 'odd) 'number)) '$yes) (ask-declare x even-odd) '$yes) ((eq evod-ans '$no) (if is-integer (if (eq even-odd '$even) (ask-declare x '$odd) (ask-declare x '$even))) '$no) (t '$unknown)))) (defun ask-integerp (x) (let (integer-ans) (if (and (mplusp x) (integerp (cadr x))) (setq x (addn (cddr x) t))) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (cond ((or (maxima-integerp x) (memalike x integerl)) '$yes) ((or ($numberp x) (nonintegerp x) (memalike x nonintegerl)) '$no) ((eq (setq integer-ans (ask-prop x 'integer nil)) '$yes) (ask-declare x '$integer) '$yes) ((eq integer-ans '$no) (ask-declare x '$noninteger) '$no) (t '$unknown)))) (defun ask-declare (x property) (cond ((atom x) (meval `(($declare) ,x ,property)) (if limitp (setq integer-info (cons `(($kind) ,x ,property) integer-info)))) ((and limitp (eq property '$integer)) (setq integerl (cons x integerl))) ((and limitp (eq property '$noninteger)) (setq nonintegerl (cons x nonintegerl))))) ;;; Asks the user a question about the property of an object. ;;; Returns only $yes, $no or $unknown. (defun ask-prop (object property fun-or-number) (if fun-or-number (setq fun-or-number (list '| | fun-or-number))) (do ((end-flag) (answer)) (end-flag (cond ((member answer '($yes |$Y| |$y|) :test #'eq) '$yes) ((member answer '($no |$N| |$n|) :test #'eq) '$no) ((member answer '($unknown $uk) :test #'eq) '$unknown))) (setq answer (retrieve `((mtext) "Is " ,object ,(if (member (char (symbol-name property) 0) '(#\a #\e #\i #\o #\u) :test #'char-equal) " an " " a ") ,property ,@fun-or-number "?") nil)) (cond ((member answer '($yes |$Y| |$y| |$N| |$n| $no $unknown $uk) :test #'eq) (setq end-flag t)) (t (mtell "~%Acceptable answers are: yes, y, Y, no, n, N, unknown, uk~%")))))
23568
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by <NAME>,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ** (c) Copyright 1981 Massachusetts Institute of Technology ** ;;; ;;; Toplevel Functions: ($ASKINTEGER EXP <OPTIONAL-ARG>) ;;; ;;; EXP -> any Macsyma expression. ;;; <OPTIONAL-ARG> -> $EVEN, $ODD, $INTEGER. ;;; If not given, defaults to $INTEGER. ;;; ;;; returns -> $YES, $NO, $UNKNOWN. ;;; ;;; If LIMITP is non-NIL the facts collected will be consed onto the list ;;; INTEGER-INFO. ;;; ;;; Implementors Functions: (ASK-INTEGER <EXP> <WHAT-KIND>) ;;; same as $ASKINTEGER with less error checking and ;;; requires two arguments. ;;; ;;; Support Functions: ASK-EVOD -> is a symbol an even or odd number? ;;; ASK-INTEGERP -> is a symbol an integer? ;;; ASK-PROP -> ask the user a question about a symbol. ;;; (in-package :maxima) (macsyma-module askp) (declare-top (special limitp integer-info)) (defmfun $askinteger (x &optional (mode '$integer)) (if (member mode '($even $odd $integer) :test #'eq) (ask-integer x mode) (improper-arg-err mode '$askinteger))) (defun ask-integer (x even-odd) (setq x (sratsimp (sublis '((z** . 0) (*z* . 0)) x))) (cond ((ratnump x) '$no) ((eq even-odd '$integer) (ask-integerp x)) (t (ask-evod x even-odd)))) (defun ask-evod (x even-odd) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (let ((evod-ans (evod x)) (is-integer (maxima-integerp x))) (cond ((equal evod-ans even-odd) '$yes) ((and ($numberp x) (not is-integer)) '$no) ((and is-integer evod-ans) '$no) ((eq (setq evod-ans (ask-prop x (if (eq even-odd '$even) 'even 'odd) 'number)) '$yes) (ask-declare x even-odd) '$yes) ((eq evod-ans '$no) (if is-integer (if (eq even-odd '$even) (ask-declare x '$odd) (ask-declare x '$even))) '$no) (t '$unknown)))) (defun ask-integerp (x) (let (integer-ans) (if (and (mplusp x) (integerp (cadr x))) (setq x (addn (cddr x) t))) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (cond ((or (maxima-integerp x) (memalike x integerl)) '$yes) ((or ($numberp x) (nonintegerp x) (memalike x nonintegerl)) '$no) ((eq (setq integer-ans (ask-prop x 'integer nil)) '$yes) (ask-declare x '$integer) '$yes) ((eq integer-ans '$no) (ask-declare x '$noninteger) '$no) (t '$unknown)))) (defun ask-declare (x property) (cond ((atom x) (meval `(($declare) ,x ,property)) (if limitp (setq integer-info (cons `(($kind) ,x ,property) integer-info)))) ((and limitp (eq property '$integer)) (setq integerl (cons x integerl))) ((and limitp (eq property '$noninteger)) (setq nonintegerl (cons x nonintegerl))))) ;;; Asks the user a question about the property of an object. ;;; Returns only $yes, $no or $unknown. (defun ask-prop (object property fun-or-number) (if fun-or-number (setq fun-or-number (list '| | fun-or-number))) (do ((end-flag) (answer)) (end-flag (cond ((member answer '($yes |$Y| |$y|) :test #'eq) '$yes) ((member answer '($no |$N| |$n|) :test #'eq) '$no) ((member answer '($unknown $uk) :test #'eq) '$unknown))) (setq answer (retrieve `((mtext) "Is " ,object ,(if (member (char (symbol-name property) 0) '(#\a #\e #\i #\o #\u) :test #'char-equal) " an " " a ") ,property ,@fun-or-number "?") nil)) (cond ((member answer '($yes |$Y| |$y| |$N| |$n| $no $unknown $uk) :test #'eq) (setq end-flag t)) (t (mtell "~%Acceptable answers are: yes, y, Y, no, n, N, unknown, uk~%")))))
true
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by PI:NAME:<NAME>END_PI,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ** (c) Copyright 1981 Massachusetts Institute of Technology ** ;;; ;;; Toplevel Functions: ($ASKINTEGER EXP <OPTIONAL-ARG>) ;;; ;;; EXP -> any Macsyma expression. ;;; <OPTIONAL-ARG> -> $EVEN, $ODD, $INTEGER. ;;; If not given, defaults to $INTEGER. ;;; ;;; returns -> $YES, $NO, $UNKNOWN. ;;; ;;; If LIMITP is non-NIL the facts collected will be consed onto the list ;;; INTEGER-INFO. ;;; ;;; Implementors Functions: (ASK-INTEGER <EXP> <WHAT-KIND>) ;;; same as $ASKINTEGER with less error checking and ;;; requires two arguments. ;;; ;;; Support Functions: ASK-EVOD -> is a symbol an even or odd number? ;;; ASK-INTEGERP -> is a symbol an integer? ;;; ASK-PROP -> ask the user a question about a symbol. ;;; (in-package :maxima) (macsyma-module askp) (declare-top (special limitp integer-info)) (defmfun $askinteger (x &optional (mode '$integer)) (if (member mode '($even $odd $integer) :test #'eq) (ask-integer x mode) (improper-arg-err mode '$askinteger))) (defun ask-integer (x even-odd) (setq x (sratsimp (sublis '((z** . 0) (*z* . 0)) x))) (cond ((ratnump x) '$no) ((eq even-odd '$integer) (ask-integerp x)) (t (ask-evod x even-odd)))) (defun ask-evod (x even-odd) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (let ((evod-ans (evod x)) (is-integer (maxima-integerp x))) (cond ((equal evod-ans even-odd) '$yes) ((and ($numberp x) (not is-integer)) '$no) ((and is-integer evod-ans) '$no) ((eq (setq evod-ans (ask-prop x (if (eq even-odd '$even) 'even 'odd) 'number)) '$yes) (ask-declare x even-odd) '$yes) ((eq evod-ans '$no) (if is-integer (if (eq even-odd '$even) (ask-declare x '$odd) (ask-declare x '$even))) '$no) (t '$unknown)))) (defun ask-integerp (x) (let (integer-ans) (if (and (mplusp x) (integerp (cadr x))) (setq x (addn (cddr x) t))) (if (and (mtimesp x) (equal (cadr x) -1)) (setq x (muln (cddr x) t))) (cond ((or (maxima-integerp x) (memalike x integerl)) '$yes) ((or ($numberp x) (nonintegerp x) (memalike x nonintegerl)) '$no) ((eq (setq integer-ans (ask-prop x 'integer nil)) '$yes) (ask-declare x '$integer) '$yes) ((eq integer-ans '$no) (ask-declare x '$noninteger) '$no) (t '$unknown)))) (defun ask-declare (x property) (cond ((atom x) (meval `(($declare) ,x ,property)) (if limitp (setq integer-info (cons `(($kind) ,x ,property) integer-info)))) ((and limitp (eq property '$integer)) (setq integerl (cons x integerl))) ((and limitp (eq property '$noninteger)) (setq nonintegerl (cons x nonintegerl))))) ;;; Asks the user a question about the property of an object. ;;; Returns only $yes, $no or $unknown. (defun ask-prop (object property fun-or-number) (if fun-or-number (setq fun-or-number (list '| | fun-or-number))) (do ((end-flag) (answer)) (end-flag (cond ((member answer '($yes |$Y| |$y|) :test #'eq) '$yes) ((member answer '($no |$N| |$n|) :test #'eq) '$no) ((member answer '($unknown $uk) :test #'eq) '$unknown))) (setq answer (retrieve `((mtext) "Is " ,object ,(if (member (char (symbol-name property) 0) '(#\a #\e #\i #\o #\u) :test #'char-equal) " an " " a ") ,property ,@fun-or-number "?") nil)) (cond ((member answer '($yes |$Y| |$y| |$N| |$n| $no $unknown $uk) :test #'eq) (setq end-flag t)) (t (mtell "~%Acceptable answers are: yes, y, Y, no, n, N, unknown, uk~%")))))
[ { "context": "to the records library\n;\n; Copyright (C) 2008-2011 Eric Smith and Stanford University\n; Copyright (C) 2013-2020", "end": 73, "score": 0.9996032118797302, "start": 63, "tag": "NAME", "value": "Eric Smith" }, { "context": "ense. See the file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;", "end": 234, "score": 0.9995937943458557, "start": 224, "tag": "NAME", "value": "Eric Smith" }, { "context": " file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 258, "score": 0.9999334216117859, "start": 236, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/maps/maps.lisp
ayazhafiz/acl2
0
; Additions to the records library ; ; Copyright (C) 2008-2011 Eric Smith and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: Eric Smith ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; TODO: Clean this up ;FIXME move stuff into maps0? ;FIXME put in more support for fast execution - see books/defexec/other-apps/records/records.lisp - maybe base this book on that one ;maps are basically records with "domain" and "new address" operators ;; TODO: See also ../axe/maps2.lisp ;fixme some of these are set theorems? (include-book "maps0") (include-book "../sets/sets") (defun key-set (r) (declare (xargs :guard (rcdp r))) (if (consp r) (set::insert (caar r) (key-set (cdr r))) (set::emptyset))) (defthm setp-key-set (set::setp (key-set r))) (defun rkeys (r) (declare (type t r)) (key-set (acl2->rcd r))) (defthm true-list-p-of-rkeys (true-listp (rkeys r)) :rule-classes :type-prescription) (defthm in-key-set-s-aux (implies (wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s (implies (and (wfr r) ;(wfkey a) ) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (in-theory (disable rkeys)) ;; stuff that should be in the records book: (defthm s-hack-1 (equal (s a nil nil) nil) :hints (("Goal" :in-theory (enable s)))) (in-theory (enable g-of-s-redux)) ;dup (defthm acl2->rcd-does-nothing (implies (not (ifrp r)) (equal (acl2->rcd r) r)) :hints (("Goal" :in-theory (enable acl2->rcd)))) ;logically the same as g, but has a guard and should execute much faster (defun fastg (a x) (declare (xargs :guard (not (IFRP X)))) ;fixme - should the guard be mapp? (mbe :logic (G-AUX A (ACL2->RCD X)) :exec (G-AUX A X))) (defthm fastg-becomes-g (equal (fastg a x) (g a x)) :hints (("Goal" :in-theory (enable g fastg)))) (defun dom (s) (declare (type t s)) (rkeys s)) ;disabling since this can introduce map reasoning into an unrelated problem (defthmd wfr-hack1 (IMPLIES (AND (not (ifrp r)) ;(WFR R) (CAAR R)) (CDAR R)) :hints (("Goal" :in-theory (enable WFR)))) (defthm wfr-hack2 (IMPLIES (AND (CONSP R) (not (ifrp r)) ;(WFR R) ;A (<< A (CAAR R))) (NOT (G-AUX A (CDR R)))) :hints (("Goal" :in-theory (enable wfr)))) (DEFUN WFR2 (R) (DECLARE (TYPE T R)) (AND (rcdp r) (NOT (IFRP R)) (WFKEYED R))) (defthm wfr-hack3 (IMPLIES (AND (CONSP R) (WFR2 R) ) (WFR2 (CDR R))) :hints (("Goal" :in-theory (enable wfr2 WFKEYED)))) (defthm wfr-hack3-good (IMPLIES (AND (CONSP R) (WFR R) ) (WFR (CDR R))) :hints (("Goal" :use wfr-hack3 :in-theory (e/d (wfr) ( wfr-hack3))))) ;; (defthm wfr-hack3-ifrp ;; (IMPLIES (AND (CONSP R) ;; ;(rcdp r) ;; (not (ifrp r)) ;(WFR R) ;; ) ;; (not (ifrp (cdr r))) ;(WFR (CDR R)) ;; ) ;; :hints (("Goal" :do-not '(generalize ;eliminate-destructors ;; ) ;; ; :expand (IFRP r) ;; :in-theory (enable wfr WFKEYED)))) (defthm wfr-hack4 (IMPLIES (AND (WFR R) a (NOT (G A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set g ;wfr wfr-hack1 wfkeyed)))) ;; (defthm wfr-hack4-try ;; (IMPLIES (AND (not (ifrp r)) ;(WFR R) ;; a ;; (NOT (G A R))) ;; (NOT (SET::IN A (KEY-SET R)))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :in-theory (enable rkeys key-set g ;wfr ;; wfkeyed)))) ;disable?! (defthm wfr-hack5 (IMPLIES (AND (NOT (G A (CDR R))) (not (ifrp r)) ;(WFR R) A (G A R)) (EQUAL (CAAR R) A)) :hints (("Goal" :in-theory (e/d (g wfr WFKEYED) ())))) (defthm g-of-caar (IMPLIES (AND (not (ifrp r)) (CONSP R) ) (G (CAAR R) R)) :hints (("Goal" :in-theory (enable g) :do-not '(generalize eliminate-destructors)))) (defthm g-iff (implies (and (wfr r) ; (not (ifrp r)) a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set)))) (defthm g-iff-ifrp (implies (and ;(wfr r) (ifrp r) ;weird case ;a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :expand ((SET::IN A '(NIL))) :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) ;; (thm ;; (IMPLIES (AND (not (ifrp R)) A (G A R)) ;; (SET::IN A (KEY-SET R))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :induct t ;; :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) (defthm in-of-key-set-hack (IMPLIES (AND (<< A (CAAR R)) (RCDP R)) (NOT (SET::IN A (KEY-SET R))))) (defthm rcdp-when-not-ifrp (implies (not (ifrp r)) (rcdp r))) (defthm in-of-key-set-hack-2 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (NOT (G-AUX A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm in-of-key-set-hack-3 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (G-AUX A R)) (SET::IN A (KEY-SET R))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm g-iff-gen (iff (g a r) (set::in a (rkeys r))) :otf-flg t :hints (("Goal" :do-not '(generalize eliminate-destructors) :use (:instance g-iff-ifrp) ; :induct t :in-theory (e/d (RKEYS ACL2->RCD g key-set) (g-iff-ifrp))))) ;move to sets ;expensive? (defthm head-when-empty (implies (set::empty ads) (equal (set::head ads) nil)) :hints (("Goal" :in-theory (enable set::head set::sfix)))) (defthm setp-of-rkeys (equal (set::setp (rkeys r)) t) :hints (("Goal" :in-theory (enable rkeys)))) ;slow proof! (defthm in-key-set-s-aux-two (implies (not (ifrp r)) ;(wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s-two-main-case (implies (not (ifrp r)) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s rkeys SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two-weird-case (implies (ifrp r) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :do-not '(generalize eliminate-destructors) :in-theory (enable s rkeys ACL2->RCD RCD->ACL2 set::in SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r)))) :hints (("Goal" :cases ((ifrp r))))) (defthm g-when-not-in-rkeys-cheap (implies (NOT (SET::IN key (RKEYS rec))) (equal (G key rec) nil)) :rule-classes ((:rewrite :backchain-limit-lst (0)))) (defthm equal-nil-s (implies (not (equal nil v)) (equal (equal nil (s a v r)) nil))) ;return the keys of the map as a list (defun key-list (map) (declare (type t map)) (set::2list (acl2::rkeys map))) ;fixme flesh out - or use a different version of maps (defund mapp (map) (declare (xargs :guard t)) (wfr map) ;requires the keys to be non-nil ) (local (defthm mapp-of-s-helper (implies (and (mapp map) v a ) (mapp (s a v map))) :hints (("Goal" :induct (S-AUX A V MAP) :in-theory (enable wfr WFKEYED wfkey s s-aux mapp ifrp RCD->ACL2))))) (local (defthm mapp-of-s-helper-nil (implies (and (mapp map) (equal v nil) ;this case a ) (mapp (s a v map))) :hints (("Goal" ;:induct (S-AUX A V MAP) :use (:instance wfr-of-clr (key a) (r map)) ; :in-theory (e/d (S-AUX mapp s ifrp) (RCDP-WHEN-NOT-IFRP)) :in-theory (e/d (clr mapp) (S==R)) )))) (defthm mapp-of-s (implies (and (mapp map) a) (mapp (s a v map))) :hints (("Goal" :cases ((equal v nil))))) (defthm in-of-rkeys-of-s-one (implies (and v (set::in k1 (rkeys map))) (set::in k1 (rkeys (s k2 v map))))) (defthm in-of-rkeys-of-s-two (implies (and v (equal k1 k2)) (set::in k1 (rkeys (s k2 v map))))) ;does something like this already exist? (defun alist-to-map (alist) (declare (xargs :guard (alistp alist))) (if (endp alist) (empty-map) (let* ((entry (car alist)) (key (car entry)) (val (cdr entry))) (s key val (alist-to-map (cdr alist)))))) ;expensive? (defthm clr-when-not-in-rkeys (implies (not (set::in ad (RKEYS heap))) (equal (CLR ad heap) heap)) :hints (("Goal" :in-theory (e/d (CLR) (;S-NIL-BECOMES-CLR ;fixme looped! s==r ))))) (defthmd rkeys-of-s-safe (implies (not (equal nil v)) ;phrasing is for axe (TODO: can we just say v?) (equal (rkeys (s a v r)) (set::insert a (rkeys r)))))
73898
; Additions to the records library ; ; Copyright (C) 2008-2011 <NAME> and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; TODO: Clean this up ;FIXME move stuff into maps0? ;FIXME put in more support for fast execution - see books/defexec/other-apps/records/records.lisp - maybe base this book on that one ;maps are basically records with "domain" and "new address" operators ;; TODO: See also ../axe/maps2.lisp ;fixme some of these are set theorems? (include-book "maps0") (include-book "../sets/sets") (defun key-set (r) (declare (xargs :guard (rcdp r))) (if (consp r) (set::insert (caar r) (key-set (cdr r))) (set::emptyset))) (defthm setp-key-set (set::setp (key-set r))) (defun rkeys (r) (declare (type t r)) (key-set (acl2->rcd r))) (defthm true-list-p-of-rkeys (true-listp (rkeys r)) :rule-classes :type-prescription) (defthm in-key-set-s-aux (implies (wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s (implies (and (wfr r) ;(wfkey a) ) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (in-theory (disable rkeys)) ;; stuff that should be in the records book: (defthm s-hack-1 (equal (s a nil nil) nil) :hints (("Goal" :in-theory (enable s)))) (in-theory (enable g-of-s-redux)) ;dup (defthm acl2->rcd-does-nothing (implies (not (ifrp r)) (equal (acl2->rcd r) r)) :hints (("Goal" :in-theory (enable acl2->rcd)))) ;logically the same as g, but has a guard and should execute much faster (defun fastg (a x) (declare (xargs :guard (not (IFRP X)))) ;fixme - should the guard be mapp? (mbe :logic (G-AUX A (ACL2->RCD X)) :exec (G-AUX A X))) (defthm fastg-becomes-g (equal (fastg a x) (g a x)) :hints (("Goal" :in-theory (enable g fastg)))) (defun dom (s) (declare (type t s)) (rkeys s)) ;disabling since this can introduce map reasoning into an unrelated problem (defthmd wfr-hack1 (IMPLIES (AND (not (ifrp r)) ;(WFR R) (CAAR R)) (CDAR R)) :hints (("Goal" :in-theory (enable WFR)))) (defthm wfr-hack2 (IMPLIES (AND (CONSP R) (not (ifrp r)) ;(WFR R) ;A (<< A (CAAR R))) (NOT (G-AUX A (CDR R)))) :hints (("Goal" :in-theory (enable wfr)))) (DEFUN WFR2 (R) (DECLARE (TYPE T R)) (AND (rcdp r) (NOT (IFRP R)) (WFKEYED R))) (defthm wfr-hack3 (IMPLIES (AND (CONSP R) (WFR2 R) ) (WFR2 (CDR R))) :hints (("Goal" :in-theory (enable wfr2 WFKEYED)))) (defthm wfr-hack3-good (IMPLIES (AND (CONSP R) (WFR R) ) (WFR (CDR R))) :hints (("Goal" :use wfr-hack3 :in-theory (e/d (wfr) ( wfr-hack3))))) ;; (defthm wfr-hack3-ifrp ;; (IMPLIES (AND (CONSP R) ;; ;(rcdp r) ;; (not (ifrp r)) ;(WFR R) ;; ) ;; (not (ifrp (cdr r))) ;(WFR (CDR R)) ;; ) ;; :hints (("Goal" :do-not '(generalize ;eliminate-destructors ;; ) ;; ; :expand (IFRP r) ;; :in-theory (enable wfr WFKEYED)))) (defthm wfr-hack4 (IMPLIES (AND (WFR R) a (NOT (G A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set g ;wfr wfr-hack1 wfkeyed)))) ;; (defthm wfr-hack4-try ;; (IMPLIES (AND (not (ifrp r)) ;(WFR R) ;; a ;; (NOT (G A R))) ;; (NOT (SET::IN A (KEY-SET R)))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :in-theory (enable rkeys key-set g ;wfr ;; wfkeyed)))) ;disable?! (defthm wfr-hack5 (IMPLIES (AND (NOT (G A (CDR R))) (not (ifrp r)) ;(WFR R) A (G A R)) (EQUAL (CAAR R) A)) :hints (("Goal" :in-theory (e/d (g wfr WFKEYED) ())))) (defthm g-of-caar (IMPLIES (AND (not (ifrp r)) (CONSP R) ) (G (CAAR R) R)) :hints (("Goal" :in-theory (enable g) :do-not '(generalize eliminate-destructors)))) (defthm g-iff (implies (and (wfr r) ; (not (ifrp r)) a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set)))) (defthm g-iff-ifrp (implies (and ;(wfr r) (ifrp r) ;weird case ;a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :expand ((SET::IN A '(NIL))) :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) ;; (thm ;; (IMPLIES (AND (not (ifrp R)) A (G A R)) ;; (SET::IN A (KEY-SET R))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :induct t ;; :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) (defthm in-of-key-set-hack (IMPLIES (AND (<< A (CAAR R)) (RCDP R)) (NOT (SET::IN A (KEY-SET R))))) (defthm rcdp-when-not-ifrp (implies (not (ifrp r)) (rcdp r))) (defthm in-of-key-set-hack-2 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (NOT (G-AUX A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm in-of-key-set-hack-3 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (G-AUX A R)) (SET::IN A (KEY-SET R))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm g-iff-gen (iff (g a r) (set::in a (rkeys r))) :otf-flg t :hints (("Goal" :do-not '(generalize eliminate-destructors) :use (:instance g-iff-ifrp) ; :induct t :in-theory (e/d (RKEYS ACL2->RCD g key-set) (g-iff-ifrp))))) ;move to sets ;expensive? (defthm head-when-empty (implies (set::empty ads) (equal (set::head ads) nil)) :hints (("Goal" :in-theory (enable set::head set::sfix)))) (defthm setp-of-rkeys (equal (set::setp (rkeys r)) t) :hints (("Goal" :in-theory (enable rkeys)))) ;slow proof! (defthm in-key-set-s-aux-two (implies (not (ifrp r)) ;(wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s-two-main-case (implies (not (ifrp r)) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s rkeys SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two-weird-case (implies (ifrp r) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :do-not '(generalize eliminate-destructors) :in-theory (enable s rkeys ACL2->RCD RCD->ACL2 set::in SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r)))) :hints (("Goal" :cases ((ifrp r))))) (defthm g-when-not-in-rkeys-cheap (implies (NOT (SET::IN key (RKEYS rec))) (equal (G key rec) nil)) :rule-classes ((:rewrite :backchain-limit-lst (0)))) (defthm equal-nil-s (implies (not (equal nil v)) (equal (equal nil (s a v r)) nil))) ;return the keys of the map as a list (defun key-list (map) (declare (type t map)) (set::2list (acl2::rkeys map))) ;fixme flesh out - or use a different version of maps (defund mapp (map) (declare (xargs :guard t)) (wfr map) ;requires the keys to be non-nil ) (local (defthm mapp-of-s-helper (implies (and (mapp map) v a ) (mapp (s a v map))) :hints (("Goal" :induct (S-AUX A V MAP) :in-theory (enable wfr WFKEYED wfkey s s-aux mapp ifrp RCD->ACL2))))) (local (defthm mapp-of-s-helper-nil (implies (and (mapp map) (equal v nil) ;this case a ) (mapp (s a v map))) :hints (("Goal" ;:induct (S-AUX A V MAP) :use (:instance wfr-of-clr (key a) (r map)) ; :in-theory (e/d (S-AUX mapp s ifrp) (RCDP-WHEN-NOT-IFRP)) :in-theory (e/d (clr mapp) (S==R)) )))) (defthm mapp-of-s (implies (and (mapp map) a) (mapp (s a v map))) :hints (("Goal" :cases ((equal v nil))))) (defthm in-of-rkeys-of-s-one (implies (and v (set::in k1 (rkeys map))) (set::in k1 (rkeys (s k2 v map))))) (defthm in-of-rkeys-of-s-two (implies (and v (equal k1 k2)) (set::in k1 (rkeys (s k2 v map))))) ;does something like this already exist? (defun alist-to-map (alist) (declare (xargs :guard (alistp alist))) (if (endp alist) (empty-map) (let* ((entry (car alist)) (key (car entry)) (val (cdr entry))) (s key val (alist-to-map (cdr alist)))))) ;expensive? (defthm clr-when-not-in-rkeys (implies (not (set::in ad (RKEYS heap))) (equal (CLR ad heap) heap)) :hints (("Goal" :in-theory (e/d (CLR) (;S-NIL-BECOMES-CLR ;fixme looped! s==r ))))) (defthmd rkeys-of-s-safe (implies (not (equal nil v)) ;phrasing is for axe (TODO: can we just say v?) (equal (rkeys (s a v r)) (set::insert a (rkeys r)))))
true
; Additions to the records library ; ; Copyright (C) 2008-2011 PI:NAME:<NAME>END_PI and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; TODO: Clean this up ;FIXME move stuff into maps0? ;FIXME put in more support for fast execution - see books/defexec/other-apps/records/records.lisp - maybe base this book on that one ;maps are basically records with "domain" and "new address" operators ;; TODO: See also ../axe/maps2.lisp ;fixme some of these are set theorems? (include-book "maps0") (include-book "../sets/sets") (defun key-set (r) (declare (xargs :guard (rcdp r))) (if (consp r) (set::insert (caar r) (key-set (cdr r))) (set::emptyset))) (defthm setp-key-set (set::setp (key-set r))) (defun rkeys (r) (declare (type t r)) (key-set (acl2->rcd r))) (defthm true-list-p-of-rkeys (true-listp (rkeys r)) :rule-classes :type-prescription) (defthm in-key-set-s-aux (implies (wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s (implies (and (wfr r) ;(wfkey a) ) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (in-theory (disable rkeys)) ;; stuff that should be in the records book: (defthm s-hack-1 (equal (s a nil nil) nil) :hints (("Goal" :in-theory (enable s)))) (in-theory (enable g-of-s-redux)) ;dup (defthm acl2->rcd-does-nothing (implies (not (ifrp r)) (equal (acl2->rcd r) r)) :hints (("Goal" :in-theory (enable acl2->rcd)))) ;logically the same as g, but has a guard and should execute much faster (defun fastg (a x) (declare (xargs :guard (not (IFRP X)))) ;fixme - should the guard be mapp? (mbe :logic (G-AUX A (ACL2->RCD X)) :exec (G-AUX A X))) (defthm fastg-becomes-g (equal (fastg a x) (g a x)) :hints (("Goal" :in-theory (enable g fastg)))) (defun dom (s) (declare (type t s)) (rkeys s)) ;disabling since this can introduce map reasoning into an unrelated problem (defthmd wfr-hack1 (IMPLIES (AND (not (ifrp r)) ;(WFR R) (CAAR R)) (CDAR R)) :hints (("Goal" :in-theory (enable WFR)))) (defthm wfr-hack2 (IMPLIES (AND (CONSP R) (not (ifrp r)) ;(WFR R) ;A (<< A (CAAR R))) (NOT (G-AUX A (CDR R)))) :hints (("Goal" :in-theory (enable wfr)))) (DEFUN WFR2 (R) (DECLARE (TYPE T R)) (AND (rcdp r) (NOT (IFRP R)) (WFKEYED R))) (defthm wfr-hack3 (IMPLIES (AND (CONSP R) (WFR2 R) ) (WFR2 (CDR R))) :hints (("Goal" :in-theory (enable wfr2 WFKEYED)))) (defthm wfr-hack3-good (IMPLIES (AND (CONSP R) (WFR R) ) (WFR (CDR R))) :hints (("Goal" :use wfr-hack3 :in-theory (e/d (wfr) ( wfr-hack3))))) ;; (defthm wfr-hack3-ifrp ;; (IMPLIES (AND (CONSP R) ;; ;(rcdp r) ;; (not (ifrp r)) ;(WFR R) ;; ) ;; (not (ifrp (cdr r))) ;(WFR (CDR R)) ;; ) ;; :hints (("Goal" :do-not '(generalize ;eliminate-destructors ;; ) ;; ; :expand (IFRP r) ;; :in-theory (enable wfr WFKEYED)))) (defthm wfr-hack4 (IMPLIES (AND (WFR R) a (NOT (G A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set g ;wfr wfr-hack1 wfkeyed)))) ;; (defthm wfr-hack4-try ;; (IMPLIES (AND (not (ifrp r)) ;(WFR R) ;; a ;; (NOT (G A R))) ;; (NOT (SET::IN A (KEY-SET R)))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :in-theory (enable rkeys key-set g ;wfr ;; wfkeyed)))) ;disable?! (defthm wfr-hack5 (IMPLIES (AND (NOT (G A (CDR R))) (not (ifrp r)) ;(WFR R) A (G A R)) (EQUAL (CAAR R) A)) :hints (("Goal" :in-theory (e/d (g wfr WFKEYED) ())))) (defthm g-of-caar (IMPLIES (AND (not (ifrp r)) (CONSP R) ) (G (CAAR R) R)) :hints (("Goal" :in-theory (enable g) :do-not '(generalize eliminate-destructors)))) (defthm g-iff (implies (and (wfr r) ; (not (ifrp r)) a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable rkeys key-set)))) (defthm g-iff-ifrp (implies (and ;(wfr r) (ifrp r) ;weird case ;a ) (iff (g a r) (set::in a (rkeys r)))) :hints (("Goal" :do-not '(generalize eliminate-destructors) :expand ((SET::IN A '(NIL))) :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) ;; (thm ;; (IMPLIES (AND (not (ifrp R)) A (G A R)) ;; (SET::IN A (KEY-SET R))) ;; :hints (("Goal" :do-not '(generalize eliminate-destructors) ;; :induct t ;; :in-theory (e/d (RKEYS ACL2->RCD g) (ifrp))))) (defthm in-of-key-set-hack (IMPLIES (AND (<< A (CAAR R)) (RCDP R)) (NOT (SET::IN A (KEY-SET R))))) (defthm rcdp-when-not-ifrp (implies (not (ifrp r)) (rcdp r))) (defthm in-of-key-set-hack-2 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (NOT (G-AUX A R))) (NOT (SET::IN A (KEY-SET R)))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm in-of-key-set-hack-3 (IMPLIES (AND (rcdp r) ;(NOT (IFRP R)) (G-AUX A R)) (SET::IN A (KEY-SET R))) :hints (("Goal" :do-not '(generalize eliminate-destructors)))) (defthm g-iff-gen (iff (g a r) (set::in a (rkeys r))) :otf-flg t :hints (("Goal" :do-not '(generalize eliminate-destructors) :use (:instance g-iff-ifrp) ; :induct t :in-theory (e/d (RKEYS ACL2->RCD g key-set) (g-iff-ifrp))))) ;move to sets ;expensive? (defthm head-when-empty (implies (set::empty ads) (equal (set::head ads) nil)) :hints (("Goal" :in-theory (enable set::head set::sfix)))) (defthm setp-of-rkeys (equal (set::setp (rkeys r)) t) :hints (("Goal" :in-theory (enable rkeys)))) ;slow proof! (defthm in-key-set-s-aux-two (implies (not (ifrp r)) ;(wfr r) (equal (set::in a (key-set (s-aux p v r))) (if v (or (equal a p) (set::in a (key-set r))) (and (not (equal a p)) (set::in a (key-set r)))))) :hints (("goal" :in-theory (e/d (WFKEYED wfr s-aux) (set::in))))) (defthm rkeys-s-two-main-case (implies (not (ifrp r)) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :in-theory (enable s rkeys SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two-weird-case (implies (ifrp r) (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r))))) :hints (("goal" :do-not '(generalize eliminate-destructors) :in-theory (enable s rkeys ACL2->RCD RCD->ACL2 set::in SET::DOUBLE-CONTAINMENT-EXPENSIVE)))) (defthm rkeys-s-two (equal (rkeys (s a v r)) (if v (set::insert a (rkeys r)) (set::delete a (rkeys r)))) :hints (("Goal" :cases ((ifrp r))))) (defthm g-when-not-in-rkeys-cheap (implies (NOT (SET::IN key (RKEYS rec))) (equal (G key rec) nil)) :rule-classes ((:rewrite :backchain-limit-lst (0)))) (defthm equal-nil-s (implies (not (equal nil v)) (equal (equal nil (s a v r)) nil))) ;return the keys of the map as a list (defun key-list (map) (declare (type t map)) (set::2list (acl2::rkeys map))) ;fixme flesh out - or use a different version of maps (defund mapp (map) (declare (xargs :guard t)) (wfr map) ;requires the keys to be non-nil ) (local (defthm mapp-of-s-helper (implies (and (mapp map) v a ) (mapp (s a v map))) :hints (("Goal" :induct (S-AUX A V MAP) :in-theory (enable wfr WFKEYED wfkey s s-aux mapp ifrp RCD->ACL2))))) (local (defthm mapp-of-s-helper-nil (implies (and (mapp map) (equal v nil) ;this case a ) (mapp (s a v map))) :hints (("Goal" ;:induct (S-AUX A V MAP) :use (:instance wfr-of-clr (key a) (r map)) ; :in-theory (e/d (S-AUX mapp s ifrp) (RCDP-WHEN-NOT-IFRP)) :in-theory (e/d (clr mapp) (S==R)) )))) (defthm mapp-of-s (implies (and (mapp map) a) (mapp (s a v map))) :hints (("Goal" :cases ((equal v nil))))) (defthm in-of-rkeys-of-s-one (implies (and v (set::in k1 (rkeys map))) (set::in k1 (rkeys (s k2 v map))))) (defthm in-of-rkeys-of-s-two (implies (and v (equal k1 k2)) (set::in k1 (rkeys (s k2 v map))))) ;does something like this already exist? (defun alist-to-map (alist) (declare (xargs :guard (alistp alist))) (if (endp alist) (empty-map) (let* ((entry (car alist)) (key (car entry)) (val (cdr entry))) (s key val (alist-to-map (cdr alist)))))) ;expensive? (defthm clr-when-not-in-rkeys (implies (not (set::in ad (RKEYS heap))) (equal (CLR ad heap) heap)) :hints (("Goal" :in-theory (e/d (CLR) (;S-NIL-BECOMES-CLR ;fixme looped! s==r ))))) (defthmd rkeys-of-s-safe (implies (not (equal nil v)) ;phrasing is for axe (TODO: can we just say v?) (equal (rkeys (s a v r)) (set::insert a (rkeys r)))))
[ { "context": "ress from various public API servers.\"\n :author \"Jeff Francis <[email protected]>\"\n :license \"MIT, see file LICE", "end": 182, "score": 0.9998695850372314, "start": 170, "tag": "NAME", "value": "Jeff Francis" }, { "context": "ous public API servers.\"\n :author \"Jeff Francis <[email protected]>\"\n :license \"MIT, see file LICENSE\"\n :depends-o", "end": 199, "score": 0.999925971031189, "start": 184, "tag": "EMAIL", "value": "[email protected]" } ]
whatismyip.asd
jfrancis42/whatismyip-lisp
0
;;;; whatismyip.asd (asdf:defsystem #:whatismyip :description "A Common Lisp client for retrieving your public IP address from various public API servers." :author "Jeff Francis <[email protected]>" :license "MIT, see file LICENSE" :depends-on (#:cl-json #:drakma #:split-sequence #:cl-html-parse #:babel) :serial t :components ((:file "package") (:file "whatismyip")))
39762
;;;; whatismyip.asd (asdf:defsystem #:whatismyip :description "A Common Lisp client for retrieving your public IP address from various public API servers." :author "<NAME> <<EMAIL>>" :license "MIT, see file LICENSE" :depends-on (#:cl-json #:drakma #:split-sequence #:cl-html-parse #:babel) :serial t :components ((:file "package") (:file "whatismyip")))
true
;;;; whatismyip.asd (asdf:defsystem #:whatismyip :description "A Common Lisp client for retrieving your public IP address from various public API servers." :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "MIT, see file LICENSE" :depends-on (#:cl-json #:drakma #:split-sequence #:cl-html-parse #:babel) :serial t :components ((:file "package") (:file "whatismyip")))
[ { "context": " Communication) Package\n;;;\n;;; (c) Copyright 2013 Reid Simmons. All rights reserved.\n;;;\n;;; FILE: ipcLisp.lisp", "end": 172, "score": 0.9997152090072632, "start": 160, "tag": "NAME", "value": "Reid Simmons" }, { "context": ";; $Date: 2013/07/31 19:54:49 $\n;;; $Author: reids $\n;;; $State: Exp $\n;;; $Locker: $\n;;;\n;;; ", "end": 493, "score": 0.999663233757019, "start": 488, "tag": "USERNAME", "value": "reids" } ]
lisp/ipcLisp.lisp
CMU-RASL/ipc
0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PROJECT: IPC (Interprocess Communication) Package ;;; ;;; (c) Copyright 2013 Reid Simmons. All rights reserved. ;;; ;;; FILE: ipcLisp.lisp ;;; ;;; ABSTRACT: Lisp code for interfacing specifically with the C version of IPC ;;; Used by SWIG (see IPC.i) ;;; ;;; $Id: ipcLisp.lisp,v 2.1 2013/07/31 19:54:49 reids Exp $ ;;; $Revision: 2.1 $ ;;; $Date: 2013/07/31 19:54:49 $ ;;; $Author: reids $ ;;; $State: Exp $ ;;; $Locker: $ ;;; ;;; Copyright (c) 2011, Carnegie Mellon University ;;; This software is distributed under the terms of the ;;; Simplified BSD License (see ipc/LICENSE.TXT) ;;; ;;; REVISION HISTORY ;;; $Log: ipcLisp.lisp,v $ ;;; Revision 2.1 2013/07/31 19:54:49 reids ;;; Updated for using SWIG ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :IPC) (defstruct (handler-data) key name proc unmarshall client-data timer-ref) ;; Export this function (cl::defmacro defun-external (name (&rest args) &body body) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defun ,name ,args ,@body))) ;; Export this constant (cl::defmacro defconstant-external (name val) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defconstant ,name ,val))) (defconstant-external IPC_WAIT_FOREVER #xFFFFFFFF) (defconstant-external TRIGGER_FOREVER #xFFFFFFFF) (defconstant-external IPC_VARIABLE_LENGTH #xFFFFFFFF) (defconstant-external IPC_FIXED_LENGTH (1- #xFFFFFFFF)) (defparameter *KEY_HASH_TABLE* (make-hash-table) "Hash table keyed on handler key, value is handler-data structure") (defparameter *NAME_HASH_TABLE* (make-hash-table :test #'equal) "Hash table keyed on handler name, value is handler key") (defparameter *CHANGE_HANDLERS_TABLE* (make-hash-table :test #'equal) "Hash table of change handlers (each entry a list of handlers)") (defparameter *CONNECT_HANDLERS_LIST* nil "List of connection handlers") (defparameter *DISCONNECT_HANDLERS_LIST* nil "List of disconnection handlers") (defparameter *MSG_CLASS_TABLE* (make-hash-table :test #'equal) "Hash table of classes associated with messages") (defparameter *HANDLER_NUMBER* 0 "Handler key, counts up from one") (defun handler-name (handler) (format nil "~a" (cond ((functionp handler) #+:franz-inc (excl::external-fn_symdef handler) #-:franz-inc handler) ;; This is not right (t handler)))) (defun msg-handler-name (msgName handler) (format nil "~a_~a" msgName (handler-name handler))) (defun query-handler-name (msgName handler) (format nil "Q_~a_~a" msgName (handler-name handler))) (defun fd-handler-name (fd handler) (format nil "~d_~a" fd (handler-name handler))) (defun timer-handler-name (handler) (format nil "~a" (handler-name handler))) (defun get-handler-data-by-key (key) (gethash key *KEY_HASH_TABLE*)) (defun get-handler-data-by-name (name) (let ((key (gethash name *NAME_HASH_TABLE*))) (when key (gethash key *KEY_HASH_TABLE*)))) (defun set-handler-data (key name proc client-data &optional (unmarshall nil)) (setf (gethash name *NAME_HASH_TABLE*) key) (setf (gethash key *KEY_HASH_TABLE*) (make-handler-data :name name :key key :proc proc :unmarshall unmarshall :client-data client-data))) (defun remove-handler-data-by-key (key) (let ((handler-data (get-handler-data-by-key key))) (when handler-data (remhash (handler-data-name handler-data) *NAME_HASH_TABLE*) (remhash key *KEY_HASH_TABLE*)))) (defun remove-handler-data-by-name (name) (let ((handler-data (get-handler-data-by-name name))) (when handler-data (remhash name *NAME_HASH_TABLE*) (remhash (handler-data-key handler-data) *KEY_HASH_TABLE*)))) (defun update-handler-data (handler-name handler client-data unmarshall) (let ((handler-data (get-handler-data-by-name handler-name))) (cond (handler-data (unless (equal (handler-data-client-data handler-data) client-data) (format t "Resetting client data for handler ~a~%" handler-name) (setf (handler-data-client-data handler-data) client-data)) (setf (handler-data-proc handler-data) handler) (setf (handler-data-unmarshall handler-data) unmarshall)) (t (setq handler-data (set-handler-data (incf *HANDLER_NUMBER*) handler-name handler client-data unmarshall)))) handler-data)) (defun handler-test (handler hnd-data) (equal handler (handler-data-name hnd-data))) (defun find-handler (handler handler-list) (car (member (handler-name handler) handler-list :test #'handler-test))) (defmacro add-handler (handler handler-list &optional (client-data nil)) `(setq ,handler-list (cons (make-handler-data :name (handler-name ,handler) :proc ,handler :client-data ,client-data) ,handler-list))) (defmacro rem-handler (handler handler-list) `(setq ,handler-list (remove (handler-name ,handler) ,handler-list :test #'handler-test))) (defun freeByteArray (varcontent) (unless (zerop (IPC_VARCONTENT_TYPE_length varcontent)) (IPC_freeByteArray (IPC_VARCONTENT_TYPE_content varcontent)))) (defun boolVal (val) (if (= val 0) nil t)) (defun return-error (errno) (ipcSetError errno) IPC_Error) (defun-external IPC_isConnected () (boolVal (IPC::_IPC_isConnected))) (defun-external IPC_isModuleConnected (module) (boolVal (IPC::_IPC_isModuleConnected module))) (defun-external IPC_isMsgDefined (msg) (boolVal (IPC::_IPC_isMsgDefined msg))) (defun-external IPC_defineMsg (msgName length formatString) (_IPC_defineMsg msgName length (or formatString 0))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_defstruct)) (defun ipc-marshall (formatter lisp-data) (cond ((eql (checkMarshallStatus formatter) IPC_Error) (values IPC_Error 0 0)) (t (let ((length (BufferSize formatter lisp-data)) (byte-array nil)) (when (> length 0) (setf byte-array (createByteArray length)) (let ((buffer (createBuffer byte-array))) (EncodeData formatter lisp-data buffer) (freeBuffer buffer))) (values IPC_OK length byte-array))))) (defun-external IPC_marshall (formatter lisp-data varcontent) (cond ((null varcontent) (return-error IPC_Null_Argument)) (t (multiple-value-bind (retval length byte-array) (ipc-marshall formatter lisp-data) (when (eql retval IPC_OK) (setf (IPC_VARCONTENT_TYPE_length varcontent) length) (setf (IPC_VARCONTENT_TYPE_content varcontent) byte-array)) retval)))) (defun-external _IPC_unmarshall (formatter byte-array object) (cond ((zerop (validFormatter formatter)) nil) (t (let ((buffer (createBuffer byte-array))) (prog1 (DecodeData formatter buffer object) (freeBuffer buffer)))))) (defmacro IPC_unmarshall (formatter byte-array data) `(cond ((eql (checkMarshallStatus ,formatter) IPC_Error) IPC_Error) (t (setf ,data (_IPC_unmarshall ,formatter ,byte-array ,data)) IPC_OK))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_unmarshall)) (defun-external IPC_unmarshallData (formatter byte-array &optional (classSymbol nil)) (_IPC_unmarshall formatter byte-array (make-data-struct classSymbol))) (defun foreign-callable-index (func) (second (multiple-value-list (ff:register-foreign-callable func :reuse t)))) (defun ipc-lisp-init() (clrhash *KEY_HASH_TABLE*) (clrhash *NAME_HASH_TABLE*) (clrhash *CHANGE_HANDLERS_TABLE*) (setq *CONNECT_HANDLERS_LIST* nil) (setq *DISCONNECT_HANDLERS_LIST* nil) (setf (aref TransTable CHAR_FMT) 'CHAR_Trans) (setf (aref TransTable BYTE_FMT) 'BYTE_Trans) (setf (aref TransTable UBYTE_FMT) 'UBYTE_Trans) (setf (aref TransTable SHORT_FMT) 'SHORT_Trans) (setf (aref TransTable INT_FMT) 'INT_Trans) (setf (aref TransTable LONG_FMT) 'INT_Trans) (setf (aref TransTable FLOAT_FMT) 'FLOAT_Trans) (setf (aref TransTable DOUBLE_FMT) 'DOUBLE_Trans) (setf (aref TransTable BOOLEAN_FMT) 'BOOLEAN_Trans) (setf (aref TransTable STR_FMT) 'STR_Trans) (setf (aref TransTable USHORT_FMT) 'USHORT_Trans) (setf (aref TransTable UINT_FMT) 'UINT_Trans) (setf (aref TransTable ULONG_FMT) 'UINT_Trans) (registerIndices (foreign-callable-index #'msgCallbackHandler) (foreign-callable-index #'queryCallbackHandler) (foreign-callable-index #'fdCallbackHandler) (foreign-callable-index #'connectCallbackHandler) (foreign-callable-index #'disconnectCallbackHandler) (foreign-callable-index #'changeCallbackHandler) (foreign-callable-index #'timerCallbackHandler)) (setExitProc) ) (defun-external IPC_initialize () (ipc-lisp-init) (IPC::_IPC_initialize)) (defun-external IPC_connect (module) (ipc-lisp-init) (IPC::_IPC_connect module)) (defun-external IPC_connectModule (module server) (ipc-lisp-init) (IPC::_IPC_connectModule module server)) (defun-external IPC_connectNoListen (module) (ipc-lisp-init) (IPC::_IPC_connectNoListen module)) (defun-external IPC_connectModuleNoListen (module server) (ipc-lisp-init) (IPC::_IPC_connectModuleNoListen module server)) (defun-external IPC_parseFormat (format) (cond ((null format) (_IPC_parseFormat "")) ((not (stringp format)) (return-error IPC_Illegal_Formatter)) (t (_IPC_parseFormat format)))) (defun-external IPC_publishData (msgName data) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (retVal (cond ((null data) (IPC_publish msgName 0 (IPC_VARCONTENT_TYPE_content vc))) ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_Error)) (IPC_publish msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc))) (t IPC_Error)))) (freeByteArray vc) retVal)) (defun getMsgClass (msgName formatter) (cond ((or (null formatter) (= (validFormatter formatter) 0)) nil) (t (let ((oclass (gethash msgName *MSG_CLASS_TABLE*))) (unless oclass (format t "WARNING: Missing class associated with message ~a~%" msgName)) oclass)))) (defun-foreign-callable msgCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable queryCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable fdCallbackHandler ((fd :int) (key :int)) (let ((handlerData (get-handler-data-by-key key))) ;;(format t "fdCallbackHandler: ~a~%" key) (cond ((null handlerData) (format t "Ooops -- no handler for fd ~d~%" key)) (t (funcall (handler-data-proc handlerData) fd (handler-data-client-data handlerData)))))) (defun-foreign-callable connectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "connectCallbackHandler: ~a~%" moduleName) (dolist (connectHandler *CONNECT_HANDLERS_LIST*) (funcall (handler-data-proc connectHandler) moduleName (handler-data-client-data connectHandler)))) (defun-foreign-callable disconnectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "disconnectCallbackHandler: ~a~%" moduleName) (dolist (disconnectHandler *DISCONNECT_HANDLERS_LIST*) (funcall (handler-data-proc disconnectHandler) moduleName (handler-data-client-data disconnectHandler)))) (defun-foreign-callable changeCallbackHandler ((msgName (* :char)) (numHandlers :int)) (setq msgName (ff::native-to-string msgName)) ;;(format t "changeCallbackHandler: ~a ~a~%" msgName numHandlers) (let ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*))) (when change-handlers (dolist (change-handler change-handlers) (funcall (handler-data-proc change-handler) msgName numHandlers (handler-data-client-data change-handler)))))) (defun-external IPC_subscribe (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_subscribeData (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data t))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_unsubscribe (msg-name handler) (let ((hnd-name (msg-handler-name msg-name handler))) (remove-handler-data-by-name hnd-name) (_IPC_unsubscribe msg-name hnd-name))) (defun-external IPC_subscribeFD (fd fdHandler &optional (client-data nil)) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (update-handler-data hnd-name fdHandler client-data nil))) (subscribeFD fd (handler-data-key handler-data)))) (defun-external IPC_unsubscribeFD (fd fdHandler) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (get-handler-data-by-name hnd-name))) (cond (handler-data (remove-handler-data-by-key (handler-data-key handler-data)) (unsubscribeFD fd)) (t (format t "Ooops: ~a not subscribed for fd ~d~%" (handler-name fdHandler) fd) IPC_Error)))) (defun-external IPC_subscribeConnect (connectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *CONNECT_HANDLERS_LIST*)) (hndData (find-handler connectHandler *CONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler connectHandler *CONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing connect handler client data for ~a~%" (handler-name connectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *CONNECT_HANDLERS_LIST*) 1)) (subscribeConnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_subscribeDisconnect (disconnectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*)) (hndData (find-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler disconnectHandler *DISCONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing disconnect handler client data for ~a~%" (handler-name disconnectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *DISCONNECT_HANDLERS_LIST*))) (subscribeDisconnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeConnect (connectHandler) (let ((oldLen (length *CONNECT_HANDLERS_LIST*))) (rem-handler connectHandler *CONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *CONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeConnect: Connect handler ~a not found~%" (handler-name connectHandler)) IPC_Error) ((zerop (length *CONNECT_HANDLERS_LIST*)) (unsubscribeConnect)) (t IPC_OK)))) (defun-external IPC_unsubscribeDisconnect (disconnectHandler) (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*))) (rem-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *DISCONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeDisconnect: Disconnect handler ~a not found~%" (handler-name disconnectHandler)) IPC_Error) ((zerop (length *DISCONNECT_HANDLERS_LIST*)) (unsubscribeDisconnect)) (t IPC_OK)))) (defun-external IPC_subscribeHandlerChange (msgName changeHandler &optional (clientData nil)) ;; Do it this way so that multiple handlers can be subscribed for same message (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((null change-handlers) (add-handler changeHandler change-handlers clientData)) ((null hnd-data) (add-handler changeHandler change-handlers clientData)) ((not (equal (handler-data-client-data hnd-data) clientData)) (format t "WARNING: Replacing change handler client data for ~a~%" (handler-name changeHandler)) (setf (handler-data-client-data hnd-data) clientData))) (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) change-handlers) (cond ((and (zerop oldlen) (= (length change-handlers) 1)) (subscribeHandlerChange msgName)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeHandlerChange (msgName changeHandler) (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((zerop oldlen) (format t "No change handler found for message ~a~%" msgName) IPC_Error) ((null hnd-data) (format t "No change handler found for message ~a~%" msgName) IPC_Error) (t (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) (remove hnd-data change-handlers)) (cond ((= oldlen 1) (unsubscribeHandlerChange msgName)) (t IPC_OK)))))) ;;; This is pretty kludgy and inefficient, but it works! (defun-external IPC_printData (formatter ostream data) (let ((vc (new_IPC_VARCONTENT_TYPE)) (retval IPC_OK)) (when (and (eql (setf retval (IPC_marshall formatter data vc)) IPC_OK) (eql (setf retval (printData formatter ".pd.tmp" vc)) IPC_OK)) (with-open-file (istream (open ".pd.tmp" :direction :input)) (loop with ch = nil while (setf ch (read-char istream nil nil)) do (write-char ch ostream))) (delete-file ".pd.tmp") retval))) (defun-external IPC_readData (formatter istream) (declare (ignore formatter istream)) (format t "IPC_readData: Not yet implemented~%") IPC_Error) (defun-external IPC_queryResponse (msgName length content timeout) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE)) (ret (queryResponse msgName length content vc replyFormat timeout))) (values (IPC_VARCONTENT_TYPE_content vc) ret))) (defun-external IPC_queryResponseVC (msgName varcontent timeout) (IPC_queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) timeout)) (defun-external IPC_queryResponseData (msgName data timeoutMSecs) (let ((varcontent (new_IPC_VARCONTENT_TYPE)) (responseObject nil) (ret IPC_OK)) (setf ret (IPC_marshall (IPC_msgFormatter msgName) data varcontent)) (when (eql ret IPC_OK) (let ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE))) (setf ret (queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) vc replyFormat timeoutMSecs)) (freeByteArray varcontent) (when (eql ret IPC_OK) (let ((formatter (FORMAT_CONTAINER_TYPE_format replyFormat))) (setf responseObject (make-data-struct (getMsgClass (FORMAT_CONTAINER_TYPE_msgName replyFormat) formatter))) (setf ret (IPC_unmarshall formatter (IPC_VARCONTENT_TYPE_content vc) responseObject)))))) (values responseObject ret))) (defun-external IPC_msgClass (msgName classSymbol) (setf (gethash msgName *MSG_CLASS_TABLE*) classSymbol)) (defun-external IPC_respondData (msgInstance msgName data) (let ((vc (new_IPC_VARCONTENT_TYPE))) (cond ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_OK)) IPC_Error) (t (let ((retVal (IPC_respondVC msgInstance msgName vc))) (freeByteArray vc) retVal))))) (defun-external IPC_queryNotify (msg-name length content handler &optional (client-data nil)) (let* ((hnd-name (query-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (queryNotify msg-name length content (handler-data-key handler-data)))) (defun-external IPC_queryNotifyVC (msgName varcontent handler &optional (clientData nil)) (IPC_queryNotify msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) handler clientData)) (defun-external IPC_queryNotifyData (msgName data handler &optional (clientData nil)) (let* ((hnd-name (query-handler-name msgName handler)) (handler-data (update-handler-data hnd-name handler clientData t))) (cond ((null data) (IPC_publish msgName 0 nil)) (t (let ((vc (new_IPC_VARCONTENT_TYPE)) (retVal IPC_OK)) (setq retVal (IPC_marshall (IPC_msgFormatter msgName) data vc)) (cond ((eql retVal IPC_OK) (setq retVal (queryNotify msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc) (handler-data-key handler-data))) (freeByteArray vc))) retVal))))) (defun addTimer (tdelay count handler client-data) (let* ((hnd-name (timer-handler-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil)) (timerRef (new_TIMER_REF_CONTAINER_TYPE)) (retval (addTimerGetRef tdelay count (handler-data-key handler-data) timerRef))) (cond ((eql retval IPC_OK) (setf (handler-data-timer-ref handler-data) (TIMER_REF_CONTAINER_TYPE_timerRef timerRef)) (values (TIMER_REF_CONTAINER_TYPE_timerRef timerRef) IPC_OK)) (t (values nil retval))))) (defun removeTimer (handlerIndex) (remove-handler-data-by-key handlerIndex)) (defun _IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (let* ((hnd-name (timer-handler-name handler)) (handler-data (get-handler-data-by-name hnd-name))) (when handler-data (format t "WARNING: Replacing existing timer for handler ~a~%" handler) (removeTimer (handler-data-key handler-data))) (multiple-value-bind (timerRef retVal) (addTimer tdelay count handler clientData) (when timerRefContainer (setf (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer) timerRef)) retVal))) (defun-external IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (_IPC_addTimerGetRef tdelay count handler clientData timerRefContainer)) (defun-external IPC_addTimer (tdelay count handler &optional (clientData nil)) (_IPC_addTimerGetRef tdelay count handler clientData nil)) (defun-external IPC_addOneShotTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay 1 handler clientData)) (defun-external IPC_addPeriodicTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay TRIGGER_FOREVER handler clientData)) (defun _IPC_removeByTimerRef (timerRef) (let ((handler-data nil)) (maphash #'(lambda (key hnd-data) (declare (ignore key)) (when (eql (handler-data-timer-ref hnd-data) timerRef) (setf handler-data hnd-data))) *KEY_HASH_TABLE*) (cond (handler-data (prog1 (_IPC_removeTimerByRef timerRef) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer with ref (~a) does not exist~%" timerRef) IPC_OK)))) (defun-external IPC_removeTimerByRef (timerRefContainer) (_IPC_removeByTimerRef (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer))) (defun-external IPC_removeTimer (handler) (let ((handler-data (get-handler-data-by-name (timer-handler-name handler)))) (cond (handler-data (prog1 (_IPC_removeByTimerRef (handler-data-timer-ref handler-data)) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer for handler (~a) does not exist~%" (handler-name handler)) IPC_OK)))) (defun-foreign-callable timerCallbackHandler ((hndIndex :int) (currentTime :int) (scheduledTime :int)) (let ((hnd-data (get-handler-data-by-key hndIndex))) (cond (hnd-data (funcall (handler-data-proc hnd-data) (handler-data-client-data hnd-data) currentTime scheduledTime) (when (zerop (maxTriggers (handler-data-timer-ref hnd-data))) (format t "Deleting timer ~a~%" (handler-data-name hnd-data)) (removeTimer hndIndex))) (t (format t "Ooops -- no handler for timer~%")))))
71241
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PROJECT: IPC (Interprocess Communication) Package ;;; ;;; (c) Copyright 2013 <NAME>. All rights reserved. ;;; ;;; FILE: ipcLisp.lisp ;;; ;;; ABSTRACT: Lisp code for interfacing specifically with the C version of IPC ;;; Used by SWIG (see IPC.i) ;;; ;;; $Id: ipcLisp.lisp,v 2.1 2013/07/31 19:54:49 reids Exp $ ;;; $Revision: 2.1 $ ;;; $Date: 2013/07/31 19:54:49 $ ;;; $Author: reids $ ;;; $State: Exp $ ;;; $Locker: $ ;;; ;;; Copyright (c) 2011, Carnegie Mellon University ;;; This software is distributed under the terms of the ;;; Simplified BSD License (see ipc/LICENSE.TXT) ;;; ;;; REVISION HISTORY ;;; $Log: ipcLisp.lisp,v $ ;;; Revision 2.1 2013/07/31 19:54:49 reids ;;; Updated for using SWIG ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :IPC) (defstruct (handler-data) key name proc unmarshall client-data timer-ref) ;; Export this function (cl::defmacro defun-external (name (&rest args) &body body) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defun ,name ,args ,@body))) ;; Export this constant (cl::defmacro defconstant-external (name val) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defconstant ,name ,val))) (defconstant-external IPC_WAIT_FOREVER #xFFFFFFFF) (defconstant-external TRIGGER_FOREVER #xFFFFFFFF) (defconstant-external IPC_VARIABLE_LENGTH #xFFFFFFFF) (defconstant-external IPC_FIXED_LENGTH (1- #xFFFFFFFF)) (defparameter *KEY_HASH_TABLE* (make-hash-table) "Hash table keyed on handler key, value is handler-data structure") (defparameter *NAME_HASH_TABLE* (make-hash-table :test #'equal) "Hash table keyed on handler name, value is handler key") (defparameter *CHANGE_HANDLERS_TABLE* (make-hash-table :test #'equal) "Hash table of change handlers (each entry a list of handlers)") (defparameter *CONNECT_HANDLERS_LIST* nil "List of connection handlers") (defparameter *DISCONNECT_HANDLERS_LIST* nil "List of disconnection handlers") (defparameter *MSG_CLASS_TABLE* (make-hash-table :test #'equal) "Hash table of classes associated with messages") (defparameter *HANDLER_NUMBER* 0 "Handler key, counts up from one") (defun handler-name (handler) (format nil "~a" (cond ((functionp handler) #+:franz-inc (excl::external-fn_symdef handler) #-:franz-inc handler) ;; This is not right (t handler)))) (defun msg-handler-name (msgName handler) (format nil "~a_~a" msgName (handler-name handler))) (defun query-handler-name (msgName handler) (format nil "Q_~a_~a" msgName (handler-name handler))) (defun fd-handler-name (fd handler) (format nil "~d_~a" fd (handler-name handler))) (defun timer-handler-name (handler) (format nil "~a" (handler-name handler))) (defun get-handler-data-by-key (key) (gethash key *KEY_HASH_TABLE*)) (defun get-handler-data-by-name (name) (let ((key (gethash name *NAME_HASH_TABLE*))) (when key (gethash key *KEY_HASH_TABLE*)))) (defun set-handler-data (key name proc client-data &optional (unmarshall nil)) (setf (gethash name *NAME_HASH_TABLE*) key) (setf (gethash key *KEY_HASH_TABLE*) (make-handler-data :name name :key key :proc proc :unmarshall unmarshall :client-data client-data))) (defun remove-handler-data-by-key (key) (let ((handler-data (get-handler-data-by-key key))) (when handler-data (remhash (handler-data-name handler-data) *NAME_HASH_TABLE*) (remhash key *KEY_HASH_TABLE*)))) (defun remove-handler-data-by-name (name) (let ((handler-data (get-handler-data-by-name name))) (when handler-data (remhash name *NAME_HASH_TABLE*) (remhash (handler-data-key handler-data) *KEY_HASH_TABLE*)))) (defun update-handler-data (handler-name handler client-data unmarshall) (let ((handler-data (get-handler-data-by-name handler-name))) (cond (handler-data (unless (equal (handler-data-client-data handler-data) client-data) (format t "Resetting client data for handler ~a~%" handler-name) (setf (handler-data-client-data handler-data) client-data)) (setf (handler-data-proc handler-data) handler) (setf (handler-data-unmarshall handler-data) unmarshall)) (t (setq handler-data (set-handler-data (incf *HANDLER_NUMBER*) handler-name handler client-data unmarshall)))) handler-data)) (defun handler-test (handler hnd-data) (equal handler (handler-data-name hnd-data))) (defun find-handler (handler handler-list) (car (member (handler-name handler) handler-list :test #'handler-test))) (defmacro add-handler (handler handler-list &optional (client-data nil)) `(setq ,handler-list (cons (make-handler-data :name (handler-name ,handler) :proc ,handler :client-data ,client-data) ,handler-list))) (defmacro rem-handler (handler handler-list) `(setq ,handler-list (remove (handler-name ,handler) ,handler-list :test #'handler-test))) (defun freeByteArray (varcontent) (unless (zerop (IPC_VARCONTENT_TYPE_length varcontent)) (IPC_freeByteArray (IPC_VARCONTENT_TYPE_content varcontent)))) (defun boolVal (val) (if (= val 0) nil t)) (defun return-error (errno) (ipcSetError errno) IPC_Error) (defun-external IPC_isConnected () (boolVal (IPC::_IPC_isConnected))) (defun-external IPC_isModuleConnected (module) (boolVal (IPC::_IPC_isModuleConnected module))) (defun-external IPC_isMsgDefined (msg) (boolVal (IPC::_IPC_isMsgDefined msg))) (defun-external IPC_defineMsg (msgName length formatString) (_IPC_defineMsg msgName length (or formatString 0))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_defstruct)) (defun ipc-marshall (formatter lisp-data) (cond ((eql (checkMarshallStatus formatter) IPC_Error) (values IPC_Error 0 0)) (t (let ((length (BufferSize formatter lisp-data)) (byte-array nil)) (when (> length 0) (setf byte-array (createByteArray length)) (let ((buffer (createBuffer byte-array))) (EncodeData formatter lisp-data buffer) (freeBuffer buffer))) (values IPC_OK length byte-array))))) (defun-external IPC_marshall (formatter lisp-data varcontent) (cond ((null varcontent) (return-error IPC_Null_Argument)) (t (multiple-value-bind (retval length byte-array) (ipc-marshall formatter lisp-data) (when (eql retval IPC_OK) (setf (IPC_VARCONTENT_TYPE_length varcontent) length) (setf (IPC_VARCONTENT_TYPE_content varcontent) byte-array)) retval)))) (defun-external _IPC_unmarshall (formatter byte-array object) (cond ((zerop (validFormatter formatter)) nil) (t (let ((buffer (createBuffer byte-array))) (prog1 (DecodeData formatter buffer object) (freeBuffer buffer)))))) (defmacro IPC_unmarshall (formatter byte-array data) `(cond ((eql (checkMarshallStatus ,formatter) IPC_Error) IPC_Error) (t (setf ,data (_IPC_unmarshall ,formatter ,byte-array ,data)) IPC_OK))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_unmarshall)) (defun-external IPC_unmarshallData (formatter byte-array &optional (classSymbol nil)) (_IPC_unmarshall formatter byte-array (make-data-struct classSymbol))) (defun foreign-callable-index (func) (second (multiple-value-list (ff:register-foreign-callable func :reuse t)))) (defun ipc-lisp-init() (clrhash *KEY_HASH_TABLE*) (clrhash *NAME_HASH_TABLE*) (clrhash *CHANGE_HANDLERS_TABLE*) (setq *CONNECT_HANDLERS_LIST* nil) (setq *DISCONNECT_HANDLERS_LIST* nil) (setf (aref TransTable CHAR_FMT) 'CHAR_Trans) (setf (aref TransTable BYTE_FMT) 'BYTE_Trans) (setf (aref TransTable UBYTE_FMT) 'UBYTE_Trans) (setf (aref TransTable SHORT_FMT) 'SHORT_Trans) (setf (aref TransTable INT_FMT) 'INT_Trans) (setf (aref TransTable LONG_FMT) 'INT_Trans) (setf (aref TransTable FLOAT_FMT) 'FLOAT_Trans) (setf (aref TransTable DOUBLE_FMT) 'DOUBLE_Trans) (setf (aref TransTable BOOLEAN_FMT) 'BOOLEAN_Trans) (setf (aref TransTable STR_FMT) 'STR_Trans) (setf (aref TransTable USHORT_FMT) 'USHORT_Trans) (setf (aref TransTable UINT_FMT) 'UINT_Trans) (setf (aref TransTable ULONG_FMT) 'UINT_Trans) (registerIndices (foreign-callable-index #'msgCallbackHandler) (foreign-callable-index #'queryCallbackHandler) (foreign-callable-index #'fdCallbackHandler) (foreign-callable-index #'connectCallbackHandler) (foreign-callable-index #'disconnectCallbackHandler) (foreign-callable-index #'changeCallbackHandler) (foreign-callable-index #'timerCallbackHandler)) (setExitProc) ) (defun-external IPC_initialize () (ipc-lisp-init) (IPC::_IPC_initialize)) (defun-external IPC_connect (module) (ipc-lisp-init) (IPC::_IPC_connect module)) (defun-external IPC_connectModule (module server) (ipc-lisp-init) (IPC::_IPC_connectModule module server)) (defun-external IPC_connectNoListen (module) (ipc-lisp-init) (IPC::_IPC_connectNoListen module)) (defun-external IPC_connectModuleNoListen (module server) (ipc-lisp-init) (IPC::_IPC_connectModuleNoListen module server)) (defun-external IPC_parseFormat (format) (cond ((null format) (_IPC_parseFormat "")) ((not (stringp format)) (return-error IPC_Illegal_Formatter)) (t (_IPC_parseFormat format)))) (defun-external IPC_publishData (msgName data) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (retVal (cond ((null data) (IPC_publish msgName 0 (IPC_VARCONTENT_TYPE_content vc))) ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_Error)) (IPC_publish msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc))) (t IPC_Error)))) (freeByteArray vc) retVal)) (defun getMsgClass (msgName formatter) (cond ((or (null formatter) (= (validFormatter formatter) 0)) nil) (t (let ((oclass (gethash msgName *MSG_CLASS_TABLE*))) (unless oclass (format t "WARNING: Missing class associated with message ~a~%" msgName)) oclass)))) (defun-foreign-callable msgCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable queryCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable fdCallbackHandler ((fd :int) (key :int)) (let ((handlerData (get-handler-data-by-key key))) ;;(format t "fdCallbackHandler: ~a~%" key) (cond ((null handlerData) (format t "Ooops -- no handler for fd ~d~%" key)) (t (funcall (handler-data-proc handlerData) fd (handler-data-client-data handlerData)))))) (defun-foreign-callable connectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "connectCallbackHandler: ~a~%" moduleName) (dolist (connectHandler *CONNECT_HANDLERS_LIST*) (funcall (handler-data-proc connectHandler) moduleName (handler-data-client-data connectHandler)))) (defun-foreign-callable disconnectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "disconnectCallbackHandler: ~a~%" moduleName) (dolist (disconnectHandler *DISCONNECT_HANDLERS_LIST*) (funcall (handler-data-proc disconnectHandler) moduleName (handler-data-client-data disconnectHandler)))) (defun-foreign-callable changeCallbackHandler ((msgName (* :char)) (numHandlers :int)) (setq msgName (ff::native-to-string msgName)) ;;(format t "changeCallbackHandler: ~a ~a~%" msgName numHandlers) (let ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*))) (when change-handlers (dolist (change-handler change-handlers) (funcall (handler-data-proc change-handler) msgName numHandlers (handler-data-client-data change-handler)))))) (defun-external IPC_subscribe (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_subscribeData (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data t))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_unsubscribe (msg-name handler) (let ((hnd-name (msg-handler-name msg-name handler))) (remove-handler-data-by-name hnd-name) (_IPC_unsubscribe msg-name hnd-name))) (defun-external IPC_subscribeFD (fd fdHandler &optional (client-data nil)) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (update-handler-data hnd-name fdHandler client-data nil))) (subscribeFD fd (handler-data-key handler-data)))) (defun-external IPC_unsubscribeFD (fd fdHandler) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (get-handler-data-by-name hnd-name))) (cond (handler-data (remove-handler-data-by-key (handler-data-key handler-data)) (unsubscribeFD fd)) (t (format t "Ooops: ~a not subscribed for fd ~d~%" (handler-name fdHandler) fd) IPC_Error)))) (defun-external IPC_subscribeConnect (connectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *CONNECT_HANDLERS_LIST*)) (hndData (find-handler connectHandler *CONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler connectHandler *CONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing connect handler client data for ~a~%" (handler-name connectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *CONNECT_HANDLERS_LIST*) 1)) (subscribeConnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_subscribeDisconnect (disconnectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*)) (hndData (find-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler disconnectHandler *DISCONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing disconnect handler client data for ~a~%" (handler-name disconnectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *DISCONNECT_HANDLERS_LIST*))) (subscribeDisconnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeConnect (connectHandler) (let ((oldLen (length *CONNECT_HANDLERS_LIST*))) (rem-handler connectHandler *CONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *CONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeConnect: Connect handler ~a not found~%" (handler-name connectHandler)) IPC_Error) ((zerop (length *CONNECT_HANDLERS_LIST*)) (unsubscribeConnect)) (t IPC_OK)))) (defun-external IPC_unsubscribeDisconnect (disconnectHandler) (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*))) (rem-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *DISCONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeDisconnect: Disconnect handler ~a not found~%" (handler-name disconnectHandler)) IPC_Error) ((zerop (length *DISCONNECT_HANDLERS_LIST*)) (unsubscribeDisconnect)) (t IPC_OK)))) (defun-external IPC_subscribeHandlerChange (msgName changeHandler &optional (clientData nil)) ;; Do it this way so that multiple handlers can be subscribed for same message (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((null change-handlers) (add-handler changeHandler change-handlers clientData)) ((null hnd-data) (add-handler changeHandler change-handlers clientData)) ((not (equal (handler-data-client-data hnd-data) clientData)) (format t "WARNING: Replacing change handler client data for ~a~%" (handler-name changeHandler)) (setf (handler-data-client-data hnd-data) clientData))) (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) change-handlers) (cond ((and (zerop oldlen) (= (length change-handlers) 1)) (subscribeHandlerChange msgName)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeHandlerChange (msgName changeHandler) (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((zerop oldlen) (format t "No change handler found for message ~a~%" msgName) IPC_Error) ((null hnd-data) (format t "No change handler found for message ~a~%" msgName) IPC_Error) (t (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) (remove hnd-data change-handlers)) (cond ((= oldlen 1) (unsubscribeHandlerChange msgName)) (t IPC_OK)))))) ;;; This is pretty kludgy and inefficient, but it works! (defun-external IPC_printData (formatter ostream data) (let ((vc (new_IPC_VARCONTENT_TYPE)) (retval IPC_OK)) (when (and (eql (setf retval (IPC_marshall formatter data vc)) IPC_OK) (eql (setf retval (printData formatter ".pd.tmp" vc)) IPC_OK)) (with-open-file (istream (open ".pd.tmp" :direction :input)) (loop with ch = nil while (setf ch (read-char istream nil nil)) do (write-char ch ostream))) (delete-file ".pd.tmp") retval))) (defun-external IPC_readData (formatter istream) (declare (ignore formatter istream)) (format t "IPC_readData: Not yet implemented~%") IPC_Error) (defun-external IPC_queryResponse (msgName length content timeout) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE)) (ret (queryResponse msgName length content vc replyFormat timeout))) (values (IPC_VARCONTENT_TYPE_content vc) ret))) (defun-external IPC_queryResponseVC (msgName varcontent timeout) (IPC_queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) timeout)) (defun-external IPC_queryResponseData (msgName data timeoutMSecs) (let ((varcontent (new_IPC_VARCONTENT_TYPE)) (responseObject nil) (ret IPC_OK)) (setf ret (IPC_marshall (IPC_msgFormatter msgName) data varcontent)) (when (eql ret IPC_OK) (let ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE))) (setf ret (queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) vc replyFormat timeoutMSecs)) (freeByteArray varcontent) (when (eql ret IPC_OK) (let ((formatter (FORMAT_CONTAINER_TYPE_format replyFormat))) (setf responseObject (make-data-struct (getMsgClass (FORMAT_CONTAINER_TYPE_msgName replyFormat) formatter))) (setf ret (IPC_unmarshall formatter (IPC_VARCONTENT_TYPE_content vc) responseObject)))))) (values responseObject ret))) (defun-external IPC_msgClass (msgName classSymbol) (setf (gethash msgName *MSG_CLASS_TABLE*) classSymbol)) (defun-external IPC_respondData (msgInstance msgName data) (let ((vc (new_IPC_VARCONTENT_TYPE))) (cond ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_OK)) IPC_Error) (t (let ((retVal (IPC_respondVC msgInstance msgName vc))) (freeByteArray vc) retVal))))) (defun-external IPC_queryNotify (msg-name length content handler &optional (client-data nil)) (let* ((hnd-name (query-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (queryNotify msg-name length content (handler-data-key handler-data)))) (defun-external IPC_queryNotifyVC (msgName varcontent handler &optional (clientData nil)) (IPC_queryNotify msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) handler clientData)) (defun-external IPC_queryNotifyData (msgName data handler &optional (clientData nil)) (let* ((hnd-name (query-handler-name msgName handler)) (handler-data (update-handler-data hnd-name handler clientData t))) (cond ((null data) (IPC_publish msgName 0 nil)) (t (let ((vc (new_IPC_VARCONTENT_TYPE)) (retVal IPC_OK)) (setq retVal (IPC_marshall (IPC_msgFormatter msgName) data vc)) (cond ((eql retVal IPC_OK) (setq retVal (queryNotify msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc) (handler-data-key handler-data))) (freeByteArray vc))) retVal))))) (defun addTimer (tdelay count handler client-data) (let* ((hnd-name (timer-handler-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil)) (timerRef (new_TIMER_REF_CONTAINER_TYPE)) (retval (addTimerGetRef tdelay count (handler-data-key handler-data) timerRef))) (cond ((eql retval IPC_OK) (setf (handler-data-timer-ref handler-data) (TIMER_REF_CONTAINER_TYPE_timerRef timerRef)) (values (TIMER_REF_CONTAINER_TYPE_timerRef timerRef) IPC_OK)) (t (values nil retval))))) (defun removeTimer (handlerIndex) (remove-handler-data-by-key handlerIndex)) (defun _IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (let* ((hnd-name (timer-handler-name handler)) (handler-data (get-handler-data-by-name hnd-name))) (when handler-data (format t "WARNING: Replacing existing timer for handler ~a~%" handler) (removeTimer (handler-data-key handler-data))) (multiple-value-bind (timerRef retVal) (addTimer tdelay count handler clientData) (when timerRefContainer (setf (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer) timerRef)) retVal))) (defun-external IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (_IPC_addTimerGetRef tdelay count handler clientData timerRefContainer)) (defun-external IPC_addTimer (tdelay count handler &optional (clientData nil)) (_IPC_addTimerGetRef tdelay count handler clientData nil)) (defun-external IPC_addOneShotTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay 1 handler clientData)) (defun-external IPC_addPeriodicTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay TRIGGER_FOREVER handler clientData)) (defun _IPC_removeByTimerRef (timerRef) (let ((handler-data nil)) (maphash #'(lambda (key hnd-data) (declare (ignore key)) (when (eql (handler-data-timer-ref hnd-data) timerRef) (setf handler-data hnd-data))) *KEY_HASH_TABLE*) (cond (handler-data (prog1 (_IPC_removeTimerByRef timerRef) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer with ref (~a) does not exist~%" timerRef) IPC_OK)))) (defun-external IPC_removeTimerByRef (timerRefContainer) (_IPC_removeByTimerRef (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer))) (defun-external IPC_removeTimer (handler) (let ((handler-data (get-handler-data-by-name (timer-handler-name handler)))) (cond (handler-data (prog1 (_IPC_removeByTimerRef (handler-data-timer-ref handler-data)) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer for handler (~a) does not exist~%" (handler-name handler)) IPC_OK)))) (defun-foreign-callable timerCallbackHandler ((hndIndex :int) (currentTime :int) (scheduledTime :int)) (let ((hnd-data (get-handler-data-by-key hndIndex))) (cond (hnd-data (funcall (handler-data-proc hnd-data) (handler-data-client-data hnd-data) currentTime scheduledTime) (when (zerop (maxTriggers (handler-data-timer-ref hnd-data))) (format t "Deleting timer ~a~%" (handler-data-name hnd-data)) (removeTimer hndIndex))) (t (format t "Ooops -- no handler for timer~%")))))
true
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; PROJECT: IPC (Interprocess Communication) Package ;;; ;;; (c) Copyright 2013 PI:NAME:<NAME>END_PI. All rights reserved. ;;; ;;; FILE: ipcLisp.lisp ;;; ;;; ABSTRACT: Lisp code for interfacing specifically with the C version of IPC ;;; Used by SWIG (see IPC.i) ;;; ;;; $Id: ipcLisp.lisp,v 2.1 2013/07/31 19:54:49 reids Exp $ ;;; $Revision: 2.1 $ ;;; $Date: 2013/07/31 19:54:49 $ ;;; $Author: reids $ ;;; $State: Exp $ ;;; $Locker: $ ;;; ;;; Copyright (c) 2011, Carnegie Mellon University ;;; This software is distributed under the terms of the ;;; Simplified BSD License (see ipc/LICENSE.TXT) ;;; ;;; REVISION HISTORY ;;; $Log: ipcLisp.lisp,v $ ;;; Revision 2.1 2013/07/31 19:54:49 reids ;;; Updated for using SWIG ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :IPC) (defstruct (handler-data) key name proc unmarshall client-data timer-ref) ;; Export this function (cl::defmacro defun-external (name (&rest args) &body body) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defun ,name ,args ,@body))) ;; Export this constant (cl::defmacro defconstant-external (name val) `(eval-when (:compile-toplevel :load-toplevel :execute) (cl::export ',name) (defconstant ,name ,val))) (defconstant-external IPC_WAIT_FOREVER #xFFFFFFFF) (defconstant-external TRIGGER_FOREVER #xFFFFFFFF) (defconstant-external IPC_VARIABLE_LENGTH #xFFFFFFFF) (defconstant-external IPC_FIXED_LENGTH (1- #xFFFFFFFF)) (defparameter *KEY_HASH_TABLE* (make-hash-table) "Hash table keyed on handler key, value is handler-data structure") (defparameter *NAME_HASH_TABLE* (make-hash-table :test #'equal) "Hash table keyed on handler name, value is handler key") (defparameter *CHANGE_HANDLERS_TABLE* (make-hash-table :test #'equal) "Hash table of change handlers (each entry a list of handlers)") (defparameter *CONNECT_HANDLERS_LIST* nil "List of connection handlers") (defparameter *DISCONNECT_HANDLERS_LIST* nil "List of disconnection handlers") (defparameter *MSG_CLASS_TABLE* (make-hash-table :test #'equal) "Hash table of classes associated with messages") (defparameter *HANDLER_NUMBER* 0 "Handler key, counts up from one") (defun handler-name (handler) (format nil "~a" (cond ((functionp handler) #+:franz-inc (excl::external-fn_symdef handler) #-:franz-inc handler) ;; This is not right (t handler)))) (defun msg-handler-name (msgName handler) (format nil "~a_~a" msgName (handler-name handler))) (defun query-handler-name (msgName handler) (format nil "Q_~a_~a" msgName (handler-name handler))) (defun fd-handler-name (fd handler) (format nil "~d_~a" fd (handler-name handler))) (defun timer-handler-name (handler) (format nil "~a" (handler-name handler))) (defun get-handler-data-by-key (key) (gethash key *KEY_HASH_TABLE*)) (defun get-handler-data-by-name (name) (let ((key (gethash name *NAME_HASH_TABLE*))) (when key (gethash key *KEY_HASH_TABLE*)))) (defun set-handler-data (key name proc client-data &optional (unmarshall nil)) (setf (gethash name *NAME_HASH_TABLE*) key) (setf (gethash key *KEY_HASH_TABLE*) (make-handler-data :name name :key key :proc proc :unmarshall unmarshall :client-data client-data))) (defun remove-handler-data-by-key (key) (let ((handler-data (get-handler-data-by-key key))) (when handler-data (remhash (handler-data-name handler-data) *NAME_HASH_TABLE*) (remhash key *KEY_HASH_TABLE*)))) (defun remove-handler-data-by-name (name) (let ((handler-data (get-handler-data-by-name name))) (when handler-data (remhash name *NAME_HASH_TABLE*) (remhash (handler-data-key handler-data) *KEY_HASH_TABLE*)))) (defun update-handler-data (handler-name handler client-data unmarshall) (let ((handler-data (get-handler-data-by-name handler-name))) (cond (handler-data (unless (equal (handler-data-client-data handler-data) client-data) (format t "Resetting client data for handler ~a~%" handler-name) (setf (handler-data-client-data handler-data) client-data)) (setf (handler-data-proc handler-data) handler) (setf (handler-data-unmarshall handler-data) unmarshall)) (t (setq handler-data (set-handler-data (incf *HANDLER_NUMBER*) handler-name handler client-data unmarshall)))) handler-data)) (defun handler-test (handler hnd-data) (equal handler (handler-data-name hnd-data))) (defun find-handler (handler handler-list) (car (member (handler-name handler) handler-list :test #'handler-test))) (defmacro add-handler (handler handler-list &optional (client-data nil)) `(setq ,handler-list (cons (make-handler-data :name (handler-name ,handler) :proc ,handler :client-data ,client-data) ,handler-list))) (defmacro rem-handler (handler handler-list) `(setq ,handler-list (remove (handler-name ,handler) ,handler-list :test #'handler-test))) (defun freeByteArray (varcontent) (unless (zerop (IPC_VARCONTENT_TYPE_length varcontent)) (IPC_freeByteArray (IPC_VARCONTENT_TYPE_content varcontent)))) (defun boolVal (val) (if (= val 0) nil t)) (defun return-error (errno) (ipcSetError errno) IPC_Error) (defun-external IPC_isConnected () (boolVal (IPC::_IPC_isConnected))) (defun-external IPC_isModuleConnected (module) (boolVal (IPC::_IPC_isModuleConnected module))) (defun-external IPC_isMsgDefined (msg) (boolVal (IPC::_IPC_isMsgDefined msg))) (defun-external IPC_defineMsg (msgName length formatString) (_IPC_defineMsg msgName length (or formatString 0))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_defstruct)) (defun ipc-marshall (formatter lisp-data) (cond ((eql (checkMarshallStatus formatter) IPC_Error) (values IPC_Error 0 0)) (t (let ((length (BufferSize formatter lisp-data)) (byte-array nil)) (when (> length 0) (setf byte-array (createByteArray length)) (let ((buffer (createBuffer byte-array))) (EncodeData formatter lisp-data buffer) (freeBuffer buffer))) (values IPC_OK length byte-array))))) (defun-external IPC_marshall (formatter lisp-data varcontent) (cond ((null varcontent) (return-error IPC_Null_Argument)) (t (multiple-value-bind (retval length byte-array) (ipc-marshall formatter lisp-data) (when (eql retval IPC_OK) (setf (IPC_VARCONTENT_TYPE_length varcontent) length) (setf (IPC_VARCONTENT_TYPE_content varcontent) byte-array)) retval)))) (defun-external _IPC_unmarshall (formatter byte-array object) (cond ((zerop (validFormatter formatter)) nil) (t (let ((buffer (createBuffer byte-array))) (prog1 (DecodeData formatter buffer object) (freeBuffer buffer)))))) (defmacro IPC_unmarshall (formatter byte-array data) `(cond ((eql (checkMarshallStatus ,formatter) IPC_Error) IPC_Error) (t (setf ,data (_IPC_unmarshall ,formatter ,byte-array ,data)) IPC_OK))) (eval-when (:compile-toplevel :load-toplevel :execute) (cl::export 'IPC_unmarshall)) (defun-external IPC_unmarshallData (formatter byte-array &optional (classSymbol nil)) (_IPC_unmarshall formatter byte-array (make-data-struct classSymbol))) (defun foreign-callable-index (func) (second (multiple-value-list (ff:register-foreign-callable func :reuse t)))) (defun ipc-lisp-init() (clrhash *KEY_HASH_TABLE*) (clrhash *NAME_HASH_TABLE*) (clrhash *CHANGE_HANDLERS_TABLE*) (setq *CONNECT_HANDLERS_LIST* nil) (setq *DISCONNECT_HANDLERS_LIST* nil) (setf (aref TransTable CHAR_FMT) 'CHAR_Trans) (setf (aref TransTable BYTE_FMT) 'BYTE_Trans) (setf (aref TransTable UBYTE_FMT) 'UBYTE_Trans) (setf (aref TransTable SHORT_FMT) 'SHORT_Trans) (setf (aref TransTable INT_FMT) 'INT_Trans) (setf (aref TransTable LONG_FMT) 'INT_Trans) (setf (aref TransTable FLOAT_FMT) 'FLOAT_Trans) (setf (aref TransTable DOUBLE_FMT) 'DOUBLE_Trans) (setf (aref TransTable BOOLEAN_FMT) 'BOOLEAN_Trans) (setf (aref TransTable STR_FMT) 'STR_Trans) (setf (aref TransTable USHORT_FMT) 'USHORT_Trans) (setf (aref TransTable UINT_FMT) 'UINT_Trans) (setf (aref TransTable ULONG_FMT) 'UINT_Trans) (registerIndices (foreign-callable-index #'msgCallbackHandler) (foreign-callable-index #'queryCallbackHandler) (foreign-callable-index #'fdCallbackHandler) (foreign-callable-index #'connectCallbackHandler) (foreign-callable-index #'disconnectCallbackHandler) (foreign-callable-index #'changeCallbackHandler) (foreign-callable-index #'timerCallbackHandler)) (setExitProc) ) (defun-external IPC_initialize () (ipc-lisp-init) (IPC::_IPC_initialize)) (defun-external IPC_connect (module) (ipc-lisp-init) (IPC::_IPC_connect module)) (defun-external IPC_connectModule (module server) (ipc-lisp-init) (IPC::_IPC_connectModule module server)) (defun-external IPC_connectNoListen (module) (ipc-lisp-init) (IPC::_IPC_connectNoListen module)) (defun-external IPC_connectModuleNoListen (module server) (ipc-lisp-init) (IPC::_IPC_connectModuleNoListen module server)) (defun-external IPC_parseFormat (format) (cond ((null format) (_IPC_parseFormat "")) ((not (stringp format)) (return-error IPC_Illegal_Formatter)) (t (_IPC_parseFormat format)))) (defun-external IPC_publishData (msgName data) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (retVal (cond ((null data) (IPC_publish msgName 0 (IPC_VARCONTENT_TYPE_content vc))) ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_Error)) (IPC_publish msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc))) (t IPC_Error)))) (freeByteArray vc) retVal)) (defun getMsgClass (msgName formatter) (cond ((or (null formatter) (= (validFormatter formatter) 0)) nil) (t (let ((oclass (gethash msgName *MSG_CLASS_TABLE*))) (unless oclass (format t "WARNING: Missing class associated with message ~a~%" msgName)) oclass)))) (defun-foreign-callable msgCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable queryCallbackHandler ((msgInstancePtr (* void)) (byteArray (* void)) (key :int)) (let ((msgInstance (make-instance 'foreign-pointer :foreign-address msgInstancePtr)) (handlerData (get-handler-data-by-key key))) (cond ((null handlerData) (format t "Ooops -- no handler for ~a~%" (IPC_msgInstanceName msgInstance))) ((handler-data-unmarshall handlerData) (let* ((formatter (IPC_msgInstanceFormatter msgInstance)) (data (make-data-struct (getMsgClass (IPC_msgInstanceName msgInstance) formatter)))) (cond ((eql (IPC_unmarshall formatter byteArray data) IPC_Error) (return-error IPC_Mismatched_Formatter)) (t (funcall (handler-data-proc handlerData) msgInstance data (handler-data-client-data handlerData)))) (IPC_freeByteArray byteArray))) (t (funcall (handler-data-proc handlerData) msgInstance byteArray (handler-data-client-data handlerData)))))) (defun-foreign-callable fdCallbackHandler ((fd :int) (key :int)) (let ((handlerData (get-handler-data-by-key key))) ;;(format t "fdCallbackHandler: ~a~%" key) (cond ((null handlerData) (format t "Ooops -- no handler for fd ~d~%" key)) (t (funcall (handler-data-proc handlerData) fd (handler-data-client-data handlerData)))))) (defun-foreign-callable connectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "connectCallbackHandler: ~a~%" moduleName) (dolist (connectHandler *CONNECT_HANDLERS_LIST*) (funcall (handler-data-proc connectHandler) moduleName (handler-data-client-data connectHandler)))) (defun-foreign-callable disconnectCallbackHandler ((moduleName (* :char))) (setq moduleName (ff::native-to-string moduleName)) ;;(format t "disconnectCallbackHandler: ~a~%" moduleName) (dolist (disconnectHandler *DISCONNECT_HANDLERS_LIST*) (funcall (handler-data-proc disconnectHandler) moduleName (handler-data-client-data disconnectHandler)))) (defun-foreign-callable changeCallbackHandler ((msgName (* :char)) (numHandlers :int)) (setq msgName (ff::native-to-string msgName)) ;;(format t "changeCallbackHandler: ~a ~a~%" msgName numHandlers) (let ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*))) (when change-handlers (dolist (change-handler change-handlers) (funcall (handler-data-proc change-handler) msgName numHandlers (handler-data-client-data change-handler)))))) (defun-external IPC_subscribe (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_subscribeData (msg-name handler &optional (client-data nil)) (let* ((hnd-name (msg-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data t))) (subscribe msg-name hnd-name (handler-data-key handler-data)))) (defun-external IPC_unsubscribe (msg-name handler) (let ((hnd-name (msg-handler-name msg-name handler))) (remove-handler-data-by-name hnd-name) (_IPC_unsubscribe msg-name hnd-name))) (defun-external IPC_subscribeFD (fd fdHandler &optional (client-data nil)) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (update-handler-data hnd-name fdHandler client-data nil))) (subscribeFD fd (handler-data-key handler-data)))) (defun-external IPC_unsubscribeFD (fd fdHandler) (let* ((hnd-name (fd-handler-name fd fdHandler)) (handler-data (get-handler-data-by-name hnd-name))) (cond (handler-data (remove-handler-data-by-key (handler-data-key handler-data)) (unsubscribeFD fd)) (t (format t "Ooops: ~a not subscribed for fd ~d~%" (handler-name fdHandler) fd) IPC_Error)))) (defun-external IPC_subscribeConnect (connectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *CONNECT_HANDLERS_LIST*)) (hndData (find-handler connectHandler *CONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler connectHandler *CONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing connect handler client data for ~a~%" (handler-name connectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *CONNECT_HANDLERS_LIST*) 1)) (subscribeConnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_subscribeDisconnect (disconnectHandler &optional (client-data nil)) ;; Do it this way so that multiple handlers can be subscribed (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*)) (hndData (find-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*))) (cond ((null hndData) (add-handler disconnectHandler *DISCONNECT_HANDLERS_LIST* client-data)) ((not (equal (handler-data-client-data hndData) client-data)) (format t "WARNING: Replacing disconnect handler client data for ~a~%" (handler-name disconnectHandler)) (setf (handler-data-client-data hndData) client-data))) (cond ((and (zerop oldLen) (= (length *DISCONNECT_HANDLERS_LIST*))) (subscribeDisconnect)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeConnect (connectHandler) (let ((oldLen (length *CONNECT_HANDLERS_LIST*))) (rem-handler connectHandler *CONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *CONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeConnect: Connect handler ~a not found~%" (handler-name connectHandler)) IPC_Error) ((zerop (length *CONNECT_HANDLERS_LIST*)) (unsubscribeConnect)) (t IPC_OK)))) (defun-external IPC_unsubscribeDisconnect (disconnectHandler) (let ((oldLen (length *DISCONNECT_HANDLERS_LIST*))) (rem-handler disconnectHandler *DISCONNECT_HANDLERS_LIST*) (cond ((= oldLen (length *DISCONNECT_HANDLERS_LIST*)) (format t "IPC_unsubscribeDisconnect: Disconnect handler ~a not found~%" (handler-name disconnectHandler)) IPC_Error) ((zerop (length *DISCONNECT_HANDLERS_LIST*)) (unsubscribeDisconnect)) (t IPC_OK)))) (defun-external IPC_subscribeHandlerChange (msgName changeHandler &optional (clientData nil)) ;; Do it this way so that multiple handlers can be subscribed for same message (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((null change-handlers) (add-handler changeHandler change-handlers clientData)) ((null hnd-data) (add-handler changeHandler change-handlers clientData)) ((not (equal (handler-data-client-data hnd-data) clientData)) (format t "WARNING: Replacing change handler client data for ~a~%" (handler-name changeHandler)) (setf (handler-data-client-data hnd-data) clientData))) (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) change-handlers) (cond ((and (zerop oldlen) (= (length change-handlers) 1)) (subscribeHandlerChange msgName)) ((IPC_isConnected) IPC_OK) (t IPC_Error)))) (defun-external IPC_unsubscribeHandlerChange (msgName changeHandler) (let* ((change-handlers (gethash msgName *CHANGE_HANDLERS_TABLE*)) (oldlen (length change-handlers)) (hnd-data (find-handler changeHandler change-handlers))) (cond ((zerop oldlen) (format t "No change handler found for message ~a~%" msgName) IPC_Error) ((null hnd-data) (format t "No change handler found for message ~a~%" msgName) IPC_Error) (t (setf (gethash msgName *CHANGE_HANDLERS_TABLE*) (remove hnd-data change-handlers)) (cond ((= oldlen 1) (unsubscribeHandlerChange msgName)) (t IPC_OK)))))) ;;; This is pretty kludgy and inefficient, but it works! (defun-external IPC_printData (formatter ostream data) (let ((vc (new_IPC_VARCONTENT_TYPE)) (retval IPC_OK)) (when (and (eql (setf retval (IPC_marshall formatter data vc)) IPC_OK) (eql (setf retval (printData formatter ".pd.tmp" vc)) IPC_OK)) (with-open-file (istream (open ".pd.tmp" :direction :input)) (loop with ch = nil while (setf ch (read-char istream nil nil)) do (write-char ch ostream))) (delete-file ".pd.tmp") retval))) (defun-external IPC_readData (formatter istream) (declare (ignore formatter istream)) (format t "IPC_readData: Not yet implemented~%") IPC_Error) (defun-external IPC_queryResponse (msgName length content timeout) (let* ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE)) (ret (queryResponse msgName length content vc replyFormat timeout))) (values (IPC_VARCONTENT_TYPE_content vc) ret))) (defun-external IPC_queryResponseVC (msgName varcontent timeout) (IPC_queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) timeout)) (defun-external IPC_queryResponseData (msgName data timeoutMSecs) (let ((varcontent (new_IPC_VARCONTENT_TYPE)) (responseObject nil) (ret IPC_OK)) (setf ret (IPC_marshall (IPC_msgFormatter msgName) data varcontent)) (when (eql ret IPC_OK) (let ((vc (new_IPC_VARCONTENT_TYPE)) (replyFormat (new_FORMAT_CONTAINER_TYPE))) (setf ret (queryResponse msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) vc replyFormat timeoutMSecs)) (freeByteArray varcontent) (when (eql ret IPC_OK) (let ((formatter (FORMAT_CONTAINER_TYPE_format replyFormat))) (setf responseObject (make-data-struct (getMsgClass (FORMAT_CONTAINER_TYPE_msgName replyFormat) formatter))) (setf ret (IPC_unmarshall formatter (IPC_VARCONTENT_TYPE_content vc) responseObject)))))) (values responseObject ret))) (defun-external IPC_msgClass (msgName classSymbol) (setf (gethash msgName *MSG_CLASS_TABLE*) classSymbol)) (defun-external IPC_respondData (msgInstance msgName data) (let ((vc (new_IPC_VARCONTENT_TYPE))) (cond ((not (eql (IPC_marshall (IPC_msgFormatter msgName) data vc) IPC_OK)) IPC_Error) (t (let ((retVal (IPC_respondVC msgInstance msgName vc))) (freeByteArray vc) retVal))))) (defun-external IPC_queryNotify (msg-name length content handler &optional (client-data nil)) (let* ((hnd-name (query-handler-name msg-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil))) (queryNotify msg-name length content (handler-data-key handler-data)))) (defun-external IPC_queryNotifyVC (msgName varcontent handler &optional (clientData nil)) (IPC_queryNotify msgName (IPC_VARCONTENT_TYPE_length varcontent) (IPC_VARCONTENT_TYPE_content varcontent) handler clientData)) (defun-external IPC_queryNotifyData (msgName data handler &optional (clientData nil)) (let* ((hnd-name (query-handler-name msgName handler)) (handler-data (update-handler-data hnd-name handler clientData t))) (cond ((null data) (IPC_publish msgName 0 nil)) (t (let ((vc (new_IPC_VARCONTENT_TYPE)) (retVal IPC_OK)) (setq retVal (IPC_marshall (IPC_msgFormatter msgName) data vc)) (cond ((eql retVal IPC_OK) (setq retVal (queryNotify msgName (IPC_VARCONTENT_TYPE_length vc) (IPC_VARCONTENT_TYPE_content vc) (handler-data-key handler-data))) (freeByteArray vc))) retVal))))) (defun addTimer (tdelay count handler client-data) (let* ((hnd-name (timer-handler-name handler)) (handler-data (update-handler-data hnd-name handler client-data nil)) (timerRef (new_TIMER_REF_CONTAINER_TYPE)) (retval (addTimerGetRef tdelay count (handler-data-key handler-data) timerRef))) (cond ((eql retval IPC_OK) (setf (handler-data-timer-ref handler-data) (TIMER_REF_CONTAINER_TYPE_timerRef timerRef)) (values (TIMER_REF_CONTAINER_TYPE_timerRef timerRef) IPC_OK)) (t (values nil retval))))) (defun removeTimer (handlerIndex) (remove-handler-data-by-key handlerIndex)) (defun _IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (let* ((hnd-name (timer-handler-name handler)) (handler-data (get-handler-data-by-name hnd-name))) (when handler-data (format t "WARNING: Replacing existing timer for handler ~a~%" handler) (removeTimer (handler-data-key handler-data))) (multiple-value-bind (timerRef retVal) (addTimer tdelay count handler clientData) (when timerRefContainer (setf (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer) timerRef)) retVal))) (defun-external IPC_addTimerGetRef (tdelay count handler clientData timerRefContainer) (_IPC_addTimerGetRef tdelay count handler clientData timerRefContainer)) (defun-external IPC_addTimer (tdelay count handler &optional (clientData nil)) (_IPC_addTimerGetRef tdelay count handler clientData nil)) (defun-external IPC_addOneShotTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay 1 handler clientData)) (defun-external IPC_addPeriodicTimer (tdelay handler &optional (clientData nil)) (IPC_addTimer tdelay TRIGGER_FOREVER handler clientData)) (defun _IPC_removeByTimerRef (timerRef) (let ((handler-data nil)) (maphash #'(lambda (key hnd-data) (declare (ignore key)) (when (eql (handler-data-timer-ref hnd-data) timerRef) (setf handler-data hnd-data))) *KEY_HASH_TABLE*) (cond (handler-data (prog1 (_IPC_removeTimerByRef timerRef) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer with ref (~a) does not exist~%" timerRef) IPC_OK)))) (defun-external IPC_removeTimerByRef (timerRefContainer) (_IPC_removeByTimerRef (TIMER_REF_CONTAINER_TYPE_timerRef timerRefContainer))) (defun-external IPC_removeTimer (handler) (let ((handler-data (get-handler-data-by-name (timer-handler-name handler)))) (cond (handler-data (prog1 (_IPC_removeByTimerRef (handler-data-timer-ref handler-data)) (removeTimer (handler-data-key handler-data)))) (t (format t "Timer for handler (~a) does not exist~%" (handler-name handler)) IPC_OK)))) (defun-foreign-callable timerCallbackHandler ((hndIndex :int) (currentTime :int) (scheduledTime :int)) (let ((hnd-data (get-handler-data-by-key hndIndex))) (cond (hnd-data (funcall (handler-data-proc hnd-data) (handler-data-client-data hnd-data) currentTime scheduledTime) (when (zerop (maxTriggers (handler-data-timer-ref hnd-data))) (format t "Deleting timer ~a~%" (handler-data-name hnd-data)) (removeTimer hndIndex))) (t (format t "Ooops -- no handler for timer~%")))))
[ { "context": " (:read-file-form \"version.sexp\")\n :author \"Steven Nunez <[email protected]>\"\n :license :MS-PL\n :", "end": 1040, "score": 0.9998944401741028, "start": 1028, "tag": "NAME", "value": "Steven Nunez" }, { "context": "orm \"version.sexp\")\n :author \"Steven Nunez <[email protected]>\"\n :license :MS-PL\n :depends-on (\"cffi\")\n ", "end": 1062, "score": 0.9999319314956665, "start": 1042, "tag": "EMAIL", "value": "[email protected]" } ]
cephes.asd
Common-Lisp-Statistics/cephes.cl
11
;;; -*- Mode: LISP; Base: 10; Syntax: ANSI-Common-Lisp; Package: ASDF -*- ;;; Copyright (c) 2021 by Symbolics Pte. Ltd. All rights reserved. ;; Define a makefile as a kind of source file in ASDF (defclass makefile (source-file) ((type :initform "m"))) (defmethod perform ((o load-op) (c makefile)) t) (defmethod perform ((o compile-op) (c makefile)) (let* ((lib-dir (system-relative-pathname "cephes" "scipy-cephes")) (lib (make-pathname :directory `(:relative ,(namestring lib-dir)) :name "libmd" :type #+unix "so" #+(or windows win32) "dll")) (built (probe-file (namestring lib)))) (if built (format *error-output* "Library ~S exists, skipping build" lib) (format *error-output* "Building ~S~%" lib)) (unless built (chdir (native-namestring lib-dir)) (run-program "make" :output t)))) (defsystem "cephes" :description "Wrapper for the Cephes Mathematical Library" :version (:read-file-form "version.sexp") :author "Steven Nunez <[email protected]>" :license :MS-PL :depends-on ("cffi") :serial t :components ((:module "libmd" :components ((:makefile "makefile"))) (:file "package") (:file "init") (:file "cephes")))
33567
;;; -*- Mode: LISP; Base: 10; Syntax: ANSI-Common-Lisp; Package: ASDF -*- ;;; Copyright (c) 2021 by Symbolics Pte. Ltd. All rights reserved. ;; Define a makefile as a kind of source file in ASDF (defclass makefile (source-file) ((type :initform "m"))) (defmethod perform ((o load-op) (c makefile)) t) (defmethod perform ((o compile-op) (c makefile)) (let* ((lib-dir (system-relative-pathname "cephes" "scipy-cephes")) (lib (make-pathname :directory `(:relative ,(namestring lib-dir)) :name "libmd" :type #+unix "so" #+(or windows win32) "dll")) (built (probe-file (namestring lib)))) (if built (format *error-output* "Library ~S exists, skipping build" lib) (format *error-output* "Building ~S~%" lib)) (unless built (chdir (native-namestring lib-dir)) (run-program "make" :output t)))) (defsystem "cephes" :description "Wrapper for the Cephes Mathematical Library" :version (:read-file-form "version.sexp") :author "<NAME> <<EMAIL>>" :license :MS-PL :depends-on ("cffi") :serial t :components ((:module "libmd" :components ((:makefile "makefile"))) (:file "package") (:file "init") (:file "cephes")))
true
;;; -*- Mode: LISP; Base: 10; Syntax: ANSI-Common-Lisp; Package: ASDF -*- ;;; Copyright (c) 2021 by Symbolics Pte. Ltd. All rights reserved. ;; Define a makefile as a kind of source file in ASDF (defclass makefile (source-file) ((type :initform "m"))) (defmethod perform ((o load-op) (c makefile)) t) (defmethod perform ((o compile-op) (c makefile)) (let* ((lib-dir (system-relative-pathname "cephes" "scipy-cephes")) (lib (make-pathname :directory `(:relative ,(namestring lib-dir)) :name "libmd" :type #+unix "so" #+(or windows win32) "dll")) (built (probe-file (namestring lib)))) (if built (format *error-output* "Library ~S exists, skipping build" lib) (format *error-output* "Building ~S~%" lib)) (unless built (chdir (native-namestring lib-dir)) (run-program "make" :output t)))) (defsystem "cephes" :description "Wrapper for the Cephes Mathematical Library" :version (:read-file-form "version.sexp") :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license :MS-PL :depends-on ("cffi") :serial t :components ((:module "libmd" :components ((:makefile "makefile"))) (:file "package") (:file "init") (:file "cephes")))
[ { "context": ";;; Copyright (c) 2015 Ivan Shvedunov\n;;;\n;;; Permission is hereby granted, free of cha", "end": 37, "score": 0.9997206330299377, "start": 23, "tag": "NAME", "value": "Ivan Shvedunov" } ]
specials.lisp
ivan4th/cl-mqtt
14
;;; Copyright (c) 2015 Ivan Shvedunov ;;; ;;; Permission is hereby granted, free of charge, to any person obtaining a copy ;;; of this software and associated documentation files (the "Software"), to deal ;;; in the Software without restriction, including without limitation the rights ;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;;; copies of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be included in ;;; all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;;; THE SOFTWARE. (in-package :cl-mqtt) (defparameter *initial-input-buffer-size* 1024) (defparameter *max-packet-len* (* 1024 1024)) ;; FIXME (should be configurable) (defvar *mqtt-message-extra-initargs* (make-hash-table)) (defvar *mqtt-packet-builders* (make-hash-table)) (defvar *mqtt-packet-parsers* (make-hash-table)) (defparameter *control-packet-types* #(nil :connect ; 1 :connack ; 2 :publish ; 3 :puback ; 4 :pubrec ; 5 :pubrel ; 6 :pubcomp ; 7 :subscribe ; 8 :suback ; 9 :unsubscribe ; 10 :unsuback ; 11 :pingreq ; 12 :pingresp ; 13 :disconnect ; 14 nil)) (defparameter *ret-codes* #(:accepted :unacceptable-protocol-version :identifier-rejected :server-unavailable :bad-user-name-or-password :not-authorized))
75665
;;; Copyright (c) 2015 <NAME> ;;; ;;; Permission is hereby granted, free of charge, to any person obtaining a copy ;;; of this software and associated documentation files (the "Software"), to deal ;;; in the Software without restriction, including without limitation the rights ;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;;; copies of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be included in ;;; all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;;; THE SOFTWARE. (in-package :cl-mqtt) (defparameter *initial-input-buffer-size* 1024) (defparameter *max-packet-len* (* 1024 1024)) ;; FIXME (should be configurable) (defvar *mqtt-message-extra-initargs* (make-hash-table)) (defvar *mqtt-packet-builders* (make-hash-table)) (defvar *mqtt-packet-parsers* (make-hash-table)) (defparameter *control-packet-types* #(nil :connect ; 1 :connack ; 2 :publish ; 3 :puback ; 4 :pubrec ; 5 :pubrel ; 6 :pubcomp ; 7 :subscribe ; 8 :suback ; 9 :unsubscribe ; 10 :unsuback ; 11 :pingreq ; 12 :pingresp ; 13 :disconnect ; 14 nil)) (defparameter *ret-codes* #(:accepted :unacceptable-protocol-version :identifier-rejected :server-unavailable :bad-user-name-or-password :not-authorized))
true
;;; Copyright (c) 2015 PI:NAME:<NAME>END_PI ;;; ;;; Permission is hereby granted, free of charge, to any person obtaining a copy ;;; of this software and associated documentation files (the "Software"), to deal ;;; in the Software without restriction, including without limitation the rights ;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;;; copies of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be included in ;;; all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;;; THE SOFTWARE. (in-package :cl-mqtt) (defparameter *initial-input-buffer-size* 1024) (defparameter *max-packet-len* (* 1024 1024)) ;; FIXME (should be configurable) (defvar *mqtt-message-extra-initargs* (make-hash-table)) (defvar *mqtt-packet-builders* (make-hash-table)) (defvar *mqtt-packet-parsers* (make-hash-table)) (defparameter *control-packet-types* #(nil :connect ; 1 :connack ; 2 :publish ; 3 :puback ; 4 :pubrec ; 5 :pubrel ; 6 :pubcomp ; 7 :subscribe ; 8 :suback ; 9 :unsubscribe ; 10 :unsuback ; 11 :pingreq ; 12 :pingresp ; 13 :disconnect ; 14 nil)) (defparameter *ret-codes* #(:accepted :unacceptable-protocol-version :identifier-rejected :server-unavailable :bad-user-name-or-password :not-authorized))
[ { "context": ":defsystem squirl\n :version \"0.1\"\n :maintainer \"Kat Marchán <[email protected]>\"\n :licence \"MIT\"\n :descri", "end": 150, "score": 0.999853253364563, "start": 139, "tag": "NAME", "value": "Kat Marchán" }, { "context": "uirl\n :version \"0.1\"\n :maintainer \"Kat Marchán <[email protected]>\"\n :licence \"MIT\"\n :description \"A pure lisp im", "end": 171, "score": 0.999929666519165, "start": 152, "tag": "EMAIL", "value": "[email protected]" } ]
squirl.asd
death/squirl
0
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; indent-tabs-mode: nil -*- (asdf:defsystem squirl :version "0.1" :maintainer "Kat Marchán <[email protected]>" :licence "MIT" :description "A pure lisp implementation of the Chipmunk 2D physics engine." :components ((:module "src" :components ((:file "arbiter" :depends-on ("vec" "shape" "collision" "contact")) (:file "body" :depends-on ("vec")) (:file "bounding-box" :depends-on ("vec")) (:file "collision" :depends-on ("shape" "poly-shape" "contact")) (:file "contact" :depends-on ("vec")) (:file "convenience" :depends-on ("body" "shape" "poly-shape" "vec")) (:file "hash-set" :depends-on ("utils")) (:file "package") (:file "shape" :depends-on ("vec" "bounding-box" "body")) (:file "poly-shape" :depends-on ("shape")) (:file "squirl" :depends-on ("vec")) (:file "utils" :depends-on ("package")) (:file "vec" :depends-on ("utils")) (:file "world" :depends-on ("vec" "arbiter" "body")) (:file "world-hash" :depends-on ("hash-set" "vec")) (:module "constraints" :depends-on ("shape" "poly-shape" "arbiter") :components ((:file "breakable-joint" :depends-on ("constraints")) (:file "constraints" :depends-on ("util")) (:file "damped-rotary-spring" :depends-on ("spring")) (:file "damped-spring" :depends-on ("spring")) (:file "gear-joint" :depends-on ("constraints")) (:file "groove-joint" :depends-on ("constraints")) (:file "pin-joint" :depends-on ("constraints")) (:file "pivot-joint" :depends-on ("constraints")) (:file "ratchet-joint" :depends-on ("constraints")) (:file "rotary-limit-joint" :depends-on ("constraints")) (:file "simple-motor" :depends-on ("constraints")) (:file "slide-joint" :depends-on ("constraints")) (:file "spring" :depends-on ("constraints")) (:file "util")))))))
92054
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; indent-tabs-mode: nil -*- (asdf:defsystem squirl :version "0.1" :maintainer "<NAME> <<EMAIL>>" :licence "MIT" :description "A pure lisp implementation of the Chipmunk 2D physics engine." :components ((:module "src" :components ((:file "arbiter" :depends-on ("vec" "shape" "collision" "contact")) (:file "body" :depends-on ("vec")) (:file "bounding-box" :depends-on ("vec")) (:file "collision" :depends-on ("shape" "poly-shape" "contact")) (:file "contact" :depends-on ("vec")) (:file "convenience" :depends-on ("body" "shape" "poly-shape" "vec")) (:file "hash-set" :depends-on ("utils")) (:file "package") (:file "shape" :depends-on ("vec" "bounding-box" "body")) (:file "poly-shape" :depends-on ("shape")) (:file "squirl" :depends-on ("vec")) (:file "utils" :depends-on ("package")) (:file "vec" :depends-on ("utils")) (:file "world" :depends-on ("vec" "arbiter" "body")) (:file "world-hash" :depends-on ("hash-set" "vec")) (:module "constraints" :depends-on ("shape" "poly-shape" "arbiter") :components ((:file "breakable-joint" :depends-on ("constraints")) (:file "constraints" :depends-on ("util")) (:file "damped-rotary-spring" :depends-on ("spring")) (:file "damped-spring" :depends-on ("spring")) (:file "gear-joint" :depends-on ("constraints")) (:file "groove-joint" :depends-on ("constraints")) (:file "pin-joint" :depends-on ("constraints")) (:file "pivot-joint" :depends-on ("constraints")) (:file "ratchet-joint" :depends-on ("constraints")) (:file "rotary-limit-joint" :depends-on ("constraints")) (:file "simple-motor" :depends-on ("constraints")) (:file "slide-joint" :depends-on ("constraints")) (:file "spring" :depends-on ("constraints")) (:file "util")))))))
true
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; indent-tabs-mode: nil -*- (asdf:defsystem squirl :version "0.1" :maintainer "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :licence "MIT" :description "A pure lisp implementation of the Chipmunk 2D physics engine." :components ((:module "src" :components ((:file "arbiter" :depends-on ("vec" "shape" "collision" "contact")) (:file "body" :depends-on ("vec")) (:file "bounding-box" :depends-on ("vec")) (:file "collision" :depends-on ("shape" "poly-shape" "contact")) (:file "contact" :depends-on ("vec")) (:file "convenience" :depends-on ("body" "shape" "poly-shape" "vec")) (:file "hash-set" :depends-on ("utils")) (:file "package") (:file "shape" :depends-on ("vec" "bounding-box" "body")) (:file "poly-shape" :depends-on ("shape")) (:file "squirl" :depends-on ("vec")) (:file "utils" :depends-on ("package")) (:file "vec" :depends-on ("utils")) (:file "world" :depends-on ("vec" "arbiter" "body")) (:file "world-hash" :depends-on ("hash-set" "vec")) (:module "constraints" :depends-on ("shape" "poly-shape" "arbiter") :components ((:file "breakable-joint" :depends-on ("constraints")) (:file "constraints" :depends-on ("util")) (:file "damped-rotary-spring" :depends-on ("spring")) (:file "damped-spring" :depends-on ("spring")) (:file "gear-joint" :depends-on ("constraints")) (:file "groove-joint" :depends-on ("constraints")) (:file "pin-joint" :depends-on ("constraints")) (:file "pivot-joint" :depends-on ("constraints")) (:file "ratchet-joint" :depends-on ("constraints")) (:file "rotary-limit-joint" :depends-on ("constraints")) (:file "simple-motor" :depends-on ("constraints")) (:file "slide-joint" :depends-on ("constraints")) (:file "spring" :depends-on ("constraints")) (:file "util")))))))
[ { "context": "se function and with-disposable macro\"\n :author \"Chris Bagley\"\n :license \"BSD 2 Clause\"\n :serial t\n :compone", "end": 133, "score": 0.9998670816421509, "start": 121, "tag": "NAME", "value": "Chris Bagley" } ]
disposable.asd
cbaggers/disposable
0
;;;; disposable.asd (asdf:defsystem #:disposable :description "Dispose function and with-disposable macro" :author "Chris Bagley" :license "BSD 2 Clause" :serial t :components ((:file "package") (:file "disposable")))
47892
;;;; disposable.asd (asdf:defsystem #:disposable :description "Dispose function and with-disposable macro" :author "<NAME>" :license "BSD 2 Clause" :serial t :components ((:file "package") (:file "disposable")))
true
;;;; disposable.asd (asdf:defsystem #:disposable :description "Dispose function and with-disposable macro" :author "PI:NAME:<NAME>END_PI" :license "BSD 2 Clause" :serial t :components ((:file "package") (:file "disposable")))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 191, "score": 0.9998704791069031, "start": 174, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 211, "score": 0.9999292492866516, "start": 193, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/java/package.lsp
kazarmy/acl2
305
; Java Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "std/portcullis" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpkg "JAVA" (append (set-difference-eq *std-pkg-symbols* '(package-name pointers values)) '(*nil* *pkg-witness-name* *primitive-formals-and-guards* *stobjs-out-invalid* add-const-to-untranslate-preprocess add-suffix all-ffn-symbs all-fnnames all-fnnames-lst all-fnnames1 all-free/bound-vars all-vars-open all-vars-open-lst alpha/digit-chars alpha/digit/dash-charlist-p alpha/digit/uscore/dollar-charlist-p alpha/uscore/dollar-char-p arity+ bad-atom<= body bool char-downcase char-upcase chars=>nats check-if-call check-lambda-call check-list-call check-mv-let-call check-unary-lambda-call conjoin cons-listp cons-pos-alistp define-sk defmacro+ defthm-commutative deftutorial defxdoc+ doublets-to-alist dumb-occur-var-open dumb-occur-var-open-lst ensure-doublet-list$ ensure-function-name-list$ ensure-list-functions$ ensure-list-has-no-duplicates$ ensure-string-or-nil$ ensure-term-ground$ ensure-value-is-boolean$ ensure-value-is-function-name$ ensure-value-is-in-list$ ensure-value-is-string$ ensure-value-is-untranslated-term$ er-soft+ explode fargn fargs fcons-term fcons-term* ffn-symb ffn-symb-p flambda-applicationp flambdap flatten fmt-hard-right-margin fmt-soft-right-margin formals formals+ fquotep function-namep function-name-listp implicate implode impossible index-of integers-from-to irecursivep keyword-listp known-packages+ lambda-body lambda-formals logext loghead logic-fns-with-raw-code logicp lower-case-p make-lambda make-mv-let-call maybe-natp maybe-stringp msg-listp mvify nat nats=>string no-stobjs-p number-of-results+ organize-symbols-by-name organize-symbols-by-pkg packn packn-pos partition-rest-and-keyword-args patbind-fun patbind-run-unless patbind-run-when pos pos-listp primitivep printable-charlist-p program-fns-with-raw-code pseudo-fn-args-p pseudo-fn-p pseudo-lambda pseudo-lambda->body pseudo-lambda->formals pseudo-lambda-p pseudo-lambdap pseudo-term-call pseudo-term-call->args pseudo-term-call->fn pseudo-term-case pseudo-term-count pseudo-term-equiv pseudo-term-fix pseudo-term-fncall pseudo-term-fncall->args pseudo-term-fncall->fn pseudo-term-kind pseudo-term-lambda pseudo-term-lambda->args pseudo-term-lambda->body pseudo-term-lambda->formals pseudo-term-list-count pseudo-term-null pseudo-term-quote pseudo-term-quote->val pseudo-term-var pseudo-term-var->name pseudo-termfn-listp pseudo-termfnp pseudo-var-p pure-raw-p quote-listp rawp remove-assocs-eq remove-dead-if-branches remove-mbe-exec remove-mbe-logic remove-progn remove-trivial-vars remove-unused-vars sbyte8 sbyte8p sbyte8-listp sbyte16 sbyte16p sbyte16-listp sbyte32 sbyte32p sbyte32-listp sbyte64 sbyte64p sbyte64-listp sort-symbol-listp str-fix string-downcase string-string-alistp string-symbollist-alistp string-upcase subcor-var string=>nats symbol-list symbol-name-lst symbol-pos-alistp symbol-string-alistp symbol-symbol-alistp symbol-symbollist-alistp symbol-package-name-lst table-alist+ tail-recursive-p term-possible-numbers-of-results trans-eval tuplep typed-tuplep ubody ubody+ ubyte8 ubyte16 ubyte16p ubyte16-listp ubyte8=>hexchars ubyte8s=>hexstring uguard unnormalized-body unquote-term unquote-term-list unsigned-byte-listp upper-case-p variablep std::defret-mutual set::list-in str::chars-in-charset-p str::natstr)))
96826
; Java Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "std/portcullis" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpkg "JAVA" (append (set-difference-eq *std-pkg-symbols* '(package-name pointers values)) '(*nil* *pkg-witness-name* *primitive-formals-and-guards* *stobjs-out-invalid* add-const-to-untranslate-preprocess add-suffix all-ffn-symbs all-fnnames all-fnnames-lst all-fnnames1 all-free/bound-vars all-vars-open all-vars-open-lst alpha/digit-chars alpha/digit/dash-charlist-p alpha/digit/uscore/dollar-charlist-p alpha/uscore/dollar-char-p arity+ bad-atom<= body bool char-downcase char-upcase chars=>nats check-if-call check-lambda-call check-list-call check-mv-let-call check-unary-lambda-call conjoin cons-listp cons-pos-alistp define-sk defmacro+ defthm-commutative deftutorial defxdoc+ doublets-to-alist dumb-occur-var-open dumb-occur-var-open-lst ensure-doublet-list$ ensure-function-name-list$ ensure-list-functions$ ensure-list-has-no-duplicates$ ensure-string-or-nil$ ensure-term-ground$ ensure-value-is-boolean$ ensure-value-is-function-name$ ensure-value-is-in-list$ ensure-value-is-string$ ensure-value-is-untranslated-term$ er-soft+ explode fargn fargs fcons-term fcons-term* ffn-symb ffn-symb-p flambda-applicationp flambdap flatten fmt-hard-right-margin fmt-soft-right-margin formals formals+ fquotep function-namep function-name-listp implicate implode impossible index-of integers-from-to irecursivep keyword-listp known-packages+ lambda-body lambda-formals logext loghead logic-fns-with-raw-code logicp lower-case-p make-lambda make-mv-let-call maybe-natp maybe-stringp msg-listp mvify nat nats=>string no-stobjs-p number-of-results+ organize-symbols-by-name organize-symbols-by-pkg packn packn-pos partition-rest-and-keyword-args patbind-fun patbind-run-unless patbind-run-when pos pos-listp primitivep printable-charlist-p program-fns-with-raw-code pseudo-fn-args-p pseudo-fn-p pseudo-lambda pseudo-lambda->body pseudo-lambda->formals pseudo-lambda-p pseudo-lambdap pseudo-term-call pseudo-term-call->args pseudo-term-call->fn pseudo-term-case pseudo-term-count pseudo-term-equiv pseudo-term-fix pseudo-term-fncall pseudo-term-fncall->args pseudo-term-fncall->fn pseudo-term-kind pseudo-term-lambda pseudo-term-lambda->args pseudo-term-lambda->body pseudo-term-lambda->formals pseudo-term-list-count pseudo-term-null pseudo-term-quote pseudo-term-quote->val pseudo-term-var pseudo-term-var->name pseudo-termfn-listp pseudo-termfnp pseudo-var-p pure-raw-p quote-listp rawp remove-assocs-eq remove-dead-if-branches remove-mbe-exec remove-mbe-logic remove-progn remove-trivial-vars remove-unused-vars sbyte8 sbyte8p sbyte8-listp sbyte16 sbyte16p sbyte16-listp sbyte32 sbyte32p sbyte32-listp sbyte64 sbyte64p sbyte64-listp sort-symbol-listp str-fix string-downcase string-string-alistp string-symbollist-alistp string-upcase subcor-var string=>nats symbol-list symbol-name-lst symbol-pos-alistp symbol-string-alistp symbol-symbol-alistp symbol-symbollist-alistp symbol-package-name-lst table-alist+ tail-recursive-p term-possible-numbers-of-results trans-eval tuplep typed-tuplep ubody ubody+ ubyte8 ubyte16 ubyte16p ubyte16-listp ubyte8=>hexchars ubyte8s=>hexstring uguard unnormalized-body unquote-term unquote-term-list unsigned-byte-listp upper-case-p variablep std::defret-mutual set::list-in str::chars-in-charset-p str::natstr)))
true
; Java Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "std/portcullis" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpkg "JAVA" (append (set-difference-eq *std-pkg-symbols* '(package-name pointers values)) '(*nil* *pkg-witness-name* *primitive-formals-and-guards* *stobjs-out-invalid* add-const-to-untranslate-preprocess add-suffix all-ffn-symbs all-fnnames all-fnnames-lst all-fnnames1 all-free/bound-vars all-vars-open all-vars-open-lst alpha/digit-chars alpha/digit/dash-charlist-p alpha/digit/uscore/dollar-charlist-p alpha/uscore/dollar-char-p arity+ bad-atom<= body bool char-downcase char-upcase chars=>nats check-if-call check-lambda-call check-list-call check-mv-let-call check-unary-lambda-call conjoin cons-listp cons-pos-alistp define-sk defmacro+ defthm-commutative deftutorial defxdoc+ doublets-to-alist dumb-occur-var-open dumb-occur-var-open-lst ensure-doublet-list$ ensure-function-name-list$ ensure-list-functions$ ensure-list-has-no-duplicates$ ensure-string-or-nil$ ensure-term-ground$ ensure-value-is-boolean$ ensure-value-is-function-name$ ensure-value-is-in-list$ ensure-value-is-string$ ensure-value-is-untranslated-term$ er-soft+ explode fargn fargs fcons-term fcons-term* ffn-symb ffn-symb-p flambda-applicationp flambdap flatten fmt-hard-right-margin fmt-soft-right-margin formals formals+ fquotep function-namep function-name-listp implicate implode impossible index-of integers-from-to irecursivep keyword-listp known-packages+ lambda-body lambda-formals logext loghead logic-fns-with-raw-code logicp lower-case-p make-lambda make-mv-let-call maybe-natp maybe-stringp msg-listp mvify nat nats=>string no-stobjs-p number-of-results+ organize-symbols-by-name organize-symbols-by-pkg packn packn-pos partition-rest-and-keyword-args patbind-fun patbind-run-unless patbind-run-when pos pos-listp primitivep printable-charlist-p program-fns-with-raw-code pseudo-fn-args-p pseudo-fn-p pseudo-lambda pseudo-lambda->body pseudo-lambda->formals pseudo-lambda-p pseudo-lambdap pseudo-term-call pseudo-term-call->args pseudo-term-call->fn pseudo-term-case pseudo-term-count pseudo-term-equiv pseudo-term-fix pseudo-term-fncall pseudo-term-fncall->args pseudo-term-fncall->fn pseudo-term-kind pseudo-term-lambda pseudo-term-lambda->args pseudo-term-lambda->body pseudo-term-lambda->formals pseudo-term-list-count pseudo-term-null pseudo-term-quote pseudo-term-quote->val pseudo-term-var pseudo-term-var->name pseudo-termfn-listp pseudo-termfnp pseudo-var-p pure-raw-p quote-listp rawp remove-assocs-eq remove-dead-if-branches remove-mbe-exec remove-mbe-logic remove-progn remove-trivial-vars remove-unused-vars sbyte8 sbyte8p sbyte8-listp sbyte16 sbyte16p sbyte16-listp sbyte32 sbyte32p sbyte32-listp sbyte64 sbyte64p sbyte64-listp sort-symbol-listp str-fix string-downcase string-string-alistp string-symbollist-alistp string-upcase subcor-var string=>nats symbol-list symbol-name-lst symbol-pos-alistp symbol-string-alistp symbol-symbol-alistp symbol-symbollist-alistp symbol-package-name-lst table-alist+ tail-recursive-p term-possible-numbers-of-results trans-eval tuplep typed-tuplep ubody ubody+ ubyte8 ubyte16 ubyte16p ubyte16-listp ubyte8=>hexchars ubyte8s=>hexstring uguard unnormalized-body unquote-term unquote-term-list unsigned-byte-listp upper-case-p variablep std::defret-mutual set::list-in str::chars-in-charset-p str::natstr)))
[ { "context": ";;; Gene Kim 7-23-2018\n;;;\n;;; Code for high-level inference m", "end": 12, "score": 0.9995343685150146, "start": 4, "tag": "NAME", "value": "Gene Kim" } ]
inference.lisp
genelkim/ulf-fracas
0
;;; Gene Kim 7-23-2018 ;;; ;;; Code for high-level inference management. ;;; This is loaded last because it refers to functions defined in all the other ;;; components. (in-package :ulf-fracas) ;; Creating the d1 and d2 labels for the conversion rule (defparameter *d1* (list 'some.d 'a.d 'an.d 'no.d)) (defparameter *d2* (list 'some.d 'a.d 'an.d)) ;; Function that checks if the list given is in the form of the upper ;; part of the conversion formula. The form: ;; ((*d1* <pred>) ((<tense> be.v) (= (*d2* <pred>)))) (defun is-conversion-form (inulf) (util:in-intern (inulf ulf :ulf-fracas) (and (listp ulf) (= (length ulf) 2) ; (*d1* <pred>) (listp (first ulf)) (= (length (first ulf)) 2) (member (first (first ulf)) *d1*) (ulf-lib:pred? (second (first ulf))) ; ((<tense> be.v) (= (*d2* <pred>))) (listp (second ulf)) (= (length (second ulf)) 2) (let ((tbe (first (second ulf))) (eqd2pred (second (second ulf)))) (and ; (<tense> be.v) (listp tbe) (= (length tbe) 2) (ulf-lib:lex-tense? (first tbe)) (equal (second tbe) 'be.v) ; (= (*d2* <pred>)) (listp eqd2pred) (= (length eqd2pred) 2) (equal (first eqd2pred) '=) ; (*d2* <pred>) (listp (second eqd2pred)) (= (length (second eqd2pred)) 2) (member (first (second eqd2pred)) *d2*) (ulf-lib:pred? (second (second eqd2pred)))))))) ;; Conversion rule that returns the lower part of the formula and ;; takes as an input the upper part of the formula (defun conversion-rule (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (if (is-conversion-form ulf) ; We've checked the form so we can expand it safely. (let* ((d1 (first (first ulf))) (p1 (second (first ulf))) (vp (second ulf)) ; ((<tense> be.v) (= (*d2* pred2))) (tense (first (first vp))) (d2 (first (second (second vp)))) (p2 (second (second (second vp))))) ; Rebuild, replacing the two predicates. (list (list d1 p2) (list (list tense 'be.v) (list '= (list d2 p1)))))))) (util:memoize 'conversion-rule) (defun uci-list (ulf) (let ((res (conversion-rule-ttt ulf))) (if (and (not (null res)) (not (equal res ulf))) (list res) nil))) (defun uci-list-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from uci-list. Finds the two points where the result and source diverge and just swaps the polarities of those two subtrees. Since the conversion rule only works when both the subject and object of the copula have indefinites or no.d scoping, which have symmetric polarities on the restrictor and body, we can do this without keeping track of the scoping relations. Arguments: ulf: The resulting ULF src-ulfs: List of ULFs (in this case with one element) that led to ULF. Returns: A polarity marked version of `ulf` based on the sources." (assert (= 1 (length src-ulfs))) (labels ((apply-polarity-with-divergence-map (curmlulf srcmlulf divergence-map topsrcml) "Applies the polarity from a source taking account subtree movement through a divergence map. The divergence map gives the corresponding index position of the second tree at points of divergence. At these points, the current second tree is replaced with point marked in the divergence map. Arguments: curmlulf: The multi-labeled-tree-node for the current ULF. srcmlulf: The multi-labeled-tree-node for the source ULF, including polarity. divergence-map: A list of two elements mapping the curmlulf index to the corresponding srcmlulf index when the trees diverge. topsrcml: The multi-labeled-tree for the top of the source ULF (for accessing subtrees at divergences) Returns: A labeled-tree with the polarity markings of curmlulf." (let ((cur-srcmlulf srcmlulf) (curexpr (expr curmlulf)) curpol) ;; At a divergence, replace srcmlulf using the divergence map. (when (assoc (index curmlulf) divergence-map) (setf cur-srcmlulf (node-at-index topsrcml (cdr (assoc (index curmlulf) divergence-map))))) (setf curpol (get-label-from-key topsrcml 'polarity (index cur-srcmlulf))) (cond ;; Base case. ((atom (expr curmlulf)) (make-instance 'labeled-tree :expr curexpr :label curpol)) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (curchild srcchild) (apply-polarity-with-divergence-map curchild srcchild divergence-map topsrcml)) (expr curmlulf) (expr cur-srcmlulf)) :label curpol)))))) ; end of labels defs ;; Main body of labels. (let* ((src-mulf (get-infer-nlog-marked-ulf (first src-ulfs))) (reslulf (dfs-label-tree ulf)) (srclulf (dfs-label-tree (first src-ulfs))) (divergences (find-divergences reslulf srclulf)) ;; Build the multi-label trees. (resmlulf (build-multi-labeled-tree reslulf nil nil)) (srcmlulf (build-multi-labeled-tree srclulf (list src-mulf) '(polarity))) divergence-map) (assert (= 2 (length divergences))) ;; Swap the indices of the divergences. (setf divergence-map (list (cons (car (first divergences)) (cdr (second divergences))) (cons (car (second divergences)) (cdr (first divergences))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergence-map (root resmlulf) (root srcmlulf) divergence-map srcmlulf))))) ;; Register this function for marking dispatch. (setf (gethash 'uci-list *infer-nlog-marking-dispatch-fn-ht*) #'uci-list-marking-from-source-dispatch) (defun conversion-rule-ttt (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (ttt:apply-rules '((/ (((!1 some.d a.d an.d no.d) (!2 pred?)) ; matches (d1 pred1) (((!3 lex-tense?) be.v) ; matches (tense be.v) (= ((!4 some.d a.d an.d) (!5 pred?))))) ; matches (= (d2 pred2)) ; rebuild swapping pred1 (!2) and pred2 (!5) ((!1 !5) ((!3 be.v) (= (!4 !2)))))) ulf))) (util:memoize 'conversion-rule-ttt) ;; Matches a monotonicity rule ULF ;; ((every.d/all.d P1) ((pres be.v) (= (indef.d/k P2)))) ;; or more generally ;; ((every.d/all.d P1) ((pres be.v) <pred>)) (defun mon-form? (inulf) (in-intern (inulf ulf :ulf-fracas) (ttt:match-expr '(((! every.d all.d) pred?) ((pres be.v) ; this is redundant (! (= ((! a.d an.d k) pred?)) pred?))) ulf))) ;; Extracts the first predicate from a monotonicity ULF. (defun get-mon-p1 (ulf) (second (first ulf))) ;; Extracts the second predicate from a monotonicity ULF. ;; If it is a noun (= (indef/k <pred>)), simply pull it out. ;; If it's not a noun, turn it into one with (n+preds thing.n (that.rel ((pres be.v) <pred>))) (defun get-mon-p2 (ulf) (cond ;; Simple noun case. ((ttt:match-expr '(_! ; subj (_! ; copula (= ((! a.d an.d k some.d) pred?)))) ulf) (second (second (second (second ulf))))) ;; Simple term case. ((ttt:match-expr '(_! (_! (= term?))) ulf) (second (second ulf))) ;; General case. (t (let ((rawpred (second (second ulf)))) (list 'n+preds 'thing.n (list 'that.rel (list '(pres be.v) rawpred))))))) ;; Helper function that checks the polarity of a predicate and ;; its determiner, switches p1 with p2 ;; and adds the change to the list of ULFs returned ;; ;; Arguments: ;; curpred - predicate to replace ;; newpred - the new value for the replaced predicate ;; b - marked ULF ;; bu - unmarked ULF ;; pol - polarity of the predicate context (defun tr-switch-pred (curpred newpred b bu pol) ;; The base case is of the form: ;; (pred1 pol) (cond ((and (ulf-lib:pred? bu) (equal bu curpred) (equal (global-polarity b) pol)) ;; replace curpred with newpred. No need to recurse since curpred won't ;; match any subcomponent of bu. (list newpred)) ;; Special case: the cur and new preds are both equality with a term and we ;; found a matching term. Ignore the equal signs and just replace the terms. ((and (listp curpred) (= 2 (length curpred)) (eql '= (first curpred)) (listp newpred) (= 2 (length newpred)) (eql '= (first newpred)) (equal (second curpred) bu) (equal (global-polarity b) pol)) (list (second newpred))) ((listp bu) (apply #'append (mapcar (lambda (i) (index-recurse i curpred newpred (get-ulf b) bu pol)) (range (length bu))))) (t nil))) (defun range (max &key (min 0) (step 1)) (loop for n from min below max by step collect n)) ;; Recurses into the current index and returns the value with the results of ;; the recursion inserted into the correct position of the input formula. (defun index-recurse (i cp np b bu pol) (let* ((c (nth i b)) (cu (nth i bu)) (recval (tr-switch-pred cp np c cu pol)) (pre-slice (subseq bu 0 i)) (post-slice (subseq bu (1+ i)))) (mapcar (lambda (x) (append pre-slice (list x) post-slice)) recval))) ;; Monotonicity rule that returns the lower part of the formula and ;; takes as an input the upper parts of the formula ;; {in}definite-det? --> use to check delta (defun umi-positive-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf1) (get-mon-p2 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '+)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf2) (get-mon-p2 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '+)))) results)))) (defun umi-negative-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf1) (get-mon-p1 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '-)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf2) (get-mon-p1 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '-)))) results)))) ;;; Dispatch Fn ;;; 1. Get divergences between result and the two inputs, the one with fewer divergences is the basis function, the other is the monotonicity rule. ;;; 2. Get the polarity marking of the basis ;;; 3. Get the polarity marking of the corresponding predicate of the monotonicity rule. ;;; 4. Use the polarity marking of the basis, until the divergence. At the divergence, use the predicate polarity. No polarity flipping is necessary since negative contexts lead to the antecedent which is also in negative context adn vice versa. (defun umi-marking-dispatch-fn (ulf src-ulfs) "Dispatch polarity marking function for UMI rules." (assert (= 2 (length src-ulfs))) (labels ((apply-polarity-with-divergences (reslulf basis-mulf basis-divergence-point mon-mulf in-divergence) "Given divergence point and current divergence state transfers polarity from the source ulfs to the result ulf." (let ((in-divergence (or in-divergence (= (label reslulf) basis-divergence-point)))) (cond ;; In divergence and match with monotonicity predicate, use the monotonicity predicate. ((and in-divergence (equal (unlabeled-tree reslulf) (unlabeled-tree mon-mulf))) mon-mulf) ;; In divergence and atom. ((and in-divergence (atom (expr reslulf))) (make-instance 'labeled-tree :expr (expr reslulf) :label (label mon-mulf))) ;; Otherwise in divergence, recurse and label current monotonicity with top of predicate. (in-divergence (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild) (apply-polarity-with-divergences reschild nil ; not used in divergence basis-divergence-point mon-mulf in-divergence)) (expr reslulf)) :label (label mon-mulf))) ;; Base case. ((atom (expr reslulf)) (make-instance 'labeled-tree :expr (expr reslulf) :label (label basis-mulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild basis-child) (apply-polarity-with-divergences reschild basis-child basis-divergence-point mon-mulf in-divergence)) (expr reslulf) (expr basis-mulf)) :label (label basis-mulf)))))) (get-antecedent-pred-mon (mon-mulf) "Gets the antecedent predicate of a monotonicity rule mulf." (second (expr (first (expr mon-mulf))))) (get-consequent-pred-mon (mon-mulf) "Gets the consequent predicate of a monotonicity rule mulf." ;; ((<det> <pred1>) ((<tense> be.v) <pred2>)) (second (expr (second (expr mon-mulf))))) (common-ancestor (lulf points) "Returns the index of the lowest common ancestor of the given list of points." ;; Returns a list of completed points if incomplete a number for the index if complete. (let* ((curres (if (member (label lulf) points) (list (label lulf)) nil)) (all-recres curres)) (cond ((atom (expr lulf)) curres) (t (loop for child in (expr lulf) do (let ((recres (common-ancestor child points))) (if (numberp recres) ;; Recursive result is complete, just go back up. (return-from common-ancestor recres) ;; Add recursive result. (setf all-recres (append all-recres recres))))) (setf all-recres (remove-duplicates all-recres)) (if (= (length all-recres) (length points)) (label lulf) all-recres)))))) ;; Labels body. (let* ((reslulf (dfs-label-tree ulf)) (srclulfs (mapcar #'dfs-label-tree src-ulfs)) (srcmulfs (mapcar #'get-infer-nlog-marked-ulf src-ulfs)) (src-divergences (mapcar #'(lambda (srclulf) (find-divergences reslulf srclulf)) srclulfs)) (basis-idx (cond ;; Basis is the non monotonicity rule format, if only one fits that. ((and (mon-form? (first src-ulfs)) (not (mon-form? (second src-ulfs)))) 1) ((and (not (mon-form? (first src-ulfs))) (mon-form? (second src-ulfs))) 0) ;; Otherwise, the basis is the one with fewer divergences. ((<= (length (first src-divergences)) (length (second src-divergences))) 0) (t 1))) (mon-idx (- 1 basis-idx)) (basis-mulf (nth basis-idx srcmulfs)) (basis-mlulf (build-multi-labeled-tree (nth basis-idx srclulfs) (list basis-mulf) '(polarity))) (basis-divergences (nth basis-idx src-divergences)) (basis-divergence-point (common-ancestor reslulf (mapcar #'car basis-divergences))) (basis-divergence-src-pt (common-ancestor (nth basis-idx srclulfs) (mapcar #'cdr basis-divergences))) (mon-mulf (if (eql '- (get-label-from-key basis-mlulf 'polarity basis-divergence-src-pt)) (get-antecedent-pred-mon (nth mon-idx srcmulfs)) (get-consequent-pred-mon (nth mon-idx srcmulfs))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergences reslulf basis-mulf basis-divergence-point mon-mulf nil))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'umi-positive-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) (setf (gethash 'umi-negative-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) ;;; ;;; Negations ;;; (defun neg-elim (ulf) (if (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf) (list (second (second ulf))) nil)) (defun neg-intro (ulf) (if (not (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf)) (list (list 'not (list 'not ulf))))) (defun replace-ab (a b ulf) (labels ((idx-recurse (i) (let ((recval (replace-ab a b (nth i ulf))) (pre (subseq ulf 0 i)) (post (subseq ulf (1+ i)))) (mapcar (lambda (x) (append pre (list x) post)) recval)))) ; labels body (cond ((equal a ulf) (list b)) ((atom ulf) nil) (t (apply #'append (mapcar (lambda (i) (idx-recurse i)) (range (length ulf)))))))) (defun no2notindef (ulf) (let ((no2indefs (apply #'append (mapcar #'(lambda (indef) (replace-ab 'no.d indef ulf)) '(some.d a.d an.d))))) ; Add 'not at the top-level of all the formulas. (mapcar #'(lambda (newulf) (list 'not newulf)) no2indefs))) (defun no2notindef-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from no2notindef." ;; 1. Strip top-level not from the result. ;; 2. Map over all of the same polarities. ;; 3. Make the top-level polarity negative and then add the not back in with ;; a positive polarity there. (assert (= 1 (length src-ulfs))) (labels ((transfer-polarities (ulf srcmulf) "Builds a marked ULF with `ulf` values and `srcmulf` polarities. Both must have the same shape." (cond ;; Base case. ((atom ulf) (make-instance 'labeled-tree :expr ulf :label (global-polarity srcmulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'transfer-polarities ulf (get-ulf srcmulf)) :label (global-polarity srcmulf)))))) ;; Main body. (labeled-tree-to-marked-ulf (let ((core-form (transfer-polarities (second ulf) (get-infer-nlog-marked-ulf (first src-ulfs))))) (setf (label core-form) '-) (make-instance 'labeled-tree :expr (list (make-instance 'labeled-tree :expr 'not :label '+) core-form) :label '+))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'no2notindef *infer-nlog-marking-dispatch-fn-ht*) #'no2notindef-marking-from-source-dispatch)
21369
;;; <NAME> 7-23-2018 ;;; ;;; Code for high-level inference management. ;;; This is loaded last because it refers to functions defined in all the other ;;; components. (in-package :ulf-fracas) ;; Creating the d1 and d2 labels for the conversion rule (defparameter *d1* (list 'some.d 'a.d 'an.d 'no.d)) (defparameter *d2* (list 'some.d 'a.d 'an.d)) ;; Function that checks if the list given is in the form of the upper ;; part of the conversion formula. The form: ;; ((*d1* <pred>) ((<tense> be.v) (= (*d2* <pred>)))) (defun is-conversion-form (inulf) (util:in-intern (inulf ulf :ulf-fracas) (and (listp ulf) (= (length ulf) 2) ; (*d1* <pred>) (listp (first ulf)) (= (length (first ulf)) 2) (member (first (first ulf)) *d1*) (ulf-lib:pred? (second (first ulf))) ; ((<tense> be.v) (= (*d2* <pred>))) (listp (second ulf)) (= (length (second ulf)) 2) (let ((tbe (first (second ulf))) (eqd2pred (second (second ulf)))) (and ; (<tense> be.v) (listp tbe) (= (length tbe) 2) (ulf-lib:lex-tense? (first tbe)) (equal (second tbe) 'be.v) ; (= (*d2* <pred>)) (listp eqd2pred) (= (length eqd2pred) 2) (equal (first eqd2pred) '=) ; (*d2* <pred>) (listp (second eqd2pred)) (= (length (second eqd2pred)) 2) (member (first (second eqd2pred)) *d2*) (ulf-lib:pred? (second (second eqd2pred)))))))) ;; Conversion rule that returns the lower part of the formula and ;; takes as an input the upper part of the formula (defun conversion-rule (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (if (is-conversion-form ulf) ; We've checked the form so we can expand it safely. (let* ((d1 (first (first ulf))) (p1 (second (first ulf))) (vp (second ulf)) ; ((<tense> be.v) (= (*d2* pred2))) (tense (first (first vp))) (d2 (first (second (second vp)))) (p2 (second (second (second vp))))) ; Rebuild, replacing the two predicates. (list (list d1 p2) (list (list tense 'be.v) (list '= (list d2 p1)))))))) (util:memoize 'conversion-rule) (defun uci-list (ulf) (let ((res (conversion-rule-ttt ulf))) (if (and (not (null res)) (not (equal res ulf))) (list res) nil))) (defun uci-list-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from uci-list. Finds the two points where the result and source diverge and just swaps the polarities of those two subtrees. Since the conversion rule only works when both the subject and object of the copula have indefinites or no.d scoping, which have symmetric polarities on the restrictor and body, we can do this without keeping track of the scoping relations. Arguments: ulf: The resulting ULF src-ulfs: List of ULFs (in this case with one element) that led to ULF. Returns: A polarity marked version of `ulf` based on the sources." (assert (= 1 (length src-ulfs))) (labels ((apply-polarity-with-divergence-map (curmlulf srcmlulf divergence-map topsrcml) "Applies the polarity from a source taking account subtree movement through a divergence map. The divergence map gives the corresponding index position of the second tree at points of divergence. At these points, the current second tree is replaced with point marked in the divergence map. Arguments: curmlulf: The multi-labeled-tree-node for the current ULF. srcmlulf: The multi-labeled-tree-node for the source ULF, including polarity. divergence-map: A list of two elements mapping the curmlulf index to the corresponding srcmlulf index when the trees diverge. topsrcml: The multi-labeled-tree for the top of the source ULF (for accessing subtrees at divergences) Returns: A labeled-tree with the polarity markings of curmlulf." (let ((cur-srcmlulf srcmlulf) (curexpr (expr curmlulf)) curpol) ;; At a divergence, replace srcmlulf using the divergence map. (when (assoc (index curmlulf) divergence-map) (setf cur-srcmlulf (node-at-index topsrcml (cdr (assoc (index curmlulf) divergence-map))))) (setf curpol (get-label-from-key topsrcml 'polarity (index cur-srcmlulf))) (cond ;; Base case. ((atom (expr curmlulf)) (make-instance 'labeled-tree :expr curexpr :label curpol)) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (curchild srcchild) (apply-polarity-with-divergence-map curchild srcchild divergence-map topsrcml)) (expr curmlulf) (expr cur-srcmlulf)) :label curpol)))))) ; end of labels defs ;; Main body of labels. (let* ((src-mulf (get-infer-nlog-marked-ulf (first src-ulfs))) (reslulf (dfs-label-tree ulf)) (srclulf (dfs-label-tree (first src-ulfs))) (divergences (find-divergences reslulf srclulf)) ;; Build the multi-label trees. (resmlulf (build-multi-labeled-tree reslulf nil nil)) (srcmlulf (build-multi-labeled-tree srclulf (list src-mulf) '(polarity))) divergence-map) (assert (= 2 (length divergences))) ;; Swap the indices of the divergences. (setf divergence-map (list (cons (car (first divergences)) (cdr (second divergences))) (cons (car (second divergences)) (cdr (first divergences))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergence-map (root resmlulf) (root srcmlulf) divergence-map srcmlulf))))) ;; Register this function for marking dispatch. (setf (gethash 'uci-list *infer-nlog-marking-dispatch-fn-ht*) #'uci-list-marking-from-source-dispatch) (defun conversion-rule-ttt (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (ttt:apply-rules '((/ (((!1 some.d a.d an.d no.d) (!2 pred?)) ; matches (d1 pred1) (((!3 lex-tense?) be.v) ; matches (tense be.v) (= ((!4 some.d a.d an.d) (!5 pred?))))) ; matches (= (d2 pred2)) ; rebuild swapping pred1 (!2) and pred2 (!5) ((!1 !5) ((!3 be.v) (= (!4 !2)))))) ulf))) (util:memoize 'conversion-rule-ttt) ;; Matches a monotonicity rule ULF ;; ((every.d/all.d P1) ((pres be.v) (= (indef.d/k P2)))) ;; or more generally ;; ((every.d/all.d P1) ((pres be.v) <pred>)) (defun mon-form? (inulf) (in-intern (inulf ulf :ulf-fracas) (ttt:match-expr '(((! every.d all.d) pred?) ((pres be.v) ; this is redundant (! (= ((! a.d an.d k) pred?)) pred?))) ulf))) ;; Extracts the first predicate from a monotonicity ULF. (defun get-mon-p1 (ulf) (second (first ulf))) ;; Extracts the second predicate from a monotonicity ULF. ;; If it is a noun (= (indef/k <pred>)), simply pull it out. ;; If it's not a noun, turn it into one with (n+preds thing.n (that.rel ((pres be.v) <pred>))) (defun get-mon-p2 (ulf) (cond ;; Simple noun case. ((ttt:match-expr '(_! ; subj (_! ; copula (= ((! a.d an.d k some.d) pred?)))) ulf) (second (second (second (second ulf))))) ;; Simple term case. ((ttt:match-expr '(_! (_! (= term?))) ulf) (second (second ulf))) ;; General case. (t (let ((rawpred (second (second ulf)))) (list 'n+preds 'thing.n (list 'that.rel (list '(pres be.v) rawpred))))))) ;; Helper function that checks the polarity of a predicate and ;; its determiner, switches p1 with p2 ;; and adds the change to the list of ULFs returned ;; ;; Arguments: ;; curpred - predicate to replace ;; newpred - the new value for the replaced predicate ;; b - marked ULF ;; bu - unmarked ULF ;; pol - polarity of the predicate context (defun tr-switch-pred (curpred newpred b bu pol) ;; The base case is of the form: ;; (pred1 pol) (cond ((and (ulf-lib:pred? bu) (equal bu curpred) (equal (global-polarity b) pol)) ;; replace curpred with newpred. No need to recurse since curpred won't ;; match any subcomponent of bu. (list newpred)) ;; Special case: the cur and new preds are both equality with a term and we ;; found a matching term. Ignore the equal signs and just replace the terms. ((and (listp curpred) (= 2 (length curpred)) (eql '= (first curpred)) (listp newpred) (= 2 (length newpred)) (eql '= (first newpred)) (equal (second curpred) bu) (equal (global-polarity b) pol)) (list (second newpred))) ((listp bu) (apply #'append (mapcar (lambda (i) (index-recurse i curpred newpred (get-ulf b) bu pol)) (range (length bu))))) (t nil))) (defun range (max &key (min 0) (step 1)) (loop for n from min below max by step collect n)) ;; Recurses into the current index and returns the value with the results of ;; the recursion inserted into the correct position of the input formula. (defun index-recurse (i cp np b bu pol) (let* ((c (nth i b)) (cu (nth i bu)) (recval (tr-switch-pred cp np c cu pol)) (pre-slice (subseq bu 0 i)) (post-slice (subseq bu (1+ i)))) (mapcar (lambda (x) (append pre-slice (list x) post-slice)) recval))) ;; Monotonicity rule that returns the lower part of the formula and ;; takes as an input the upper parts of the formula ;; {in}definite-det? --> use to check delta (defun umi-positive-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf1) (get-mon-p2 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '+)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf2) (get-mon-p2 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '+)))) results)))) (defun umi-negative-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf1) (get-mon-p1 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '-)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf2) (get-mon-p1 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '-)))) results)))) ;;; Dispatch Fn ;;; 1. Get divergences between result and the two inputs, the one with fewer divergences is the basis function, the other is the monotonicity rule. ;;; 2. Get the polarity marking of the basis ;;; 3. Get the polarity marking of the corresponding predicate of the monotonicity rule. ;;; 4. Use the polarity marking of the basis, until the divergence. At the divergence, use the predicate polarity. No polarity flipping is necessary since negative contexts lead to the antecedent which is also in negative context adn vice versa. (defun umi-marking-dispatch-fn (ulf src-ulfs) "Dispatch polarity marking function for UMI rules." (assert (= 2 (length src-ulfs))) (labels ((apply-polarity-with-divergences (reslulf basis-mulf basis-divergence-point mon-mulf in-divergence) "Given divergence point and current divergence state transfers polarity from the source ulfs to the result ulf." (let ((in-divergence (or in-divergence (= (label reslulf) basis-divergence-point)))) (cond ;; In divergence and match with monotonicity predicate, use the monotonicity predicate. ((and in-divergence (equal (unlabeled-tree reslulf) (unlabeled-tree mon-mulf))) mon-mulf) ;; In divergence and atom. ((and in-divergence (atom (expr reslulf))) (make-instance 'labeled-tree :expr (expr reslulf) :label (label mon-mulf))) ;; Otherwise in divergence, recurse and label current monotonicity with top of predicate. (in-divergence (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild) (apply-polarity-with-divergences reschild nil ; not used in divergence basis-divergence-point mon-mulf in-divergence)) (expr reslulf)) :label (label mon-mulf))) ;; Base case. ((atom (expr reslulf)) (make-instance 'labeled-tree :expr (expr reslulf) :label (label basis-mulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild basis-child) (apply-polarity-with-divergences reschild basis-child basis-divergence-point mon-mulf in-divergence)) (expr reslulf) (expr basis-mulf)) :label (label basis-mulf)))))) (get-antecedent-pred-mon (mon-mulf) "Gets the antecedent predicate of a monotonicity rule mulf." (second (expr (first (expr mon-mulf))))) (get-consequent-pred-mon (mon-mulf) "Gets the consequent predicate of a monotonicity rule mulf." ;; ((<det> <pred1>) ((<tense> be.v) <pred2>)) (second (expr (second (expr mon-mulf))))) (common-ancestor (lulf points) "Returns the index of the lowest common ancestor of the given list of points." ;; Returns a list of completed points if incomplete a number for the index if complete. (let* ((curres (if (member (label lulf) points) (list (label lulf)) nil)) (all-recres curres)) (cond ((atom (expr lulf)) curres) (t (loop for child in (expr lulf) do (let ((recres (common-ancestor child points))) (if (numberp recres) ;; Recursive result is complete, just go back up. (return-from common-ancestor recres) ;; Add recursive result. (setf all-recres (append all-recres recres))))) (setf all-recres (remove-duplicates all-recres)) (if (= (length all-recres) (length points)) (label lulf) all-recres)))))) ;; Labels body. (let* ((reslulf (dfs-label-tree ulf)) (srclulfs (mapcar #'dfs-label-tree src-ulfs)) (srcmulfs (mapcar #'get-infer-nlog-marked-ulf src-ulfs)) (src-divergences (mapcar #'(lambda (srclulf) (find-divergences reslulf srclulf)) srclulfs)) (basis-idx (cond ;; Basis is the non monotonicity rule format, if only one fits that. ((and (mon-form? (first src-ulfs)) (not (mon-form? (second src-ulfs)))) 1) ((and (not (mon-form? (first src-ulfs))) (mon-form? (second src-ulfs))) 0) ;; Otherwise, the basis is the one with fewer divergences. ((<= (length (first src-divergences)) (length (second src-divergences))) 0) (t 1))) (mon-idx (- 1 basis-idx)) (basis-mulf (nth basis-idx srcmulfs)) (basis-mlulf (build-multi-labeled-tree (nth basis-idx srclulfs) (list basis-mulf) '(polarity))) (basis-divergences (nth basis-idx src-divergences)) (basis-divergence-point (common-ancestor reslulf (mapcar #'car basis-divergences))) (basis-divergence-src-pt (common-ancestor (nth basis-idx srclulfs) (mapcar #'cdr basis-divergences))) (mon-mulf (if (eql '- (get-label-from-key basis-mlulf 'polarity basis-divergence-src-pt)) (get-antecedent-pred-mon (nth mon-idx srcmulfs)) (get-consequent-pred-mon (nth mon-idx srcmulfs))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergences reslulf basis-mulf basis-divergence-point mon-mulf nil))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'umi-positive-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) (setf (gethash 'umi-negative-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) ;;; ;;; Negations ;;; (defun neg-elim (ulf) (if (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf) (list (second (second ulf))) nil)) (defun neg-intro (ulf) (if (not (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf)) (list (list 'not (list 'not ulf))))) (defun replace-ab (a b ulf) (labels ((idx-recurse (i) (let ((recval (replace-ab a b (nth i ulf))) (pre (subseq ulf 0 i)) (post (subseq ulf (1+ i)))) (mapcar (lambda (x) (append pre (list x) post)) recval)))) ; labels body (cond ((equal a ulf) (list b)) ((atom ulf) nil) (t (apply #'append (mapcar (lambda (i) (idx-recurse i)) (range (length ulf)))))))) (defun no2notindef (ulf) (let ((no2indefs (apply #'append (mapcar #'(lambda (indef) (replace-ab 'no.d indef ulf)) '(some.d a.d an.d))))) ; Add 'not at the top-level of all the formulas. (mapcar #'(lambda (newulf) (list 'not newulf)) no2indefs))) (defun no2notindef-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from no2notindef." ;; 1. Strip top-level not from the result. ;; 2. Map over all of the same polarities. ;; 3. Make the top-level polarity negative and then add the not back in with ;; a positive polarity there. (assert (= 1 (length src-ulfs))) (labels ((transfer-polarities (ulf srcmulf) "Builds a marked ULF with `ulf` values and `srcmulf` polarities. Both must have the same shape." (cond ;; Base case. ((atom ulf) (make-instance 'labeled-tree :expr ulf :label (global-polarity srcmulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'transfer-polarities ulf (get-ulf srcmulf)) :label (global-polarity srcmulf)))))) ;; Main body. (labeled-tree-to-marked-ulf (let ((core-form (transfer-polarities (second ulf) (get-infer-nlog-marked-ulf (first src-ulfs))))) (setf (label core-form) '-) (make-instance 'labeled-tree :expr (list (make-instance 'labeled-tree :expr 'not :label '+) core-form) :label '+))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'no2notindef *infer-nlog-marking-dispatch-fn-ht*) #'no2notindef-marking-from-source-dispatch)
true
;;; PI:NAME:<NAME>END_PI 7-23-2018 ;;; ;;; Code for high-level inference management. ;;; This is loaded last because it refers to functions defined in all the other ;;; components. (in-package :ulf-fracas) ;; Creating the d1 and d2 labels for the conversion rule (defparameter *d1* (list 'some.d 'a.d 'an.d 'no.d)) (defparameter *d2* (list 'some.d 'a.d 'an.d)) ;; Function that checks if the list given is in the form of the upper ;; part of the conversion formula. The form: ;; ((*d1* <pred>) ((<tense> be.v) (= (*d2* <pred>)))) (defun is-conversion-form (inulf) (util:in-intern (inulf ulf :ulf-fracas) (and (listp ulf) (= (length ulf) 2) ; (*d1* <pred>) (listp (first ulf)) (= (length (first ulf)) 2) (member (first (first ulf)) *d1*) (ulf-lib:pred? (second (first ulf))) ; ((<tense> be.v) (= (*d2* <pred>))) (listp (second ulf)) (= (length (second ulf)) 2) (let ((tbe (first (second ulf))) (eqd2pred (second (second ulf)))) (and ; (<tense> be.v) (listp tbe) (= (length tbe) 2) (ulf-lib:lex-tense? (first tbe)) (equal (second tbe) 'be.v) ; (= (*d2* <pred>)) (listp eqd2pred) (= (length eqd2pred) 2) (equal (first eqd2pred) '=) ; (*d2* <pred>) (listp (second eqd2pred)) (= (length (second eqd2pred)) 2) (member (first (second eqd2pred)) *d2*) (ulf-lib:pred? (second (second eqd2pred)))))))) ;; Conversion rule that returns the lower part of the formula and ;; takes as an input the upper part of the formula (defun conversion-rule (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (if (is-conversion-form ulf) ; We've checked the form so we can expand it safely. (let* ((d1 (first (first ulf))) (p1 (second (first ulf))) (vp (second ulf)) ; ((<tense> be.v) (= (*d2* pred2))) (tense (first (first vp))) (d2 (first (second (second vp)))) (p2 (second (second (second vp))))) ; Rebuild, replacing the two predicates. (list (list d1 p2) (list (list tense 'be.v) (list '= (list d2 p1)))))))) (util:memoize 'conversion-rule) (defun uci-list (ulf) (let ((res (conversion-rule-ttt ulf))) (if (and (not (null res)) (not (equal res ulf))) (list res) nil))) (defun uci-list-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from uci-list. Finds the two points where the result and source diverge and just swaps the polarities of those two subtrees. Since the conversion rule only works when both the subject and object of the copula have indefinites or no.d scoping, which have symmetric polarities on the restrictor and body, we can do this without keeping track of the scoping relations. Arguments: ulf: The resulting ULF src-ulfs: List of ULFs (in this case with one element) that led to ULF. Returns: A polarity marked version of `ulf` based on the sources." (assert (= 1 (length src-ulfs))) (labels ((apply-polarity-with-divergence-map (curmlulf srcmlulf divergence-map topsrcml) "Applies the polarity from a source taking account subtree movement through a divergence map. The divergence map gives the corresponding index position of the second tree at points of divergence. At these points, the current second tree is replaced with point marked in the divergence map. Arguments: curmlulf: The multi-labeled-tree-node for the current ULF. srcmlulf: The multi-labeled-tree-node for the source ULF, including polarity. divergence-map: A list of two elements mapping the curmlulf index to the corresponding srcmlulf index when the trees diverge. topsrcml: The multi-labeled-tree for the top of the source ULF (for accessing subtrees at divergences) Returns: A labeled-tree with the polarity markings of curmlulf." (let ((cur-srcmlulf srcmlulf) (curexpr (expr curmlulf)) curpol) ;; At a divergence, replace srcmlulf using the divergence map. (when (assoc (index curmlulf) divergence-map) (setf cur-srcmlulf (node-at-index topsrcml (cdr (assoc (index curmlulf) divergence-map))))) (setf curpol (get-label-from-key topsrcml 'polarity (index cur-srcmlulf))) (cond ;; Base case. ((atom (expr curmlulf)) (make-instance 'labeled-tree :expr curexpr :label curpol)) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (curchild srcchild) (apply-polarity-with-divergence-map curchild srcchild divergence-map topsrcml)) (expr curmlulf) (expr cur-srcmlulf)) :label curpol)))))) ; end of labels defs ;; Main body of labels. (let* ((src-mulf (get-infer-nlog-marked-ulf (first src-ulfs))) (reslulf (dfs-label-tree ulf)) (srclulf (dfs-label-tree (first src-ulfs))) (divergences (find-divergences reslulf srclulf)) ;; Build the multi-label trees. (resmlulf (build-multi-labeled-tree reslulf nil nil)) (srcmlulf (build-multi-labeled-tree srclulf (list src-mulf) '(polarity))) divergence-map) (assert (= 2 (length divergences))) ;; Swap the indices of the divergences. (setf divergence-map (list (cons (car (first divergences)) (cdr (second divergences))) (cons (car (second divergences)) (cdr (first divergences))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergence-map (root resmlulf) (root srcmlulf) divergence-map srcmlulf))))) ;; Register this function for marking dispatch. (setf (gethash 'uci-list *infer-nlog-marking-dispatch-fn-ht*) #'uci-list-marking-from-source-dispatch) (defun conversion-rule-ttt (inulf &key (callpkg nil)) (util:inout-intern (inulf ulf :ulf-fracas :callpkg callpkg) (ttt:apply-rules '((/ (((!1 some.d a.d an.d no.d) (!2 pred?)) ; matches (d1 pred1) (((!3 lex-tense?) be.v) ; matches (tense be.v) (= ((!4 some.d a.d an.d) (!5 pred?))))) ; matches (= (d2 pred2)) ; rebuild swapping pred1 (!2) and pred2 (!5) ((!1 !5) ((!3 be.v) (= (!4 !2)))))) ulf))) (util:memoize 'conversion-rule-ttt) ;; Matches a monotonicity rule ULF ;; ((every.d/all.d P1) ((pres be.v) (= (indef.d/k P2)))) ;; or more generally ;; ((every.d/all.d P1) ((pres be.v) <pred>)) (defun mon-form? (inulf) (in-intern (inulf ulf :ulf-fracas) (ttt:match-expr '(((! every.d all.d) pred?) ((pres be.v) ; this is redundant (! (= ((! a.d an.d k) pred?)) pred?))) ulf))) ;; Extracts the first predicate from a monotonicity ULF. (defun get-mon-p1 (ulf) (second (first ulf))) ;; Extracts the second predicate from a monotonicity ULF. ;; If it is a noun (= (indef/k <pred>)), simply pull it out. ;; If it's not a noun, turn it into one with (n+preds thing.n (that.rel ((pres be.v) <pred>))) (defun get-mon-p2 (ulf) (cond ;; Simple noun case. ((ttt:match-expr '(_! ; subj (_! ; copula (= ((! a.d an.d k some.d) pred?)))) ulf) (second (second (second (second ulf))))) ;; Simple term case. ((ttt:match-expr '(_! (_! (= term?))) ulf) (second (second ulf))) ;; General case. (t (let ((rawpred (second (second ulf)))) (list 'n+preds 'thing.n (list 'that.rel (list '(pres be.v) rawpred))))))) ;; Helper function that checks the polarity of a predicate and ;; its determiner, switches p1 with p2 ;; and adds the change to the list of ULFs returned ;; ;; Arguments: ;; curpred - predicate to replace ;; newpred - the new value for the replaced predicate ;; b - marked ULF ;; bu - unmarked ULF ;; pol - polarity of the predicate context (defun tr-switch-pred (curpred newpred b bu pol) ;; The base case is of the form: ;; (pred1 pol) (cond ((and (ulf-lib:pred? bu) (equal bu curpred) (equal (global-polarity b) pol)) ;; replace curpred with newpred. No need to recurse since curpred won't ;; match any subcomponent of bu. (list newpred)) ;; Special case: the cur and new preds are both equality with a term and we ;; found a matching term. Ignore the equal signs and just replace the terms. ((and (listp curpred) (= 2 (length curpred)) (eql '= (first curpred)) (listp newpred) (= 2 (length newpred)) (eql '= (first newpred)) (equal (second curpred) bu) (equal (global-polarity b) pol)) (list (second newpred))) ((listp bu) (apply #'append (mapcar (lambda (i) (index-recurse i curpred newpred (get-ulf b) bu pol)) (range (length bu))))) (t nil))) (defun range (max &key (min 0) (step 1)) (loop for n from min below max by step collect n)) ;; Recurses into the current index and returns the value with the results of ;; the recursion inserted into the correct position of the input formula. (defun index-recurse (i cp np b bu pol) (let* ((c (nth i b)) (cu (nth i bu)) (recval (tr-switch-pred cp np c cu pol)) (pre-slice (subseq bu 0 i)) (post-slice (subseq bu (1+ i)))) (mapcar (lambda (x) (append pre-slice (list x) post-slice)) recval))) ;; Monotonicity rule that returns the lower part of the formula and ;; takes as an input the upper parts of the formula ;; {in}definite-det? --> use to check delta (defun umi-positive-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf1) (get-mon-p2 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '+)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p1 ulf2) (get-mon-p2 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '+)))) results)))) (defun umi-negative-polarity (inulf1 inulf2 &key (callpkg nil)) (inout-intern (inulf1 ulf1 :ulf-fracas :callpkg callpkg) (in-intern (inulf2 ulf2 :ulf-fracas) (let (results) (if (and (mon-form? ulf1) (listp ulf2)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf1) (get-mon-p1 ulf1) (get-infer-nlog-marked-ulf ulf2) ulf2 '-)))) (if (and (mon-form? ulf2) (listp ulf1)) (setf results (append results (tr-switch-pred (get-mon-p2 ulf2) (get-mon-p1 ulf2) (get-infer-nlog-marked-ulf ulf1) ulf1 '-)))) results)))) ;;; Dispatch Fn ;;; 1. Get divergences between result and the two inputs, the one with fewer divergences is the basis function, the other is the monotonicity rule. ;;; 2. Get the polarity marking of the basis ;;; 3. Get the polarity marking of the corresponding predicate of the monotonicity rule. ;;; 4. Use the polarity marking of the basis, until the divergence. At the divergence, use the predicate polarity. No polarity flipping is necessary since negative contexts lead to the antecedent which is also in negative context adn vice versa. (defun umi-marking-dispatch-fn (ulf src-ulfs) "Dispatch polarity marking function for UMI rules." (assert (= 2 (length src-ulfs))) (labels ((apply-polarity-with-divergences (reslulf basis-mulf basis-divergence-point mon-mulf in-divergence) "Given divergence point and current divergence state transfers polarity from the source ulfs to the result ulf." (let ((in-divergence (or in-divergence (= (label reslulf) basis-divergence-point)))) (cond ;; In divergence and match with monotonicity predicate, use the monotonicity predicate. ((and in-divergence (equal (unlabeled-tree reslulf) (unlabeled-tree mon-mulf))) mon-mulf) ;; In divergence and atom. ((and in-divergence (atom (expr reslulf))) (make-instance 'labeled-tree :expr (expr reslulf) :label (label mon-mulf))) ;; Otherwise in divergence, recurse and label current monotonicity with top of predicate. (in-divergence (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild) (apply-polarity-with-divergences reschild nil ; not used in divergence basis-divergence-point mon-mulf in-divergence)) (expr reslulf)) :label (label mon-mulf))) ;; Base case. ((atom (expr reslulf)) (make-instance 'labeled-tree :expr (expr reslulf) :label (label basis-mulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'(lambda (reschild basis-child) (apply-polarity-with-divergences reschild basis-child basis-divergence-point mon-mulf in-divergence)) (expr reslulf) (expr basis-mulf)) :label (label basis-mulf)))))) (get-antecedent-pred-mon (mon-mulf) "Gets the antecedent predicate of a monotonicity rule mulf." (second (expr (first (expr mon-mulf))))) (get-consequent-pred-mon (mon-mulf) "Gets the consequent predicate of a monotonicity rule mulf." ;; ((<det> <pred1>) ((<tense> be.v) <pred2>)) (second (expr (second (expr mon-mulf))))) (common-ancestor (lulf points) "Returns the index of the lowest common ancestor of the given list of points." ;; Returns a list of completed points if incomplete a number for the index if complete. (let* ((curres (if (member (label lulf) points) (list (label lulf)) nil)) (all-recres curres)) (cond ((atom (expr lulf)) curres) (t (loop for child in (expr lulf) do (let ((recres (common-ancestor child points))) (if (numberp recres) ;; Recursive result is complete, just go back up. (return-from common-ancestor recres) ;; Add recursive result. (setf all-recres (append all-recres recres))))) (setf all-recres (remove-duplicates all-recres)) (if (= (length all-recres) (length points)) (label lulf) all-recres)))))) ;; Labels body. (let* ((reslulf (dfs-label-tree ulf)) (srclulfs (mapcar #'dfs-label-tree src-ulfs)) (srcmulfs (mapcar #'get-infer-nlog-marked-ulf src-ulfs)) (src-divergences (mapcar #'(lambda (srclulf) (find-divergences reslulf srclulf)) srclulfs)) (basis-idx (cond ;; Basis is the non monotonicity rule format, if only one fits that. ((and (mon-form? (first src-ulfs)) (not (mon-form? (second src-ulfs)))) 1) ((and (not (mon-form? (first src-ulfs))) (mon-form? (second src-ulfs))) 0) ;; Otherwise, the basis is the one with fewer divergences. ((<= (length (first src-divergences)) (length (second src-divergences))) 0) (t 1))) (mon-idx (- 1 basis-idx)) (basis-mulf (nth basis-idx srcmulfs)) (basis-mlulf (build-multi-labeled-tree (nth basis-idx srclulfs) (list basis-mulf) '(polarity))) (basis-divergences (nth basis-idx src-divergences)) (basis-divergence-point (common-ancestor reslulf (mapcar #'car basis-divergences))) (basis-divergence-src-pt (common-ancestor (nth basis-idx srclulfs) (mapcar #'cdr basis-divergences))) (mon-mulf (if (eql '- (get-label-from-key basis-mlulf 'polarity basis-divergence-src-pt)) (get-antecedent-pred-mon (nth mon-idx srcmulfs)) (get-consequent-pred-mon (nth mon-idx srcmulfs))))) (labeled-tree-to-marked-ulf (apply-polarity-with-divergences reslulf basis-mulf basis-divergence-point mon-mulf nil))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'umi-positive-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) (setf (gethash 'umi-negative-polarity *infer-nlog-marking-dispatch-fn-ht*) #'umi-marking-dispatch-fn) ;;; ;;; Negations ;;; (defun neg-elim (ulf) (if (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf) (list (second (second ulf))) nil)) (defun neg-intro (ulf) (if (not (ttt:match-expr '((!1 not not.adv-s) ((!2 not not.adv-s) _!3)) ulf)) (list (list 'not (list 'not ulf))))) (defun replace-ab (a b ulf) (labels ((idx-recurse (i) (let ((recval (replace-ab a b (nth i ulf))) (pre (subseq ulf 0 i)) (post (subseq ulf (1+ i)))) (mapcar (lambda (x) (append pre (list x) post)) recval)))) ; labels body (cond ((equal a ulf) (list b)) ((atom ulf) nil) (t (apply #'append (mapcar (lambda (i) (idx-recurse i)) (range (length ulf)))))))) (defun no2notindef (ulf) (let ((no2indefs (apply #'append (mapcar #'(lambda (indef) (replace-ab 'no.d indef ulf)) '(some.d a.d an.d))))) ; Add 'not at the top-level of all the formulas. (mapcar #'(lambda (newulf) (list 'not newulf)) no2indefs))) (defun no2notindef-marking-from-source-dispatch (ulf src-ulfs) "Dispatch function for getting polarity markings for a ULF from no2notindef." ;; 1. Strip top-level not from the result. ;; 2. Map over all of the same polarities. ;; 3. Make the top-level polarity negative and then add the not back in with ;; a positive polarity there. (assert (= 1 (length src-ulfs))) (labels ((transfer-polarities (ulf srcmulf) "Builds a marked ULF with `ulf` values and `srcmulf` polarities. Both must have the same shape." (cond ;; Base case. ((atom ulf) (make-instance 'labeled-tree :expr ulf :label (global-polarity srcmulf))) ;; Recursive case. (t (make-instance 'labeled-tree :expr (mapcar #'transfer-polarities ulf (get-ulf srcmulf)) :label (global-polarity srcmulf)))))) ;; Main body. (labeled-tree-to-marked-ulf (let ((core-form (transfer-polarities (second ulf) (get-infer-nlog-marked-ulf (first src-ulfs))))) (setf (label core-form) '-) (make-instance 'labeled-tree :expr (list (make-instance 'labeled-tree :expr 'not :label '+) core-form) :label '+))))) ;; Register this function for polarity marking dispatch. (setf (gethash 'no2notindef *infer-nlog-marking-dispatch-fn-ht*) #'no2notindef-marking-from-source-dispatch)
[ { "context": "Mass Ave, Cambridge, MA 02139, USA.\n\n; Written by: Panagiotis Manolios who can be reached as follows.\n\n; Email: manolios", "end": 771, "score": 0.9998825192451477, "start": 752, "tag": "NAME", "value": "Panagiotis Manolios" }, { "context": " Manolios who can be reached as follows.\n\n; Email: [email protected]\n\n; Postal Mail:\n; College of Computing\n; CERCS La", "end": 835, "score": 0.9999313354492188, "start": 813, "tag": "EMAIL", "value": "[email protected]" } ]
books/workshops/2002/manolios-kaufmann/support/sorting/insertion-sort.lisp
mayankmanj/acl2
305
; Copyright (C) 2001 Georgia Institute of Technology ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Written by: Panagiotis Manolios who can be reached as follows. ; Email: [email protected] ; Postal Mail: ; College of Computing ; CERCS Lab ; Georgia Institute of Technology ; 801 Atlantic Drive ; Atlanta, Georgia 30332-0280 U.S.A. (in-package "ACL2") (include-book "perm-order") (defun insert (a x) (if (consp x) (if (<<= a (car x)) (cons a x) (cons (car x) (insert a (cdr x)))) (list a))) (defun isort (x) (if (consp x) (insert (car x) (isort (cdr x))) nil)) (defthm ordered-insert (implies (orderedp y) (orderedp (insert x y)))) (defthm ordered-sort (orderedp (isort x))) (defthm perm-insert (perm (insert x y) (cons x y))) (defthm perm-sort (perm (isort x) x)) (defthm insert-insert (equal (insert x (insert y z)) (insert y (insert x z))) :rule-classes ((:rewrite :loop-stopper ((x y))))) (defthm insert-in (equal (isort (insert x y)) (isort (cons x y)))) (defthm insert-sort-remove (implies (in x y) (equal (insert x (isort (remove-el x y))) (isort y)))) (defthm sort-canonical (implies (and (perm x y) ;; Added for mod to ACL2 v2-8 that does better matching for calls of ;; equivalence relations against the current context, to avoid a rewriter ;; loop in the proof of mail: (syntaxp (not (term-order x y)))) (equal (isort x) (isort y)))) (defthm main (equal (perm x y) (equal (isort x) (isort y))) :hints (("goal" :use ((:instance perm-sort (x y)) (:instance perm-sort)) :in-theory (disable perm-sort))) :rule-classes nil) (defthm main2 (implies (and (orderedp x) (perm x y)) (equal (isort y) x)) :rule-classes nil) (defthm main3 (implies (and (orderedp x) (orderedp y) (perm x y)) (equal x y)) :hints (("goal" :use ((:instance main2) (:instance main2 (x y))))) :rule-classes nil)
67505
; Copyright (C) 2001 Georgia Institute of Technology ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Written by: <NAME> who can be reached as follows. ; Email: <EMAIL> ; Postal Mail: ; College of Computing ; CERCS Lab ; Georgia Institute of Technology ; 801 Atlantic Drive ; Atlanta, Georgia 30332-0280 U.S.A. (in-package "ACL2") (include-book "perm-order") (defun insert (a x) (if (consp x) (if (<<= a (car x)) (cons a x) (cons (car x) (insert a (cdr x)))) (list a))) (defun isort (x) (if (consp x) (insert (car x) (isort (cdr x))) nil)) (defthm ordered-insert (implies (orderedp y) (orderedp (insert x y)))) (defthm ordered-sort (orderedp (isort x))) (defthm perm-insert (perm (insert x y) (cons x y))) (defthm perm-sort (perm (isort x) x)) (defthm insert-insert (equal (insert x (insert y z)) (insert y (insert x z))) :rule-classes ((:rewrite :loop-stopper ((x y))))) (defthm insert-in (equal (isort (insert x y)) (isort (cons x y)))) (defthm insert-sort-remove (implies (in x y) (equal (insert x (isort (remove-el x y))) (isort y)))) (defthm sort-canonical (implies (and (perm x y) ;; Added for mod to ACL2 v2-8 that does better matching for calls of ;; equivalence relations against the current context, to avoid a rewriter ;; loop in the proof of mail: (syntaxp (not (term-order x y)))) (equal (isort x) (isort y)))) (defthm main (equal (perm x y) (equal (isort x) (isort y))) :hints (("goal" :use ((:instance perm-sort (x y)) (:instance perm-sort)) :in-theory (disable perm-sort))) :rule-classes nil) (defthm main2 (implies (and (orderedp x) (perm x y)) (equal (isort y) x)) :rule-classes nil) (defthm main3 (implies (and (orderedp x) (orderedp y) (perm x y)) (equal x y)) :hints (("goal" :use ((:instance main2) (:instance main2 (x y))))) :rule-classes nil)
true
; Copyright (C) 2001 Georgia Institute of Technology ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; Written by: PI:NAME:<NAME>END_PI who can be reached as follows. ; Email: PI:EMAIL:<EMAIL>END_PI ; Postal Mail: ; College of Computing ; CERCS Lab ; Georgia Institute of Technology ; 801 Atlantic Drive ; Atlanta, Georgia 30332-0280 U.S.A. (in-package "ACL2") (include-book "perm-order") (defun insert (a x) (if (consp x) (if (<<= a (car x)) (cons a x) (cons (car x) (insert a (cdr x)))) (list a))) (defun isort (x) (if (consp x) (insert (car x) (isort (cdr x))) nil)) (defthm ordered-insert (implies (orderedp y) (orderedp (insert x y)))) (defthm ordered-sort (orderedp (isort x))) (defthm perm-insert (perm (insert x y) (cons x y))) (defthm perm-sort (perm (isort x) x)) (defthm insert-insert (equal (insert x (insert y z)) (insert y (insert x z))) :rule-classes ((:rewrite :loop-stopper ((x y))))) (defthm insert-in (equal (isort (insert x y)) (isort (cons x y)))) (defthm insert-sort-remove (implies (in x y) (equal (insert x (isort (remove-el x y))) (isort y)))) (defthm sort-canonical (implies (and (perm x y) ;; Added for mod to ACL2 v2-8 that does better matching for calls of ;; equivalence relations against the current context, to avoid a rewriter ;; loop in the proof of mail: (syntaxp (not (term-order x y)))) (equal (isort x) (isort y)))) (defthm main (equal (perm x y) (equal (isort x) (isort y))) :hints (("goal" :use ((:instance perm-sort (x y)) (:instance perm-sort)) :in-theory (disable perm-sort))) :rule-classes nil) (defthm main2 (implies (and (orderedp x) (perm x y)) (equal (isort y) x)) :rule-classes nil) (defthm main3 (implies (and (orderedp x) (orderedp y) (perm x y)) (equal x y)) :hints (("goal" :use ((:instance main2) (:instance main2 (x y))))) :rule-classes nil)
[ { "context": "#!/localhome/tnrangwi/bin/sbcl --script\n; Author: Thorsten Rangwich\n; See file LICENSE for copyright and usage of thi", "end": 67, "score": 0.999825656414032, "start": 50, "tag": "NAME", "value": "Thorsten Rangwich" }, { "context": "et-service:socket-server :privileged-addresses '(\"127.0.0.1\") :bindaddr \"127.0.0.1\" :port 1971))\n\n(socket-ser", "end": 480, "score": 0.99952632188797, "start": 471, "tag": "IP_ADDRESS", "value": "127.0.0.1" }, { "context": "r :privileged-addresses '(\"127.0.0.1\") :bindaddr \"127.0.0.1\" :port 1971))\n\n(socket-service:push-handler\n *ser", "end": 503, "score": 0.9994164705276489, "start": 494, "tag": "IP_ADDRESS", "value": "127.0.0.1" } ]
lisp/test_server.lisp
tnrangwi/CompareProgrammingUsingHolidayManager
0
#!/localhome/tnrangwi/bin/sbcl --script ; Author: Thorsten Rangwich ; See file LICENSE for copyright and usage of this code. ; This tests the socket server. One function is pushed to ; the server and then the server is run. ; FIXME: There should be a require here instead. Test with sbcl how to get this solved in this prototype. (load "basetools.lisp") (load "socket-service.lisp") (defvar *server* (make-instance 'socket-service:socket-server :privileged-addresses '("127.0.0.1") :bindaddr "127.0.0.1" :port 1971)) (socket-service:push-handler *server* ; the socket server, where to add the function "echo" ; the server's name of the function (lambda (argv fdfunc mem &key &allow-other-keys) ; well, the function itself. The signature is documented in the interface. (let ((echo-counter (basetools:getattr mem "echo-counter"))) (if (eq echo-counter NIL) (setf echo-counter 0)) (incf echo-counter) (format T "echo counter:~A~%" echo-counter) ; (funcall fdfunc (list (format NIL "~A" echo-counter))) (funcall fdfunc (list echo-counter)) (basetools:setattr mem "echo-counter" echo-counter) (funcall fdfunc argv) (funcall fdfunc)))) (socket-service:run-services-until-shutdown *server*) ; effectively now run the socket server, with this one function added. (format T "finished!") ; something made the server shut down.
48757
#!/localhome/tnrangwi/bin/sbcl --script ; Author: <NAME> ; See file LICENSE for copyright and usage of this code. ; This tests the socket server. One function is pushed to ; the server and then the server is run. ; FIXME: There should be a require here instead. Test with sbcl how to get this solved in this prototype. (load "basetools.lisp") (load "socket-service.lisp") (defvar *server* (make-instance 'socket-service:socket-server :privileged-addresses '("127.0.0.1") :bindaddr "127.0.0.1" :port 1971)) (socket-service:push-handler *server* ; the socket server, where to add the function "echo" ; the server's name of the function (lambda (argv fdfunc mem &key &allow-other-keys) ; well, the function itself. The signature is documented in the interface. (let ((echo-counter (basetools:getattr mem "echo-counter"))) (if (eq echo-counter NIL) (setf echo-counter 0)) (incf echo-counter) (format T "echo counter:~A~%" echo-counter) ; (funcall fdfunc (list (format NIL "~A" echo-counter))) (funcall fdfunc (list echo-counter)) (basetools:setattr mem "echo-counter" echo-counter) (funcall fdfunc argv) (funcall fdfunc)))) (socket-service:run-services-until-shutdown *server*) ; effectively now run the socket server, with this one function added. (format T "finished!") ; something made the server shut down.
true
#!/localhome/tnrangwi/bin/sbcl --script ; Author: PI:NAME:<NAME>END_PI ; See file LICENSE for copyright and usage of this code. ; This tests the socket server. One function is pushed to ; the server and then the server is run. ; FIXME: There should be a require here instead. Test with sbcl how to get this solved in this prototype. (load "basetools.lisp") (load "socket-service.lisp") (defvar *server* (make-instance 'socket-service:socket-server :privileged-addresses '("127.0.0.1") :bindaddr "127.0.0.1" :port 1971)) (socket-service:push-handler *server* ; the socket server, where to add the function "echo" ; the server's name of the function (lambda (argv fdfunc mem &key &allow-other-keys) ; well, the function itself. The signature is documented in the interface. (let ((echo-counter (basetools:getattr mem "echo-counter"))) (if (eq echo-counter NIL) (setf echo-counter 0)) (incf echo-counter) (format T "echo counter:~A~%" echo-counter) ; (funcall fdfunc (list (format NIL "~A" echo-counter))) (funcall fdfunc (list echo-counter)) (basetools:setattr mem "echo-counter" echo-counter) (funcall fdfunc argv) (funcall fdfunc)))) (socket-service:run-services-until-shutdown *server*) ; effectively now run the socket server, with this one function added. (format T "finished!") ; something made the server shut down.
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(includ", "end": 1416, "score": 0.9998764991760254, "start": 1406, "tag": "NAME", "value": "Sol Swords" }, { "context": "IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(include-book \"g-if\")\n(includ", "end": 1438, "score": 0.9999303817749023, "start": 1418, "tag": "EMAIL", "value": "[email protected]" } ]
books/centaur/gl/g-logior.lisp
solswords/acl2
0
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Sol Swords <[email protected]> (in-package "GL") (include-book "g-if") (include-book "g-primitives-help") (include-book "symbolic-arithmetic") (include-book "eval-g-base") (local (include-book "eval-g-base-help")) (local (include-book "hyp-fix")) (local (include-book "std/basic/arith-equivs" :dir :system)) (defun g-binary-logior-of-numbers (x y) (declare (xargs :guard (and (general-numberp x) (general-numberp y)))) (b* (((mv xrn xrd xin xid) (general-number-components x)) ((mv yrn yrd yin yid) (general-number-components y)) ((mv xintp xintp-known) (if (equal xrd '(t)) (mv (bfr-or (bfr-=-ss xin nil) (bfr-=-uu xid nil)) t) (mv nil nil))) ((mv yintp yintp-known) (if (equal yrd '(t)) (mv (bfr-or (bfr-=-ss yin nil) (bfr-=-uu yid nil)) t) (mv nil nil)))) (if (and xintp-known yintp-known) (mk-g-number (list-fix (bfr-logior-ss (bfr-ite-bss-fn xintp xrn nil) (bfr-ite-bss-fn yintp yrn nil)))) (g-apply 'binary-logior (gl-list x y))))) (in-theory (disable (g-binary-logior-of-numbers))) (defthm deps-of-g-binary-logior-of-numbers (implies (and (not (gobj-depends-on k p x)) (not (gobj-depends-on k p y)) (general-numberp x) (general-numberp y)) (not (gobj-depends-on k p (g-binary-logior-of-numbers x y))))) (local (defthm logior-non-integers (and (implies (not (integerp i)) (equal (logior i j) (logior 0 j))) (implies (not (integerp j)) (equal (logior i j) (logior i 0)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (progn ;; (defthm gobjectp-g-binary-logior-of-numbers ;; (implies (and (gobjectp x) ;; (general-numberp x) ;; (gobjectp y) ;; (general-numberp y)) ;; (gobjectp (g-binary-logior-of-numbers x y))) ;; :hints(("Goal" :in-theory (disable general-numberp ;; general-number-components)))) (defthm g-binary-logior-of-numbers-correct (implies (and (general-numberp x) (general-numberp y)) (equal (eval-g-base (g-binary-logior-of-numbers x y) env) (logior (eval-g-base x env) (eval-g-base y env)))) :hints (("goal" :in-theory (e/d* ((:ruleset general-object-possibilities)) (general-numberp general-number-components)) :do-not-induct t))))) (in-theory (disable g-binary-logior-of-numbers)) (def-g-binary-op binary-logior (b* ((i-num (if (general-numberp i) i 0)) (j-num (if (general-numberp j) j 0))) (gret (g-binary-logior-of-numbers i-num j-num)))) (verify-g-guards binary-logior :hints `(("Goal" :in-theory (disable* ,gfn general-concretep-def)))) (def-gobj-dependency-thm binary-logior :hints `(("goal" :induct ,gcall :expand (,gcall) :in-theory (disable (:d ,gfn))))) (local (defthm logior-non-acl2-numbers (and (implies (not (acl2-numberp i)) (equal (logior i j) (logior 0 j))) (implies (not (acl2-numberp j)) (equal (logior i j) (logior i 0)))))) (def-g-correct-thm binary-logior eval-g-base :hints `(("Goal" :in-theory (e/d* (general-concretep-atom (:ruleset general-object-possibilities) not-general-numberp-not-acl2-numberp) ((:definition ,gfn) general-concretep-def binary-logior components-to-number hons-assoc-equal eval-g-base-non-cons default-car default-cdr (:rules-of-class :type-prescription :here))) :induct (,gfn i j . ,params) :do-not-induct t :expand ((,gfn i j . ,params)))))
15839
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> (in-package "GL") (include-book "g-if") (include-book "g-primitives-help") (include-book "symbolic-arithmetic") (include-book "eval-g-base") (local (include-book "eval-g-base-help")) (local (include-book "hyp-fix")) (local (include-book "std/basic/arith-equivs" :dir :system)) (defun g-binary-logior-of-numbers (x y) (declare (xargs :guard (and (general-numberp x) (general-numberp y)))) (b* (((mv xrn xrd xin xid) (general-number-components x)) ((mv yrn yrd yin yid) (general-number-components y)) ((mv xintp xintp-known) (if (equal xrd '(t)) (mv (bfr-or (bfr-=-ss xin nil) (bfr-=-uu xid nil)) t) (mv nil nil))) ((mv yintp yintp-known) (if (equal yrd '(t)) (mv (bfr-or (bfr-=-ss yin nil) (bfr-=-uu yid nil)) t) (mv nil nil)))) (if (and xintp-known yintp-known) (mk-g-number (list-fix (bfr-logior-ss (bfr-ite-bss-fn xintp xrn nil) (bfr-ite-bss-fn yintp yrn nil)))) (g-apply 'binary-logior (gl-list x y))))) (in-theory (disable (g-binary-logior-of-numbers))) (defthm deps-of-g-binary-logior-of-numbers (implies (and (not (gobj-depends-on k p x)) (not (gobj-depends-on k p y)) (general-numberp x) (general-numberp y)) (not (gobj-depends-on k p (g-binary-logior-of-numbers x y))))) (local (defthm logior-non-integers (and (implies (not (integerp i)) (equal (logior i j) (logior 0 j))) (implies (not (integerp j)) (equal (logior i j) (logior i 0)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (progn ;; (defthm gobjectp-g-binary-logior-of-numbers ;; (implies (and (gobjectp x) ;; (general-numberp x) ;; (gobjectp y) ;; (general-numberp y)) ;; (gobjectp (g-binary-logior-of-numbers x y))) ;; :hints(("Goal" :in-theory (disable general-numberp ;; general-number-components)))) (defthm g-binary-logior-of-numbers-correct (implies (and (general-numberp x) (general-numberp y)) (equal (eval-g-base (g-binary-logior-of-numbers x y) env) (logior (eval-g-base x env) (eval-g-base y env)))) :hints (("goal" :in-theory (e/d* ((:ruleset general-object-possibilities)) (general-numberp general-number-components)) :do-not-induct t))))) (in-theory (disable g-binary-logior-of-numbers)) (def-g-binary-op binary-logior (b* ((i-num (if (general-numberp i) i 0)) (j-num (if (general-numberp j) j 0))) (gret (g-binary-logior-of-numbers i-num j-num)))) (verify-g-guards binary-logior :hints `(("Goal" :in-theory (disable* ,gfn general-concretep-def)))) (def-gobj-dependency-thm binary-logior :hints `(("goal" :induct ,gcall :expand (,gcall) :in-theory (disable (:d ,gfn))))) (local (defthm logior-non-acl2-numbers (and (implies (not (acl2-numberp i)) (equal (logior i j) (logior 0 j))) (implies (not (acl2-numberp j)) (equal (logior i j) (logior i 0)))))) (def-g-correct-thm binary-logior eval-g-base :hints `(("Goal" :in-theory (e/d* (general-concretep-atom (:ruleset general-object-possibilities) not-general-numberp-not-acl2-numberp) ((:definition ,gfn) general-concretep-def binary-logior components-to-number hons-assoc-equal eval-g-base-non-cons default-car default-cdr (:rules-of-class :type-prescription :here))) :induct (,gfn i j . ,params) :do-not-induct t :expand ((,gfn i j . ,params)))))
true
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "GL") (include-book "g-if") (include-book "g-primitives-help") (include-book "symbolic-arithmetic") (include-book "eval-g-base") (local (include-book "eval-g-base-help")) (local (include-book "hyp-fix")) (local (include-book "std/basic/arith-equivs" :dir :system)) (defun g-binary-logior-of-numbers (x y) (declare (xargs :guard (and (general-numberp x) (general-numberp y)))) (b* (((mv xrn xrd xin xid) (general-number-components x)) ((mv yrn yrd yin yid) (general-number-components y)) ((mv xintp xintp-known) (if (equal xrd '(t)) (mv (bfr-or (bfr-=-ss xin nil) (bfr-=-uu xid nil)) t) (mv nil nil))) ((mv yintp yintp-known) (if (equal yrd '(t)) (mv (bfr-or (bfr-=-ss yin nil) (bfr-=-uu yid nil)) t) (mv nil nil)))) (if (and xintp-known yintp-known) (mk-g-number (list-fix (bfr-logior-ss (bfr-ite-bss-fn xintp xrn nil) (bfr-ite-bss-fn yintp yrn nil)))) (g-apply 'binary-logior (gl-list x y))))) (in-theory (disable (g-binary-logior-of-numbers))) (defthm deps-of-g-binary-logior-of-numbers (implies (and (not (gobj-depends-on k p x)) (not (gobj-depends-on k p y)) (general-numberp x) (general-numberp y)) (not (gobj-depends-on k p (g-binary-logior-of-numbers x y))))) (local (defthm logior-non-integers (and (implies (not (integerp i)) (equal (logior i j) (logior 0 j))) (implies (not (integerp j)) (equal (logior i j) (logior i 0)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (progn ;; (defthm gobjectp-g-binary-logior-of-numbers ;; (implies (and (gobjectp x) ;; (general-numberp x) ;; (gobjectp y) ;; (general-numberp y)) ;; (gobjectp (g-binary-logior-of-numbers x y))) ;; :hints(("Goal" :in-theory (disable general-numberp ;; general-number-components)))) (defthm g-binary-logior-of-numbers-correct (implies (and (general-numberp x) (general-numberp y)) (equal (eval-g-base (g-binary-logior-of-numbers x y) env) (logior (eval-g-base x env) (eval-g-base y env)))) :hints (("goal" :in-theory (e/d* ((:ruleset general-object-possibilities)) (general-numberp general-number-components)) :do-not-induct t))))) (in-theory (disable g-binary-logior-of-numbers)) (def-g-binary-op binary-logior (b* ((i-num (if (general-numberp i) i 0)) (j-num (if (general-numberp j) j 0))) (gret (g-binary-logior-of-numbers i-num j-num)))) (verify-g-guards binary-logior :hints `(("Goal" :in-theory (disable* ,gfn general-concretep-def)))) (def-gobj-dependency-thm binary-logior :hints `(("goal" :induct ,gcall :expand (,gcall) :in-theory (disable (:d ,gfn))))) (local (defthm logior-non-acl2-numbers (and (implies (not (acl2-numberp i)) (equal (logior i j) (logior 0 j))) (implies (not (acl2-numberp j)) (equal (logior i j) (logior i 0)))))) (def-g-correct-thm binary-logior eval-g-base :hints `(("Goal" :in-theory (e/d* (general-concretep-atom (:ruleset general-object-possibilities) not-general-numberp-not-acl2-numberp) ((:definition ,gfn) general-concretep-def binary-logior components-to-number hons-assoc-equal eval-g-base-non-cons default-car default-cdr (:rules-of-class :type-prescription :here))) :induct (,gfn i j . ,params) :do-not-induct t :expand ((,gfn i j . ,params)))))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 205, "score": 0.9998784065246582, "start": 188, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 225, "score": 0.9999297261238098, "start": 207, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/ethereum/semaphore/edwards2montgomery-proof.lisp
mayankmanj/acl2
305
; Ethereum Semaphore Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ZKSEMAPHORE") (include-book "kestrel/ethereum/semaphore/prime-field-abbreviations" :dir :system) (include-book "kestrel/ethereum/semaphore/json-to-r1cs/load-circom-json" :dir :system) (include-book "kestrel/prime-fields/prime-fields" :dir :system) (include-book "std/util/define" :dir :system) (include-book "std/util/defrule" :dir :system) (local (include-book "kestrel/prime-fields/prime-fields-rules" :dir :system)) ; (depends-on "json/edwards2montgomery.json") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file contains a proof of the Edwards2Montgomery() ciruit component ; (see the Circom code of Semaphore). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Load the circuit. (acl2::load-circom-json "json/edwards2montgomery.json" '(baby-jubjub-prime)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This circuit converts ; Edwards curve coordinates to Montgomery curve coordinates: ; ; 1 + y 1 + y ; [u, v] = [ ------- , ---------- ] ; 1 - y (1 - y)x ; ; Here x and y are the inputs (Edwards curve coordinates) ; while u and v are the outputs (Montgomery curve coordinates). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The circuit implicitly assumes that ; all the input and output variables are field elements, ; and that the denominators are not 0. ; We capture all of these assumptions in the precondition predicate. (define precond (x y u v) :returns (yes/no booleanp) (and (pfep x) (pfep y) (pfep u) (pfep v) (not (equal x 0)) (not (equal y 1)))) ; The specification is the one sketched above, ; where all the operations are field operations. ; We formalize the specification as follows, ; but we should eventually use ; the elliptic curve library and the definition of BabyJubjub here. (define edwards2montgomery ((x pfep) (y pfep)) :guard (and (not (equal x 0)) (not (equal y 1))) :returns (mv (u pfep) (v pfep)) (b* ((u (pfdiv (pfadd 1 y) (pfsub 1 y))) (v (pfdiv (pfadd 1 y) (pfmul (pfsub 1 y) x)))) (mv u v))) (define spec (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (b* (((mv u$ v$) (edwards2montgomery x y))) (and (equal u u$) (equal v v$))) :guard-hints (("Goal" :in-theory (enable precond)))) ; The circuit predicate is mechanically obtained as usual ; (e.g. see explanation in the MultiMux1 and MultiMux3 proofs). (define circuit (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (r1cs::r1cs-holdsp (acl2::edwards2montgomery-make-r1cs) (list (cons :|main.in[0]| x) (cons :|main.in[1]| y) (cons :|main.out[0]| u) (cons :|main.out[1]| v))) :guard-hints (("Goal" :in-theory (e/d (precond r1cs::r1cs-valuationp) ((:e baby-jubjub-prime)))))) ; Looking at the Circom code, the proof is really easy: ; just divide to go from the circuit to the specification, ; and just multiply to go from the specification to the circuit; ; also take into account the equality of u with (1+y)/(1-y) for v. ; The proof in ACL2 is more roundabout, ; but with the right rewrite rules we can get this proved. ; We need to disable the rules of distributivity of * over +, ; because they work against us here: ; for instance, they turn (1 - y) * x into x - x * y (see formulas above), ; but instead we want to treat (1 - y) as "atomic". ; We also need the rule PFIELD::INV-OF-MUL ; to turn 1/(a*b) into (1/a)*(1/b), ; which is critical to reach a normal form in which ; certain terms and their inverses can be canceled together ; (via other rules in the prime field library). ; We also need to expand division into multiplication by inverse: ; analogously to how subtraction is enabled by default, ; perhaps division should be also enabled by default. (defruled circuit-is-spec (implies (precond u v x y) (equal (circuit u v x y) (spec u v x y))) :enable (precond circuit r1cs::r1cs-holdsp r1cs::r1cs-constraints-holdp r1cs::r1cs-constraint-holdsp r1cs::dot-product spec edwards2montgomery pfield::div pfield::inv-of-mul (:e baby-jubjub-prime)) :disable (pfield::mul-of-add-arg1 pfield::mul-of-add-arg2))
85920
; Ethereum Semaphore Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ZKSEMAPHORE") (include-book "kestrel/ethereum/semaphore/prime-field-abbreviations" :dir :system) (include-book "kestrel/ethereum/semaphore/json-to-r1cs/load-circom-json" :dir :system) (include-book "kestrel/prime-fields/prime-fields" :dir :system) (include-book "std/util/define" :dir :system) (include-book "std/util/defrule" :dir :system) (local (include-book "kestrel/prime-fields/prime-fields-rules" :dir :system)) ; (depends-on "json/edwards2montgomery.json") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file contains a proof of the Edwards2Montgomery() ciruit component ; (see the Circom code of Semaphore). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Load the circuit. (acl2::load-circom-json "json/edwards2montgomery.json" '(baby-jubjub-prime)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This circuit converts ; Edwards curve coordinates to Montgomery curve coordinates: ; ; 1 + y 1 + y ; [u, v] = [ ------- , ---------- ] ; 1 - y (1 - y)x ; ; Here x and y are the inputs (Edwards curve coordinates) ; while u and v are the outputs (Montgomery curve coordinates). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The circuit implicitly assumes that ; all the input and output variables are field elements, ; and that the denominators are not 0. ; We capture all of these assumptions in the precondition predicate. (define precond (x y u v) :returns (yes/no booleanp) (and (pfep x) (pfep y) (pfep u) (pfep v) (not (equal x 0)) (not (equal y 1)))) ; The specification is the one sketched above, ; where all the operations are field operations. ; We formalize the specification as follows, ; but we should eventually use ; the elliptic curve library and the definition of BabyJubjub here. (define edwards2montgomery ((x pfep) (y pfep)) :guard (and (not (equal x 0)) (not (equal y 1))) :returns (mv (u pfep) (v pfep)) (b* ((u (pfdiv (pfadd 1 y) (pfsub 1 y))) (v (pfdiv (pfadd 1 y) (pfmul (pfsub 1 y) x)))) (mv u v))) (define spec (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (b* (((mv u$ v$) (edwards2montgomery x y))) (and (equal u u$) (equal v v$))) :guard-hints (("Goal" :in-theory (enable precond)))) ; The circuit predicate is mechanically obtained as usual ; (e.g. see explanation in the MultiMux1 and MultiMux3 proofs). (define circuit (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (r1cs::r1cs-holdsp (acl2::edwards2montgomery-make-r1cs) (list (cons :|main.in[0]| x) (cons :|main.in[1]| y) (cons :|main.out[0]| u) (cons :|main.out[1]| v))) :guard-hints (("Goal" :in-theory (e/d (precond r1cs::r1cs-valuationp) ((:e baby-jubjub-prime)))))) ; Looking at the Circom code, the proof is really easy: ; just divide to go from the circuit to the specification, ; and just multiply to go from the specification to the circuit; ; also take into account the equality of u with (1+y)/(1-y) for v. ; The proof in ACL2 is more roundabout, ; but with the right rewrite rules we can get this proved. ; We need to disable the rules of distributivity of * over +, ; because they work against us here: ; for instance, they turn (1 - y) * x into x - x * y (see formulas above), ; but instead we want to treat (1 - y) as "atomic". ; We also need the rule PFIELD::INV-OF-MUL ; to turn 1/(a*b) into (1/a)*(1/b), ; which is critical to reach a normal form in which ; certain terms and their inverses can be canceled together ; (via other rules in the prime field library). ; We also need to expand division into multiplication by inverse: ; analogously to how subtraction is enabled by default, ; perhaps division should be also enabled by default. (defruled circuit-is-spec (implies (precond u v x y) (equal (circuit u v x y) (spec u v x y))) :enable (precond circuit r1cs::r1cs-holdsp r1cs::r1cs-constraints-holdp r1cs::r1cs-constraint-holdsp r1cs::dot-product spec edwards2montgomery pfield::div pfield::inv-of-mul (:e baby-jubjub-prime)) :disable (pfield::mul-of-add-arg1 pfield::mul-of-add-arg2))
true
; Ethereum Semaphore Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ZKSEMAPHORE") (include-book "kestrel/ethereum/semaphore/prime-field-abbreviations" :dir :system) (include-book "kestrel/ethereum/semaphore/json-to-r1cs/load-circom-json" :dir :system) (include-book "kestrel/prime-fields/prime-fields" :dir :system) (include-book "std/util/define" :dir :system) (include-book "std/util/defrule" :dir :system) (local (include-book "kestrel/prime-fields/prime-fields-rules" :dir :system)) ; (depends-on "json/edwards2montgomery.json") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file contains a proof of the Edwards2Montgomery() ciruit component ; (see the Circom code of Semaphore). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Load the circuit. (acl2::load-circom-json "json/edwards2montgomery.json" '(baby-jubjub-prime)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This circuit converts ; Edwards curve coordinates to Montgomery curve coordinates: ; ; 1 + y 1 + y ; [u, v] = [ ------- , ---------- ] ; 1 - y (1 - y)x ; ; Here x and y are the inputs (Edwards curve coordinates) ; while u and v are the outputs (Montgomery curve coordinates). ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The circuit implicitly assumes that ; all the input and output variables are field elements, ; and that the denominators are not 0. ; We capture all of these assumptions in the precondition predicate. (define precond (x y u v) :returns (yes/no booleanp) (and (pfep x) (pfep y) (pfep u) (pfep v) (not (equal x 0)) (not (equal y 1)))) ; The specification is the one sketched above, ; where all the operations are field operations. ; We formalize the specification as follows, ; but we should eventually use ; the elliptic curve library and the definition of BabyJubjub here. (define edwards2montgomery ((x pfep) (y pfep)) :guard (and (not (equal x 0)) (not (equal y 1))) :returns (mv (u pfep) (v pfep)) (b* ((u (pfdiv (pfadd 1 y) (pfsub 1 y))) (v (pfdiv (pfadd 1 y) (pfmul (pfsub 1 y) x)))) (mv u v))) (define spec (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (b* (((mv u$ v$) (edwards2montgomery x y))) (and (equal u u$) (equal v v$))) :guard-hints (("Goal" :in-theory (enable precond)))) ; The circuit predicate is mechanically obtained as usual ; (e.g. see explanation in the MultiMux1 and MultiMux3 proofs). (define circuit (x y u v) :guard (precond x y u v) :returns (yes/no booleanp) (r1cs::r1cs-holdsp (acl2::edwards2montgomery-make-r1cs) (list (cons :|main.in[0]| x) (cons :|main.in[1]| y) (cons :|main.out[0]| u) (cons :|main.out[1]| v))) :guard-hints (("Goal" :in-theory (e/d (precond r1cs::r1cs-valuationp) ((:e baby-jubjub-prime)))))) ; Looking at the Circom code, the proof is really easy: ; just divide to go from the circuit to the specification, ; and just multiply to go from the specification to the circuit; ; also take into account the equality of u with (1+y)/(1-y) for v. ; The proof in ACL2 is more roundabout, ; but with the right rewrite rules we can get this proved. ; We need to disable the rules of distributivity of * over +, ; because they work against us here: ; for instance, they turn (1 - y) * x into x - x * y (see formulas above), ; but instead we want to treat (1 - y) as "atomic". ; We also need the rule PFIELD::INV-OF-MUL ; to turn 1/(a*b) into (1/a)*(1/b), ; which is critical to reach a normal form in which ; certain terms and their inverses can be canceled together ; (via other rules in the prime field library). ; We also need to expand division into multiplication by inverse: ; analogously to how subtraction is enabled by default, ; perhaps division should be also enabled by default. (defruled circuit-is-spec (implies (precond u v x y) (equal (circuit u v x y) (spec u v x y))) :enable (precond circuit r1cs::r1cs-holdsp r1cs::r1cs-constraints-holdp r1cs::r1cs-constraint-holdsp r1cs::dot-product spec edwards2montgomery pfield::div pfield::inv-of-mul (:e baby-jubjub-prime)) :disable (pfield::mul-of-add-arg1 pfield::mul-of-add-arg2))
[ { "context": "; Tests of defthm-stp\n;\n; Copyright (C) 2008-2011 Eric Smith and Stanford University\n; Copyright (C) 2013-2020", "end": 60, "score": 0.9996638298034668, "start": 50, "tag": "NAME", "value": "Eric Smith" }, { "context": "ense. See the file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;", "end": 271, "score": 0.999724268913269, "start": 261, "tag": "NAME", "value": "Eric Smith" }, { "context": " file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 295, "score": 0.9999291896820068, "start": 273, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/axe/defthm-stp-tests.lisp
mayankmanj/acl2
305
; Tests of defthm-stp ; ; Copyright (C) 2008-2011 Eric Smith and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: Eric Smith ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ; cert_param: (uses-stp) (include-book "defthm-stp") (include-book "std/testing/must-fail" :dir :system) (include-book "kestrel/utilities/deftest" :dir :system) (deftest (defthm-stp test1 (equal (bvplus 32 x y) (bvplus 32 y x)))) ;; test of :rule-classes nil (deftest (defthm-stp test2 (equal (bvplus 32 x y) (bvplus 32 x y)) :rule-classes nil)) ;; this one is not true: (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)))) ;; test :counterexample (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)) :counterexample t)) (must-fail (defthm-stp test3 x :counterexample t))
38890
; Tests of defthm-stp ; ; Copyright (C) 2008-2011 <NAME> and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ; cert_param: (uses-stp) (include-book "defthm-stp") (include-book "std/testing/must-fail" :dir :system) (include-book "kestrel/utilities/deftest" :dir :system) (deftest (defthm-stp test1 (equal (bvplus 32 x y) (bvplus 32 y x)))) ;; test of :rule-classes nil (deftest (defthm-stp test2 (equal (bvplus 32 x y) (bvplus 32 x y)) :rule-classes nil)) ;; this one is not true: (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)))) ;; test :counterexample (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)) :counterexample t)) (must-fail (defthm-stp test3 x :counterexample t))
true
; Tests of defthm-stp ; ; Copyright (C) 2008-2011 PI:NAME:<NAME>END_PI and Stanford University ; Copyright (C) 2013-2020 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ; cert_param: (uses-stp) (include-book "defthm-stp") (include-book "std/testing/must-fail" :dir :system) (include-book "kestrel/utilities/deftest" :dir :system) (deftest (defthm-stp test1 (equal (bvplus 32 x y) (bvplus 32 y x)))) ;; test of :rule-classes nil (deftest (defthm-stp test2 (equal (bvplus 32 x y) (bvplus 32 x y)) :rule-classes nil)) ;; this one is not true: (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)))) ;; test :counterexample (must-fail (defthm-stp test3 (equal (bvplus 32 x y) (bvplus 32 x z)) :counterexample t)) (must-fail (defthm-stp test3 x :counterexample t))
[ { "context": ";;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; \n;;; Author : Dan Bothell\n;;; Copyright : (c) 2004 Dan Bothell\n;;; Availa", "end": 171, "score": 0.9997572302818298, "start": 160, "tag": "NAME", "value": "Dan Bothell" }, { "context": "thor : Dan Bothell\n;;; Copyright : (c) 2004 Dan Bothell\n;;; Availability: Covered by the GNU LGPL, see LG", "end": 210, "score": 0.9958814978599548, "start": 199, "tag": "NAME", "value": "Dan Bothell" }, { "context": " : Pittsburgh, PA 15213-3890\n;;; : [email protected]\n;;; \n;;; \n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 437, "score": 0.9999313354492188, "start": 418, "tag": "EMAIL", "value": "[email protected]" }, { "context": "change the colors used in the grid.\n;;; 2011.10.28 Dan [1.1]\n;;; : * Adding a different disp", "end": 1947, "score": 0.9976303577423096, "start": 1944, "tag": "NAME", "value": "Dan" }, { "context": "nor control over the graph display.\n;;; 2011.11.17 Dan\n;;; : * Added support for another dis", "end": 2491, "score": 0.9711599946022034, "start": 2488, "tag": "NAME", "value": "Dan" }, { "context": "ch case they're all drawn width 1).\n;;; 2011.12.06 Dan\n;;; : * Adding the extra data to the ", "end": 2912, "score": 0.9795494675636292, "start": 2909, "tag": "NAME", "value": "Dan" }, { "context": "rite out a .dot file for the graph.\n;;; 2011.12.07 Dan\n;;; : * Added the command production-", "end": 3086, "score": 0.8916848301887512, "start": 3083, "tag": "NAME", "value": "Dan" }, { "context": ": graph viewer is used instead. \n;;; 2011.12.22 Dan\n;;; : * Added another type of display", "end": 3888, "score": 0.806402325630188, "start": 3885, "tag": "NAME", "value": "Dan" }, { "context": "nother type of display - utilities.\n;;; 2012.02.01 Dan\n;;; : * Added a declare and removed u", "end": 3970, "score": 0.6062349677085876, "start": 3967, "tag": "NAME", "value": "Dan" }, { "context": " : some load time warnings.\n;;; 2012.03.12 Dan\n;;; : * Save both the current utility", "end": 4112, "score": 0.9794514775276184, "start": 4109, "tag": "NAME", "value": "Dan" }, { "context": "ent production history viewer info.\n;;; 2012.03.22 Dan\n;;; : * Changed the graph display for", "end": 4283, "score": 0.9525420069694519, "start": 4280, "tag": "NAME", "value": "Dan" }, { "context": "r the current display's green box).\n;;; 2012.04.27 Dan\n;;; : * Fixed a bug with displaying t", "end": 4703, "score": 0.9788135290145874, "start": 4700, "tag": "NAME", "value": "Dan" }, { "context": " graph\n;;; : display.\n;;; 2013.01.10 Dan\n;;; : * Changed the environment data ", "end": 4959, "score": 0.985842764377594, "start": 4956, "tag": "NAME", "value": "Dan" } ]
cogsciabc/learningmodel/actr6/other-files/production-history.lisp
akangasr/cogsciabc
1
;;; -*- mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Author : Dan Bothell ;;; Copyright : (c) 2004 Dan Bothell ;;; Availability: Covered by the GNU LGPL, see LGPL.txt ;;; Address : Department of Psychology ;;; : Carnegie Mellon University ;;; : Pittsburgh, PA 15213-3890 ;;; : [email protected] ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Filename : production-history.lisp ;;; Version : 1.1 ;;; ;;; Description : Code to support the production trace tool in the environment. ;;; ;;; Bugs : ;;; ;;; To do : [X] Consider making a module for this to allow configuration ;;; : of the display (colors, widths, restricted productions, ;;; : etc) and provide a simple parameter switch to enable. ;;; : [ ] Draw the links "better" with respect to crossing and ;;; : overlapping. ;;; ;;; ----- History ----- ;;; 2008.08.06 Dan ;;; : * Initial creation. ;;; 2008.08.06 Dan ;;; : * Making it a module and doing some optimizing on how it ;;; : stores/creates the data to send because it can't handle ;;; : long runs (zbrodoff tutorial model often results in an ;;; : allocation error). ;;; 2008.08.07 Dan ;;; : * Another stability improvement. It now breaks the grid ;;; : up into smaller updates to send over to the environment ;;; : to avoid having to create one very large string. Slows ;;; : down the displaying, but shouldn't result in any allocation ;;; : issues. ;;; 2008.08.12 Dan ;;; : * Added the :p-history-colors parameter to allow one to ;;; : change the colors used in the grid. ;;; 2011.10.28 Dan [1.1] ;;; : * Adding a different display option for the data - a directed ;;; : graph with the productions as nodes and where a link from A->B ;;; : indicates that B was in the conflict set after A fired. ;;; : * Changed the name of the function used by the previous display ;;; : to production-history-chart-data since the new tool is actually ;;; : a graph. ;;; : * Added parameters for some minor control over the graph display. ;;; 2011.11.17 Dan ;;; : * Added support for another display option in the history graph: ;;; : "Frequencies" which draws the links with widths based on thier ;;; : relative frequencies. The most frequent will be drawn 1/4 of ;;; : the x spacing wide and the rest scaled to that (unless all are ;;; : the same in which case they're all drawn width 1). ;;; 2011.12.06 Dan ;;; : * Adding the extra data to the info sent for the graph so that ;;; : the tcl side can write out a .dot file for the graph. ;;; 2011.12.07 Dan ;;; : * Added the command production-transition-graph which prints ;;; : a DOT representation of the saved production history data ;;; : to the current ACT-R command output stream for the specified ;;; : graph type which can be one of :all, :run, :cycle, :unique-run, ;;; : or :unique-cycle. The graphs correspond to those that are ;;; : shown in the environment tool using the corresponding buttons, ;;; : and when there are multiple subgraphs each has its own cluster ;;; : in the output. This allows one to create the graphs without ;;; : without having the environment connected if an external DOT ;;; : graph viewer is used instead. ;;; 2011.12.22 Dan ;;; : * Added another type of display - utilities. ;;; 2012.02.01 Dan ;;; : * Added a declare and removed unused variables to clean up ;;; : some load time warnings. ;;; 2012.03.12 Dan ;;; : * Save both the current utility and the U(n) value for display ;;; : in the environment production history viewer info. ;;; 2012.03.22 Dan ;;; : * Changed the graph display for runs and utilities so that it ;;; : doesn't show the unchosen links from the end of one session ;;; : to the beginning of the next on the following display (that ;;; : is the dashed links from the previous displays red box to the ;;; : unchosen competitors for the current display's green box). ;;; 2012.04.27 Dan ;;; : * Fixed a bug with displaying the utility graph when there are ;;; : no utility differences. ;;; : * Added an option for hiding the unused productions in the graph ;;; : display. ;;; 2013.01.10 Dan ;;; : * Changed the environment data cache to an equalp hashtable ;;; : since the keys are now a cons of the handler name and the ;;; : window to prevent issues with multi-environment settings. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; General Docs: ;;; ;;; Open either of the production history tools, "Production History" or "Production ;;; Graph" before running the model or set the :save-p-history parameter to t in the ;;; model to enable the recording. Once the model stops running the information ;;; about the productions which were in the conflict set during the run can be ;;; viewed using the tools. ;;; ;;; For the "History" tool, once the model has run click the "Get history" button ;;; in the bottom left corner of the production history window. It will draw a grid ;;; with the rows being the productions in the model and the columns being the times ;;; at which a conflict-resolution event occurred. ;;; ;;; The cells in the grid are color coded based on what happened during the ;;; conflict resolution event at the time indicated for the column. ;;; ;;; If the production was the one selected the cell will be green. ;;; If the production was in the conflict set, but not selected then the cell ;;; will be orange. ;;; If the production was not in the conflict set then the cell will be red. ;;; If the production did not exist at that time the cell will be white. ;;; ;;; Placing the cursor over a cell will cause some details for that production ;;; during that conflict resolution event to be printed at the bottom of the ;;; window. ;;; ;;; For the green and orange cells it will print the utility value for the ;;; production at that time. For the red cells it will print the whynot ;;; information indicating the condition that caused the production to not be ;;; in the conflict set. There is no extra information to print for a white ;;; cell. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; For the "Graph" tool, after the model has run click one of the 6 buttons ;;; "All transitions", "Frequencies", "Cycles", "Unique Cycles", "Runs", "Unique Runs" ;;; or "Utilities" to have the data displayed. All of the displays are drawn the same ;;; way and the common features will be described before indicating what differs among ;;; the button choices. ;;; ;;; The display will show all of the productions in the model in boxes. If the ;;; box has a black border then it was selected and fired at some point in the ;;; model's run. If it has a gray border then it was not selected and fired. ;;; If there is a green border around a production then it is the first production ;;; which was selected for the currently displayed information, and if it has ;;; a red border then it was the last production selected for the currently displayed ;;; information. ;;; ;;; An arrow from a production A to production B means that production B was in ;;; the conflict set after production A fired. If the arrow has a solid black line then ;;; production B was selected and fired after A, but if the arrow has a dashed gray ;;; line then it was not selected and fired. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; The "All transitions" button shows the data for all production firings over ;;; the entire run of the model. The "Frequencies" button shows the same data ;;; except that the thickness of the links reflects their relative frequencies. ;;; The most frequent will be 1/4 of :p-history-graph-x wide and the others ;;; scaled appropriately. ;;; ;;; The "Cycles" and "Unique Cycles" buttons show the data broken down into ;;; cycles which occur in the graph (when a loop is formed by a production ;;; eventually firing again after itself). The display will show only one ;;; cycle at a time. The number of cycles which occurred is shown below ;;; the graph and the "-" and "+" buttons can be used to change which cycle ;;; is shown. For "Cycles" all production firings are shown and the cycles ;;; are displayed in temporal order with the model time for the start and end ;;; displayed at the bottom of the window. For the "Unique Cycles" it only ;;; shows one instance of each cycle that occurs and no specific time information ;;; is shown. ;;; ;;; The "Runs" and "Unique Runs" buttons show the data broken down into sections ;;; based on when one of the ACT-R running commands were called. The display will ;;; only one "run" at a time. The number of non-empty runs which occurred is ;;; shown below the graph and the "-" and "+" buttons can be used to change which run ;;; is shown. For "Runs" all production firings are shown and the runs ;;; are displayed in temporal order with the model time for the start and end ;;; of the run displayed at the bottom of the window. For the "Unique Runs" it only ;;; shows one instance of each production graph that occurs in a run and no specific ;;; time information is shown. ;;; ;;; The "Utilities" button breaks the data down into sections based on when the ;;; model receives a reward. Each of the production boxes will be the same width ;;; in this display and may have two additional bars displayed within the box. ;;; A blue bar at the top represents the relative utility of that production before ;;; the reward which ended this section has been applied and a blue bar at the ;;; bottom represents the relative utility of that production after the reward ;;; has been applied. The utility values are scaled so that the range between the ;;; minimum utility across all sections and the maximum utility across all sections ;;; can be displayed. If there is no bottom bar then it means that there was no ;;; reward provided (the last chart may end because the model stopped instead of ;;; because there was a reward provided). ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Public API: ;;; ;;; :save-p-history parameter ;;; Enables the recording of production history for display (default is nil). ;;; ;;; :draw-blank-columns parameter ;;; When set to t (the default value) all conflict resolution events get drawn ;;; in the environment tool. If set to nil then conflict resolution events ;;; which had a null conflict set don't get drawn. ;;; ;;; :p-history-colors ;;; This parameter can be used to change the colors displayed in the grid. ;;; If it is nil (the default) then the green, orange, and red defaults are ;;; used for selected, conflict set, and mismatched respectively. It can be ;;; set to a list of 3 values where each value is either a color string or nil. ;;; A valid color string starts with the character # and is followed by 3, 6, ;;; 9 hex digits. Those digits represent the components of the color to use ;;; and specify the Red, Green, and Blue values respectively using the same ;;; number of bits for each (thus either 8, 16, or 24 bits per color). An ;;; example would be "#00F" for blue or "#44DA22" which is the green color ;;; used by default. ;;; ;;; :p-history-graph-x ;;; The horizontal pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;; :p-history-graph-y ;;; The vertical pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Design Choices: ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #+:packaged-actr (in-package :act-r) #+(and :clean-actr (not :packaged-actr) :ALLEGRO-IDE) (in-package :cg-user) #-(or (not :clean-actr) :packaged-actr :ALLEGRO-IDE) (in-package :cl-user) (defstruct p-history-module history enabled why-not-list draw-blanks current-data color-list graph-table x-spacing y-spacing) (defstruct p-history time selected matched mismatched info tag) (defun production-history-reward-markers (reward) (declare (ignore reward)) (let ((history (get-module production-history))) (when (p-history-module-enabled history) (push (make-p-history :tag :reward :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history history))))) (defun production-history-start-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :start :time (mp-time)) (p-history-module-history ph)))) (defun production-history-stop-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :stop :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history ph)))) (defun production-history-recorder (cs) (let* ((history (get-module production-history)) (best (car cs)) (mismatched (set-difference (all-productions) cs)) (block (make-p-history :mismatched mismatched :time (mp-time)))) (no-output (let ((ut (sgp :ut))) (when (and best (or (not (numberp ut)) (and (numberp ut) (>= (caar (spp-fct (list best :utility))) ut)))) (setf (p-history-selected block) best)) (dolist (x cs) (push (cons x (car (spp-fct (list x :utility :u)))) (p-history-info block))) (dolist (x mismatched) (let* ((reason (production-failure-reason x)) (index (position reason (p-history-module-why-not-list history) :test #'string-equal))) (unless index (setf index (length (p-history-module-why-not-list history))) (push-last reason (p-history-module-why-not-list history))) (push (cons x (list index 0)) (p-history-info block))))) (if (p-history-selected block) (setf (p-history-matched block) (cdr cs)) (setf (p-history-matched block) cs)) (push block (p-history-module-history history)) nil))) (defun production-history-chart-data (item) (declare (ignore item)) (let ((history (get-module production-history))) (when (null (p-history-module-current-data history)) (parse-production-history-chart-data)) (let ((data (p-history-module-current-data history))) (if (> (length data) 200) (let ((results (subseq data 0 200))) (setf (p-history-module-current-data history) (subseq data 200)) (mapcar (lambda (x) (format nil "~{~S ~}" x)) results)) (progn (setf (p-history-module-current-data history) nil) (mapcar (lambda (x) (format nil "~{~S ~}" x)) (push (list 'done) data))))))) (defun parse-production-history-chart-data () (let* ((results nil) (history (get-module production-history)) (p-names (all-productions)) (columns 0) (name-size (apply 'max (mapcar (lambda (x) (length (symbol-name x))) p-names)))) (dolist (x (p-history-module-history history)) (when (and (or (p-history-module-draw-blanks history) (or (p-history-selected x) (p-history-matched x))) (null (p-history-tag x))) (let ((col (list 'column (p-history-time x)))) (dolist (y p-names) (cond ((eq y (p-history-selected x)) (push-last 0 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-matched x)) (push-last 1 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-mismatched x)) (push-last 2 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))))) (incf columns) (push col results)))) (push (cons 'labels p-names) results) (push (list 'colors (aif (nth 0 (p-history-module-color-list history)) it "#44DA22") (aif (nth 1 (p-history-module-color-list history)) it "#FCA31D") (aif (nth 2 (p-history-module-color-list history)) it "#E1031E")) results) (push (cons 'reasons (p-history-module-why-not-list history)) results) (push (list 'size (* 20 (1+ (length p-names))) 20 (* 9 name-size) 80 (* 80 columns)) results) (setf (p-history-module-current-data history) results) nil)) (defstruct (p-history-node (:conc-name phn-)) name color-starts color-ends cycle-starts cycle-ends links utilities) (defstruct (p-history-link (:conc-name phl-)) target color count cycle from-time to-time) (defstruct (p-history-display (:conc-name phd-)) name x y color width links starts ends utilities) (defstruct (p-history-cache (:conc-name phc-)) offsets holes max-loops max height min-u max-u) (defun parse-production-history-graph (which) (let ((nodes (mapcar (lambda (x) (make-p-history-node :name x :links nil)) (all-productions))) (history (get-module production-history)) (loops nil) (current-loop nil) (cycle 0) (top nil) (previous nil) (max-color 0) (max-cycle 0) (start-time nil) (min-utility nil) (max-utility nil) (stop-utilities nil)) (dolist (x (reverse (p-history-module-history history))) (let ((selected (p-history-selected x)) (matched (p-history-matched x)) (time (p-history-time x))) (cond ((find which '(:all :freq :color :cycle)) (when (or matched selected) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (when (find selected current-loop :key 'car) ;; completed a loop (let* ((existing-color (position (cons selected (mapcar 'car current-loop)) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) current-loop (cons (cons selected time) (butlast current-loop))) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find selected nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find selected nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (cons selected (mapcar 'car current-loop)) loops))) (incf cycle) (setf current-loop nil)) (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))))) ((find which '(:run :run-color)) (when (or matched selected (p-history-tag x)) (when (eq :start (p-history-tag x)) (setf start-time time)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (and current-loop (eq :stop (p-history-tag x))) ;; completed a loop (let* ((existing-color (position (mapcar 'car current-loop) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (cons cycle start-time) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find (caar current-loop) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (mapcar 'car current-loop) loops))) (incf cycle) (setf current-loop nil) ;; don't want the dashed lines from end of ;; one run going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)))) (t ;;(find which '(:utility)) (when (or matched selected (p-history-tag x)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (eq :stop (p-history-tag x)) (setf stop-utilities (p-history-info x))) (when (and current-loop (eq :reward (p-history-tag x))) ;; set the current scores (dolist (reward (p-history-info x)) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward)))) ;; completed a loop (let* () (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color 0 :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) ;; don't want the dashed lines from end of ;; one loop going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)) (incf cycle) (setf current-loop nil))))))) (when (and (eq which :utility) stop-utilities) (dolist (reward stop-utilities) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward))))) (when (or (> (length current-loop) 0)) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (push (make-p-history-link :target to :color (length loops) :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (length loops) (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (length loops) (phn-color-ends previous)) (push (cons cycle (cdar current-loop)) (phn-cycle-ends previous)) (setf max-color (length loops)) (setf max-cycle cycle)) (list top (when previous (phn-name previous)) nodes (list max-color max-cycle) (list min-utility max-utility)))) (defun filter-links (links which number) (case which ((:all :freq) (setf links (remove-duplicates links :key (lambda (x) (cons (phl-target x) (phl-count x))))) (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) links :key (lambda (y) (when (phl-count y) (phl-target y)))))) links)) ((:run :cycle :utility) (remove-if-not (lambda (x) (= (phl-cycle x) number)) links)) ((:run-color :color) (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) number)) links) :key 'phl-target)))) (defun remove-p-history-entry (name) (remhash name (p-history-module-graph-table (get-module production-history)))) (defun create-production-graph-coords (name which number with-labels show-unused) (let ((module (get-module production-history))) (if (p-history-module-history module) (multiple-value-bind (value exists) (if with-labels (values nil nil) (gethash name (p-history-module-graph-table module))) (if exists (p-history-display-output which number with-labels (phc-offsets value) (phc-holes value) (phc-max-loops value) (phc-max value) (phc-height value) (phc-min-u value) (phc-max-u value)) (let* ((layer-data (parse-production-history-graph :cycle)) (data (if (find which '(:freq :all :color :cycle)) layer-data (parse-production-history-graph which))) (min-u (first (fifth data))) (max-u (second (fifth data))) (unused (all-productions)) (current (car data)) (next nil) (layers nil) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (first (fourth data))) ((:run :cycle :utility) (second (fourth data)))))) (while current (dolist (x current) (setf unused (remove x unused))) (dolist (x current) (dolist (y (phn-links (find x (third layer-data) :key 'phn-name))) (when (and (phl-count y) (find (phl-target y) unused)) (setf unused (remove (phl-target y) unused)) (push (phl-target y) next)))) (push current layers) (setf current next) (setf next nil)) (when (and unused show-unused) (push unused layers)) (let ((max 0) (cur 0) (y 65) (offsets nil) (widths nil) (holes nil) (max-width (* 10 (apply 'max (mapcar (lambda (x) (length (symbol-name x))) (all-productions)))))) (dolist (layer (reverse layers)) (let ((hole (list (round (p-history-module-x-spacing module) 2)))) (setf cur 0) (dolist (item layer) (let ((width (if (eq which :utility) max-width (* 10 (length (symbol-name item)))))) (push (make-p-history-display :name item :links (awhen (find item (third data) :key 'phn-name) (phn-links it)) :width width :x (+ cur (round width 2)) :y y :starts (case which ((:all :freq) (if (eq item start) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-starts (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-starts (find item (third data) :key 'phn-name)))) :ends (case which ((:all :freq) (if (eq item end) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-ends (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-ends (find item (third data) :key 'phn-name)))) :color (if (find item unused) 'gray 'black) :utilities (awhen (find item (third data) :key 'phn-name) (phn-utilities it))) offsets) ; (cons item (cons (+ cur (round width 2)) y)) offsets) (when (= (length hole) 1) (push (- cur (round (p-history-module-x-spacing module) 2)) hole)) (push (+ cur width (round (p-history-module-x-spacing module) 2)) hole) (incf cur (+ width (p-history-module-x-spacing module))))) (decf cur (p-history-module-x-spacing module)) (when (> cur max) (setf max cur)) (push (cons cur y) widths) (push-last y hole) (push hole holes) (incf y (+ 30 (p-history-module-y-spacing module))))) (incf max (* 2 (p-history-module-x-spacing module))) (setf holes (mapcar (lambda (x) (reverse (cons (- max (round (p-history-module-x-spacing module) 2)) x))) holes)) (dolist (w widths) (unless (= (car w) max) (dolist (o offsets) (when (= (phd-y o) (cdr w)) (incf (phd-x o) (round (- max (car w)) 2)))) (let ((h (find (cdr w) holes :key 'car))) (setf holes (cons (concatenate 'list (subseq h 0 2) (mapcar (lambda (x) (+ x (round (- max (car w)) 2))) (subseq (butlast h) 2)) (last h)) (remove h holes)))))) (setf (gethash name (p-history-module-graph-table module)) (make-p-history-cache :offsets offsets :holes holes :max-loops max-loops :max max :height y :min-u min-u :max-u max-u)) (p-history-display-output which number with-labels offsets holes max-loops max y min-u max-u))))) (list "size 300 40" "label \"no graph data to display\" 150 20 0 0 299 39 red" "cycles 0" "done")))) (defun p-history-display-output (which number with-labels offsets holes max-loops max height min-u max-u) (let ((min-time -1) (max-time -1) (links nil) (module (get-module production-history)) (max-link-count 0) (equal-link-counts t)) (when (and (numberp min-u) (numberp max-u) (= min-u max-u)) (setf min-u (1- min-u)) (setf max-u (1+ max-u))) (dolist (o offsets) (dolist (link (filter-links (phd-links o) which number)) ;; for now just using a next closest hole metric for ;; multi-level links but at some point may want to try ;; a shortest path instead or some sort of non-intersecting algorithm (let ((target (find (phl-target link) offsets :key 'phd-name)) (link-count (if (find which '(:freq #|:run :run-color if I want to do these too need to filter on color/run as well |#)) (count-if (lambda (x) (eq (phl-target x) (phl-target link))) (phd-links o)) nil))) (when (and (numberp link-count) (> link-count max-link-count)) (unless (zerop max-link-count) (setf equal-link-counts nil)) (setf max-link-count link-count)) (cond ((eq (phd-name o) (phd-name target)) ;; self link ;;; if left end loop on left side ;;; if right end loop on right side ;;; if in middle loop on bottom (cond ((= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; left end uses both left sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) ((= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; right end uses both right sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) (t (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) 5) (+ (phd-y o) 15) (+ (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 5) (+ (phd-y o) 15)) links)))) ((= (phd-y o) (phd-y target)) ;; same row ;; link bottom right of leftmost to bottom left of rightmost (if (> (phd-x target) (phd-x o)) ;; left to right (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (+ (+ (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x target) (round (phd-width target) 2)) (+ (phd-x o) (round (phd-width o) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (- (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links) ;; right to left (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (- (- (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x o) (round (phd-width o) 2)) (+ (phd-x target) (round (phd-width target) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (+ (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links))) ((> (phd-y target) (phd-y o)) ;; forward i.e. down ;; if one layer down draw bottom center to top center directly ;; otherwise draw bottom center to top center going through next closest hole (if (= (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15) (phd-x target) (- (phd-y target) 15)) links) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15)) (let ((x (phd-x o)) (vals nil)) (dotimes (i (- (/ (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (+ (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (- y 20) vals) ;; a little slack above and below (push min-x vals) (push (+ y 20) vals) (setf x min-x))) (reverse vals)) (list (phd-x target) (- (phd-y target) 15))) links))) (t ;; backward i.e. up ;; going up draw from 1/3 left or right of center top to l/r 1/3 from center bottom ;; which left and which right depends on positions ;; if only one level apart then pick both sides based on position of from relative to to ;; - if from left of to then go from left to left otherwise go right to right ;; if multiple levels then ;; if from is leftmost in it's row start and end are both left ;; if from is rightmost in it's row start and end are both right ;; if to is left of from then use left for from and right for to ;; if to is right of from then use right for from and left for to ;; if same column then check which side of screen left start is on ;; if it's on the left use left for both ;; otherwise use right for both ;; all intermediates are based on next closest hole (going up) (if (= (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) ;; one level up (if (<= (phd-x o) (phd-x target)) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (- (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (+ (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links)) ;; multiple levels (let ((start-x nil) (end-x nil)) (cond ((and (= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (<= (- (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; left end uses both left sides if target point also on left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((and (= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (>= (+ (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; right end uses both right sides if target also on right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((< (phd-x target) (phd-x o)) ; target is to the left so start on left and end on right (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((> (phd-x target) (phd-x o)) ; target is to the right so start on right and end on left (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((< (phd-x o) (round max 2)) ;; same column so use the side of screen to judge and same for both ;; left is left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) (t ;; same column so use the side of screen to judge and same for both ;; right is right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6))))) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count start-x (- (phd-y o) 15)) (let ((x start-x) (vals nil)) (dotimes (i (- (/ (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (- (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (+ y 20) vals) (push min-x vals) (push (- y 20) vals) (setf x min-x))) (reverse vals)) (list end-x (+ (phd-y target) 15))) links)))))))) (append (list (format nil "size ~d ~d" max height)) (let ((results nil)) (dolist (x offsets) (when with-labels (push (format nil "label ~S ~d ~d ~d ~d ~d ~d ~s" (phd-name x) (phd-x x) (phd-y x) (- (phd-x x) (round (phd-width x) 2)) (- (phd-y x) 15) (+ (phd-x x) (round (phd-width x) 2)) (+ (phd-y x) 15) (if (keywordp (phd-color x)) 'black (phd-color x))) results)) (when (eq which :utility) (awhen (assoc number (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (- (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (- (phd-y x) 9) 'blue) results)) (awhen (assoc (1+ number) (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (+ (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (+ (phd-y x) 9) 'blue) results))) (awhen (find number (phd-starts x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf min-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) 2) (- (phd-y x) 17) (+ (phd-x x) (round (phd-width x) 2) 2) (+ (phd-y x) 17) 'green) results)) (awhen (find number (phd-ends x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf max-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -2) (- (phd-y x) 13) (+ (phd-x x) (round (phd-width x) 2) -2) (+ (phd-y x) 13) 'red) results))) results) (mapcar (lambda (x) (format nil "link ~s ~s ~s ~d~{ ~d~}" (first x) (second x) (third x) (if (or (null (fourth x)) equal-link-counts (= 1 max-link-count) (= 0 max-link-count)) 1 (let ((max-width (round (p-history-module-x-spacing module) 4))) (max 1 (round (* max-width (/ (fourth x) max-link-count)))))) (cddddr x))) ;; because frequency needs to count links there are potentially duplicates but only need ;; to send over one of each... (remove-duplicates links :test (lambda (x y) (and (eq (first x) (first y)) (eq (second x) (second y)) (eq (third x) (third y)))))) (when (and (or (eq which :cycle) (eq which :run) (eq which :utility)) (> min-time -1) (> max-time -1)) (list (format nil "min_time ~f" min-time) (format nil "max_time ~f" max-time))) (list (format nil "cycles ~d" max-loops)) #| show the holes for debugging (let ((z nil)) (dolist (x holes) (mapcar (lambda (y) (push (format nil "link blue ~d ~d ~d ~d" y (- (car x) 15) y (+ (car x) 15)) z)) (cdr x))) z) |# (list "done")))) ;;; A command to allow getting .dot output of the graphs without using the environment. (defun production-transition-graph (&optional (which :all)) (verify-current-model "Cannot generate a production transition graph because there is no current model." (unless (find which '(:all :cycle :run :unique-cycle :unique-run)) (print-warning "Invalid graph type. Must be one of (:all :cycle :run :unique-cycle :unique-run).") (return-from production-transition-graph)) (when (eq which :unique-cycle) (setf which :color)) (when (eq which :unique-run) (setf which :run-color)) (let* ((data (parse-production-history-graph which)) (unused (all-productions)) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (1+ (first (fourth data)))) ((:run :cycle) (1+ (second (fourth data))))))) (cond ((eq which :all) (command-output "digraph \"~s\" {" (current-model)) (command-output " \"~s\" [ color = green ];" start) (unless (eq start end) (command-output " \"~s\" [ color = red ];" end)) (dolist (node (third data)) (let* ((transitions (remove-duplicates (phn-links node) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (if (phl-count link) (progn (setf unused (remove (phl-target link) unused)) (command-output " \"~s\" -> \"~s\" ;" (phn-name node) (phl-target link))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (phn-name node) (phl-target link)))))) (dolist (node unused) (command-output " \"~s\" [color = gray] ;" node)) (command-output "}")) ((or (eq which :color) (eq which :run-color)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i (if (eq which :color) "unique cycle" "unique run") (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key 'phn-color-starts))) (end-node (phn-name (find i (third data) :test 'member :key 'phn-color-ends))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")) ((or (eq which :cycle) (eq which :run)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i which (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-starts y)))))) (end-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-ends y)))))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-cycle x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-cycle x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")))))) (defun reset-p-history-module (module) (setf (p-history-module-history module) nil) (setf (p-history-module-why-not-list module) nil) (setf (p-history-module-graph-table module) (make-hash-table :test 'equalp))) (defun params-p-history-module (instance param) (if (consp param) (case (car param) (:save-p-history (no-output (progn (if (cdr param) (progn (unless (find 'production-history-recorder (car (sgp :conflict-set-hook))) (sgp :conflict-set-hook production-history-recorder)) (unless (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (sgp :reward-notify-hook production-history-reward-markers))) (progn (when (find 'production-history-recorder (car (sgp :conflict-set-hook))) (let ((old-hooks (car (sgp :conflict-set-hook)))) (sgp :conflict-set-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-recorder) (sgp-fct (list :conflict-set-hook x)))))) (when (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (let ((old-hooks (car (sgp :reward-notify-hook)))) (sgp :reward-notify-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-reward-markers) (sgp-fct (list :reward-notify-hook x)))))))) (setf (p-history-module-enabled instance) (cdr param))))) (:p-history-colors (setf (p-history-module-color-list instance) (cdr param))) (:draw-blank-columns (setf (p-history-module-draw-blanks instance) (cdr param))) (:p-history-graph-x (setf (p-history-module-x-spacing instance) (cdr param))) (:p-history-graph-y (setf (p-history-module-y-spacing instance) (cdr param)))) (case param (:save-p-history (p-history-module-enabled instance)) (:p-history-colors (p-history-module-color-list instance)) (:draw-blank-columns (p-history-module-draw-blanks instance)) (:p-history-graph-x (p-history-module-x-spacing instance)) (:p-history-graph-y (p-history-module-y-spacing instance))))) (define-module-fct 'production-history nil (list (define-parameter :save-p-history :valid-test 'tornil :default-value nil :warning "T or nil" :documentation "Whether or not to record the utility and whynot history of all conflict-resolution events.") (define-parameter :p-history-colors :valid-test (lambda (x) (or (null x) (and (listp x) (<= (length x) 3) (every (lambda (y) (or (null y) (stringp y))) x)))) :default-value nil :warning "nil or a list of up to 3 color strings" :documentation "The colors to use for the selected, other matched, and mismatched cells respectively.") (define-parameter :draw-blank-columns :valid-test 'tornil :default-value t :warning "T or nil" :documentation "Whether or not to draw the columns which have no matched productions.") (define-parameter :p-history-graph-x :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 40 :warning "non-negative integer" :documentation "Horizontal pixels between production boxes.") (define-parameter :p-history-graph-y :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 90 :warning "non-negative integer" :documentation "Vertical pixels between production boxes.")) :creation (lambda (x) (declare (ignore x)) (make-p-history-module)) :reset 'reset-p-history-module :params 'params-p-history-module :run-start 'production-history-start-markers :run-end 'production-history-stop-markers :version "1.1" :documentation "Module to record production history for display in the environment.") #| This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |#
52269
;;; -*- mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Author : <NAME> ;;; Copyright : (c) 2004 <NAME> ;;; Availability: Covered by the GNU LGPL, see LGPL.txt ;;; Address : Department of Psychology ;;; : Carnegie Mellon University ;;; : Pittsburgh, PA 15213-3890 ;;; : <EMAIL> ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Filename : production-history.lisp ;;; Version : 1.1 ;;; ;;; Description : Code to support the production trace tool in the environment. ;;; ;;; Bugs : ;;; ;;; To do : [X] Consider making a module for this to allow configuration ;;; : of the display (colors, widths, restricted productions, ;;; : etc) and provide a simple parameter switch to enable. ;;; : [ ] Draw the links "better" with respect to crossing and ;;; : overlapping. ;;; ;;; ----- History ----- ;;; 2008.08.06 Dan ;;; : * Initial creation. ;;; 2008.08.06 Dan ;;; : * Making it a module and doing some optimizing on how it ;;; : stores/creates the data to send because it can't handle ;;; : long runs (zbrodoff tutorial model often results in an ;;; : allocation error). ;;; 2008.08.07 Dan ;;; : * Another stability improvement. It now breaks the grid ;;; : up into smaller updates to send over to the environment ;;; : to avoid having to create one very large string. Slows ;;; : down the displaying, but shouldn't result in any allocation ;;; : issues. ;;; 2008.08.12 Dan ;;; : * Added the :p-history-colors parameter to allow one to ;;; : change the colors used in the grid. ;;; 2011.10.28 <NAME> [1.1] ;;; : * Adding a different display option for the data - a directed ;;; : graph with the productions as nodes and where a link from A->B ;;; : indicates that B was in the conflict set after A fired. ;;; : * Changed the name of the function used by the previous display ;;; : to production-history-chart-data since the new tool is actually ;;; : a graph. ;;; : * Added parameters for some minor control over the graph display. ;;; 2011.11.17 <NAME> ;;; : * Added support for another display option in the history graph: ;;; : "Frequencies" which draws the links with widths based on thier ;;; : relative frequencies. The most frequent will be drawn 1/4 of ;;; : the x spacing wide and the rest scaled to that (unless all are ;;; : the same in which case they're all drawn width 1). ;;; 2011.12.06 <NAME> ;;; : * Adding the extra data to the info sent for the graph so that ;;; : the tcl side can write out a .dot file for the graph. ;;; 2011.12.07 <NAME> ;;; : * Added the command production-transition-graph which prints ;;; : a DOT representation of the saved production history data ;;; : to the current ACT-R command output stream for the specified ;;; : graph type which can be one of :all, :run, :cycle, :unique-run, ;;; : or :unique-cycle. The graphs correspond to those that are ;;; : shown in the environment tool using the corresponding buttons, ;;; : and when there are multiple subgraphs each has its own cluster ;;; : in the output. This allows one to create the graphs without ;;; : without having the environment connected if an external DOT ;;; : graph viewer is used instead. ;;; 2011.12.22 <NAME> ;;; : * Added another type of display - utilities. ;;; 2012.02.01 <NAME> ;;; : * Added a declare and removed unused variables to clean up ;;; : some load time warnings. ;;; 2012.03.12 <NAME> ;;; : * Save both the current utility and the U(n) value for display ;;; : in the environment production history viewer info. ;;; 2012.03.22 <NAME> ;;; : * Changed the graph display for runs and utilities so that it ;;; : doesn't show the unchosen links from the end of one session ;;; : to the beginning of the next on the following display (that ;;; : is the dashed links from the previous displays red box to the ;;; : unchosen competitors for the current display's green box). ;;; 2012.04.27 <NAME> ;;; : * Fixed a bug with displaying the utility graph when there are ;;; : no utility differences. ;;; : * Added an option for hiding the unused productions in the graph ;;; : display. ;;; 2013.01.10 <NAME> ;;; : * Changed the environment data cache to an equalp hashtable ;;; : since the keys are now a cons of the handler name and the ;;; : window to prevent issues with multi-environment settings. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; General Docs: ;;; ;;; Open either of the production history tools, "Production History" or "Production ;;; Graph" before running the model or set the :save-p-history parameter to t in the ;;; model to enable the recording. Once the model stops running the information ;;; about the productions which were in the conflict set during the run can be ;;; viewed using the tools. ;;; ;;; For the "History" tool, once the model has run click the "Get history" button ;;; in the bottom left corner of the production history window. It will draw a grid ;;; with the rows being the productions in the model and the columns being the times ;;; at which a conflict-resolution event occurred. ;;; ;;; The cells in the grid are color coded based on what happened during the ;;; conflict resolution event at the time indicated for the column. ;;; ;;; If the production was the one selected the cell will be green. ;;; If the production was in the conflict set, but not selected then the cell ;;; will be orange. ;;; If the production was not in the conflict set then the cell will be red. ;;; If the production did not exist at that time the cell will be white. ;;; ;;; Placing the cursor over a cell will cause some details for that production ;;; during that conflict resolution event to be printed at the bottom of the ;;; window. ;;; ;;; For the green and orange cells it will print the utility value for the ;;; production at that time. For the red cells it will print the whynot ;;; information indicating the condition that caused the production to not be ;;; in the conflict set. There is no extra information to print for a white ;;; cell. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; For the "Graph" tool, after the model has run click one of the 6 buttons ;;; "All transitions", "Frequencies", "Cycles", "Unique Cycles", "Runs", "Unique Runs" ;;; or "Utilities" to have the data displayed. All of the displays are drawn the same ;;; way and the common features will be described before indicating what differs among ;;; the button choices. ;;; ;;; The display will show all of the productions in the model in boxes. If the ;;; box has a black border then it was selected and fired at some point in the ;;; model's run. If it has a gray border then it was not selected and fired. ;;; If there is a green border around a production then it is the first production ;;; which was selected for the currently displayed information, and if it has ;;; a red border then it was the last production selected for the currently displayed ;;; information. ;;; ;;; An arrow from a production A to production B means that production B was in ;;; the conflict set after production A fired. If the arrow has a solid black line then ;;; production B was selected and fired after A, but if the arrow has a dashed gray ;;; line then it was not selected and fired. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; The "All transitions" button shows the data for all production firings over ;;; the entire run of the model. The "Frequencies" button shows the same data ;;; except that the thickness of the links reflects their relative frequencies. ;;; The most frequent will be 1/4 of :p-history-graph-x wide and the others ;;; scaled appropriately. ;;; ;;; The "Cycles" and "Unique Cycles" buttons show the data broken down into ;;; cycles which occur in the graph (when a loop is formed by a production ;;; eventually firing again after itself). The display will show only one ;;; cycle at a time. The number of cycles which occurred is shown below ;;; the graph and the "-" and "+" buttons can be used to change which cycle ;;; is shown. For "Cycles" all production firings are shown and the cycles ;;; are displayed in temporal order with the model time for the start and end ;;; displayed at the bottom of the window. For the "Unique Cycles" it only ;;; shows one instance of each cycle that occurs and no specific time information ;;; is shown. ;;; ;;; The "Runs" and "Unique Runs" buttons show the data broken down into sections ;;; based on when one of the ACT-R running commands were called. The display will ;;; only one "run" at a time. The number of non-empty runs which occurred is ;;; shown below the graph and the "-" and "+" buttons can be used to change which run ;;; is shown. For "Runs" all production firings are shown and the runs ;;; are displayed in temporal order with the model time for the start and end ;;; of the run displayed at the bottom of the window. For the "Unique Runs" it only ;;; shows one instance of each production graph that occurs in a run and no specific ;;; time information is shown. ;;; ;;; The "Utilities" button breaks the data down into sections based on when the ;;; model receives a reward. Each of the production boxes will be the same width ;;; in this display and may have two additional bars displayed within the box. ;;; A blue bar at the top represents the relative utility of that production before ;;; the reward which ended this section has been applied and a blue bar at the ;;; bottom represents the relative utility of that production after the reward ;;; has been applied. The utility values are scaled so that the range between the ;;; minimum utility across all sections and the maximum utility across all sections ;;; can be displayed. If there is no bottom bar then it means that there was no ;;; reward provided (the last chart may end because the model stopped instead of ;;; because there was a reward provided). ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Public API: ;;; ;;; :save-p-history parameter ;;; Enables the recording of production history for display (default is nil). ;;; ;;; :draw-blank-columns parameter ;;; When set to t (the default value) all conflict resolution events get drawn ;;; in the environment tool. If set to nil then conflict resolution events ;;; which had a null conflict set don't get drawn. ;;; ;;; :p-history-colors ;;; This parameter can be used to change the colors displayed in the grid. ;;; If it is nil (the default) then the green, orange, and red defaults are ;;; used for selected, conflict set, and mismatched respectively. It can be ;;; set to a list of 3 values where each value is either a color string or nil. ;;; A valid color string starts with the character # and is followed by 3, 6, ;;; 9 hex digits. Those digits represent the components of the color to use ;;; and specify the Red, Green, and Blue values respectively using the same ;;; number of bits for each (thus either 8, 16, or 24 bits per color). An ;;; example would be "#00F" for blue or "#44DA22" which is the green color ;;; used by default. ;;; ;;; :p-history-graph-x ;;; The horizontal pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;; :p-history-graph-y ;;; The vertical pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Design Choices: ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #+:packaged-actr (in-package :act-r) #+(and :clean-actr (not :packaged-actr) :ALLEGRO-IDE) (in-package :cg-user) #-(or (not :clean-actr) :packaged-actr :ALLEGRO-IDE) (in-package :cl-user) (defstruct p-history-module history enabled why-not-list draw-blanks current-data color-list graph-table x-spacing y-spacing) (defstruct p-history time selected matched mismatched info tag) (defun production-history-reward-markers (reward) (declare (ignore reward)) (let ((history (get-module production-history))) (when (p-history-module-enabled history) (push (make-p-history :tag :reward :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history history))))) (defun production-history-start-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :start :time (mp-time)) (p-history-module-history ph)))) (defun production-history-stop-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :stop :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history ph)))) (defun production-history-recorder (cs) (let* ((history (get-module production-history)) (best (car cs)) (mismatched (set-difference (all-productions) cs)) (block (make-p-history :mismatched mismatched :time (mp-time)))) (no-output (let ((ut (sgp :ut))) (when (and best (or (not (numberp ut)) (and (numberp ut) (>= (caar (spp-fct (list best :utility))) ut)))) (setf (p-history-selected block) best)) (dolist (x cs) (push (cons x (car (spp-fct (list x :utility :u)))) (p-history-info block))) (dolist (x mismatched) (let* ((reason (production-failure-reason x)) (index (position reason (p-history-module-why-not-list history) :test #'string-equal))) (unless index (setf index (length (p-history-module-why-not-list history))) (push-last reason (p-history-module-why-not-list history))) (push (cons x (list index 0)) (p-history-info block))))) (if (p-history-selected block) (setf (p-history-matched block) (cdr cs)) (setf (p-history-matched block) cs)) (push block (p-history-module-history history)) nil))) (defun production-history-chart-data (item) (declare (ignore item)) (let ((history (get-module production-history))) (when (null (p-history-module-current-data history)) (parse-production-history-chart-data)) (let ((data (p-history-module-current-data history))) (if (> (length data) 200) (let ((results (subseq data 0 200))) (setf (p-history-module-current-data history) (subseq data 200)) (mapcar (lambda (x) (format nil "~{~S ~}" x)) results)) (progn (setf (p-history-module-current-data history) nil) (mapcar (lambda (x) (format nil "~{~S ~}" x)) (push (list 'done) data))))))) (defun parse-production-history-chart-data () (let* ((results nil) (history (get-module production-history)) (p-names (all-productions)) (columns 0) (name-size (apply 'max (mapcar (lambda (x) (length (symbol-name x))) p-names)))) (dolist (x (p-history-module-history history)) (when (and (or (p-history-module-draw-blanks history) (or (p-history-selected x) (p-history-matched x))) (null (p-history-tag x))) (let ((col (list 'column (p-history-time x)))) (dolist (y p-names) (cond ((eq y (p-history-selected x)) (push-last 0 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-matched x)) (push-last 1 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-mismatched x)) (push-last 2 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))))) (incf columns) (push col results)))) (push (cons 'labels p-names) results) (push (list 'colors (aif (nth 0 (p-history-module-color-list history)) it "#44DA22") (aif (nth 1 (p-history-module-color-list history)) it "#FCA31D") (aif (nth 2 (p-history-module-color-list history)) it "#E1031E")) results) (push (cons 'reasons (p-history-module-why-not-list history)) results) (push (list 'size (* 20 (1+ (length p-names))) 20 (* 9 name-size) 80 (* 80 columns)) results) (setf (p-history-module-current-data history) results) nil)) (defstruct (p-history-node (:conc-name phn-)) name color-starts color-ends cycle-starts cycle-ends links utilities) (defstruct (p-history-link (:conc-name phl-)) target color count cycle from-time to-time) (defstruct (p-history-display (:conc-name phd-)) name x y color width links starts ends utilities) (defstruct (p-history-cache (:conc-name phc-)) offsets holes max-loops max height min-u max-u) (defun parse-production-history-graph (which) (let ((nodes (mapcar (lambda (x) (make-p-history-node :name x :links nil)) (all-productions))) (history (get-module production-history)) (loops nil) (current-loop nil) (cycle 0) (top nil) (previous nil) (max-color 0) (max-cycle 0) (start-time nil) (min-utility nil) (max-utility nil) (stop-utilities nil)) (dolist (x (reverse (p-history-module-history history))) (let ((selected (p-history-selected x)) (matched (p-history-matched x)) (time (p-history-time x))) (cond ((find which '(:all :freq :color :cycle)) (when (or matched selected) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (when (find selected current-loop :key 'car) ;; completed a loop (let* ((existing-color (position (cons selected (mapcar 'car current-loop)) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) current-loop (cons (cons selected time) (butlast current-loop))) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find selected nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find selected nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (cons selected (mapcar 'car current-loop)) loops))) (incf cycle) (setf current-loop nil)) (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))))) ((find which '(:run :run-color)) (when (or matched selected (p-history-tag x)) (when (eq :start (p-history-tag x)) (setf start-time time)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (and current-loop (eq :stop (p-history-tag x))) ;; completed a loop (let* ((existing-color (position (mapcar 'car current-loop) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (cons cycle start-time) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find (caar current-loop) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (mapcar 'car current-loop) loops))) (incf cycle) (setf current-loop nil) ;; don't want the dashed lines from end of ;; one run going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)))) (t ;;(find which '(:utility)) (when (or matched selected (p-history-tag x)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (eq :stop (p-history-tag x)) (setf stop-utilities (p-history-info x))) (when (and current-loop (eq :reward (p-history-tag x))) ;; set the current scores (dolist (reward (p-history-info x)) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward)))) ;; completed a loop (let* () (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color 0 :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) ;; don't want the dashed lines from end of ;; one loop going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)) (incf cycle) (setf current-loop nil))))))) (when (and (eq which :utility) stop-utilities) (dolist (reward stop-utilities) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward))))) (when (or (> (length current-loop) 0)) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (push (make-p-history-link :target to :color (length loops) :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (length loops) (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (length loops) (phn-color-ends previous)) (push (cons cycle (cdar current-loop)) (phn-cycle-ends previous)) (setf max-color (length loops)) (setf max-cycle cycle)) (list top (when previous (phn-name previous)) nodes (list max-color max-cycle) (list min-utility max-utility)))) (defun filter-links (links which number) (case which ((:all :freq) (setf links (remove-duplicates links :key (lambda (x) (cons (phl-target x) (phl-count x))))) (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) links :key (lambda (y) (when (phl-count y) (phl-target y)))))) links)) ((:run :cycle :utility) (remove-if-not (lambda (x) (= (phl-cycle x) number)) links)) ((:run-color :color) (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) number)) links) :key 'phl-target)))) (defun remove-p-history-entry (name) (remhash name (p-history-module-graph-table (get-module production-history)))) (defun create-production-graph-coords (name which number with-labels show-unused) (let ((module (get-module production-history))) (if (p-history-module-history module) (multiple-value-bind (value exists) (if with-labels (values nil nil) (gethash name (p-history-module-graph-table module))) (if exists (p-history-display-output which number with-labels (phc-offsets value) (phc-holes value) (phc-max-loops value) (phc-max value) (phc-height value) (phc-min-u value) (phc-max-u value)) (let* ((layer-data (parse-production-history-graph :cycle)) (data (if (find which '(:freq :all :color :cycle)) layer-data (parse-production-history-graph which))) (min-u (first (fifth data))) (max-u (second (fifth data))) (unused (all-productions)) (current (car data)) (next nil) (layers nil) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (first (fourth data))) ((:run :cycle :utility) (second (fourth data)))))) (while current (dolist (x current) (setf unused (remove x unused))) (dolist (x current) (dolist (y (phn-links (find x (third layer-data) :key 'phn-name))) (when (and (phl-count y) (find (phl-target y) unused)) (setf unused (remove (phl-target y) unused)) (push (phl-target y) next)))) (push current layers) (setf current next) (setf next nil)) (when (and unused show-unused) (push unused layers)) (let ((max 0) (cur 0) (y 65) (offsets nil) (widths nil) (holes nil) (max-width (* 10 (apply 'max (mapcar (lambda (x) (length (symbol-name x))) (all-productions)))))) (dolist (layer (reverse layers)) (let ((hole (list (round (p-history-module-x-spacing module) 2)))) (setf cur 0) (dolist (item layer) (let ((width (if (eq which :utility) max-width (* 10 (length (symbol-name item)))))) (push (make-p-history-display :name item :links (awhen (find item (third data) :key 'phn-name) (phn-links it)) :width width :x (+ cur (round width 2)) :y y :starts (case which ((:all :freq) (if (eq item start) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-starts (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-starts (find item (third data) :key 'phn-name)))) :ends (case which ((:all :freq) (if (eq item end) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-ends (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-ends (find item (third data) :key 'phn-name)))) :color (if (find item unused) 'gray 'black) :utilities (awhen (find item (third data) :key 'phn-name) (phn-utilities it))) offsets) ; (cons item (cons (+ cur (round width 2)) y)) offsets) (when (= (length hole) 1) (push (- cur (round (p-history-module-x-spacing module) 2)) hole)) (push (+ cur width (round (p-history-module-x-spacing module) 2)) hole) (incf cur (+ width (p-history-module-x-spacing module))))) (decf cur (p-history-module-x-spacing module)) (when (> cur max) (setf max cur)) (push (cons cur y) widths) (push-last y hole) (push hole holes) (incf y (+ 30 (p-history-module-y-spacing module))))) (incf max (* 2 (p-history-module-x-spacing module))) (setf holes (mapcar (lambda (x) (reverse (cons (- max (round (p-history-module-x-spacing module) 2)) x))) holes)) (dolist (w widths) (unless (= (car w) max) (dolist (o offsets) (when (= (phd-y o) (cdr w)) (incf (phd-x o) (round (- max (car w)) 2)))) (let ((h (find (cdr w) holes :key 'car))) (setf holes (cons (concatenate 'list (subseq h 0 2) (mapcar (lambda (x) (+ x (round (- max (car w)) 2))) (subseq (butlast h) 2)) (last h)) (remove h holes)))))) (setf (gethash name (p-history-module-graph-table module)) (make-p-history-cache :offsets offsets :holes holes :max-loops max-loops :max max :height y :min-u min-u :max-u max-u)) (p-history-display-output which number with-labels offsets holes max-loops max y min-u max-u))))) (list "size 300 40" "label \"no graph data to display\" 150 20 0 0 299 39 red" "cycles 0" "done")))) (defun p-history-display-output (which number with-labels offsets holes max-loops max height min-u max-u) (let ((min-time -1) (max-time -1) (links nil) (module (get-module production-history)) (max-link-count 0) (equal-link-counts t)) (when (and (numberp min-u) (numberp max-u) (= min-u max-u)) (setf min-u (1- min-u)) (setf max-u (1+ max-u))) (dolist (o offsets) (dolist (link (filter-links (phd-links o) which number)) ;; for now just using a next closest hole metric for ;; multi-level links but at some point may want to try ;; a shortest path instead or some sort of non-intersecting algorithm (let ((target (find (phl-target link) offsets :key 'phd-name)) (link-count (if (find which '(:freq #|:run :run-color if I want to do these too need to filter on color/run as well |#)) (count-if (lambda (x) (eq (phl-target x) (phl-target link))) (phd-links o)) nil))) (when (and (numberp link-count) (> link-count max-link-count)) (unless (zerop max-link-count) (setf equal-link-counts nil)) (setf max-link-count link-count)) (cond ((eq (phd-name o) (phd-name target)) ;; self link ;;; if left end loop on left side ;;; if right end loop on right side ;;; if in middle loop on bottom (cond ((= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; left end uses both left sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) ((= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; right end uses both right sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) (t (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) 5) (+ (phd-y o) 15) (+ (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 5) (+ (phd-y o) 15)) links)))) ((= (phd-y o) (phd-y target)) ;; same row ;; link bottom right of leftmost to bottom left of rightmost (if (> (phd-x target) (phd-x o)) ;; left to right (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (+ (+ (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x target) (round (phd-width target) 2)) (+ (phd-x o) (round (phd-width o) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (- (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links) ;; right to left (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (- (- (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x o) (round (phd-width o) 2)) (+ (phd-x target) (round (phd-width target) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (+ (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links))) ((> (phd-y target) (phd-y o)) ;; forward i.e. down ;; if one layer down draw bottom center to top center directly ;; otherwise draw bottom center to top center going through next closest hole (if (= (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15) (phd-x target) (- (phd-y target) 15)) links) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15)) (let ((x (phd-x o)) (vals nil)) (dotimes (i (- (/ (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (+ (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (- y 20) vals) ;; a little slack above and below (push min-x vals) (push (+ y 20) vals) (setf x min-x))) (reverse vals)) (list (phd-x target) (- (phd-y target) 15))) links))) (t ;; backward i.e. up ;; going up draw from 1/3 left or right of center top to l/r 1/3 from center bottom ;; which left and which right depends on positions ;; if only one level apart then pick both sides based on position of from relative to to ;; - if from left of to then go from left to left otherwise go right to right ;; if multiple levels then ;; if from is leftmost in it's row start and end are both left ;; if from is rightmost in it's row start and end are both right ;; if to is left of from then use left for from and right for to ;; if to is right of from then use right for from and left for to ;; if same column then check which side of screen left start is on ;; if it's on the left use left for both ;; otherwise use right for both ;; all intermediates are based on next closest hole (going up) (if (= (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) ;; one level up (if (<= (phd-x o) (phd-x target)) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (- (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (+ (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links)) ;; multiple levels (let ((start-x nil) (end-x nil)) (cond ((and (= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (<= (- (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; left end uses both left sides if target point also on left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((and (= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (>= (+ (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; right end uses both right sides if target also on right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((< (phd-x target) (phd-x o)) ; target is to the left so start on left and end on right (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((> (phd-x target) (phd-x o)) ; target is to the right so start on right and end on left (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((< (phd-x o) (round max 2)) ;; same column so use the side of screen to judge and same for both ;; left is left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) (t ;; same column so use the side of screen to judge and same for both ;; right is right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6))))) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count start-x (- (phd-y o) 15)) (let ((x start-x) (vals nil)) (dotimes (i (- (/ (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (- (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (+ y 20) vals) (push min-x vals) (push (- y 20) vals) (setf x min-x))) (reverse vals)) (list end-x (+ (phd-y target) 15))) links)))))))) (append (list (format nil "size ~d ~d" max height)) (let ((results nil)) (dolist (x offsets) (when with-labels (push (format nil "label ~S ~d ~d ~d ~d ~d ~d ~s" (phd-name x) (phd-x x) (phd-y x) (- (phd-x x) (round (phd-width x) 2)) (- (phd-y x) 15) (+ (phd-x x) (round (phd-width x) 2)) (+ (phd-y x) 15) (if (keywordp (phd-color x)) 'black (phd-color x))) results)) (when (eq which :utility) (awhen (assoc number (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (- (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (- (phd-y x) 9) 'blue) results)) (awhen (assoc (1+ number) (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (+ (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (+ (phd-y x) 9) 'blue) results))) (awhen (find number (phd-starts x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf min-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) 2) (- (phd-y x) 17) (+ (phd-x x) (round (phd-width x) 2) 2) (+ (phd-y x) 17) 'green) results)) (awhen (find number (phd-ends x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf max-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -2) (- (phd-y x) 13) (+ (phd-x x) (round (phd-width x) 2) -2) (+ (phd-y x) 13) 'red) results))) results) (mapcar (lambda (x) (format nil "link ~s ~s ~s ~d~{ ~d~}" (first x) (second x) (third x) (if (or (null (fourth x)) equal-link-counts (= 1 max-link-count) (= 0 max-link-count)) 1 (let ((max-width (round (p-history-module-x-spacing module) 4))) (max 1 (round (* max-width (/ (fourth x) max-link-count)))))) (cddddr x))) ;; because frequency needs to count links there are potentially duplicates but only need ;; to send over one of each... (remove-duplicates links :test (lambda (x y) (and (eq (first x) (first y)) (eq (second x) (second y)) (eq (third x) (third y)))))) (when (and (or (eq which :cycle) (eq which :run) (eq which :utility)) (> min-time -1) (> max-time -1)) (list (format nil "min_time ~f" min-time) (format nil "max_time ~f" max-time))) (list (format nil "cycles ~d" max-loops)) #| show the holes for debugging (let ((z nil)) (dolist (x holes) (mapcar (lambda (y) (push (format nil "link blue ~d ~d ~d ~d" y (- (car x) 15) y (+ (car x) 15)) z)) (cdr x))) z) |# (list "done")))) ;;; A command to allow getting .dot output of the graphs without using the environment. (defun production-transition-graph (&optional (which :all)) (verify-current-model "Cannot generate a production transition graph because there is no current model." (unless (find which '(:all :cycle :run :unique-cycle :unique-run)) (print-warning "Invalid graph type. Must be one of (:all :cycle :run :unique-cycle :unique-run).") (return-from production-transition-graph)) (when (eq which :unique-cycle) (setf which :color)) (when (eq which :unique-run) (setf which :run-color)) (let* ((data (parse-production-history-graph which)) (unused (all-productions)) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (1+ (first (fourth data)))) ((:run :cycle) (1+ (second (fourth data))))))) (cond ((eq which :all) (command-output "digraph \"~s\" {" (current-model)) (command-output " \"~s\" [ color = green ];" start) (unless (eq start end) (command-output " \"~s\" [ color = red ];" end)) (dolist (node (third data)) (let* ((transitions (remove-duplicates (phn-links node) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (if (phl-count link) (progn (setf unused (remove (phl-target link) unused)) (command-output " \"~s\" -> \"~s\" ;" (phn-name node) (phl-target link))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (phn-name node) (phl-target link)))))) (dolist (node unused) (command-output " \"~s\" [color = gray] ;" node)) (command-output "}")) ((or (eq which :color) (eq which :run-color)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i (if (eq which :color) "unique cycle" "unique run") (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key 'phn-color-starts))) (end-node (phn-name (find i (third data) :test 'member :key 'phn-color-ends))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")) ((or (eq which :cycle) (eq which :run)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i which (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-starts y)))))) (end-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-ends y)))))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-cycle x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-cycle x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")))))) (defun reset-p-history-module (module) (setf (p-history-module-history module) nil) (setf (p-history-module-why-not-list module) nil) (setf (p-history-module-graph-table module) (make-hash-table :test 'equalp))) (defun params-p-history-module (instance param) (if (consp param) (case (car param) (:save-p-history (no-output (progn (if (cdr param) (progn (unless (find 'production-history-recorder (car (sgp :conflict-set-hook))) (sgp :conflict-set-hook production-history-recorder)) (unless (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (sgp :reward-notify-hook production-history-reward-markers))) (progn (when (find 'production-history-recorder (car (sgp :conflict-set-hook))) (let ((old-hooks (car (sgp :conflict-set-hook)))) (sgp :conflict-set-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-recorder) (sgp-fct (list :conflict-set-hook x)))))) (when (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (let ((old-hooks (car (sgp :reward-notify-hook)))) (sgp :reward-notify-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-reward-markers) (sgp-fct (list :reward-notify-hook x)))))))) (setf (p-history-module-enabled instance) (cdr param))))) (:p-history-colors (setf (p-history-module-color-list instance) (cdr param))) (:draw-blank-columns (setf (p-history-module-draw-blanks instance) (cdr param))) (:p-history-graph-x (setf (p-history-module-x-spacing instance) (cdr param))) (:p-history-graph-y (setf (p-history-module-y-spacing instance) (cdr param)))) (case param (:save-p-history (p-history-module-enabled instance)) (:p-history-colors (p-history-module-color-list instance)) (:draw-blank-columns (p-history-module-draw-blanks instance)) (:p-history-graph-x (p-history-module-x-spacing instance)) (:p-history-graph-y (p-history-module-y-spacing instance))))) (define-module-fct 'production-history nil (list (define-parameter :save-p-history :valid-test 'tornil :default-value nil :warning "T or nil" :documentation "Whether or not to record the utility and whynot history of all conflict-resolution events.") (define-parameter :p-history-colors :valid-test (lambda (x) (or (null x) (and (listp x) (<= (length x) 3) (every (lambda (y) (or (null y) (stringp y))) x)))) :default-value nil :warning "nil or a list of up to 3 color strings" :documentation "The colors to use for the selected, other matched, and mismatched cells respectively.") (define-parameter :draw-blank-columns :valid-test 'tornil :default-value t :warning "T or nil" :documentation "Whether or not to draw the columns which have no matched productions.") (define-parameter :p-history-graph-x :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 40 :warning "non-negative integer" :documentation "Horizontal pixels between production boxes.") (define-parameter :p-history-graph-y :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 90 :warning "non-negative integer" :documentation "Vertical pixels between production boxes.")) :creation (lambda (x) (declare (ignore x)) (make-p-history-module)) :reset 'reset-p-history-module :params 'params-p-history-module :run-start 'production-history-start-markers :run-end 'production-history-stop-markers :version "1.1" :documentation "Module to record production history for display in the environment.") #| This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |#
true
;;; -*- mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Author : PI:NAME:<NAME>END_PI ;;; Copyright : (c) 2004 PI:NAME:<NAME>END_PI ;;; Availability: Covered by the GNU LGPL, see LGPL.txt ;;; Address : Department of Psychology ;;; : Carnegie Mellon University ;;; : Pittsburgh, PA 15213-3890 ;;; : PI:EMAIL:<EMAIL>END_PI ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Filename : production-history.lisp ;;; Version : 1.1 ;;; ;;; Description : Code to support the production trace tool in the environment. ;;; ;;; Bugs : ;;; ;;; To do : [X] Consider making a module for this to allow configuration ;;; : of the display (colors, widths, restricted productions, ;;; : etc) and provide a simple parameter switch to enable. ;;; : [ ] Draw the links "better" with respect to crossing and ;;; : overlapping. ;;; ;;; ----- History ----- ;;; 2008.08.06 Dan ;;; : * Initial creation. ;;; 2008.08.06 Dan ;;; : * Making it a module and doing some optimizing on how it ;;; : stores/creates the data to send because it can't handle ;;; : long runs (zbrodoff tutorial model often results in an ;;; : allocation error). ;;; 2008.08.07 Dan ;;; : * Another stability improvement. It now breaks the grid ;;; : up into smaller updates to send over to the environment ;;; : to avoid having to create one very large string. Slows ;;; : down the displaying, but shouldn't result in any allocation ;;; : issues. ;;; 2008.08.12 Dan ;;; : * Added the :p-history-colors parameter to allow one to ;;; : change the colors used in the grid. ;;; 2011.10.28 PI:NAME:<NAME>END_PI [1.1] ;;; : * Adding a different display option for the data - a directed ;;; : graph with the productions as nodes and where a link from A->B ;;; : indicates that B was in the conflict set after A fired. ;;; : * Changed the name of the function used by the previous display ;;; : to production-history-chart-data since the new tool is actually ;;; : a graph. ;;; : * Added parameters for some minor control over the graph display. ;;; 2011.11.17 PI:NAME:<NAME>END_PI ;;; : * Added support for another display option in the history graph: ;;; : "Frequencies" which draws the links with widths based on thier ;;; : relative frequencies. The most frequent will be drawn 1/4 of ;;; : the x spacing wide and the rest scaled to that (unless all are ;;; : the same in which case they're all drawn width 1). ;;; 2011.12.06 PI:NAME:<NAME>END_PI ;;; : * Adding the extra data to the info sent for the graph so that ;;; : the tcl side can write out a .dot file for the graph. ;;; 2011.12.07 PI:NAME:<NAME>END_PI ;;; : * Added the command production-transition-graph which prints ;;; : a DOT representation of the saved production history data ;;; : to the current ACT-R command output stream for the specified ;;; : graph type which can be one of :all, :run, :cycle, :unique-run, ;;; : or :unique-cycle. The graphs correspond to those that are ;;; : shown in the environment tool using the corresponding buttons, ;;; : and when there are multiple subgraphs each has its own cluster ;;; : in the output. This allows one to create the graphs without ;;; : without having the environment connected if an external DOT ;;; : graph viewer is used instead. ;;; 2011.12.22 PI:NAME:<NAME>END_PI ;;; : * Added another type of display - utilities. ;;; 2012.02.01 PI:NAME:<NAME>END_PI ;;; : * Added a declare and removed unused variables to clean up ;;; : some load time warnings. ;;; 2012.03.12 PI:NAME:<NAME>END_PI ;;; : * Save both the current utility and the U(n) value for display ;;; : in the environment production history viewer info. ;;; 2012.03.22 PI:NAME:<NAME>END_PI ;;; : * Changed the graph display for runs and utilities so that it ;;; : doesn't show the unchosen links from the end of one session ;;; : to the beginning of the next on the following display (that ;;; : is the dashed links from the previous displays red box to the ;;; : unchosen competitors for the current display's green box). ;;; 2012.04.27 PI:NAME:<NAME>END_PI ;;; : * Fixed a bug with displaying the utility graph when there are ;;; : no utility differences. ;;; : * Added an option for hiding the unused productions in the graph ;;; : display. ;;; 2013.01.10 PI:NAME:<NAME>END_PI ;;; : * Changed the environment data cache to an equalp hashtable ;;; : since the keys are now a cons of the handler name and the ;;; : window to prevent issues with multi-environment settings. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; General Docs: ;;; ;;; Open either of the production history tools, "Production History" or "Production ;;; Graph" before running the model or set the :save-p-history parameter to t in the ;;; model to enable the recording. Once the model stops running the information ;;; about the productions which were in the conflict set during the run can be ;;; viewed using the tools. ;;; ;;; For the "History" tool, once the model has run click the "Get history" button ;;; in the bottom left corner of the production history window. It will draw a grid ;;; with the rows being the productions in the model and the columns being the times ;;; at which a conflict-resolution event occurred. ;;; ;;; The cells in the grid are color coded based on what happened during the ;;; conflict resolution event at the time indicated for the column. ;;; ;;; If the production was the one selected the cell will be green. ;;; If the production was in the conflict set, but not selected then the cell ;;; will be orange. ;;; If the production was not in the conflict set then the cell will be red. ;;; If the production did not exist at that time the cell will be white. ;;; ;;; Placing the cursor over a cell will cause some details for that production ;;; during that conflict resolution event to be printed at the bottom of the ;;; window. ;;; ;;; For the green and orange cells it will print the utility value for the ;;; production at that time. For the red cells it will print the whynot ;;; information indicating the condition that caused the production to not be ;;; in the conflict set. There is no extra information to print for a white ;;; cell. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; For the "Graph" tool, after the model has run click one of the 6 buttons ;;; "All transitions", "Frequencies", "Cycles", "Unique Cycles", "Runs", "Unique Runs" ;;; or "Utilities" to have the data displayed. All of the displays are drawn the same ;;; way and the common features will be described before indicating what differs among ;;; the button choices. ;;; ;;; The display will show all of the productions in the model in boxes. If the ;;; box has a black border then it was selected and fired at some point in the ;;; model's run. If it has a gray border then it was not selected and fired. ;;; If there is a green border around a production then it is the first production ;;; which was selected for the currently displayed information, and if it has ;;; a red border then it was the last production selected for the currently displayed ;;; information. ;;; ;;; An arrow from a production A to production B means that production B was in ;;; the conflict set after production A fired. If the arrow has a solid black line then ;;; production B was selected and fired after A, but if the arrow has a dashed gray ;;; line then it was not selected and fired. ;;; ;;; Clicking on the name of a production in the grid will open a new procedural ;;; viewer dialog with that production selected. ;;; ;;; The "All transitions" button shows the data for all production firings over ;;; the entire run of the model. The "Frequencies" button shows the same data ;;; except that the thickness of the links reflects their relative frequencies. ;;; The most frequent will be 1/4 of :p-history-graph-x wide and the others ;;; scaled appropriately. ;;; ;;; The "Cycles" and "Unique Cycles" buttons show the data broken down into ;;; cycles which occur in the graph (when a loop is formed by a production ;;; eventually firing again after itself). The display will show only one ;;; cycle at a time. The number of cycles which occurred is shown below ;;; the graph and the "-" and "+" buttons can be used to change which cycle ;;; is shown. For "Cycles" all production firings are shown and the cycles ;;; are displayed in temporal order with the model time for the start and end ;;; displayed at the bottom of the window. For the "Unique Cycles" it only ;;; shows one instance of each cycle that occurs and no specific time information ;;; is shown. ;;; ;;; The "Runs" and "Unique Runs" buttons show the data broken down into sections ;;; based on when one of the ACT-R running commands were called. The display will ;;; only one "run" at a time. The number of non-empty runs which occurred is ;;; shown below the graph and the "-" and "+" buttons can be used to change which run ;;; is shown. For "Runs" all production firings are shown and the runs ;;; are displayed in temporal order with the model time for the start and end ;;; of the run displayed at the bottom of the window. For the "Unique Runs" it only ;;; shows one instance of each production graph that occurs in a run and no specific ;;; time information is shown. ;;; ;;; The "Utilities" button breaks the data down into sections based on when the ;;; model receives a reward. Each of the production boxes will be the same width ;;; in this display and may have two additional bars displayed within the box. ;;; A blue bar at the top represents the relative utility of that production before ;;; the reward which ended this section has been applied and a blue bar at the ;;; bottom represents the relative utility of that production after the reward ;;; has been applied. The utility values are scaled so that the range between the ;;; minimum utility across all sections and the maximum utility across all sections ;;; can be displayed. If there is no bottom bar then it means that there was no ;;; reward provided (the last chart may end because the model stopped instead of ;;; because there was a reward provided). ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Public API: ;;; ;;; :save-p-history parameter ;;; Enables the recording of production history for display (default is nil). ;;; ;;; :draw-blank-columns parameter ;;; When set to t (the default value) all conflict resolution events get drawn ;;; in the environment tool. If set to nil then conflict resolution events ;;; which had a null conflict set don't get drawn. ;;; ;;; :p-history-colors ;;; This parameter can be used to change the colors displayed in the grid. ;;; If it is nil (the default) then the green, orange, and red defaults are ;;; used for selected, conflict set, and mismatched respectively. It can be ;;; set to a list of 3 values where each value is either a color string or nil. ;;; A valid color string starts with the character # and is followed by 3, 6, ;;; 9 hex digits. Those digits represent the components of the color to use ;;; and specify the Red, Green, and Blue values respectively using the same ;;; number of bits for each (thus either 8, 16, or 24 bits per color). An ;;; example would be "#00F" for blue or "#44DA22" which is the green color ;;; used by default. ;;; ;;; :p-history-graph-x ;;; The horizontal pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;; :p-history-graph-y ;;; The vertical pixel spacing between the production boxes in the "Production ;;; Graph" tool view. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Design Choices: ;;; ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; The code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #+:packaged-actr (in-package :act-r) #+(and :clean-actr (not :packaged-actr) :ALLEGRO-IDE) (in-package :cg-user) #-(or (not :clean-actr) :packaged-actr :ALLEGRO-IDE) (in-package :cl-user) (defstruct p-history-module history enabled why-not-list draw-blanks current-data color-list graph-table x-spacing y-spacing) (defstruct p-history time selected matched mismatched info tag) (defun production-history-reward-markers (reward) (declare (ignore reward)) (let ((history (get-module production-history))) (when (p-history-module-enabled history) (push (make-p-history :tag :reward :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history history))))) (defun production-history-start-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :start :time (mp-time)) (p-history-module-history ph)))) (defun production-history-stop-markers (ph) (when (p-history-module-enabled ph) (push (make-p-history :tag :stop :time (mp-time) :info (no-output (spp :name :u))) (p-history-module-history ph)))) (defun production-history-recorder (cs) (let* ((history (get-module production-history)) (best (car cs)) (mismatched (set-difference (all-productions) cs)) (block (make-p-history :mismatched mismatched :time (mp-time)))) (no-output (let ((ut (sgp :ut))) (when (and best (or (not (numberp ut)) (and (numberp ut) (>= (caar (spp-fct (list best :utility))) ut)))) (setf (p-history-selected block) best)) (dolist (x cs) (push (cons x (car (spp-fct (list x :utility :u)))) (p-history-info block))) (dolist (x mismatched) (let* ((reason (production-failure-reason x)) (index (position reason (p-history-module-why-not-list history) :test #'string-equal))) (unless index (setf index (length (p-history-module-why-not-list history))) (push-last reason (p-history-module-why-not-list history))) (push (cons x (list index 0)) (p-history-info block))))) (if (p-history-selected block) (setf (p-history-matched block) (cdr cs)) (setf (p-history-matched block) cs)) (push block (p-history-module-history history)) nil))) (defun production-history-chart-data (item) (declare (ignore item)) (let ((history (get-module production-history))) (when (null (p-history-module-current-data history)) (parse-production-history-chart-data)) (let ((data (p-history-module-current-data history))) (if (> (length data) 200) (let ((results (subseq data 0 200))) (setf (p-history-module-current-data history) (subseq data 200)) (mapcar (lambda (x) (format nil "~{~S ~}" x)) results)) (progn (setf (p-history-module-current-data history) nil) (mapcar (lambda (x) (format nil "~{~S ~}" x)) (push (list 'done) data))))))) (defun parse-production-history-chart-data () (let* ((results nil) (history (get-module production-history)) (p-names (all-productions)) (columns 0) (name-size (apply 'max (mapcar (lambda (x) (length (symbol-name x))) p-names)))) (dolist (x (p-history-module-history history)) (when (and (or (p-history-module-draw-blanks history) (or (p-history-selected x) (p-history-matched x))) (null (p-history-tag x))) (let ((col (list 'column (p-history-time x)))) (dolist (y p-names) (cond ((eq y (p-history-selected x)) (push-last 0 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-matched x)) (push-last 1 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))) ((find y (p-history-mismatched x)) (push-last 2 col) (let ((utilities (cdr (assoc y (p-history-info x))))) (push-last (first utilities) col) (push-last (second utilities) col))))) (incf columns) (push col results)))) (push (cons 'labels p-names) results) (push (list 'colors (aif (nth 0 (p-history-module-color-list history)) it "#44DA22") (aif (nth 1 (p-history-module-color-list history)) it "#FCA31D") (aif (nth 2 (p-history-module-color-list history)) it "#E1031E")) results) (push (cons 'reasons (p-history-module-why-not-list history)) results) (push (list 'size (* 20 (1+ (length p-names))) 20 (* 9 name-size) 80 (* 80 columns)) results) (setf (p-history-module-current-data history) results) nil)) (defstruct (p-history-node (:conc-name phn-)) name color-starts color-ends cycle-starts cycle-ends links utilities) (defstruct (p-history-link (:conc-name phl-)) target color count cycle from-time to-time) (defstruct (p-history-display (:conc-name phd-)) name x y color width links starts ends utilities) (defstruct (p-history-cache (:conc-name phc-)) offsets holes max-loops max height min-u max-u) (defun parse-production-history-graph (which) (let ((nodes (mapcar (lambda (x) (make-p-history-node :name x :links nil)) (all-productions))) (history (get-module production-history)) (loops nil) (current-loop nil) (cycle 0) (top nil) (previous nil) (max-color 0) (max-cycle 0) (start-time nil) (min-utility nil) (max-utility nil) (stop-utilities nil)) (dolist (x (reverse (p-history-module-history history))) (let ((selected (p-history-selected x)) (matched (p-history-matched x)) (time (p-history-time x))) (cond ((find which '(:all :freq :color :cycle)) (when (or matched selected) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (when (find selected current-loop :key 'car) ;; completed a loop (let* ((existing-color (position (cons selected (mapcar 'car current-loop)) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) current-loop (cons (cons selected time) (butlast current-loop))) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find selected nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find selected nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (cons selected (mapcar 'car current-loop)) loops))) (incf cycle) (setf current-loop nil)) (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))))) ((find which '(:run :run-color)) (when (or matched selected (p-history-tag x)) (when (eq :start (p-history-tag x)) (setf start-time time)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (and current-loop (eq :stop (p-history-tag x))) ;; completed a loop (let* ((existing-color (position (mapcar 'car current-loop) loops :test 'equalp)) (color (if existing-color existing-color (length loops)))) (dolist (check (mapcar 'car current-loop)) (dolist (link (phn-links (find check nodes :key 'phn-name))) (when (= -1 (phl-color link)) (setf (phl-color link) color)))) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color color :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew color (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (cons cycle start-time) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew color (phn-color-ends (find (caar current-loop) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) (when (> color max-color) (setf max-color color)) (unless existing-color (push-last (mapcar 'car current-loop) loops))) (incf cycle) (setf current-loop nil) ;; don't want the dashed lines from end of ;; one run going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)))) (t ;;(find which '(:utility)) (when (or matched selected (p-history-tag x)) (when (and (null top) selected) (dolist (y matched) (push y top)) (push selected top)) (when (and previous matched) (dolist (y matched) (unless (find y (phn-links previous) :key (lambda (z) (when (= (phl-cycle z) cycle) (phl-target z)))) (push (make-p-history-link :target y :cycle cycle :count nil :color -1 :from-time time :to-time time) (phn-links previous))))) (when selected (push (cons selected time) current-loop) (setf previous (find selected nodes :key 'phn-name))) (when (eq :stop (p-history-tag x)) (setf stop-utilities (p-history-info x))) (when (and current-loop (eq :reward (p-history-tag x))) ;; set the current scores (dolist (reward (p-history-info x)) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward)))) ;; completed a loop (let* () (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr to+time))) (awhen (find to (phn-links (find from nodes :key 'phn-name)) :key (lambda (z) (when (and (null (phl-count z)) (= (phl-cycle z) cycle)) (phl-target z)))) (setf (phn-links (find from nodes :key 'phn-name)) (remove it (phn-links (find from nodes :key 'phn-name))))) (push (make-p-history-link :target to :color 0 :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle time) (phn-cycle-ends (find (caar current-loop) nodes :key 'phn-name))) (when (> cycle max-cycle) (setf max-cycle cycle)) ;; don't want the dashed lines from end of ;; one loop going to non-starters for the next ;; loop i.e. matched but not selected. (setf previous nil)) (incf cycle) (setf current-loop nil))))))) (when (and (eq which :utility) stop-utilities) (dolist (reward stop-utilities) (push-last (cons cycle (second reward)) (phn-utilities (find (first reward) nodes :key 'phn-name))) (when (or (null min-utility) (< (second reward) min-utility)) (setf min-utility (second reward))) (when (or (null max-utility) (> (second reward) max-utility)) (setf max-utility (second reward))))) (when (or (> (length current-loop) 0)) (mapc (lambda (from+time to+time) (let ((from (car from+time)) (to (car to+time)) (from-time (cdr from+time)) (to-time (cdr from+time))) (push (make-p-history-link :target to :color (length loops) :count 1 :cycle cycle :from-time from-time :to-time to-time) (phn-links (find from nodes :key 'phn-name))))) (cdr current-loop) (butlast current-loop)) (pushnew (length loops) (phn-color-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (push (cons cycle (cdar (last current-loop))) (phn-cycle-starts (find (caar (last current-loop)) nodes :key 'phn-name))) (pushnew (length loops) (phn-color-ends previous)) (push (cons cycle (cdar current-loop)) (phn-cycle-ends previous)) (setf max-color (length loops)) (setf max-cycle cycle)) (list top (when previous (phn-name previous)) nodes (list max-color max-cycle) (list min-utility max-utility)))) (defun filter-links (links which number) (case which ((:all :freq) (setf links (remove-duplicates links :key (lambda (x) (cons (phl-target x) (phl-count x))))) (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) links :key (lambda (y) (when (phl-count y) (phl-target y)))))) links)) ((:run :cycle :utility) (remove-if-not (lambda (x) (= (phl-cycle x) number)) links)) ((:run-color :color) (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) number)) links) :key 'phl-target)))) (defun remove-p-history-entry (name) (remhash name (p-history-module-graph-table (get-module production-history)))) (defun create-production-graph-coords (name which number with-labels show-unused) (let ((module (get-module production-history))) (if (p-history-module-history module) (multiple-value-bind (value exists) (if with-labels (values nil nil) (gethash name (p-history-module-graph-table module))) (if exists (p-history-display-output which number with-labels (phc-offsets value) (phc-holes value) (phc-max-loops value) (phc-max value) (phc-height value) (phc-min-u value) (phc-max-u value)) (let* ((layer-data (parse-production-history-graph :cycle)) (data (if (find which '(:freq :all :color :cycle)) layer-data (parse-production-history-graph which))) (min-u (first (fifth data))) (max-u (second (fifth data))) (unused (all-productions)) (current (car data)) (next nil) (layers nil) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (first (fourth data))) ((:run :cycle :utility) (second (fourth data)))))) (while current (dolist (x current) (setf unused (remove x unused))) (dolist (x current) (dolist (y (phn-links (find x (third layer-data) :key 'phn-name))) (when (and (phl-count y) (find (phl-target y) unused)) (setf unused (remove (phl-target y) unused)) (push (phl-target y) next)))) (push current layers) (setf current next) (setf next nil)) (when (and unused show-unused) (push unused layers)) (let ((max 0) (cur 0) (y 65) (offsets nil) (widths nil) (holes nil) (max-width (* 10 (apply 'max (mapcar (lambda (x) (length (symbol-name x))) (all-productions)))))) (dolist (layer (reverse layers)) (let ((hole (list (round (p-history-module-x-spacing module) 2)))) (setf cur 0) (dolist (item layer) (let ((width (if (eq which :utility) max-width (* 10 (length (symbol-name item)))))) (push (make-p-history-display :name item :links (awhen (find item (third data) :key 'phn-name) (phn-links it)) :width width :x (+ cur (round width 2)) :y y :starts (case which ((:all :freq) (if (eq item start) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-starts (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-starts (find item (third data) :key 'phn-name)))) :ends (case which ((:all :freq) (if (eq item end) (list 0) nil)) ((:cycle :run :utility) (phn-cycle-ends (find item (third data) :key 'phn-name))) ((:color :run-color) (phn-color-ends (find item (third data) :key 'phn-name)))) :color (if (find item unused) 'gray 'black) :utilities (awhen (find item (third data) :key 'phn-name) (phn-utilities it))) offsets) ; (cons item (cons (+ cur (round width 2)) y)) offsets) (when (= (length hole) 1) (push (- cur (round (p-history-module-x-spacing module) 2)) hole)) (push (+ cur width (round (p-history-module-x-spacing module) 2)) hole) (incf cur (+ width (p-history-module-x-spacing module))))) (decf cur (p-history-module-x-spacing module)) (when (> cur max) (setf max cur)) (push (cons cur y) widths) (push-last y hole) (push hole holes) (incf y (+ 30 (p-history-module-y-spacing module))))) (incf max (* 2 (p-history-module-x-spacing module))) (setf holes (mapcar (lambda (x) (reverse (cons (- max (round (p-history-module-x-spacing module) 2)) x))) holes)) (dolist (w widths) (unless (= (car w) max) (dolist (o offsets) (when (= (phd-y o) (cdr w)) (incf (phd-x o) (round (- max (car w)) 2)))) (let ((h (find (cdr w) holes :key 'car))) (setf holes (cons (concatenate 'list (subseq h 0 2) (mapcar (lambda (x) (+ x (round (- max (car w)) 2))) (subseq (butlast h) 2)) (last h)) (remove h holes)))))) (setf (gethash name (p-history-module-graph-table module)) (make-p-history-cache :offsets offsets :holes holes :max-loops max-loops :max max :height y :min-u min-u :max-u max-u)) (p-history-display-output which number with-labels offsets holes max-loops max y min-u max-u))))) (list "size 300 40" "label \"no graph data to display\" 150 20 0 0 299 39 red" "cycles 0" "done")))) (defun p-history-display-output (which number with-labels offsets holes max-loops max height min-u max-u) (let ((min-time -1) (max-time -1) (links nil) (module (get-module production-history)) (max-link-count 0) (equal-link-counts t)) (when (and (numberp min-u) (numberp max-u) (= min-u max-u)) (setf min-u (1- min-u)) (setf max-u (1+ max-u))) (dolist (o offsets) (dolist (link (filter-links (phd-links o) which number)) ;; for now just using a next closest hole metric for ;; multi-level links but at some point may want to try ;; a shortest path instead or some sort of non-intersecting algorithm (let ((target (find (phl-target link) offsets :key 'phd-name)) (link-count (if (find which '(:freq #|:run :run-color if I want to do these too need to filter on color/run as well |#)) (count-if (lambda (x) (eq (phl-target x) (phl-target link))) (phd-links o)) nil))) (when (and (numberp link-count) (> link-count max-link-count)) (unless (zerop max-link-count) (setf equal-link-counts nil)) (setf max-link-count link-count)) (cond ((eq (phd-name o) (phd-name target)) ;; self link ;;; if left end loop on left side ;;; if right end loop on right side ;;; if in middle loop on bottom (cond ((= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; left end uses both left sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (- (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (- (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) ((= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) ;; right end uses both right sides (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (phd-y o) (+ (phd-x o) (round (phd-width o) 2) 15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 30) (+ (phd-x o) (round (phd-width o) 2) -15) (+ (phd-y o) 15)) links)) (t (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) 5) (+ (phd-y o) 15) (+ (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 10) (+ (phd-y o) 25) (- (phd-x o) 5) (+ (phd-y o) 15)) links)))) ((= (phd-y o) (phd-y target)) ;; same row ;; link bottom right of leftmost to bottom left of rightmost (if (> (phd-x target) (phd-x o)) ;; left to right (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (+ (+ (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x target) (round (phd-width target) 2)) (+ (phd-x o) (round (phd-width o) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (- (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links) ;; right to left (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 2)) (+ (phd-y o) 15) (- (- (phd-x o) (round (phd-width o) 2)) (round (- (- (phd-x o) (round (phd-width o) 2)) (+ (phd-x target) (round (phd-width target) 2))) 2)) (+ (phd-y o) 15 (round (p-history-module-y-spacing module) 3)) (+ (phd-x target) (round (phd-width target) 2)) (+ (phd-y o) 15)) links))) ((> (phd-y target) (phd-y o)) ;; forward i.e. down ;; if one layer down draw bottom center to top center directly ;; otherwise draw bottom center to top center going through next closest hole (if (= (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15) (phd-x target) (- (phd-y target) 15)) links) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (phd-x o) (+ (phd-y o) 15)) (let ((x (phd-x o)) (vals nil)) (dotimes (i (- (/ (- (phd-y target) (phd-y o)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (+ (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (- y 20) vals) ;; a little slack above and below (push min-x vals) (push (+ y 20) vals) (setf x min-x))) (reverse vals)) (list (phd-x target) (- (phd-y target) 15))) links))) (t ;; backward i.e. up ;; going up draw from 1/3 left or right of center top to l/r 1/3 from center bottom ;; which left and which right depends on positions ;; if only one level apart then pick both sides based on position of from relative to to ;; - if from left of to then go from left to left otherwise go right to right ;; if multiple levels then ;; if from is leftmost in it's row start and end are both left ;; if from is rightmost in it's row start and end are both right ;; if to is left of from then use left for from and right for to ;; if to is right of from then use right for from and left for to ;; if same column then check which side of screen left start is on ;; if it's on the left use left for both ;; otherwise use right for both ;; all intermediates are based on next closest hole (going up) (if (= (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) ;; one level up (if (<= (phd-x o) (phd-x target)) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (- (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (- (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links) (push (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count (+ (phd-x o) (round (phd-width o) 6)) (- (phd-y o) 15) (+ (phd-x target) (round (phd-width target) 6)) (+ (phd-y target) 15)) links)) ;; multiple levels (let ((start-x nil) (end-x nil)) (cond ((and (= (phd-x o) (apply 'min (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (<= (- (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; left end uses both left sides if target point also on left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((and (= (phd-x o) (apply 'max (mapcar 'phd-x (remove-if-not (lambda (xx) (= (phd-y xx) (phd-y o))) offsets)))) (>= (+ (phd-x target) (round (phd-width target) 6)) (round max 2))) ;; right end uses both right sides if target also on right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((< (phd-x target) (phd-x o)) ; target is to the left so start on left and end on right (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6)))) ((> (phd-x target) (phd-x o)) ; target is to the right so start on right and end on left (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) ((< (phd-x o) (round max 2)) ;; same column so use the side of screen to judge and same for both ;; left is left (setf start-x (- (phd-x o) (round (phd-width o) 6))) (setf end-x (- (phd-x target) (round (phd-width target) 6)))) (t ;; same column so use the side of screen to judge and same for both ;; right is right (setf start-x (+ (phd-x o) (round (phd-width o) 6))) (setf end-x (+ (phd-x target) (round (phd-width target) 6))))) (push (concatenate 'list (list (phd-name o) (phd-name target) (if (phl-count link) 'black 'gray) link-count start-x (- (phd-y o) 15)) (let ((x start-x) (vals nil)) (dotimes (i (- (/ (- (phd-y o) (phd-y target)) (+ 30 (p-history-module-y-spacing module))) 1)) (let* ((y (- (phd-y o) (* (1+ i) (+ 30 (p-history-module-y-spacing module))))) (hs (find y holes :key 'car)) (min max) (min-x nil)) (dolist (j (cdr hs)) (when (< (abs (- x j)) min) (setf min (abs (- x j))) (setf min-x j))) (push min-x vals) (push (+ y 20) vals) (push min-x vals) (push (- y 20) vals) (setf x min-x))) (reverse vals)) (list end-x (+ (phd-y target) 15))) links)))))))) (append (list (format nil "size ~d ~d" max height)) (let ((results nil)) (dolist (x offsets) (when with-labels (push (format nil "label ~S ~d ~d ~d ~d ~d ~d ~s" (phd-name x) (phd-x x) (phd-y x) (- (phd-x x) (round (phd-width x) 2)) (- (phd-y x) 15) (+ (phd-x x) (round (phd-width x) 2)) (+ (phd-y x) 15) (if (keywordp (phd-color x)) 'black (phd-color x))) results)) (when (eq which :utility) (awhen (assoc number (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (- (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (- (phd-y x) 9) 'blue) results)) (awhen (assoc (1+ number) (phd-utilities x)) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -4) (+ (phd-y x) 11) (+ (- (phd-x x) (round (phd-width x) 2) -4) (floor (* (- (phd-width x) 8) (/ (- (cdr it) min-u) (- max-u min-u))))) (+ (phd-y x) 9) 'blue) results))) (awhen (find number (phd-starts x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf min-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) 2) (- (phd-y x) 17) (+ (phd-x x) (round (phd-width x) 2) 2) (+ (phd-y x) 17) 'green) results)) (awhen (find number (phd-ends x) :key (if (or (eq which :cycle) (eq which :run) (eq which :utility)) 'car 'identity)) (when (or (eq which :cycle) (eq which :run) (eq which :utility)) (setf max-time (cdr it))) (push (format nil "box ~s ~d ~d ~d ~d ~s" (phd-name x) (- (phd-x x) (round (phd-width x) 2) -2) (- (phd-y x) 13) (+ (phd-x x) (round (phd-width x) 2) -2) (+ (phd-y x) 13) 'red) results))) results) (mapcar (lambda (x) (format nil "link ~s ~s ~s ~d~{ ~d~}" (first x) (second x) (third x) (if (or (null (fourth x)) equal-link-counts (= 1 max-link-count) (= 0 max-link-count)) 1 (let ((max-width (round (p-history-module-x-spacing module) 4))) (max 1 (round (* max-width (/ (fourth x) max-link-count)))))) (cddddr x))) ;; because frequency needs to count links there are potentially duplicates but only need ;; to send over one of each... (remove-duplicates links :test (lambda (x y) (and (eq (first x) (first y)) (eq (second x) (second y)) (eq (third x) (third y)))))) (when (and (or (eq which :cycle) (eq which :run) (eq which :utility)) (> min-time -1) (> max-time -1)) (list (format nil "min_time ~f" min-time) (format nil "max_time ~f" max-time))) (list (format nil "cycles ~d" max-loops)) #| show the holes for debugging (let ((z nil)) (dolist (x holes) (mapcar (lambda (y) (push (format nil "link blue ~d ~d ~d ~d" y (- (car x) 15) y (+ (car x) 15)) z)) (cdr x))) z) |# (list "done")))) ;;; A command to allow getting .dot output of the graphs without using the environment. (defun production-transition-graph (&optional (which :all)) (verify-current-model "Cannot generate a production transition graph because there is no current model." (unless (find which '(:all :cycle :run :unique-cycle :unique-run)) (print-warning "Invalid graph type. Must be one of (:all :cycle :run :unique-cycle :unique-run).") (return-from production-transition-graph)) (when (eq which :unique-cycle) (setf which :color)) (when (eq which :unique-run) (setf which :run-color)) (let* ((data (parse-production-history-graph which)) (unused (all-productions)) (start (caar data)) (end (second data)) (max-loops (case which ((:all :freq) 0) ((:run-color :color) (1+ (first (fourth data)))) ((:run :cycle) (1+ (second (fourth data))))))) (cond ((eq which :all) (command-output "digraph \"~s\" {" (current-model)) (command-output " \"~s\" [ color = green ];" start) (unless (eq start end) (command-output " \"~s\" [ color = red ];" end)) (dolist (node (third data)) (let* ((transitions (remove-duplicates (phn-links node) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (if (phl-count link) (progn (setf unused (remove (phl-target link) unused)) (command-output " \"~s\" -> \"~s\" ;" (phn-name node) (phl-target link))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (phn-name node) (phl-target link)))))) (dolist (node unused) (command-output " \"~s\" [color = gray] ;" node)) (command-output "}")) ((or (eq which :color) (eq which :run-color)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i (if (eq which :color) "unique cycle" "unique run") (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key 'phn-color-starts))) (end-node (phn-name (find i (third data) :test 'member :key 'phn-color-ends))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-color x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-count x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")) ((or (eq which :cycle) (eq which :run)) (command-output "digraph \"~s\" {" (current-model)) (dotimes (i max-loops) (command-output " subgraph cluster_~d {~% label = \"~a ~d\";" i which (1+ i)) (let ((node-names (mapcar (lambda (x) (cons x (new-name-fct x))) (mapcar 'phn-name (third data)))) (start-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-starts y)))))) (end-node (phn-name (find i (third data) :test 'member :key (lambda (y) (mapcar 'car (phn-cycle-ends y)))))) (used nil)) (command-output " \"~s\" [ color = green ];" (cdr (assoc start-node node-names))) (unless (eq start-node end-node) (command-output " \"~s\" [ color = red ];" (cdr (assoc end-node node-names)))) (pushnew (assoc start-node node-names) used) (pushnew (assoc end-node node-names) used) (dolist (node (third data)) (let* ((transitions (remove-duplicates (remove-if-not (lambda (x) (= (phl-cycle x) i)) (phn-links node)) :test (lambda (x y) (and (eq (phl-target x) (phl-target y)) (eql (phl-count x) (phl-count y)))))) (links (remove-if (lambda (x) (and (null (phl-cycle x)) (find (phl-target x) (remove x transitions) :key 'phl-target))) transitions))) (dolist (link links) (pushnew (assoc (phl-target link) node-names) used) (if (phl-count link) (command-output " \"~s\" -> \"~s\" ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))) (command-output " \"~s\" -> \"~s\" [ color = gray style = dashed ] ;" (cdr (assoc (phn-name node) node-names)) (cdr (assoc (phl-target link) node-names))))))) (dolist (x used) (command-output " \"~s\" [ label = \"~s\" ];" (cdr x) (car x))) (command-output " }"))) (command-output "}")))))) (defun reset-p-history-module (module) (setf (p-history-module-history module) nil) (setf (p-history-module-why-not-list module) nil) (setf (p-history-module-graph-table module) (make-hash-table :test 'equalp))) (defun params-p-history-module (instance param) (if (consp param) (case (car param) (:save-p-history (no-output (progn (if (cdr param) (progn (unless (find 'production-history-recorder (car (sgp :conflict-set-hook))) (sgp :conflict-set-hook production-history-recorder)) (unless (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (sgp :reward-notify-hook production-history-reward-markers))) (progn (when (find 'production-history-recorder (car (sgp :conflict-set-hook))) (let ((old-hooks (car (sgp :conflict-set-hook)))) (sgp :conflict-set-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-recorder) (sgp-fct (list :conflict-set-hook x)))))) (when (find 'production-history-reward-markers (car (sgp :reward-notify-hook))) (let ((old-hooks (car (sgp :reward-notify-hook)))) (sgp :reward-notify-hook nil) (dolist (x old-hooks) (unless (eq x 'production-history-reward-markers) (sgp-fct (list :reward-notify-hook x)))))))) (setf (p-history-module-enabled instance) (cdr param))))) (:p-history-colors (setf (p-history-module-color-list instance) (cdr param))) (:draw-blank-columns (setf (p-history-module-draw-blanks instance) (cdr param))) (:p-history-graph-x (setf (p-history-module-x-spacing instance) (cdr param))) (:p-history-graph-y (setf (p-history-module-y-spacing instance) (cdr param)))) (case param (:save-p-history (p-history-module-enabled instance)) (:p-history-colors (p-history-module-color-list instance)) (:draw-blank-columns (p-history-module-draw-blanks instance)) (:p-history-graph-x (p-history-module-x-spacing instance)) (:p-history-graph-y (p-history-module-y-spacing instance))))) (define-module-fct 'production-history nil (list (define-parameter :save-p-history :valid-test 'tornil :default-value nil :warning "T or nil" :documentation "Whether or not to record the utility and whynot history of all conflict-resolution events.") (define-parameter :p-history-colors :valid-test (lambda (x) (or (null x) (and (listp x) (<= (length x) 3) (every (lambda (y) (or (null y) (stringp y))) x)))) :default-value nil :warning "nil or a list of up to 3 color strings" :documentation "The colors to use for the selected, other matched, and mismatched cells respectively.") (define-parameter :draw-blank-columns :valid-test 'tornil :default-value t :warning "T or nil" :documentation "Whether or not to draw the columns which have no matched productions.") (define-parameter :p-history-graph-x :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 40 :warning "non-negative integer" :documentation "Horizontal pixels between production boxes.") (define-parameter :p-history-graph-y :valid-test (lambda (x) (and (numberp x) (nonneg x) (integerp x))) :default-value 90 :warning "non-negative integer" :documentation "Vertical pixels between production boxes.")) :creation (lambda (x) (declare (ignore x)) (make-p-history-module)) :reset 'reset-p-history-module :params 'params-p-history-module :run-start 'production-history-start-markers :run-end 'production-history-stop-markers :version "1.1" :documentation "Module to record production history for display in the environment.") #| This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |#
[ { "context": "built-in function min.\n;\n; Copyright (C) 2008-2011 Eric Smith and Stanford University\n; Copyright (C) 2013-2021", "end": 92, "score": 0.999634861946106, "start": 82, "tag": "NAME", "value": "Eric Smith" }, { "context": "ense. See the file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;", "end": 303, "score": 0.9994301795959473, "start": 293, "tag": "NAME", "value": "Eric Smith" }, { "context": " file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 327, "score": 0.9999319911003113, "start": 305, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/arithmetic-light/min.lisp
mayankmanj/acl2
305
; A lightweight book about the built-in function min. ; ; Copyright (C) 2008-2011 Eric Smith and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: Eric Smith ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (defthmd min-when-<=-1 (implies (and (<= x y) (acl2-numberp x) (acl2-numberp y)) (equal (min x y) x))) (defthmd min-when-<=-2 (implies (<= y x) (equal (min x y) y))) (defthm <-of-min-arg1 (equal (< (min x y) z) (or (< x z) (< y z)))) (defthm <-of-min-arg2 (equal (< z (min x y)) (and (< z x) (< z y))))
1312
; A lightweight book about the built-in function min. ; ; Copyright (C) 2008-2011 <NAME> and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (defthmd min-when-<=-1 (implies (and (<= x y) (acl2-numberp x) (acl2-numberp y)) (equal (min x y) x))) (defthmd min-when-<=-2 (implies (<= y x) (equal (min x y) y))) (defthm <-of-min-arg1 (equal (< (min x y) z) (or (< x z) (< y z)))) (defthm <-of-min-arg2 (equal (< z (min x y)) (and (< z x) (< z y))))
true
; A lightweight book about the built-in function min. ; ; Copyright (C) 2008-2011 PI:NAME:<NAME>END_PI and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (defthmd min-when-<=-1 (implies (and (<= x y) (acl2-numberp x) (acl2-numberp y)) (equal (min x y) x))) (defthmd min-when-<=-2 (implies (<= y x) (equal (min x y) y))) (defthm <-of-min-arg1 (equal (< (min x y) z) (or (< x z) (< y z)))) (defthm <-of-min-arg2 (equal (< z (min x y)) (and (< z x) (< z y))))
[ { "context": " PostgreSQL interface using sockets\n;;;; Authors: Kevin M. Rosenberg based on original code by Pierre R. Mai\n;;;; Crea", "end": 304, "score": 0.9998924732208252, "start": 286, "tag": "NAME", "value": "Kevin M. Rosenberg" }, { "context": "ors: Kevin M. Rosenberg based on original code by Pierre R. Mai\n;;;; Created: Feb 2002\n;;;;\n;;;; $Id$\n;;;;\n;;;; ", "end": 344, "score": 0.999889075756073, "start": 331, "tag": "NAME", "value": "Pierre R. Mai" }, { "context": "file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg\n;;;; and Copyright (c) 1999-2001 by Pierre R. Mai", "end": 468, "score": 0.9998867511749268, "start": 450, "tag": "NAME", "value": "Kevin M. Rosenberg" }, { "context": "n M. Rosenberg\n;;;; and Copyright (c) 1999-2001 by Pierre R. Mai\n;;;;\n;;;; CLSQL users are granted the rights to d", "end": 518, "score": 0.9998963475227356, "start": 505, "tag": "NAME", "value": "Pierre R. Mai" } ]
db-postgresql-socket3/api.lisp
Publitechs/clsql
6
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: postgresql-socket-api.lisp ;;;; Purpose: Low-level PostgreSQL interface using sockets ;;;; Authors: Kevin M. Rosenberg based on original code by Pierre R. Mai ;;;; Created: Feb 2002 ;;;; ;;;; $Id$ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* (in-package #:postgresql-socket3) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql-socket3))) t) (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :postgresql-socket3))) "T if foreign library was able to be loaded successfully. Always true for socket interface" t) (defparameter +postgresql-server-default-port+ 5432 "Default port of PostgreSQL server.") ;;;; Condition hierarchy (define-condition postgresql-condition (condition) ((connection :initarg :connection :reader postgresql-condition-connection) (message :initarg :message :reader postgresql-condition-message)) (:report (lambda (c stream) (format stream "~@<~A occurred on connection ~A. ~:@_Reason: ~A~:@>" (type-of c) (postgresql-condition-connection c) (postgresql-condition-message c))))) (define-condition postgresql-error (error postgresql-condition) ()) (define-condition postgresql-fatal-error (postgresql-error) ()) (define-condition postgresql-login-error (postgresql-fatal-error) ()) (define-condition postgresql-warning (warning postgresql-condition) ()) (define-condition postgresql-notification (postgresql-condition) () (:report (lambda (c stream) (format stream "~@<Asynchronous notification on connection ~A: ~:@_~A~:@>" (postgresql-condition-connection c) (postgresql-condition-message c)))))
28344
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: postgresql-socket-api.lisp ;;;; Purpose: Low-level PostgreSQL interface using sockets ;;;; Authors: <NAME> based on original code by <NAME> ;;;; Created: Feb 2002 ;;;; ;;;; $Id$ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by <NAME> ;;;; and Copyright (c) 1999-2001 by <NAME> ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* (in-package #:postgresql-socket3) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql-socket3))) t) (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :postgresql-socket3))) "T if foreign library was able to be loaded successfully. Always true for socket interface" t) (defparameter +postgresql-server-default-port+ 5432 "Default port of PostgreSQL server.") ;;;; Condition hierarchy (define-condition postgresql-condition (condition) ((connection :initarg :connection :reader postgresql-condition-connection) (message :initarg :message :reader postgresql-condition-message)) (:report (lambda (c stream) (format stream "~@<~A occurred on connection ~A. ~:@_Reason: ~A~:@>" (type-of c) (postgresql-condition-connection c) (postgresql-condition-message c))))) (define-condition postgresql-error (error postgresql-condition) ()) (define-condition postgresql-fatal-error (postgresql-error) ()) (define-condition postgresql-login-error (postgresql-fatal-error) ()) (define-condition postgresql-warning (warning postgresql-condition) ()) (define-condition postgresql-notification (postgresql-condition) () (:report (lambda (c stream) (format stream "~@<Asynchronous notification on connection ~A: ~:@_~A~:@>" (postgresql-condition-connection c) (postgresql-condition-message c)))))
true
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: postgresql-socket-api.lisp ;;;; Purpose: Low-level PostgreSQL interface using sockets ;;;; Authors: PI:NAME:<NAME>END_PI based on original code by PI:NAME:<NAME>END_PI ;;;; Created: Feb 2002 ;;;; ;;;; $Id$ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by PI:NAME:<NAME>END_PI ;;;; and Copyright (c) 1999-2001 by PI:NAME:<NAME>END_PI ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* (in-package #:postgresql-socket3) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql-socket3))) t) (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :postgresql-socket3))) "T if foreign library was able to be loaded successfully. Always true for socket interface" t) (defparameter +postgresql-server-default-port+ 5432 "Default port of PostgreSQL server.") ;;;; Condition hierarchy (define-condition postgresql-condition (condition) ((connection :initarg :connection :reader postgresql-condition-connection) (message :initarg :message :reader postgresql-condition-message)) (:report (lambda (c stream) (format stream "~@<~A occurred on connection ~A. ~:@_Reason: ~A~:@>" (type-of c) (postgresql-condition-connection c) (postgresql-condition-message c))))) (define-condition postgresql-error (error postgresql-condition) ()) (define-condition postgresql-fatal-error (postgresql-error) ()) (define-condition postgresql-login-error (postgresql-fatal-error) ()) (define-condition postgresql-warning (warning postgresql-condition) ()) (define-condition postgresql-notification (postgresql-condition) () (:report (lambda (c stream) (format stream "~@<Asynchronous notification on connection ~A: ~:@_~A~:@>" (postgresql-condition-connection c) (postgresql-condition-message c)))))
[ { "context": ")\n\n;;;; ** Simple list matching based on code from Paul Graham's On Lisp.\n\n(defmacro acond2 (&rest clauses)\n (i", "end": 4310, "score": 0.9803411364555359, "start": 4299, "tag": "NAME", "value": "Paul Graham" }, { "context": "ers))))))\n nil))\n\n;; Copyright (c) 2002-2006, Edward Marco Baringer\n;; All rights reserved. \n;; \n;; Redistribution an", "end": 6627, "score": 0.9998889565467834, "start": 6606, "tag": "NAME", "value": "Edward Marco Baringer" }, { "context": "ith the distribution.\n;;\n;; - Neither the name of Edward Marco Baringer, nor BESE, nor the names\n;; of its contributor", "end": 7225, "score": 0.9998291730880737, "start": 7204, "tag": "NAME", "value": "Edward Marco Baringer" } ]
src/list.lisp
pokepay/arnesi
79
;; -*- lisp -*- (in-package :it.bese.arnesi) ;;;; * Working with lists (defmacro dolist* ((iterator list &optional return-value) &body body) "Like DOLIST but destructuring-binds the elements of LIST. If ITERATOR is a symbol then dolist* is just like dolist EXCEPT that it creates a fresh binding." (if (listp iterator) (let ((i (gensym "DOLIST*-I-"))) `(dolist (,i ,list ,return-value) (destructuring-bind ,iterator ,i ,@body))) `(dolist (,iterator ,list ,return-value) (let ((,iterator ,iterator)) ,@body)))) (defun ensure-list (thing) "Returns THING as a list. If THING is already a list (as per listp) it is returned, otherwise a one element list containing THING is returned." (if (listp thing) thing (list thing))) (defun ensure-cons (thing) (if (consp thing) thing (cons thing nil))) (defun partition (list &rest lambdas) "Split LIST into sub lists according to LAMBDAS. Each element of LIST will be passed to each element of LAMBDAS, the first function in LAMBDAS which returns T will cause that element to be collected into the corresponding list. Examples: (partition '(1 2 3) #'oddp #'evenp) => ((1 3) (2)) (partition '(1 2 3) #'oddp t) => ((1 3) (1 2 3)) (partition '(1 2 3) #'oddp #'stringp) => ((1 3) nil)" (let ((collectors (mapcar (lambda (predicate) (cons (case predicate ((t :otherwise) (constantly t)) ((nil) (constantly nil)) (t predicate)) (make-collector))) lambdas))) (dolist (item list) (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item)))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defun partitionx (list &rest lambdas) (let ((collectors (mapcar (lambda (l) (cons (if (and (symbolp l) (member l (list :otherwise t) :test #'string=)) (constantly t) l) (make-collector))) lambdas))) (dolist (item list) (block item (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item) (return-from item))))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defmacro dotree ((name tree &optional ret-val) &body body) "Evaluate BODY with NAME bound to every element in TREE. Return RET-VAL." (with-unique-names (traverser list list-element) `(progn (labels ((,traverser (,list) (dolist (,list-element ,list) (if (consp ,list-element) (,traverser ,list-element) (let ((,name ,list-element)) ,@body))))) (,traverser ,tree) ,ret-val)))) (defun do-push* (list &rest items) (dolist (i items) (setf list (cons i list))) list) (define-modify-macro push* (&rest items) do-push* "Pushes every element of ITEMS onto LIST. Equivalent to calling PUSH with each element of ITEMS.") (defun proper-list-p (object) "Tests whether OBJECT is properlist. A proper list is a non circular cons chain whose last cdr is eq to NIL." (or (null object) (and (consp object) ;; check if the last cdr of object is null. deal with ;; circular lists. (loop for turtoise = object then (cdr turtoise) for hare = (cdr object) then (cddr hare) ;; we need to agressivly check hare's cdr so that the call to ;; cddr doesn't signal an error when (eq turtoise hare) return nil when (null turtoise) return t when (null hare) return t when (not (consp hare)) return nil when (null (cdr hare)) return t when (not (consp (cdr hare))) return nil when (null (cddr hare)) return t when (not (consp (cddr hare))) return nil)))) ;;;; ** Simple list matching based on code from Paul Graham's On Lisp. (defmacro acond2 (&rest clauses) (if (null clauses) nil (with-unique-names (val foundp) (destructuring-bind ((test &rest progn) &rest others) clauses `(multiple-value-bind (,val ,foundp) ,test (if (or ,val ,foundp) (let ((it ,val)) (declare (ignorable it)) ,@progn) (acond2 ,@others))))))) (defun varsymp (x) (and (symbolp x) (eq (aref (symbol-name x) 0) #\?))) (defun binding (x binds) (labels ((recbind (x binds) (aif (assoc x binds) (or (recbind (cdr it) binds) it)))) (let ((b (recbind x binds))) (values (cdr b) b)))) (defun list-match (x y &optional binds) (acond2 ((or (eql x y) (eql x '_) (eql y '_)) (values binds t)) ((binding x binds) (list-match it y binds)) ((binding y binds) (list-match x it binds)) ((varsymp x) (values (cons (cons x y) binds) t)) ((varsymp y) (values (cons (cons y x) binds) t)) ((and (consp x) (consp y) (list-match (car x) (car y) binds)) (list-match (cdr x) (cdr y) it)) (t (values nil nil)))) (defun vars (match-spec) (let ((vars nil)) (labels ((find-vars (spec) (cond ((null spec) nil) ((varsymp spec) (push spec vars)) ((consp spec) (find-vars (car spec)) (find-vars (cdr spec)))))) (find-vars match-spec)) (delete-duplicates vars))) (defmacro list-match-case (target &body clauses) (if clauses (destructuring-bind ((test &rest progn) &rest others) clauses (with-unique-names (tgt binds success) `(let ((,tgt ,target)) (multiple-value-bind (,binds ,success) (list-match ,tgt ',test) (declare (ignorable ,binds)) (if ,success (let ,(mapcar (lambda (var) `(,var (cdr (assoc ',var ,binds)))) (vars test)) (declare (ignorable ,@(vars test))) ,@progn) (list-match-case ,tgt ,@others)))))) nil)) ;; Copyright (c) 2002-2006, Edward Marco Baringer ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are ;; met: ;; ;; - Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; - Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; - Neither the name of Edward Marco Baringer, nor BESE, nor the names ;; of its contributors may be used to endorse or promote products ;; derived from this software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57532
;; -*- lisp -*- (in-package :it.bese.arnesi) ;;;; * Working with lists (defmacro dolist* ((iterator list &optional return-value) &body body) "Like DOLIST but destructuring-binds the elements of LIST. If ITERATOR is a symbol then dolist* is just like dolist EXCEPT that it creates a fresh binding." (if (listp iterator) (let ((i (gensym "DOLIST*-I-"))) `(dolist (,i ,list ,return-value) (destructuring-bind ,iterator ,i ,@body))) `(dolist (,iterator ,list ,return-value) (let ((,iterator ,iterator)) ,@body)))) (defun ensure-list (thing) "Returns THING as a list. If THING is already a list (as per listp) it is returned, otherwise a one element list containing THING is returned." (if (listp thing) thing (list thing))) (defun ensure-cons (thing) (if (consp thing) thing (cons thing nil))) (defun partition (list &rest lambdas) "Split LIST into sub lists according to LAMBDAS. Each element of LIST will be passed to each element of LAMBDAS, the first function in LAMBDAS which returns T will cause that element to be collected into the corresponding list. Examples: (partition '(1 2 3) #'oddp #'evenp) => ((1 3) (2)) (partition '(1 2 3) #'oddp t) => ((1 3) (1 2 3)) (partition '(1 2 3) #'oddp #'stringp) => ((1 3) nil)" (let ((collectors (mapcar (lambda (predicate) (cons (case predicate ((t :otherwise) (constantly t)) ((nil) (constantly nil)) (t predicate)) (make-collector))) lambdas))) (dolist (item list) (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item)))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defun partitionx (list &rest lambdas) (let ((collectors (mapcar (lambda (l) (cons (if (and (symbolp l) (member l (list :otherwise t) :test #'string=)) (constantly t) l) (make-collector))) lambdas))) (dolist (item list) (block item (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item) (return-from item))))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defmacro dotree ((name tree &optional ret-val) &body body) "Evaluate BODY with NAME bound to every element in TREE. Return RET-VAL." (with-unique-names (traverser list list-element) `(progn (labels ((,traverser (,list) (dolist (,list-element ,list) (if (consp ,list-element) (,traverser ,list-element) (let ((,name ,list-element)) ,@body))))) (,traverser ,tree) ,ret-val)))) (defun do-push* (list &rest items) (dolist (i items) (setf list (cons i list))) list) (define-modify-macro push* (&rest items) do-push* "Pushes every element of ITEMS onto LIST. Equivalent to calling PUSH with each element of ITEMS.") (defun proper-list-p (object) "Tests whether OBJECT is properlist. A proper list is a non circular cons chain whose last cdr is eq to NIL." (or (null object) (and (consp object) ;; check if the last cdr of object is null. deal with ;; circular lists. (loop for turtoise = object then (cdr turtoise) for hare = (cdr object) then (cddr hare) ;; we need to agressivly check hare's cdr so that the call to ;; cddr doesn't signal an error when (eq turtoise hare) return nil when (null turtoise) return t when (null hare) return t when (not (consp hare)) return nil when (null (cdr hare)) return t when (not (consp (cdr hare))) return nil when (null (cddr hare)) return t when (not (consp (cddr hare))) return nil)))) ;;;; ** Simple list matching based on code from <NAME>'s On Lisp. (defmacro acond2 (&rest clauses) (if (null clauses) nil (with-unique-names (val foundp) (destructuring-bind ((test &rest progn) &rest others) clauses `(multiple-value-bind (,val ,foundp) ,test (if (or ,val ,foundp) (let ((it ,val)) (declare (ignorable it)) ,@progn) (acond2 ,@others))))))) (defun varsymp (x) (and (symbolp x) (eq (aref (symbol-name x) 0) #\?))) (defun binding (x binds) (labels ((recbind (x binds) (aif (assoc x binds) (or (recbind (cdr it) binds) it)))) (let ((b (recbind x binds))) (values (cdr b) b)))) (defun list-match (x y &optional binds) (acond2 ((or (eql x y) (eql x '_) (eql y '_)) (values binds t)) ((binding x binds) (list-match it y binds)) ((binding y binds) (list-match x it binds)) ((varsymp x) (values (cons (cons x y) binds) t)) ((varsymp y) (values (cons (cons y x) binds) t)) ((and (consp x) (consp y) (list-match (car x) (car y) binds)) (list-match (cdr x) (cdr y) it)) (t (values nil nil)))) (defun vars (match-spec) (let ((vars nil)) (labels ((find-vars (spec) (cond ((null spec) nil) ((varsymp spec) (push spec vars)) ((consp spec) (find-vars (car spec)) (find-vars (cdr spec)))))) (find-vars match-spec)) (delete-duplicates vars))) (defmacro list-match-case (target &body clauses) (if clauses (destructuring-bind ((test &rest progn) &rest others) clauses (with-unique-names (tgt binds success) `(let ((,tgt ,target)) (multiple-value-bind (,binds ,success) (list-match ,tgt ',test) (declare (ignorable ,binds)) (if ,success (let ,(mapcar (lambda (var) `(,var (cdr (assoc ',var ,binds)))) (vars test)) (declare (ignorable ,@(vars test))) ,@progn) (list-match-case ,tgt ,@others)))))) nil)) ;; Copyright (c) 2002-2006, <NAME> ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are ;; met: ;; ;; - Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; - Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; - Neither the name of <NAME>, nor BESE, nor the names ;; of its contributors may be used to endorse or promote products ;; derived from this software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
true
;; -*- lisp -*- (in-package :it.bese.arnesi) ;;;; * Working with lists (defmacro dolist* ((iterator list &optional return-value) &body body) "Like DOLIST but destructuring-binds the elements of LIST. If ITERATOR is a symbol then dolist* is just like dolist EXCEPT that it creates a fresh binding." (if (listp iterator) (let ((i (gensym "DOLIST*-I-"))) `(dolist (,i ,list ,return-value) (destructuring-bind ,iterator ,i ,@body))) `(dolist (,iterator ,list ,return-value) (let ((,iterator ,iterator)) ,@body)))) (defun ensure-list (thing) "Returns THING as a list. If THING is already a list (as per listp) it is returned, otherwise a one element list containing THING is returned." (if (listp thing) thing (list thing))) (defun ensure-cons (thing) (if (consp thing) thing (cons thing nil))) (defun partition (list &rest lambdas) "Split LIST into sub lists according to LAMBDAS. Each element of LIST will be passed to each element of LAMBDAS, the first function in LAMBDAS which returns T will cause that element to be collected into the corresponding list. Examples: (partition '(1 2 3) #'oddp #'evenp) => ((1 3) (2)) (partition '(1 2 3) #'oddp t) => ((1 3) (1 2 3)) (partition '(1 2 3) #'oddp #'stringp) => ((1 3) nil)" (let ((collectors (mapcar (lambda (predicate) (cons (case predicate ((t :otherwise) (constantly t)) ((nil) (constantly nil)) (t predicate)) (make-collector))) lambdas))) (dolist (item list) (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item)))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defun partitionx (list &rest lambdas) (let ((collectors (mapcar (lambda (l) (cons (if (and (symbolp l) (member l (list :otherwise t) :test #'string=)) (constantly t) l) (make-collector))) lambdas))) (dolist (item list) (block item (dolist* ((test-func . collector-func) collectors) (when (funcall test-func item) (funcall collector-func item) (return-from item))))) (mapcar #'funcall (mapcar #'cdr collectors)))) (defmacro dotree ((name tree &optional ret-val) &body body) "Evaluate BODY with NAME bound to every element in TREE. Return RET-VAL." (with-unique-names (traverser list list-element) `(progn (labels ((,traverser (,list) (dolist (,list-element ,list) (if (consp ,list-element) (,traverser ,list-element) (let ((,name ,list-element)) ,@body))))) (,traverser ,tree) ,ret-val)))) (defun do-push* (list &rest items) (dolist (i items) (setf list (cons i list))) list) (define-modify-macro push* (&rest items) do-push* "Pushes every element of ITEMS onto LIST. Equivalent to calling PUSH with each element of ITEMS.") (defun proper-list-p (object) "Tests whether OBJECT is properlist. A proper list is a non circular cons chain whose last cdr is eq to NIL." (or (null object) (and (consp object) ;; check if the last cdr of object is null. deal with ;; circular lists. (loop for turtoise = object then (cdr turtoise) for hare = (cdr object) then (cddr hare) ;; we need to agressivly check hare's cdr so that the call to ;; cddr doesn't signal an error when (eq turtoise hare) return nil when (null turtoise) return t when (null hare) return t when (not (consp hare)) return nil when (null (cdr hare)) return t when (not (consp (cdr hare))) return nil when (null (cddr hare)) return t when (not (consp (cddr hare))) return nil)))) ;;;; ** Simple list matching based on code from PI:NAME:<NAME>END_PI's On Lisp. (defmacro acond2 (&rest clauses) (if (null clauses) nil (with-unique-names (val foundp) (destructuring-bind ((test &rest progn) &rest others) clauses `(multiple-value-bind (,val ,foundp) ,test (if (or ,val ,foundp) (let ((it ,val)) (declare (ignorable it)) ,@progn) (acond2 ,@others))))))) (defun varsymp (x) (and (symbolp x) (eq (aref (symbol-name x) 0) #\?))) (defun binding (x binds) (labels ((recbind (x binds) (aif (assoc x binds) (or (recbind (cdr it) binds) it)))) (let ((b (recbind x binds))) (values (cdr b) b)))) (defun list-match (x y &optional binds) (acond2 ((or (eql x y) (eql x '_) (eql y '_)) (values binds t)) ((binding x binds) (list-match it y binds)) ((binding y binds) (list-match x it binds)) ((varsymp x) (values (cons (cons x y) binds) t)) ((varsymp y) (values (cons (cons y x) binds) t)) ((and (consp x) (consp y) (list-match (car x) (car y) binds)) (list-match (cdr x) (cdr y) it)) (t (values nil nil)))) (defun vars (match-spec) (let ((vars nil)) (labels ((find-vars (spec) (cond ((null spec) nil) ((varsymp spec) (push spec vars)) ((consp spec) (find-vars (car spec)) (find-vars (cdr spec)))))) (find-vars match-spec)) (delete-duplicates vars))) (defmacro list-match-case (target &body clauses) (if clauses (destructuring-bind ((test &rest progn) &rest others) clauses (with-unique-names (tgt binds success) `(let ((,tgt ,target)) (multiple-value-bind (,binds ,success) (list-match ,tgt ',test) (declare (ignorable ,binds)) (if ,success (let ,(mapcar (lambda (var) `(,var (cdr (assoc ',var ,binds)))) (vars test)) (declare (ignorable ,@(vars test))) ,@progn) (list-match-case ,tgt ,@others)))))) nil)) ;; Copyright (c) 2002-2006, PI:NAME:<NAME>END_PI ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are ;; met: ;; ;; - Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; - Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; - Neither the name of PI:NAME:<NAME>END_PI, nor BESE, nor the names ;; of its contributors may be used to endorse or promote products ;; derived from this software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[ { "context": "#|\n This file is a part of Dissect\n (c) 2014 Shirakumo http://tymoon.eu ([email protected])\n Author: N", "end": 53, "score": 0.8327682018280029, "start": 47, "tag": "NAME", "value": "irakum" }, { "context": " of Dissect\n (c) 2014 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 91, "score": 0.9999198913574219, "start": 73, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.tymoon", "end": 116, "score": 0.9998922944068909, "start": 102, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.tymoonnext.dissect)\n\n(defm", "end": 136, "score": 0.9999265670776367, "start": 118, "tag": "EMAIL", "value": "[email protected]" } ]
vendor/quicklisp/dists/quicklisp/software/dissect-20210531-git/documentation.lisp
corpix/clx
29
#| This file is a part of Dissect (c) 2014 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.tymoonnext.dissect) (defmacro setdocs (&body pairs) `(progn ,@(loop for (type var doc) in pairs collect `(setf (documentation ',var ',type) ,doc)))) (setdocs (function stack "Returns a list of CALL objects describing the stack from the point where this function was called. This excludes the call to STACK itself. Any calls above a WITH-CAPPED-STACK form, and below a WITH-TRUNCATED-STACK form are also excluded. Returns an empty list on unsupported platforms. See CALL See WITH-TRUNCATED-STACK See WITH-CAPPED-STACK") (function restarts "Returns a list of RESTART objects describing the currently available restarts. Returns an empty list on unsupported platforms. See RESTART") (function with-truncated-stack "Calls BODY in an environment where a call to STACK will not report frames further down. See STACK") (function with-capped-stack "Calls BODY in an environment where a call to STACK will not report frames further up. See STACK") (function present "Prints a neat representation of THING to DESTINATION. DESTINATION can be one of the following types: (eql NIL) --- The representation is printed and returned as a string. (eql T) --- The representation is printed to *STANDARD-OUTPUT*. STREAM --- The representation is printed to the stream. THING can be one of the following types: RESTART --- Restarts are presented as: [NAME] REPORT CALL --- Calls are presented as: POS (CALL ARGS..) ENVIRONMENT --- Environments are presented as a multiline description of all the parts it references (condition, stack, restarts, thread). CONDITION --- Conditions are presented as: CONDITION [Condition of type TYPE] (EQL T) --- Presents the environment at point using CAPTURE-ENVIRONMENT. LIST --- The list can contain either restarts or calls. In both cases the behaviour is to output a header line, followed by the presentation of each item in the list on its own line. Internally the function PRESENT-OBJECT is used to perform the actual printing. See RESTART See CALL See ENVIRONMENT See CONDITION See CAPTURE-ENVIRONMENT See PRESENT-OBJECT") (function present-object "Internal generic function for pretty printing. See PRESENT")) (setdocs (type restart "Class container for restart information. See NAME See REPORT See RESTART See OBJECT See INTERACTIVE See TEST See INVOKE") (function name "Returns the restart's symbol. Use this for INVOKE-RESTART. See RESTART") (function report "Returns the report string describing the restart's effects. See RESTART") (function restart "Returns a symbol to the restart-function or a direct function-object. See RESTART") (function object "Returns the platform-internal restart object. See RESTART") (function interactive "Returns the interactive restart function. See RESTART") (function test "Returns the restart test function. See RESTART") (function invoke "Invoke the restart that the restart object references. See RESTART")) (setdocs (type unknown-arguments "Used to represent an unknown list of arguments. Instances of this class are printed as #<Unknown Arguments>") (type unavailable-argument "Used to represent an argument that isn't available in the environment. Instances of this class are printed as #<Unavailable>")) (setdocs (type call "Class container for stack frame information. See POS See CALL See ARGS See FILE See LINE See FORM") (function pos "Returns the position of the call on the stack. See CALL") (function call "Returns the stack call function. Can be either a function object or the name of a global function. See CALL") (function args "Returns a list of arguments that were used in the frame call. If the arguments list is not available, this may also return an instance of UNKNOWN-ARGUMENTS. The values in the list may be instances of UNAVAILABLE-ARGUMENT if the argument is unknown or could not be captured for some reason. See UNKNOWN-ARGUMENTS See UNAVAILABLE-ARGUMENT See CALL") (function file "If possible, returns the file the called function is defined in. See CALL") (function line "If possible, returns the line number in the file where the function is defined. See CALL") (function form "If possible, returns the actual definition form of the function. See CALL")) (setdocs (type environment "Container class for a current \"environment\". An instance of this class is intended to represent most of the runtime environment present at a particular point. It is useful for stashing away debug information for inspection at a later date. See CAPTURE-ENVIRONMENT See ENVIRONMENT-CONDITION See ENVIRONMENT-STACK See ENVIRONMENT-RESTARTS See ENVIRONMENT-THREAD") (function environment-condition "Returns the condition stored in the environment (if any). See CL:CONDITION See ENVIRONMENT") (function environment-stack "Returns a list of calls stored in the environment (if any). See CALL See ENVIRONMENT") (function environment-restarts "Returns a list of restarts stored in the environment (if any). See CL:RESTART See ENVIRONMENT") (function environment-thread "Returns the thread stored in the environment (if any). See SB-THREAD:THREAD See THREADS:THREAD See MP:PROCESS See MT:THREAD See CCL:PROCESS See PROCESS:PROCESS See THREAD:THREAD See ENVIRONMENT") (function capture-environment "Capture the current environment into an environment object. See ENVIRONMENT"))
8370
#| This file is a part of Dissect (c) 2014 Sh<NAME>o http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.tymoonnext.dissect) (defmacro setdocs (&body pairs) `(progn ,@(loop for (type var doc) in pairs collect `(setf (documentation ',var ',type) ,doc)))) (setdocs (function stack "Returns a list of CALL objects describing the stack from the point where this function was called. This excludes the call to STACK itself. Any calls above a WITH-CAPPED-STACK form, and below a WITH-TRUNCATED-STACK form are also excluded. Returns an empty list on unsupported platforms. See CALL See WITH-TRUNCATED-STACK See WITH-CAPPED-STACK") (function restarts "Returns a list of RESTART objects describing the currently available restarts. Returns an empty list on unsupported platforms. See RESTART") (function with-truncated-stack "Calls BODY in an environment where a call to STACK will not report frames further down. See STACK") (function with-capped-stack "Calls BODY in an environment where a call to STACK will not report frames further up. See STACK") (function present "Prints a neat representation of THING to DESTINATION. DESTINATION can be one of the following types: (eql NIL) --- The representation is printed and returned as a string. (eql T) --- The representation is printed to *STANDARD-OUTPUT*. STREAM --- The representation is printed to the stream. THING can be one of the following types: RESTART --- Restarts are presented as: [NAME] REPORT CALL --- Calls are presented as: POS (CALL ARGS..) ENVIRONMENT --- Environments are presented as a multiline description of all the parts it references (condition, stack, restarts, thread). CONDITION --- Conditions are presented as: CONDITION [Condition of type TYPE] (EQL T) --- Presents the environment at point using CAPTURE-ENVIRONMENT. LIST --- The list can contain either restarts or calls. In both cases the behaviour is to output a header line, followed by the presentation of each item in the list on its own line. Internally the function PRESENT-OBJECT is used to perform the actual printing. See RESTART See CALL See ENVIRONMENT See CONDITION See CAPTURE-ENVIRONMENT See PRESENT-OBJECT") (function present-object "Internal generic function for pretty printing. See PRESENT")) (setdocs (type restart "Class container for restart information. See NAME See REPORT See RESTART See OBJECT See INTERACTIVE See TEST See INVOKE") (function name "Returns the restart's symbol. Use this for INVOKE-RESTART. See RESTART") (function report "Returns the report string describing the restart's effects. See RESTART") (function restart "Returns a symbol to the restart-function or a direct function-object. See RESTART") (function object "Returns the platform-internal restart object. See RESTART") (function interactive "Returns the interactive restart function. See RESTART") (function test "Returns the restart test function. See RESTART") (function invoke "Invoke the restart that the restart object references. See RESTART")) (setdocs (type unknown-arguments "Used to represent an unknown list of arguments. Instances of this class are printed as #<Unknown Arguments>") (type unavailable-argument "Used to represent an argument that isn't available in the environment. Instances of this class are printed as #<Unavailable>")) (setdocs (type call "Class container for stack frame information. See POS See CALL See ARGS See FILE See LINE See FORM") (function pos "Returns the position of the call on the stack. See CALL") (function call "Returns the stack call function. Can be either a function object or the name of a global function. See CALL") (function args "Returns a list of arguments that were used in the frame call. If the arguments list is not available, this may also return an instance of UNKNOWN-ARGUMENTS. The values in the list may be instances of UNAVAILABLE-ARGUMENT if the argument is unknown or could not be captured for some reason. See UNKNOWN-ARGUMENTS See UNAVAILABLE-ARGUMENT See CALL") (function file "If possible, returns the file the called function is defined in. See CALL") (function line "If possible, returns the line number in the file where the function is defined. See CALL") (function form "If possible, returns the actual definition form of the function. See CALL")) (setdocs (type environment "Container class for a current \"environment\". An instance of this class is intended to represent most of the runtime environment present at a particular point. It is useful for stashing away debug information for inspection at a later date. See CAPTURE-ENVIRONMENT See ENVIRONMENT-CONDITION See ENVIRONMENT-STACK See ENVIRONMENT-RESTARTS See ENVIRONMENT-THREAD") (function environment-condition "Returns the condition stored in the environment (if any). See CL:CONDITION See ENVIRONMENT") (function environment-stack "Returns a list of calls stored in the environment (if any). See CALL See ENVIRONMENT") (function environment-restarts "Returns a list of restarts stored in the environment (if any). See CL:RESTART See ENVIRONMENT") (function environment-thread "Returns the thread stored in the environment (if any). See SB-THREAD:THREAD See THREADS:THREAD See MP:PROCESS See MT:THREAD See CCL:PROCESS See PROCESS:PROCESS See THREAD:THREAD See ENVIRONMENT") (function capture-environment "Capture the current environment into an environment object. See ENVIRONMENT"))
true
#| This file is a part of Dissect (c) 2014 ShPI:NAME:<NAME>END_PIo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.tymoonnext.dissect) (defmacro setdocs (&body pairs) `(progn ,@(loop for (type var doc) in pairs collect `(setf (documentation ',var ',type) ,doc)))) (setdocs (function stack "Returns a list of CALL objects describing the stack from the point where this function was called. This excludes the call to STACK itself. Any calls above a WITH-CAPPED-STACK form, and below a WITH-TRUNCATED-STACK form are also excluded. Returns an empty list on unsupported platforms. See CALL See WITH-TRUNCATED-STACK See WITH-CAPPED-STACK") (function restarts "Returns a list of RESTART objects describing the currently available restarts. Returns an empty list on unsupported platforms. See RESTART") (function with-truncated-stack "Calls BODY in an environment where a call to STACK will not report frames further down. See STACK") (function with-capped-stack "Calls BODY in an environment where a call to STACK will not report frames further up. See STACK") (function present "Prints a neat representation of THING to DESTINATION. DESTINATION can be one of the following types: (eql NIL) --- The representation is printed and returned as a string. (eql T) --- The representation is printed to *STANDARD-OUTPUT*. STREAM --- The representation is printed to the stream. THING can be one of the following types: RESTART --- Restarts are presented as: [NAME] REPORT CALL --- Calls are presented as: POS (CALL ARGS..) ENVIRONMENT --- Environments are presented as a multiline description of all the parts it references (condition, stack, restarts, thread). CONDITION --- Conditions are presented as: CONDITION [Condition of type TYPE] (EQL T) --- Presents the environment at point using CAPTURE-ENVIRONMENT. LIST --- The list can contain either restarts or calls. In both cases the behaviour is to output a header line, followed by the presentation of each item in the list on its own line. Internally the function PRESENT-OBJECT is used to perform the actual printing. See RESTART See CALL See ENVIRONMENT See CONDITION See CAPTURE-ENVIRONMENT See PRESENT-OBJECT") (function present-object "Internal generic function for pretty printing. See PRESENT")) (setdocs (type restart "Class container for restart information. See NAME See REPORT See RESTART See OBJECT See INTERACTIVE See TEST See INVOKE") (function name "Returns the restart's symbol. Use this for INVOKE-RESTART. See RESTART") (function report "Returns the report string describing the restart's effects. See RESTART") (function restart "Returns a symbol to the restart-function or a direct function-object. See RESTART") (function object "Returns the platform-internal restart object. See RESTART") (function interactive "Returns the interactive restart function. See RESTART") (function test "Returns the restart test function. See RESTART") (function invoke "Invoke the restart that the restart object references. See RESTART")) (setdocs (type unknown-arguments "Used to represent an unknown list of arguments. Instances of this class are printed as #<Unknown Arguments>") (type unavailable-argument "Used to represent an argument that isn't available in the environment. Instances of this class are printed as #<Unavailable>")) (setdocs (type call "Class container for stack frame information. See POS See CALL See ARGS See FILE See LINE See FORM") (function pos "Returns the position of the call on the stack. See CALL") (function call "Returns the stack call function. Can be either a function object or the name of a global function. See CALL") (function args "Returns a list of arguments that were used in the frame call. If the arguments list is not available, this may also return an instance of UNKNOWN-ARGUMENTS. The values in the list may be instances of UNAVAILABLE-ARGUMENT if the argument is unknown or could not be captured for some reason. See UNKNOWN-ARGUMENTS See UNAVAILABLE-ARGUMENT See CALL") (function file "If possible, returns the file the called function is defined in. See CALL") (function line "If possible, returns the line number in the file where the function is defined. See CALL") (function form "If possible, returns the actual definition form of the function. See CALL")) (setdocs (type environment "Container class for a current \"environment\". An instance of this class is intended to represent most of the runtime environment present at a particular point. It is useful for stashing away debug information for inspection at a later date. See CAPTURE-ENVIRONMENT See ENVIRONMENT-CONDITION See ENVIRONMENT-STACK See ENVIRONMENT-RESTARTS See ENVIRONMENT-THREAD") (function environment-condition "Returns the condition stored in the environment (if any). See CL:CONDITION See ENVIRONMENT") (function environment-stack "Returns a list of calls stored in the environment (if any). See CALL See ENVIRONMENT") (function environment-restarts "Returns a list of restarts stored in the environment (if any). See CL:RESTART See ENVIRONMENT") (function environment-thread "Returns the thread stored in the environment (if any). See SB-THREAD:THREAD See THREADS:THREAD See MP:PROCESS See MT:THREAD See CCL:PROCESS See PROCESS:PROCESS See THREAD:THREAD See ENVIRONMENT") (function capture-environment "Capture the current environment into an environment object. See ENVIRONMENT"))
[ { "context": "em :cl-syntax-anonfun\n :version \"0.2\"\n :author \"Tomohiro Matsuyama\"\n :license \"LLGPL\"\n :description \"CL-Syntax Rea", "end": 191, "score": 0.9998792409896851, "start": 173, "tag": "NAME", "value": "Tomohiro Matsuyama" } ]
vendor/quicklisp/dists/quicklisp/software/cl-syntax-20150407-git/cl-syntax-anonfun.asd
corpix/clx
4
(in-package :cl-user) (defpackage :cl-syntax-anonfun-asd (:use :cl :asdf)) (in-package :cl-syntax-anonfun-asd) (defsystem :cl-syntax-anonfun :version "0.2" :author "Tomohiro Matsuyama" :license "LLGPL" :description "CL-Syntax Reader Syntax for cl-anonfun" :depends-on (:cl-syntax :cl-anonfun) :components ((:file "contrib/anonfun")))
94589
(in-package :cl-user) (defpackage :cl-syntax-anonfun-asd (:use :cl :asdf)) (in-package :cl-syntax-anonfun-asd) (defsystem :cl-syntax-anonfun :version "0.2" :author "<NAME>" :license "LLGPL" :description "CL-Syntax Reader Syntax for cl-anonfun" :depends-on (:cl-syntax :cl-anonfun) :components ((:file "contrib/anonfun")))
true
(in-package :cl-user) (defpackage :cl-syntax-anonfun-asd (:use :cl :asdf)) (in-package :cl-syntax-anonfun-asd) (defsystem :cl-syntax-anonfun :version "0.2" :author "PI:NAME:<NAME>END_PI" :license "LLGPL" :description "CL-Syntax Reader Syntax for cl-anonfun" :depends-on (:cl-syntax :cl-anonfun) :components ((:file "contrib/anonfun")))
[ { "context": "al revision\n;;;\n\n Boxer\n Copyright 1985-2020 Andrea A. diSessa and the Estate of Edward H. Lay\n\n Portions of ", "end": 270, "score": 0.9998828172683716, "start": 253, "tag": "NAME", "value": "Andrea A. diSessa" }, { "context": "ight 1985-2020 Andrea A. diSessa and the Estate of Edward H. Lay\n\n Portions of this code may be copyright 1982-", "end": 302, "score": 0.9991779327392578, "start": 289, "tag": "NAME", "value": "Edward H. Lay" } ]
src/primitives/file-prims.lisp
boxer-project/boxer-sunrise
16
;; -*- Mode:LISP; Syntax:Common-Lisp; Package:BOXER; -*- #| $Header: file-prims.lisp,v 1.0 90/01/24 22:11:51 boxer Exp $ $Log: file-prims.lisp,v $ ;;;Revision 1.0 90/01/24 22:11:51 boxer ;;;Initial revision ;;; Boxer Copyright 1985-2020 Andrea A. diSessa and the Estate of Edward H. Lay Portions of this code may be copyright 1982-1985 Massachusetts Institute of Technology. Those portions may be used for any purpose, including commercial ones, providing that notice of MIT copyright is retained. Licensed under the 3-Clause BSD license. You may not use this file except in compliance with this license. https://opensource.org/licenses/BSD-3-Clause +-Data--+ This file is part of the | BOXER | system +-------+ This file contains all of the boxer functions which use the file system. Modification History (most recent at top) 12/15/11 write-text-stream-internal changed to handle the :interpolate option *box-encountered-during-text-file-operation* changed to :interpolate new function write-text-stream-for-boxy-row 12/22/05 wrap ignore-errors around parts of check-valid-filename-for-primitive to cleanly handle illegal pathnames (e.g. from mistyped URL protocol fields) READ-INTERNAL checks for possible null pathname to catch this case 8/23/05 fill-box-from-local-file uses new probe-search-file to check for boxer files 8/06/05 fixed truncated-filename to handle names longer than *max-filename-length* also boosted *max-filename-length* to 50 10/06/04 extended storage-{name,info} to handle xrefs 8/27/04 copyright error message in mark-for-saving referred to wrong replacement name 7/16/04 Fixed Copyright Error message in MARk-FOR-SAVING 8/15/03 added show-file-info as diagnostic tool, set-boxer-file-info 4/19/03 merged current LW and MCL files 2/03/03 destructure-file-info-box, file-info-to-file, file-to-file-info & merge-file-info 2/01/03 changed make-file-storage-info-box to make empty boxes for fields which are either null or :unspecific 10/20/02 RECORD-FILE-BOX-PLACE & RECORD-URL-BOX-PLACE stubbified and removed from READ-INTERNAL & FILL-BOX-FROM-LOCAL-FILE in preparation for "UC clean" reimplementation 9/02/02 UC free version of MARK-FOR-SAVING, added TOGGLE-MODIFIED-FLAG 8/27/02 make-file-storage-info-box, VC names must be BU symbols instead of strings make-url-storage-info-box does the same via intern-in-bu-package 8/ 8/02 finished support functions for bu::storage-xxx 8/ 5/02 added bu::storage-name and bu::storage-info 10/ 7/01 status-line-save-format-string for use in save-internal 3/ 8/01 fill-box-from-local-file: relative pathname check should check for null dirs as well as :relative 2/14/01 merged current LW and MCL files 1/15/01 lispworks version for check-valid-filename-for-primitive 10/16/00 make-backup-if-necessary now checks for 31 char pathnames 10/10/00 make-backup-if-necessary for windows will keep the pathname type 11/14/99 removed file-namestring from fill-box-from-local-file because it loses when merging a typeless pathname. Replace by make-pathname with the type component defaulting to :unspecific for null pathname-type 10/15/99 simplified fill-box-from-local-file by using file-namestring 10/14/99 save-text-file processes the modified editor object queue save-text-file-internal now renders VC's into editor boxes 9/13/99 fill-box-from-local-file, don't mark the file box dirty for relative pathname fileboxes, unless the relative part is actually changed 6/25/99 extracted pretty-file-box-name for use in other places added pretty-url-box-name (temp version), record-file-box-place, and record-url-box-place use record-file-box-place in read-internal,fill-box-from-local-file 5/25/99 changed mark-box-as-file to not be so eager to convert to :file boxtop 5/17/99 check for filename before saving old-file-prop in unmark-box-as-file 5/12/99 added eval::*novalue* return value to mark-for-saving 4/25/99 {un}mark-box-as-file now adds/removes :file :boxtop property 4/14/99 use new calling conventions for write-boxer-file-info 3/26/99 bu::mark-for-saving added 2/12/99 save-generic error messages use OPEN as the name of the prim instead of READ 2/11/99 (defboxer-primitive bu::unfile-box 2/10/99 added unmark-box-as-file 12/15/98 changed various save functions to process the mutation queue before saving 10/ 1/98 fill-box-from-local-file probes for file in relative pathname clause also separate prompts for choose file dialog when file not found 9/29/98 save-generic sets read-only? flag both ways instead of only to T 9/13/98 OPEN changed to bash name slot of world boxes 5/27/98 added autoloading case to fill-box-from-local-file for relative paths changed read-internal-1 to give lisp error (which should be handled) for missing autoload 5/27/98 Started Logging Changes: source = boxer version 2.3alphaR1 |# (in-package :boxer) ;;;; the prims (boxer-eval::defboxer-primitive bu::save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::quietly-save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document nil T)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::save-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox (current-file-box))) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-save-document))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::save-box-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox boxer-eval::*lexical-variables-root*)) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-box-save-as nil boxer-eval::*lexical-variables-root*))) boxer-eval::*novalue*) ;; use TELL to direct (boxer-eval::defboxer-primitive bu::unfile-box () (com-unfile-document)) ;; Returns TRUE, or a box with a defined reason or else FALSE, ;; meaning "some other reason" (boxer-eval::defboxer-primitive bu::safe-to-save? () (let* ((box (current-file-box)) (raw-filename (getprop box :associated-file)) ;; careful, the filename might be relative (existing-filename (cond ((null raw-filename) nil) ((eq (car (pathname-directory raw-filename)) :absolute) raw-filename) (t ; must be relative (let* ((sup-file-box (current-file-box (superior-box box))) (sup-filename (getprop sup-file-box :associated-file))) (cond ((not (null sup-filename)) (merge-pathnames raw-filename sup-filename))))))) (fps (get-boxer-file-properties existing-filename))) (cond ((null existing-filename) (make-vc '((bu::no-filename)))) #-mcl ;; MACL probe-file loses on directories ((null (probe-file (make-pathname :directory (pathname-directory existing-filename)))) (make-vc '((bu::no-directory)))) #+mcl ;; on the mac, you can "lock" files... ((and (probe-file existing-filename) (ccl::file-locked-p existing-filename)) (make-vc '((bu::file-locked)))) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname ((and (not (null fps)) (not (null (file-write-date existing-filename))) (not (= (boxer-file-creation-date fps) (file-write-date existing-filename)))) (make-vc '((bu::file-is-newer)))) ((and (not (null fps)) (not (eq (boxer-file-box fps) box))) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (if (member-boxer-file-box box fps) (make-vc '((bu::newer-other-box))) ;; the distinction between these is that in the 2nd case, the box has ;; never been saved to that filename (make-vc '((bu::newer-other-box))))) (t boxer-eval::*true*)))) (defvar *automatic-file-compression-on* nil) (defvar *file-compress-minimum-length* (* 64 1024)) ;empirical ;; this is used to catch pathnames which won't even parse (defun quote-wild-char (string quote-char) (let* ((slength (length string)) (return-string (make-array (1+ slength) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i slength) (let ((char (char string i))) (when (char= char #\*) (vector-push-extend quote-char return-string)) (vector-push-extend char return-string))) return-string)) (defun check-valid-filename-for-primitive (filename &optional defaults allow-wild) (declare (ignore allow-wild)) (cond ((pathnamep filename) ;; If it is already a pathname leave it alone (this can happen if ;; the pathname has been returned from boxer-open-file-dialog) filename) (t (ignore-errors (if (null defaults) (pathname filename) (merge-pathnames filename defaults)))))) ;; tries to be smart about file type (defun save-generic (box filename &key format read-only? always-save?) (let* ((dest-pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*)) (fps (get-boxer-file-properties dest-pathname)) (file-format (or format (getprop box :preferred-file-format) :boxer))) ;; first perform various kinds of reality checking ;; ;; we can only save out top level boxes for now, I suppose it ;; it would be possible to run the printer to generate real structure ;; then save THAT out but it seems to be too much work for a very ;; LIMITED set of circumstances (unless (box? box) (boxer-eval::primitive-signal-error :file-error "Sorry, you can only save out top level boxes")) ;; then make sure the directory exists #-mcl ;; MACL probe-file loses on directories (unless (probe-file (make-pathname :directory (pathname-directory dest-pathname))) (boxer-eval::primitive-signal-error :file-error "The directory, " (namestring dest-pathname) ", does not exist")) ;; on the mac, you can "lock" files... #+mcl (when (and (probe-file dest-pathname) (ccl::file-locked-p dest-pathname)) (boxer-eval::primitive-signal-error :file-error "The file, " (namestring dest-pathname) ", is locked")) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname (when (and (null always-save?) (not (null fps))) (cond ((and (not (null (file-write-date dest-pathname))) (not (= (boxer-file-creation-date fps) (file-write-date dest-pathname))) (not (file-overwrite-ok (format nil "~A, has been changed since last ~A. Save Anyway ?" (namestring dest-pathname) #+mcl "Open" #-mcl "READ")))) (throw 'cancel-boxer-file-dialog nil) ;; if we are going to query, then don't error out #| (boxer-eval::primitive-signal-error :file-overwrite-warning (make-box `(("The File:") (,(namestring dest-pathname)) ("has been changed since you last Read it") () ("Use REALLY-SAVE to save out changes"))))|# ) ((not (eq (boxer-file-box fps) box)) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (unless (if (member-boxer-file-box box fps) (file-overwrite-ok "Another version of this box exists and has been saved more recently. Save anyway?") (file-overwrite-ok (format nil "The file, ~A, is associated with a different box. Save Anyway ?" (namestring dest-pathname)))) ;; dont error out if we bother to ask... (throw 'cancel-boxer-file-dialog nil) #| (boxer-eval::primitive-signal-error :file-overwrite-warning "The filename, " (namestring dest-pathname) ", is associated with a different box")|# )))) (setf (read-only-box? box) read-only?) ;; this should be changed to be more data driven like the file readers ;; need to make the appropriate file type save functions more uniform 1st (case file-format (:boxer (save-internal box dest-pathname)) (:text (save-text-file-internal box dest-pathname)) (t (save-internal box dest-pathname))) ;; dump some useful properties into the resource fork ;; (before) we record current file props since changing the resource fork ;; might also change the file write date #+mcl (write-boxer-file-info box dest-pathname) ;; if everything worked, then update the file properties so we don't ;; get an error the next time we try and save out the file (record-boxer-file-properties dest-pathname (file-write-date dest-pathname) (file-author dest-pathname) box) (mark-box-as-file box dest-pathname) ;; mark the box as unmodified (mark-file-box-clean box))) ;; got to be careful, the pathname might have "~"'s (especially from backup files) ;; also, try to keep the length limited to avoid odd window resizing bug in LWW (defun status-line-save-format-string (dest-pathname) (let* ((*max-file-pathname-length* 50) ; should be adaptive to width of name-pane (pretty-path (pretty-file-box-name dest-pathname))) (format nil "Saving ~A ~~D" (cond ((find #\~ pretty-path) (quote-tilde pretty-path)) (t pretty-path))))) (defun quote-tilde (string) (let* ((lstring (length string)) (newstring (make-array (+& 1 lstring) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i lstring) (let ((char (char string i))) (cond ((char= char #\~) (vector-push-extend #\~ newstring) (vector-push-extend #\~ newstring)) (t (vector-push-extend char newstring))))) newstring)) (defun save-internal (box dest-pathname) (let* ((tmp-file-string (symbol-name (gensym))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) (unwind-protect (let ((*status-line-saving-format-string* (status-line-save-format-string dest-pathname))) ;; feedback (status-line-display 'saving-box (format nil "Saving ~A..." dest-pathname)) ;; actually dump the box (dump-top-level-box box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname)) (status-line-undisplay 'saving-box) (boxer-editor-message "~A box saved to ~A" (name-string box)(namestring dest-pathname)) ;; make sure the tmp-dest is gone (unless (null (probe-file tmp-dest)) (delete-file tmp-dest))) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) (when *automatic-file-compression-on* ;; Compress the file only if it's greater than ;; *file-compress-minimum-length*. Otherwise the time ;; it takes won't be worth it. (let ((length (with-open-file (stream dest-pathname :direction :input) (file-length stream)))) (if (> length *file-compress-minimum-length*) (compress-file dest-pathname)))))) (defun make-backup-if-necessary (dest-pathname) (when (probe-file dest-pathname) ;; looks like there already is a file with that name (rename-file dest-pathname ;; on windows systems, we have to preserve the pathname type #+win32 (merge-pathnames (concatenate 'string (pathname-name dest-pathname) *file-backup-suffix*) dest-pathname) #+mcl (let ((old-name (file-namestring dest-pathname))) ;; have to check for possible 31 char length (cond ((>= (length old-name) 31) (merge-pathnames (concatenate 'string (subseq old-name 0 30) *file-backup-suffix*) dest-pathname)) (t (concatenate 'string (namestring dest-pathname) *file-backup-suffix*)))) #-(or mcl win32) (concatenate 'string (namestring dest-pathname) *file-backup-suffix*) #+mcl :if-exists #+mcl :supersede))) ;; used to be READ (boxer-eval::defboxer-primitive bu::open ((boxer-eval::dont-copy file)) (let* ((filename (box-text-string file)) (box (read-internal filename))) ;; if the box was a world file, need to fix the NAME slot (multiple-value-bind (ro? world-box?) #+mcl (unless (url-string? filename) (boxer-file-info filename)) ;; looks in resource fork #-mcl (values nil nil) (declare (ignore ro?)) (when (or world-box? (and (stringp (slot-value box 'name)) (string= (slot-value box 'name) "WORLD"))) (setf (slot-value box 'name) nil))) box)) (boxer-eval::defboxer-primitive bu::READ ((boxer-eval::dont-copy filename)) filename (boxer-eval::primitive-signal-error :file "READ is an obsolete function, use OPEN instead")) #| (boxer-eval::defboxer-primitive bu::read-only ((boxer-eval::dont-copy filename)) (boxnet::read-only-internal (box-text-string filename))) |# ;; this can handle url strings as well as filenames... (defun read-internal (name) (if (url-string? name) (read-internal-url name) ;; can still be a bad filename here (bad URL spelling) (e.g. "htTtp://foo.bar") (let* ((pathname (check-valid-filename-for-primitive name *boxer-pathname-default*)) ;; note, we resolve the full pathname here instead of letting ;; read-internal-1 do the work so that we can have a complete ;; pathname available for the bookeeping operations which follow ;; a successful read-internal-1 (box (unless (null pathname) (read-internal-1 name pathname)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (cond ((box? box) ;(boxnet::read-box-postamble box) ;(Boxer Server stuff) no longer used (mark-box-as-file box pathname) (mark-file-box-clean box) ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box) (t (boxer-eval::primitive-signal-error :file-error "Unable to READ " name)))))) ;; Note: read-internal-1 does NOT do the bookeeping ops because some of ;; the bookkeeping operations rely on the EQness of the box and there ;; are some functions (like fill-box-from-server) which USE the result of ;; read-internal-1 to initialize another box in the editor. It is that ;; other box in the editor that the bookeeping operations need to keep ;; track of and it is in those higher up functions where the bookeeping must occur (defun read-internal-1 (filename &optional (pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (if *in-autoload-environment* (error "Autoload File not found: ~A" (namestring pathname)) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname)))) (prog1 (let* ((ftype (file-type pathname)) ;; dispatch to special readers when appropriate ;; ALL special reader take a filename arg and return a box ;; ALL implementations should handle :boxer and :text types (box (let ((special-file-reader-function (get-special-file-reader ftype))) (cond ((null special-file-reader-function) (cond ((not (null *error-on-unknown-file-type*)) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) ((not (status-line-y-or-n-p (format nil "Unknown file type, ~A, load as Text ?" ftype))) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) (t (read-text-file-internal pathname)))) (t (funcall special-file-reader-function pathname)))))) box) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)))))) (boxer-eval::defboxer-primitive bu::probe-file ((boxer-eval::dont-copy filename)) (let ((pathname (check-valid-filename-for-primitive (box-text-string filename) *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (boxer-eval::boxer-boolean (probe-file pathname)))) (boxer-eval::defboxer-primitive bu::toggle-modified-flag () (when (box? boxer-eval::*lexical-variables-root*) (cond ((file-box-dirty? boxer-eval::*lexical-variables-root*) (mark-file-box-clean boxer-eval::*lexical-variables-root*)) (t (mark-file-box-dirty boxer-eval::*lexical-variables-root*))) (modified boxer-eval::*lexical-variables-root*) boxer-eval::*novalue*)) ;;; DIRECTORY (boxer-eval::defboxer-primitive bu::directory ((boxer-eval::dont-copy file-pattern)) (make-vc (or (mapcar #'(lambda (p) (make-evrow-from-entry (intern-in-bu-package (namestring p)))) (directory-internal (box-text-string file-pattern))) (list (make-empty-evrow))))) (defvar *default-directory-type* "box") (defun directory-internal (pattern-string) (let* ((pattern-pathname (check-valid-filename-for-primitive pattern-string (make-pathname :name :wild :type #-sun :unspecific #+sun *default-directory-type* :defaults *boxer-pathname-default*) t)) (directory-name (make-pathname :directory (pathname-directory pattern-pathname) ;; mac seems to need this, bare directory pathnames ;; return NIL #+mcl :name #+mcl ':wild))) (file-pattern-match? (make-pathname :name (pathname-name pattern-pathname) :type (pathname-type pattern-pathname)) (directory directory-name)))) ;; returns a list of pattern specs for file-pattern-match? ;; expects the pattern string to already have the directory ;; components stripped off ;; a pattern-spec is a CONS composed of a keyword type as the CAR ;; and a string as the CDR (defun parse-pathname-pattern (pp) (values (parse-pattern-component (pathname-name pp)) (parse-pattern-component (pathname-type pp)))) (defun parse-pattern-component (pattern) (let ((return-specs nil) (max-wild-place (when (stringp pattern) (1-& (length pattern))))) (cond ((or (eq pattern :wild) (eq pattern :unspecific) (= max-wild-place -1)) (push (cons :wild "") return-specs)) ((stringp pattern) (let ((wild-place 0)) (loop (let ((new-wild-place (position #\* pattern :start wild-place))) (cond ((and (null new-wild-place) (zerop wild-place)) ;; this means no wild cards (push (cons :whole pattern) return-specs) (return)) ((null new-wild-place) ;; no more wild cards, but some have ;; already been processed (push (cons :end (subseq pattern wild-place)) return-specs) (return)) ;; at this point we know we have found a wild card ;; somewhere in the pattern ((and (zerop wild-place) (zerop new-wild-place)) ;; the wild card has been found at the beginning (setq wild-place 1)) ((zerop wild-place) ;; just starting but wild card has been found (push (cons :begin (subseq pattern 0 new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) ((= wild-place new-wild-place) ;; this can happen if someone type "**" in the pattern (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) (t (push (cons :inside (subseq pattern wild-place new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place))))))))) (t (error "Pattern spec, ~A, is not a string or :WILD" pattern))) (nreverse return-specs))) ;; returns the subset of file-list which matches the pattern-string (defun file-pattern-match? (pattern file-list) (let ((return-list nil)) (multiple-value-bind (name-specs type-specs) (parse-pathname-pattern pattern) (dolist (file file-list) (when (and (component-pattern-match? name-specs (pathname-name file)) (component-pattern-match? type-specs (pathname-type file))) (push file return-list))) (nreverse return-list)))) (defun component-pattern-match? (pattern-specs comp) (let ((start 0) (pattern-match? t)) (dolist (spec pattern-specs) (case (car spec) (:wild (return)) (:whole (unless (string= comp (cdr spec)) (setq pattern-match? nil)) (return)) (:begin (let ((place (search (cdr spec) comp))) (cond ((and place (zerop& place)) (setq start (length (cdr spec)))) (t (setq pattern-match? nil) (return))))) (:end (let ((place (search (cdr spec) comp :from-end t :start2 start))) (unless (and place (=& place (-& (length comp) (length (cdr spec))))) (setq pattern-match? nil) (return)))) (:inside (let ((place (search (cdr spec) comp :start2 start))) (cond ((null place) (setq pattern-match? nil) (return)) (t (setq start (+ (length (cdr spec)) start)))))))) ;; if the pattern-match? flag is still true after all of ;; the pattern-specs have run, push the file onto the return list pattern-match?)) (boxer-eval::defboxer-primitive bu::delete-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (check-valid-filename-for-primitive filestring *boxer-pathname-default*))) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (delete-file pathname) boxer-eval::*novalue*)) ;;;; TEXT File Operations ;;; connect with the outside world. These may turn out to be useful ;;; for a longer period of time than the actual boxer file operations ;;; ;;; These should eventually be rewritten to use a string buffer for ;;; read-line and write-line so they don't keep CONSing string ;;; (boxer-eval::defboxer-primitive bu::read-text-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring)))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (prog1 (read-text-file-internal pathname) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*))))))) ;;; a useful hack... (boxer-eval::defboxer-primitive bu::read-text-box-shrink ((dont-copy filename)) (boxer-eval::vpdl-push filename) (let ((result (bu::read-text-file))) (shrink result) result)) ;; we are guaranteed that pathname is valid (defun read-text-file-internal (pathname) (with-open-file (s pathname :direction ':input) (let ((return-box (read-text-stream-internal s))) (putprop return-box :text :preferred-file-format) return-box))) (defun read-text-stream-internal (stream) (let ((first-line (read-line stream nil nil))) (if (null first-line) (make-box '(())) (let* ((return-box (make-box (list (make-row-from-string first-line)))) (prev-row (first-inferior-row return-box))) (do ((current-line (read-line stream nil nil) (read-line stream nil nil))) ((null current-line) return-box) (let ((new-row (make-row-from-string current-line))) (insert-row-after-row return-box new-row prev-row) (setq prev-row new-row))))))) ;;; ':error means blow out, nil means do nothing (insert "[]") ;;; perhaps one day we should have ':interpolate (defvar *box-encountered-during-text-file-operation* :interpolate) (boxer-eval::defboxer-primitive bu::write-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) box filename ;; silence bound but not used compiler warnings (boxer-eval::primitive-signal-error :obsolete-function "WRITE-TEXT-FILE is an obsolete function, use SAVE-TEXT-FILE instead")) (boxer-eval::defboxer-primitive bu::save-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) (process-editor-mutation-queue-within-eval) (save-text-file-internal (box-or-port-target box) (box-text-string filename))) (defun save-text-file-internal (box filestring) (let* ((tmp-file-string (symbol-name (gensym))) ;should do something better (dest-pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) ;; make sure we have an editor object (cond ((box? box)) ((virtual-copy? box) (setq box (make-editor-box-from-vc box))) (t (boxer-eval::primitive-signal-error :file-error "You can only save boxes"))) ;; actually dump the box (write-text-file-internal box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) boxer-eval::*novalue*)) (defun write-text-file-internal (box pathname) (with-open-file (fs pathname :direction ':output) (write-text-stream-internal box fs (namestring pathname)))) ;;; Warn Option should be at Boxer User level instead of Lisp level (defun write-text-stream-internal (box fs &optional pathname-string) (do-box-rows ((row box)) (multiple-value-bind (string box-p) (text-string row) (if (null box-p) (write-line string fs) (case *box-encountered-during-text-file-operation* (:interpolate (write-text-stream-for-boxy-row row fs)) (:warn (warn "Box encountered during text operation, writing \"[]\"") (write-line string fs)) (:error (boxer-eval::primitive-signal-error :box-encountered-while-writing-text-file pathname-string)) (t (write-line string fs))))))) (defun write-text-stream-for-boxy-row (row fs) (do-row-chas ((cha row)) (cond ((box? cha) (terpri fs) (write-char #\[ fs) (write-text-stream-internal cha fs) (write-char #\] fs) (terpri fs)) (t (write-char cha fs)))) (terpri fs)) ;;; all of this is being replaced by the box server ;;; leave here for possible inclusion in configurations ;;; where the server is not resident (boxer-eval::defboxer-primitive bu::com-enter-box () (com-enter-box)) ;; maybe we should put some sort of reality checking into this ? (boxer-eval::defboxer-primitive bu::set-current-directory ((boxer-eval::dont-copy directory)) (flet ((directory? (pathname) (and (probe-file pathname) (string-equal (directory-namestring pathname) (namestring pathname))))) (let* ((raw-pathname (check-valid-filename-for-primitive (box-text-string directory))) (dirs (pathname-directory raw-pathname)) (name (pathname-name raw-pathname)) (pathname (if (null name) raw-pathname (make-pathname :directory (append dirs (list name)))))) (if (directory? pathname) (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)) (boxer-eval::primitive-signal-error :not-a-directory (namestring pathname))))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::current-directory () (make-vc (list (make-evrow-from-entry (intern-in-bu-package (let ((string (namestring *boxer-pathname-default*))) (subseq string 0 (search (pathname-name *boxer-pathname-default*) string :from-end t)))))))) (boxer-eval::defboxer-primitive bu::default-directory () (boxer-eval::primitive-signal-error :obsolete-function "DEFAULT-DIRECTORY is an obsolete function, use CURRENT-DIRECTORY instead")) ;;; (defmethod file-box? ((box box)) (getf (slot-value box 'plist) :associated-file)) (defmethod mark-box-as-file ((box box) &optional filename) (setf (storage-chunk? box) t) (unless (null filename) (putprop box filename :associated-file)) ;; make sure other storage chunking properties are removed (when (getprop box :url) (removeprop box :url)) (when (null (getprop box :boxtop)) (putprop box :file :boxtop)) ;; clear the modified flag (set-border-style box (if (not (null (slot-value box 'exports))) :thick-dashed :thick))) (defmethod unmark-box-as-file ((box box)) (setf (storage-chunk? box) nil) (let ((filename (getprop box :associated-file))) ;; save away the filename in case we change our mine and ;; want to make it a file box again (unless (null filename) (putprop box filename :old-associated-file)) (removeprop box :associated-file) (when (eq (getprop box :boxtop) :file) (removeprop box :boxtop)) (set-border-style box (if (not (null (slot-value box 'exports))) :dashed nil)))) (defun current-file-box (&optional (where (if (box? boxer-eval::*lexical-variables-root*) boxer-eval::*lexical-variables-root* (point-box)) #|(outermost-box)|#)) (cond ((not (box? where)) nil) ((eq where *initial-box*) where) ((storage-chunk? where) where) (t (let ((sup (superior-box where))) (when (box? sup) (current-file-box sup)))))) (defvar *max-file-pathname-length* 20) (defun pretty-file-box-name (filename) (let* ((name (pathname-name filename)) (type (pathname-type filename)) (dirs (pathname-directory filename)) (rawhost (pathname-host filename)) (prettyhost (if (null rawhost) "" (format nil "~A:" rawhost))) (name-length (+ (length name) (if (typep type 'string) (length type) 0))) (ellipsis "") (included-dirs (with-collection (when (listp dirs) ; might be :unspecific (dolist (d (cdr dirs)) (incf name-length (length d)) (if (> name-length *max-file-pathname-length*) (progn (setq ellipsis #+mcl "...:" #-mcl ".../") (return)) (collect d))))))) (cond ((and (typep type 'string) (not (null included-dirs))) (format nil #+mcl "~A~{~A:~}~A~A.~A" #-mcl "~A~{~A/~}~A~A.~A" prettyhost included-dirs ellipsis name type)) ((typep type 'string) (format nil "~A.~A" name type)) ((not (null included-dirs)) (format nil #+mcl "~A {~{~A:~}~A}" #-mcl "~A {~{~A/~}~A}" name included-dirs ellipsis)) (t ; no type, no dirs (format nil "~A" name))))) ;; placeholder, should put in trimming to *max-file-pathname-length* (defun pretty-url-box-name (url) (slot-value url 'boxnet::Scheme-string)) (defun current-file-box-name (&optional (where (point-box) #|(outermost-box)|#)) (let ((cfb (current-file-box where))) (cond ((null cfb)) (t (let ((file (getprop cfb :associated-file))) (cond ((null file) "") (t (values (pretty-file-box-name file) file)))))))) (defvar *terse-file-status* t) (defvar *initial-file-status-string-length* 70) (defvar *file-status-string* (make-array *initial-file-status-string-length* :element-type 'character :fill-pointer 0)) (defun add-string-to-file-status (string) (let ((l (length string)) (max (-& (array-total-size *file-status-string*) 3))) ; room for "..." (dotimes (i l l) (if (=& (fill-pointer *file-status-string*) max) (dotimes (i 3 (return t)) (vector-push #\. *file-status-string*)) (vector-push (char string i) *file-status-string*))))) (defun clear-file-status-string () (setf (fill-pointer *file-status-string*) 0)) ; get box file props ;; returns (values origin-type file-format read-only?) (defun get-box-file-props (filebox) (let* ((file-format (getprop filebox :preferred-file-format)) (url (getprop filebox :url))) (values (if (not (null url)) (boxnet::file-status-line-string url) :disk) (or file-format ':box) (read-only-box? filebox) (file-modified? filebox)))) (defun current-file-status (box &optional vanilla?) (let ((filebox (current-file-box box))) (if (not (box? filebox)) "??????" (let* ((raw-name (slot-value filebox 'name)) (box-name (cond ((stringp raw-name) raw-name) ((null raw-name) "No Name") ((name-row? raw-name) (text-string raw-name)) (t "???"))) (url (getprop filebox :url)) (pathname (or (getprop filebox :associated-file) (when (and url (typep url 'boxnet::local-url)) (boxnet::local-url-pathname url))))) (multiple-value-bind (origin-type file-format read-only? fmodified?) (get-box-file-props filebox) #| ;; this is now handled (as it should be) in the menu-update #+mcl ;; dynamically adjust the file menu... (let ((save-item (find "Save" (slot-value *boxer-file-menu* 'ccl::item-list) :test #'(lambda (a b) (string-equal a (ccl::menu-item-title b))))) ;(save-box-as-item (find "Save Box As..." (slot-value *boxer-file-menu* ; 'ccl::item-list) ; :test #'(lambda (a b) ; (string-equal ; a (ccl::menu-item-title b))))) ) ;; grey out File menu items if they are redundant or not applicable ;; "Save" is not applicable if there is not an existing filename ;; or if the file box has not been modified... (if (or read-only? (null pathname) (not (file-modified? filebox))) (ccl::menu-item-disable save-item) (ccl::menu-item-enable save-item)) ;; "Save Box As..." is redundant with "Save As"if the ;; cursor is in the same box as the document box ; (if (eq filebox (point-box)) ; (ccl::menu-item-disable save-box-as-item) ; (ccl::menu-item-enable save-box-as-item)) ) |# ;; print into the *file-status-string* (clear-file-status-string) (catch 'status-string-end (flet ((add-string (string) (let ((result (add-string-to-file-status string))) (when (eq result t) (throw 'status-string-end nil))))) ;; first (maybe) indicate file modified status (when (and (not vanilla?) fmodified?) (add-string #+mcl "� " #-mcl "* ")) ;;; print +mcl the box name... (add-string "File Box: ") (add-string box-name) (add-string #+mcl " � " #-mcl " | ") ;; now add info about the where the box came from... (add-string "From: ") (unless (and (null pathname) (not (eq origin-type :network))) ;; leave the where field blank if we dont have a name... (let ((adjectives nil)) (when (and read-only? (not (eq origin-type :network))) (add-string (if *terse-file-status* "(RO) " "Read Only ")) (setq adjectives t)) (case origin-type (:network (if *terse-file-status* (add-string "(net) ") (add-string "Network ")) (setq adjectives t)) (:disk (when *terse-file-status* (add-string "(disk) ")))) (unless (eq file-format :box) (add-string (string-capitalize file-format)) (add-string " ") (setq adjectives t)) (when (and adjectives (not *terse-file-status*))(add-string "file ")) (cond ((not (null pathname)) (add-string (pathname-name pathname)) (let ((type (pathname-type pathname))) (unless (or (null type) (eq type :unspecific)) (add-string ".") (add-string type))) (add-string " ") (unless *terse-file-status* ;; skip directory if terse but print something... (let ((raw-dirs (pathname-directory pathname))) (add-string "{") (when (listp raw-dirs) ; could be :unspecific (dolist (dir (cdr raw-dirs)) (add-string dir) (add-string #+mcl ":" #-mcl "/"))) (add-string "}")))) ((eq origin-type :network) (add-string (boxnet::scheme-string url)))))))) *file-status-string*))))) (defvar *max-filename-length* 50) ;; pathnames derived from other platforms wont parse into directories correctly (defun truncated-filename (pathname) (unless (pathnamep pathname) (setq pathname (pathname pathname))) (let* ((dirs (pathname-directory pathname)) (name (pathname-name pathname)) (type (pathname-type pathname)) (lname (length name)) (ltype (length type)) (ellipsis? t) (endsize (cond ((and (null name) (or (null type) (eq type ':unspecific))) (setq ellipsis? nil) 0) ((or (null type) (eq type ':unspecific)) (+ 3 lname)) ((null name) (+ 3 ltype)) (t (+ 3 lname 1 ltype)))) (return-string (make-string *max-filename-length*)) (dirstop (max& 0 (- *max-filename-length* endsize))) (idx 0)) ;(declare (dynamic-extent return-string)) (flet ((add-char (&optional (char #+mcl #\: #-mcl #\/)) (when (= idx dirstop) (throw 'dir-exit nil)) (setf (char return-string idx) char) (incf idx)) (add-string (string &optional (throw? t)) (let ((end (length string))) (do ((i 0 (1+ i))) ((or (= i end) (= idx *max-filename-length*))) (when (and throw? (= idx dirstop)) (throw 'dir-exit nil)) (setf (char return-string idx) (char string i)) (incf idx)))) (add-ellipsis () (dotimes (i 3) (setf (char return-string idx) #\.) (incf idx)))) (when (eq (car dirs) :relative) (add-char)) (catch 'dir-exit (unless (zerop dirstop) (dolist (dir (cdr dirs) (setq ellipsis? nil)) (add-string dir) (add-char)))) (unless (null ellipsis?) (add-ellipsis)) (cond ((zerop dirstop) ;; this means the name.type is already longer than the alloted space (cond ((null type) (do ((nidx (+ (- lname *max-filename-length*) 3) (1+ nidx))) ((>= idx *max-filename-length*)) (setf (char return-string idx) (char name nidx)) (incf idx))) (t ;; truncated name (do ((nidx (+ (- lname *max-filename-length*) 3 1 ltype) (1+ nidx))) ((>= idx (- *max-filename-length* ltype 1))) (setf (char return-string idx) (char name nidx)) (incf idx)) (add-char #\.) ;; and now the type (do ((i 0 (1+ i))) ((or (= i ltype) (= idx *max-filename-length*))) (setf (char return-string idx) (char type i)) (incf idx))))) ((and (null name) (or (null type) (eq type ':unspecific)))) ((or (null type) (eq type ':unspecific)) (add-string name nil)) ((null name) (add-string type nil)) (t (add-string name nil) (add-char #\.) (add-string type nil)))) (if (< idx *max-filename-length*) (subseq return-string 0 idx) return-string))) ;; walk up (backwards up the list) the path looking for a match in the ;; superior dirs ;; NOTE: not quite right, we should modify the sup-pathname as well to prune lower level ;; directories which do not match (defun dmerge-dirs (path sup-path) (let ((merged-dirs nil) (sup-dirs (cdr (pathname-directory sup-path)))) (do* ((dirs (reverse (cdr (pathname-directory path))) (cdr dirs)) (dir (car dirs) (car dirs))) ((null dir) nil) (if (member dir sup-dirs :test #'string-equal) (return (append '(:relative) merged-dirs)) (push dir merged-dirs))))) ;; see if the file exists. ;; when not being strict check for ".box" or no "".box" (defun probe-search-file (pathname) (cond ((null *strict-box-paths*) (or (probe-file pathname) (probe-file (make-pathname :type (let ((current-type (pathname-type pathname))) (cond ((or (null current-type) (eq current-type :unspecific)) "box") ((string-equal current-type "box") :unspecific) (t current-type))) :defaults pathname)))) (t (probe-file pathname)))) ;; need to hack relative pathnames here... (defun fill-box-from-local-file (box) (catch 'cancel-boxer-file-dialog (let* ((raw-pathname (getprop box :associated-file)) (raw-dirs (and raw-pathname (pathname-directory raw-pathname))) (sup-box (superior-box box)) (sup-file-box (current-file-box sup-box)) (sup-pathname (getprop sup-file-box :associated-file)) (pathname (cond ((and (eq (car raw-dirs) :absolute) (probe-search-file raw-pathname))) ((and (or (eq (car raw-dirs) :relative) ;; if the relative path is just a name, ;; raw-dirs will be null (null raw-dirs)) (or *autoloading-namestring* sup-pathname) (let ((merged-pathname (merge-pathnames (make-pathname :directory raw-dirs :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) (or *autoloading-namestring* sup-pathname)))) (probe-search-file merged-pathname)))) ;; now try various simple guesses ((let ((merged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) sup-pathname)))) (and merged-pathname (probe-search-file merged-pathname)))) ((let ((autoload-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and autoload-pathname (probe-search-file autoload-pathname)))) ;; directory merging guesses... ((let ((dmerged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname sup-pathname) :name (pathname-name raw-pathname) :type (pathname-type raw-pathname)) sup-pathname)))) (and dmerged-pathname (probe-search-file dmerged-pathname)))) ((let ((admerged-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname *autoloading-namestring*) :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and admerged-pathname (probe-search-file admerged-pathname)))) ;; guesses are all wrong, so ask the user ((and *prompt-for-server-file-not-found* (not (null *autoloading-namestring*))) (boxer-open-lost-file-dialog :prompt "(While Autoloading) Can't find" :directory raw-pathname)) (*prompt-for-server-file-not-found* (boxer-open-lost-file-dialog :prompt "Can't find" :directory raw-pathname)) ;; nothing works, return the original pathname for error message (t raw-pathname))) ;; allow an out if cached pathname is not valid (filebox (read-internal-1 pathname)) (old-ds (display-style box))) (initialize-box-from-box box filebox) ;; the vanilla init will take the display style from the file box ;; if we are autoloading, we want to use the file's display style (unless (autoload-file? box) (case old-ds (:shrunk (shrink box)) (:supershrunk (boxer::supershrink box)))) ;; if the box is transparent, export it's bindings (unless (null (exports box)) ;; this is the relevant guts of boxer-eval::set-exports without the checks ;; and setting of the exports slots (which are already set from the file) ;; will break if we ever use a selective exporting mechanism which ;; doesn't look too probably at the moment (let ((superior-box (superior-box box))) (unless (null superior-box) (boxer-eval::propagate-all-exported-bindings box superior-box) (boxer-eval::export-inferior-properties box superior-box)))) ;; if there is a cached boxtop, remove it in favor of the one being ;; read in from the file (let ((cb (getprop box :cached-boxtop))) (unless (null cb) (when (graphics-sheet? cb) (let ((bm (graphics-sheet-bit-array cb))) (unless (null bm) (deallocate-bitmap bm)))) (removeprop box :cached-boxtop))) ;; this the old style boxtop caching.... (convert to new style) (let ((bp (getprop box :boxtop))) (cond ((graphics-sheet? bp) (putprop box :standard :boxtop)) ((null bp) ;; add :file boxtop here when converting from old style. THis ;; seems more economical than hairing up dump or load (putprop box :file :boxtop)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (when (box? box) ;(boxnet::read-box-postamble box) ;(part of the Boxer Server) no longer used (mark-box-as-file box pathname) (if (and (not (equal pathname raw-pathname)) ;; don't mark dirty if we just articulated a relative pathname ;; unless the directory path has actually changed (not (and (or (null (pathname-directory raw-pathname)) (eq (pathname-directory raw-pathname) :relative)) (subsetp (cdr (pathname-directory raw-pathname)) (cdr (pathname-directory pathname)))))) (mark-file-box-dirty box) (mark-file-box-clean box))) ;; record in place menu ? ; removed for UC "clean" implementation ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box))) ;;; In case redisplay breaks,. people can still do... (defun salvage-boxer-world (&optional (save-name "salvaged-world") (verbose t)) (let ((world-save-name (merge-pathnames save-name *boxer-pathname-default*))) ;; first make sure the name is ok (loop (when (yes-or-no-p "~%Save Your Boxer World in ~A ? " world-save-name) ;; we are happy with the name, then save it away ;; otherwise, prompt for a new name (format t "~%New File Name to Save in: ") (setq world-save-name (merge-pathnames (read-line) world-save-name)))) ;; then save it away verbosely (when verbose (format t "~%Dumping boxer world to ~A" world-save-name)) (dump-top-level-box *initial-box* world-save-name) ;; now verify (when verbose (format t "~%Verifying Saved file")) (load-binary-box-internal world-save-name) (format t "~%Boxer World Saved to ~A" world-save-name) (values))) ;;; spread it around (import 'salvage-boxer-world (find-package 'user)) (import 'salvage-boxer-world (find-package :boxer-window)) (import 'salvage-boxer-world (find-package :boxer-eval)) ;; might as well be paranoid... (import 'salvage-boxer-world (find-package :boxer-user)) ;;; (boxer-eval::defboxer-primitive bu::storage-name ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-vc (list (make-evrow-from-string (namestring file))))) ((not (null url)) (make-vc (list (make-evrow-from-string (boxnet::urlstring url))))) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-vc (list (make-evrow-from-string (namestring path)))))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (boxer-eval::defboxer-primitive bu::storage-info ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-file-storage-info-box file)) ((not (null url)) (make-url-storage-info-box url)) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-file-storage-info-box path))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (defun destructure-pathname (pathname) (values (pathname-host pathname) (pathname-device pathname) (pathname-directory pathname) (pathname-name pathname) (pathname-type pathname))) ;; consider making empty boxes for null fields instead of omitting entirely ;; 2/1/03 We should have empty boxes since people will be using TELL to ;; grab fields and we shoudl have something for the names to avoid errors (defun make-file-storage-info-box (pathname) (multiple-value-bind (host device directory name type) (destructure-pathname pathname) (make-file-storage-info-box-internal host device (car directory) (cdr directory) name type))) (defun make-file-storage-info-box-internal (host device dir-type dir name type) (make-vc (list (make-vc (unless (or (null host) (eq host :unspecific)) (list (make-evrow-from-string host))) 'data-box 'bu::Host) (make-vc (unless (or (null device) (eq device :unspecific)) (list (make-evrow-from-string device))) 'data-box 'bu::Device) (make-vc (list (make-evrow-from-string dir-type)) 'data-box 'bu::directory-type) (make-vc (mapcar #'(lambda (d) (make-evrow-from-string d)) dir) 'data-box 'bu::directory) (make-vc (unless (null name) (list (make-evrow-from-string name))) 'data-box 'bu::name) (make-vc (unless (or (null type) (eq type :unspecific)) (list (make-evrow-from-string type))) 'data-box 'bu::type)) 'data-box)) (defun make-url-storage-info-box (url) (make-vc (let ((url-info-sub-boxes nil)) (do* ((value-pairs (boxnet::url-values url) (cddr value-pairs)) (name (car value-pairs) (car value-pairs)) (value (cadr value-pairs) (cadr value-pairs))) ((null value-pairs)) (push (make-vc (list (make-evrow-from-string value)) 'data-box (intern-in-bu-package (string-upcase name))) url-info-sub-boxes)) (nreverse url-info-sub-boxes)))) ;; like destructure-pathname, returns (values host device directory name type) (defun destructure-file-info-box (file-info-box) (let* ((box (box-or-port-target file-info-box)) (host (lookup-variable-in-box-only box 'bu::host)) (device (lookup-variable-in-box-only box 'bu::device)) (dir-type (lookup-variable-in-box-only box 'bu::directory-type)) (dir (lookup-variable-in-box-only box 'bu::directory)) (name (lookup-variable-in-box-only box 'bu::name)) (type (lookup-variable-in-box-only box 'bu::type))) (values (if (empty-box? host) :unspecific (box-text-string host)) (if (empty-box? device) :unspecific (box-text-string device)) (cond ((string-equal (box-text-string dir-type) "RELATIVE") :relative) (t :absolute)) (with-collection (dolist (er (get-box-rows dir)) (collect (evrow-text-string er dir)))) (box-text-string name) (if (empty-box? type) :unspecific (box-text-string type))))) (boxer-eval::defboxer-primitive bu::file-info-to-file (file-info) (multiple-value-bind (host device dir-type dir name type) (destructure-file-info-box file-info) (make-vc (list (make-evrow-from-string (namestring (make-pathname :host host :device device :directory (list* dir-type dir) :name name :type type)))) 'data-box))) (boxer-eval::defboxer-primitive bu::file-to-file-info (filename) (let ((pathname-string (box-text-string filename))) (make-file-storage-info-box pathname-string))) (boxer-eval::defboxer-primitive bu::merge-file-info (info1 info2) (multiple-value-bind (host1 dev1 dir-type1 dir1 name1 type1) (destructure-file-info-box info1) (multiple-value-bind (host2 dev2 dir-type2 dir2 name2 type2) (destructure-file-info-box info2) (make-file-storage-info-box-internal (if (or (null host1) (eq host1 :unspecific)) host2 host1) (if (or (null dev1) (eq dev1 :unspecific)) dev2 dev1) (if (or (eq dir-type1 :absolute) (eq dir-type2 :absolute)) :absolute :relative) (cond ((eq dir-type1 :absolute) dir1) ((eq dir-type2 :absolute) (append dir2 dir1)) (t (append dir2 dir1))) (if (null name1) name2 name1) (if (or (null type1) (eq type1 :unspecific)) type2 type1))))) ;;; This is just a crock, but at least it will work on the Suns as long ;;; as there's only one Boxer per machine. (defun make-temporary-filename (info) (format nil "/tmp/boxer-~a" info)) (defun read-box-from-text-stream (stream) stream boxer-eval::*novalue*) ;;; ;;; COMPRESS-FILE. ;;; ;;; These are for saving space on unix filesystems. They should go away ;;; when Ed rewrites the file system make smaller files. ;;; The user can call COMPRESS-FILE. READ will try to uncompress a file ;;; if it doesn't exist. (defun compress-file (pathname) #+Unix (progn (make-backup-if-necessary (concatenate 'string (namestring pathname) ".Z")) (boxer-run-unix-program "compress" (list "-f" (namestring pathname)))) #-Unix (progn pathname nil)) (defun uncompress-file (pathname) #+Unix (boxer-run-unix-program "uncompress" (list (namestring pathname))) #-Unix (progn pathname nil)) (defun maybe-uncompress-file (pathname) #+Unix (when (and (null (probe-file pathname)) (probe-file (concatenate 'string (namestring pathname) ".Z"))) #+Lucid (uncompress-file pathname) #-Lucid nil) #-Unix (progn pathname nil)) #-mcl (boxer-eval::defboxer-primitive bu::compress-file ((boxer-eval::dont-copy name)) (let ((filename (if (numberp name) (format nil "~D" name) (box-text-string name)))) (if (null (probe-file filename)) (boxer-eval::signal-error :FILE-NOT-FOUND (boxer-eval::copy-thing name)) (let ((error-string (compress-file filename))) (if (null error-string) boxer-eval::*novalue* (boxer-eval::signal-error :COMPRESS-FILE error-string)))))) ;;; ;;; boxer-run-unix-program ;;; ;;; Returns NIL if succesful, otherwise a list of error strings. ;;; ;;; We have to run the program asynchronously in order to get the ;;; error output into a stream. ;;; Didn't do anything about stdout, though. (defun boxer-run-unix-program (program-name arguments) #+Unix (let ((error-result #+Lucid (multiple-value-bind (stream error-output-stream exit-status process-id) ;; We can't do both :error-output :stream ;; and :wait t, so we have to assume that the process ;; is finished when when we find out that the error-output-stream ;; is done. (system::run-program program-name :arguments arguments :wait nil :if-error-output-exists nil :error-output :stream) (declare (ignore stream process-id)) (if error-output-stream (prog1 (do* ((string (read-line error-output-stream nil nil) (read-line error-output-stream nil nil)) (result nil)) ((null string) (nreverse result)) (unless (null string) (push string result))) (close error-output-stream)) (format nil "Unknown Unix Error ~D" exit-status))) #-Lucid "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (if (stringp error-result) (boxer-eval::primitive-signal-error :UNIX-PROGRAM-ERROR error-result) nil)) #-Unix (progn program-name arguments "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (defun fix-file-alus (top-box &optional (sun->mac? t)) (labels ((fix-gl (gl) (setf (graphics-command-list-alu gl) (convert-file-alu (graphics-command-list-alu gl) sun->mac?)) (do-vector-contents (gc gl) (when (member (aref gc 0) '(0 32) :test #'=) ;; if it is an CHANGE-ALU command.... (setf (aref gc 1) (convert-file-alu (aref gc 1) sun->mac?))))) (fix-box (box) (let ((graphics-sheet (graphics-sheet box))) (when (not (null graphics-sheet)) (let ((gl (graphics-sheet-graphics-list graphics-sheet))) (unless (null gl) (fix-gl gl))))) (when (sprite-box? box) (let* ((turtle (slot-value box 'associated-turtle)) (shape (shape turtle)) (ws (slot-value turtle 'window-shape))) (fix-gl shape) (fix-gl ws))))) (fix-box top-box) (do-for-all-inferior-boxes-fast (inf-box top-box) (fix-box inf-box)))) ;; order is (sun-alu . mac-alu) (defvar *file-conversion-alu-alist* '((2 . 3) ; alu-andca (5 . 0) ; alu-seta (6 . 2) ; alu-xor (7 . 1) ; alu-ior (0 . 11))) ; alu-setz (defun convert-file-alu (old-alu sun->mac?) (if sun->mac? (or (cdr (assoc old-alu *file-conversion-alu-alist* :test #'=)) 0) (or (car (rassoc old-alu *file-conversion-alu-alist* :test #'=)) 5))) (boxer-eval::defboxer-primitive bu::fix-sun-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box)) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::fix-mac-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box) nil) boxer-eval::*novalue*)
57254
;; -*- Mode:LISP; Syntax:Common-Lisp; Package:BOXER; -*- #| $Header: file-prims.lisp,v 1.0 90/01/24 22:11:51 boxer Exp $ $Log: file-prims.lisp,v $ ;;;Revision 1.0 90/01/24 22:11:51 boxer ;;;Initial revision ;;; Boxer Copyright 1985-2020 <NAME> and the Estate of <NAME> Portions of this code may be copyright 1982-1985 Massachusetts Institute of Technology. Those portions may be used for any purpose, including commercial ones, providing that notice of MIT copyright is retained. Licensed under the 3-Clause BSD license. You may not use this file except in compliance with this license. https://opensource.org/licenses/BSD-3-Clause +-Data--+ This file is part of the | BOXER | system +-------+ This file contains all of the boxer functions which use the file system. Modification History (most recent at top) 12/15/11 write-text-stream-internal changed to handle the :interpolate option *box-encountered-during-text-file-operation* changed to :interpolate new function write-text-stream-for-boxy-row 12/22/05 wrap ignore-errors around parts of check-valid-filename-for-primitive to cleanly handle illegal pathnames (e.g. from mistyped URL protocol fields) READ-INTERNAL checks for possible null pathname to catch this case 8/23/05 fill-box-from-local-file uses new probe-search-file to check for boxer files 8/06/05 fixed truncated-filename to handle names longer than *max-filename-length* also boosted *max-filename-length* to 50 10/06/04 extended storage-{name,info} to handle xrefs 8/27/04 copyright error message in mark-for-saving referred to wrong replacement name 7/16/04 Fixed Copyright Error message in MARk-FOR-SAVING 8/15/03 added show-file-info as diagnostic tool, set-boxer-file-info 4/19/03 merged current LW and MCL files 2/03/03 destructure-file-info-box, file-info-to-file, file-to-file-info & merge-file-info 2/01/03 changed make-file-storage-info-box to make empty boxes for fields which are either null or :unspecific 10/20/02 RECORD-FILE-BOX-PLACE & RECORD-URL-BOX-PLACE stubbified and removed from READ-INTERNAL & FILL-BOX-FROM-LOCAL-FILE in preparation for "UC clean" reimplementation 9/02/02 UC free version of MARK-FOR-SAVING, added TOGGLE-MODIFIED-FLAG 8/27/02 make-file-storage-info-box, VC names must be BU symbols instead of strings make-url-storage-info-box does the same via intern-in-bu-package 8/ 8/02 finished support functions for bu::storage-xxx 8/ 5/02 added bu::storage-name and bu::storage-info 10/ 7/01 status-line-save-format-string for use in save-internal 3/ 8/01 fill-box-from-local-file: relative pathname check should check for null dirs as well as :relative 2/14/01 merged current LW and MCL files 1/15/01 lispworks version for check-valid-filename-for-primitive 10/16/00 make-backup-if-necessary now checks for 31 char pathnames 10/10/00 make-backup-if-necessary for windows will keep the pathname type 11/14/99 removed file-namestring from fill-box-from-local-file because it loses when merging a typeless pathname. Replace by make-pathname with the type component defaulting to :unspecific for null pathname-type 10/15/99 simplified fill-box-from-local-file by using file-namestring 10/14/99 save-text-file processes the modified editor object queue save-text-file-internal now renders VC's into editor boxes 9/13/99 fill-box-from-local-file, don't mark the file box dirty for relative pathname fileboxes, unless the relative part is actually changed 6/25/99 extracted pretty-file-box-name for use in other places added pretty-url-box-name (temp version), record-file-box-place, and record-url-box-place use record-file-box-place in read-internal,fill-box-from-local-file 5/25/99 changed mark-box-as-file to not be so eager to convert to :file boxtop 5/17/99 check for filename before saving old-file-prop in unmark-box-as-file 5/12/99 added eval::*novalue* return value to mark-for-saving 4/25/99 {un}mark-box-as-file now adds/removes :file :boxtop property 4/14/99 use new calling conventions for write-boxer-file-info 3/26/99 bu::mark-for-saving added 2/12/99 save-generic error messages use OPEN as the name of the prim instead of READ 2/11/99 (defboxer-primitive bu::unfile-box 2/10/99 added unmark-box-as-file 12/15/98 changed various save functions to process the mutation queue before saving 10/ 1/98 fill-box-from-local-file probes for file in relative pathname clause also separate prompts for choose file dialog when file not found 9/29/98 save-generic sets read-only? flag both ways instead of only to T 9/13/98 OPEN changed to bash name slot of world boxes 5/27/98 added autoloading case to fill-box-from-local-file for relative paths changed read-internal-1 to give lisp error (which should be handled) for missing autoload 5/27/98 Started Logging Changes: source = boxer version 2.3alphaR1 |# (in-package :boxer) ;;;; the prims (boxer-eval::defboxer-primitive bu::save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::quietly-save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document nil T)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::save-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox (current-file-box))) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-save-document))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::save-box-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox boxer-eval::*lexical-variables-root*)) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-box-save-as nil boxer-eval::*lexical-variables-root*))) boxer-eval::*novalue*) ;; use TELL to direct (boxer-eval::defboxer-primitive bu::unfile-box () (com-unfile-document)) ;; Returns TRUE, or a box with a defined reason or else FALSE, ;; meaning "some other reason" (boxer-eval::defboxer-primitive bu::safe-to-save? () (let* ((box (current-file-box)) (raw-filename (getprop box :associated-file)) ;; careful, the filename might be relative (existing-filename (cond ((null raw-filename) nil) ((eq (car (pathname-directory raw-filename)) :absolute) raw-filename) (t ; must be relative (let* ((sup-file-box (current-file-box (superior-box box))) (sup-filename (getprop sup-file-box :associated-file))) (cond ((not (null sup-filename)) (merge-pathnames raw-filename sup-filename))))))) (fps (get-boxer-file-properties existing-filename))) (cond ((null existing-filename) (make-vc '((bu::no-filename)))) #-mcl ;; MACL probe-file loses on directories ((null (probe-file (make-pathname :directory (pathname-directory existing-filename)))) (make-vc '((bu::no-directory)))) #+mcl ;; on the mac, you can "lock" files... ((and (probe-file existing-filename) (ccl::file-locked-p existing-filename)) (make-vc '((bu::file-locked)))) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname ((and (not (null fps)) (not (null (file-write-date existing-filename))) (not (= (boxer-file-creation-date fps) (file-write-date existing-filename)))) (make-vc '((bu::file-is-newer)))) ((and (not (null fps)) (not (eq (boxer-file-box fps) box))) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (if (member-boxer-file-box box fps) (make-vc '((bu::newer-other-box))) ;; the distinction between these is that in the 2nd case, the box has ;; never been saved to that filename (make-vc '((bu::newer-other-box))))) (t boxer-eval::*true*)))) (defvar *automatic-file-compression-on* nil) (defvar *file-compress-minimum-length* (* 64 1024)) ;empirical ;; this is used to catch pathnames which won't even parse (defun quote-wild-char (string quote-char) (let* ((slength (length string)) (return-string (make-array (1+ slength) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i slength) (let ((char (char string i))) (when (char= char #\*) (vector-push-extend quote-char return-string)) (vector-push-extend char return-string))) return-string)) (defun check-valid-filename-for-primitive (filename &optional defaults allow-wild) (declare (ignore allow-wild)) (cond ((pathnamep filename) ;; If it is already a pathname leave it alone (this can happen if ;; the pathname has been returned from boxer-open-file-dialog) filename) (t (ignore-errors (if (null defaults) (pathname filename) (merge-pathnames filename defaults)))))) ;; tries to be smart about file type (defun save-generic (box filename &key format read-only? always-save?) (let* ((dest-pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*)) (fps (get-boxer-file-properties dest-pathname)) (file-format (or format (getprop box :preferred-file-format) :boxer))) ;; first perform various kinds of reality checking ;; ;; we can only save out top level boxes for now, I suppose it ;; it would be possible to run the printer to generate real structure ;; then save THAT out but it seems to be too much work for a very ;; LIMITED set of circumstances (unless (box? box) (boxer-eval::primitive-signal-error :file-error "Sorry, you can only save out top level boxes")) ;; then make sure the directory exists #-mcl ;; MACL probe-file loses on directories (unless (probe-file (make-pathname :directory (pathname-directory dest-pathname))) (boxer-eval::primitive-signal-error :file-error "The directory, " (namestring dest-pathname) ", does not exist")) ;; on the mac, you can "lock" files... #+mcl (when (and (probe-file dest-pathname) (ccl::file-locked-p dest-pathname)) (boxer-eval::primitive-signal-error :file-error "The file, " (namestring dest-pathname) ", is locked")) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname (when (and (null always-save?) (not (null fps))) (cond ((and (not (null (file-write-date dest-pathname))) (not (= (boxer-file-creation-date fps) (file-write-date dest-pathname))) (not (file-overwrite-ok (format nil "~A, has been changed since last ~A. Save Anyway ?" (namestring dest-pathname) #+mcl "Open" #-mcl "READ")))) (throw 'cancel-boxer-file-dialog nil) ;; if we are going to query, then don't error out #| (boxer-eval::primitive-signal-error :file-overwrite-warning (make-box `(("The File:") (,(namestring dest-pathname)) ("has been changed since you last Read it") () ("Use REALLY-SAVE to save out changes"))))|# ) ((not (eq (boxer-file-box fps) box)) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (unless (if (member-boxer-file-box box fps) (file-overwrite-ok "Another version of this box exists and has been saved more recently. Save anyway?") (file-overwrite-ok (format nil "The file, ~A, is associated with a different box. Save Anyway ?" (namestring dest-pathname)))) ;; dont error out if we bother to ask... (throw 'cancel-boxer-file-dialog nil) #| (boxer-eval::primitive-signal-error :file-overwrite-warning "The filename, " (namestring dest-pathname) ", is associated with a different box")|# )))) (setf (read-only-box? box) read-only?) ;; this should be changed to be more data driven like the file readers ;; need to make the appropriate file type save functions more uniform 1st (case file-format (:boxer (save-internal box dest-pathname)) (:text (save-text-file-internal box dest-pathname)) (t (save-internal box dest-pathname))) ;; dump some useful properties into the resource fork ;; (before) we record current file props since changing the resource fork ;; might also change the file write date #+mcl (write-boxer-file-info box dest-pathname) ;; if everything worked, then update the file properties so we don't ;; get an error the next time we try and save out the file (record-boxer-file-properties dest-pathname (file-write-date dest-pathname) (file-author dest-pathname) box) (mark-box-as-file box dest-pathname) ;; mark the box as unmodified (mark-file-box-clean box))) ;; got to be careful, the pathname might have "~"'s (especially from backup files) ;; also, try to keep the length limited to avoid odd window resizing bug in LWW (defun status-line-save-format-string (dest-pathname) (let* ((*max-file-pathname-length* 50) ; should be adaptive to width of name-pane (pretty-path (pretty-file-box-name dest-pathname))) (format nil "Saving ~A ~~D" (cond ((find #\~ pretty-path) (quote-tilde pretty-path)) (t pretty-path))))) (defun quote-tilde (string) (let* ((lstring (length string)) (newstring (make-array (+& 1 lstring) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i lstring) (let ((char (char string i))) (cond ((char= char #\~) (vector-push-extend #\~ newstring) (vector-push-extend #\~ newstring)) (t (vector-push-extend char newstring))))) newstring)) (defun save-internal (box dest-pathname) (let* ((tmp-file-string (symbol-name (gensym))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) (unwind-protect (let ((*status-line-saving-format-string* (status-line-save-format-string dest-pathname))) ;; feedback (status-line-display 'saving-box (format nil "Saving ~A..." dest-pathname)) ;; actually dump the box (dump-top-level-box box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname)) (status-line-undisplay 'saving-box) (boxer-editor-message "~A box saved to ~A" (name-string box)(namestring dest-pathname)) ;; make sure the tmp-dest is gone (unless (null (probe-file tmp-dest)) (delete-file tmp-dest))) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) (when *automatic-file-compression-on* ;; Compress the file only if it's greater than ;; *file-compress-minimum-length*. Otherwise the time ;; it takes won't be worth it. (let ((length (with-open-file (stream dest-pathname :direction :input) (file-length stream)))) (if (> length *file-compress-minimum-length*) (compress-file dest-pathname)))))) (defun make-backup-if-necessary (dest-pathname) (when (probe-file dest-pathname) ;; looks like there already is a file with that name (rename-file dest-pathname ;; on windows systems, we have to preserve the pathname type #+win32 (merge-pathnames (concatenate 'string (pathname-name dest-pathname) *file-backup-suffix*) dest-pathname) #+mcl (let ((old-name (file-namestring dest-pathname))) ;; have to check for possible 31 char length (cond ((>= (length old-name) 31) (merge-pathnames (concatenate 'string (subseq old-name 0 30) *file-backup-suffix*) dest-pathname)) (t (concatenate 'string (namestring dest-pathname) *file-backup-suffix*)))) #-(or mcl win32) (concatenate 'string (namestring dest-pathname) *file-backup-suffix*) #+mcl :if-exists #+mcl :supersede))) ;; used to be READ (boxer-eval::defboxer-primitive bu::open ((boxer-eval::dont-copy file)) (let* ((filename (box-text-string file)) (box (read-internal filename))) ;; if the box was a world file, need to fix the NAME slot (multiple-value-bind (ro? world-box?) #+mcl (unless (url-string? filename) (boxer-file-info filename)) ;; looks in resource fork #-mcl (values nil nil) (declare (ignore ro?)) (when (or world-box? (and (stringp (slot-value box 'name)) (string= (slot-value box 'name) "WORLD"))) (setf (slot-value box 'name) nil))) box)) (boxer-eval::defboxer-primitive bu::READ ((boxer-eval::dont-copy filename)) filename (boxer-eval::primitive-signal-error :file "READ is an obsolete function, use OPEN instead")) #| (boxer-eval::defboxer-primitive bu::read-only ((boxer-eval::dont-copy filename)) (boxnet::read-only-internal (box-text-string filename))) |# ;; this can handle url strings as well as filenames... (defun read-internal (name) (if (url-string? name) (read-internal-url name) ;; can still be a bad filename here (bad URL spelling) (e.g. "htTtp://foo.bar") (let* ((pathname (check-valid-filename-for-primitive name *boxer-pathname-default*)) ;; note, we resolve the full pathname here instead of letting ;; read-internal-1 do the work so that we can have a complete ;; pathname available for the bookeeping operations which follow ;; a successful read-internal-1 (box (unless (null pathname) (read-internal-1 name pathname)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (cond ((box? box) ;(boxnet::read-box-postamble box) ;(Boxer Server stuff) no longer used (mark-box-as-file box pathname) (mark-file-box-clean box) ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box) (t (boxer-eval::primitive-signal-error :file-error "Unable to READ " name)))))) ;; Note: read-internal-1 does NOT do the bookeeping ops because some of ;; the bookkeeping operations rely on the EQness of the box and there ;; are some functions (like fill-box-from-server) which USE the result of ;; read-internal-1 to initialize another box in the editor. It is that ;; other box in the editor that the bookeeping operations need to keep ;; track of and it is in those higher up functions where the bookeeping must occur (defun read-internal-1 (filename &optional (pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (if *in-autoload-environment* (error "Autoload File not found: ~A" (namestring pathname)) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname)))) (prog1 (let* ((ftype (file-type pathname)) ;; dispatch to special readers when appropriate ;; ALL special reader take a filename arg and return a box ;; ALL implementations should handle :boxer and :text types (box (let ((special-file-reader-function (get-special-file-reader ftype))) (cond ((null special-file-reader-function) (cond ((not (null *error-on-unknown-file-type*)) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) ((not (status-line-y-or-n-p (format nil "Unknown file type, ~A, load as Text ?" ftype))) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) (t (read-text-file-internal pathname)))) (t (funcall special-file-reader-function pathname)))))) box) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)))))) (boxer-eval::defboxer-primitive bu::probe-file ((boxer-eval::dont-copy filename)) (let ((pathname (check-valid-filename-for-primitive (box-text-string filename) *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (boxer-eval::boxer-boolean (probe-file pathname)))) (boxer-eval::defboxer-primitive bu::toggle-modified-flag () (when (box? boxer-eval::*lexical-variables-root*) (cond ((file-box-dirty? boxer-eval::*lexical-variables-root*) (mark-file-box-clean boxer-eval::*lexical-variables-root*)) (t (mark-file-box-dirty boxer-eval::*lexical-variables-root*))) (modified boxer-eval::*lexical-variables-root*) boxer-eval::*novalue*)) ;;; DIRECTORY (boxer-eval::defboxer-primitive bu::directory ((boxer-eval::dont-copy file-pattern)) (make-vc (or (mapcar #'(lambda (p) (make-evrow-from-entry (intern-in-bu-package (namestring p)))) (directory-internal (box-text-string file-pattern))) (list (make-empty-evrow))))) (defvar *default-directory-type* "box") (defun directory-internal (pattern-string) (let* ((pattern-pathname (check-valid-filename-for-primitive pattern-string (make-pathname :name :wild :type #-sun :unspecific #+sun *default-directory-type* :defaults *boxer-pathname-default*) t)) (directory-name (make-pathname :directory (pathname-directory pattern-pathname) ;; mac seems to need this, bare directory pathnames ;; return NIL #+mcl :name #+mcl ':wild))) (file-pattern-match? (make-pathname :name (pathname-name pattern-pathname) :type (pathname-type pattern-pathname)) (directory directory-name)))) ;; returns a list of pattern specs for file-pattern-match? ;; expects the pattern string to already have the directory ;; components stripped off ;; a pattern-spec is a CONS composed of a keyword type as the CAR ;; and a string as the CDR (defun parse-pathname-pattern (pp) (values (parse-pattern-component (pathname-name pp)) (parse-pattern-component (pathname-type pp)))) (defun parse-pattern-component (pattern) (let ((return-specs nil) (max-wild-place (when (stringp pattern) (1-& (length pattern))))) (cond ((or (eq pattern :wild) (eq pattern :unspecific) (= max-wild-place -1)) (push (cons :wild "") return-specs)) ((stringp pattern) (let ((wild-place 0)) (loop (let ((new-wild-place (position #\* pattern :start wild-place))) (cond ((and (null new-wild-place) (zerop wild-place)) ;; this means no wild cards (push (cons :whole pattern) return-specs) (return)) ((null new-wild-place) ;; no more wild cards, but some have ;; already been processed (push (cons :end (subseq pattern wild-place)) return-specs) (return)) ;; at this point we know we have found a wild card ;; somewhere in the pattern ((and (zerop wild-place) (zerop new-wild-place)) ;; the wild card has been found at the beginning (setq wild-place 1)) ((zerop wild-place) ;; just starting but wild card has been found (push (cons :begin (subseq pattern 0 new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) ((= wild-place new-wild-place) ;; this can happen if someone type "**" in the pattern (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) (t (push (cons :inside (subseq pattern wild-place new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place))))))))) (t (error "Pattern spec, ~A, is not a string or :WILD" pattern))) (nreverse return-specs))) ;; returns the subset of file-list which matches the pattern-string (defun file-pattern-match? (pattern file-list) (let ((return-list nil)) (multiple-value-bind (name-specs type-specs) (parse-pathname-pattern pattern) (dolist (file file-list) (when (and (component-pattern-match? name-specs (pathname-name file)) (component-pattern-match? type-specs (pathname-type file))) (push file return-list))) (nreverse return-list)))) (defun component-pattern-match? (pattern-specs comp) (let ((start 0) (pattern-match? t)) (dolist (spec pattern-specs) (case (car spec) (:wild (return)) (:whole (unless (string= comp (cdr spec)) (setq pattern-match? nil)) (return)) (:begin (let ((place (search (cdr spec) comp))) (cond ((and place (zerop& place)) (setq start (length (cdr spec)))) (t (setq pattern-match? nil) (return))))) (:end (let ((place (search (cdr spec) comp :from-end t :start2 start))) (unless (and place (=& place (-& (length comp) (length (cdr spec))))) (setq pattern-match? nil) (return)))) (:inside (let ((place (search (cdr spec) comp :start2 start))) (cond ((null place) (setq pattern-match? nil) (return)) (t (setq start (+ (length (cdr spec)) start)))))))) ;; if the pattern-match? flag is still true after all of ;; the pattern-specs have run, push the file onto the return list pattern-match?)) (boxer-eval::defboxer-primitive bu::delete-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (check-valid-filename-for-primitive filestring *boxer-pathname-default*))) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (delete-file pathname) boxer-eval::*novalue*)) ;;;; TEXT File Operations ;;; connect with the outside world. These may turn out to be useful ;;; for a longer period of time than the actual boxer file operations ;;; ;;; These should eventually be rewritten to use a string buffer for ;;; read-line and write-line so they don't keep CONSing string ;;; (boxer-eval::defboxer-primitive bu::read-text-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring)))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (prog1 (read-text-file-internal pathname) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*))))))) ;;; a useful hack... (boxer-eval::defboxer-primitive bu::read-text-box-shrink ((dont-copy filename)) (boxer-eval::vpdl-push filename) (let ((result (bu::read-text-file))) (shrink result) result)) ;; we are guaranteed that pathname is valid (defun read-text-file-internal (pathname) (with-open-file (s pathname :direction ':input) (let ((return-box (read-text-stream-internal s))) (putprop return-box :text :preferred-file-format) return-box))) (defun read-text-stream-internal (stream) (let ((first-line (read-line stream nil nil))) (if (null first-line) (make-box '(())) (let* ((return-box (make-box (list (make-row-from-string first-line)))) (prev-row (first-inferior-row return-box))) (do ((current-line (read-line stream nil nil) (read-line stream nil nil))) ((null current-line) return-box) (let ((new-row (make-row-from-string current-line))) (insert-row-after-row return-box new-row prev-row) (setq prev-row new-row))))))) ;;; ':error means blow out, nil means do nothing (insert "[]") ;;; perhaps one day we should have ':interpolate (defvar *box-encountered-during-text-file-operation* :interpolate) (boxer-eval::defboxer-primitive bu::write-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) box filename ;; silence bound but not used compiler warnings (boxer-eval::primitive-signal-error :obsolete-function "WRITE-TEXT-FILE is an obsolete function, use SAVE-TEXT-FILE instead")) (boxer-eval::defboxer-primitive bu::save-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) (process-editor-mutation-queue-within-eval) (save-text-file-internal (box-or-port-target box) (box-text-string filename))) (defun save-text-file-internal (box filestring) (let* ((tmp-file-string (symbol-name (gensym))) ;should do something better (dest-pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) ;; make sure we have an editor object (cond ((box? box)) ((virtual-copy? box) (setq box (make-editor-box-from-vc box))) (t (boxer-eval::primitive-signal-error :file-error "You can only save boxes"))) ;; actually dump the box (write-text-file-internal box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) boxer-eval::*novalue*)) (defun write-text-file-internal (box pathname) (with-open-file (fs pathname :direction ':output) (write-text-stream-internal box fs (namestring pathname)))) ;;; Warn Option should be at Boxer User level instead of Lisp level (defun write-text-stream-internal (box fs &optional pathname-string) (do-box-rows ((row box)) (multiple-value-bind (string box-p) (text-string row) (if (null box-p) (write-line string fs) (case *box-encountered-during-text-file-operation* (:interpolate (write-text-stream-for-boxy-row row fs)) (:warn (warn "Box encountered during text operation, writing \"[]\"") (write-line string fs)) (:error (boxer-eval::primitive-signal-error :box-encountered-while-writing-text-file pathname-string)) (t (write-line string fs))))))) (defun write-text-stream-for-boxy-row (row fs) (do-row-chas ((cha row)) (cond ((box? cha) (terpri fs) (write-char #\[ fs) (write-text-stream-internal cha fs) (write-char #\] fs) (terpri fs)) (t (write-char cha fs)))) (terpri fs)) ;;; all of this is being replaced by the box server ;;; leave here for possible inclusion in configurations ;;; where the server is not resident (boxer-eval::defboxer-primitive bu::com-enter-box () (com-enter-box)) ;; maybe we should put some sort of reality checking into this ? (boxer-eval::defboxer-primitive bu::set-current-directory ((boxer-eval::dont-copy directory)) (flet ((directory? (pathname) (and (probe-file pathname) (string-equal (directory-namestring pathname) (namestring pathname))))) (let* ((raw-pathname (check-valid-filename-for-primitive (box-text-string directory))) (dirs (pathname-directory raw-pathname)) (name (pathname-name raw-pathname)) (pathname (if (null name) raw-pathname (make-pathname :directory (append dirs (list name)))))) (if (directory? pathname) (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)) (boxer-eval::primitive-signal-error :not-a-directory (namestring pathname))))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::current-directory () (make-vc (list (make-evrow-from-entry (intern-in-bu-package (let ((string (namestring *boxer-pathname-default*))) (subseq string 0 (search (pathname-name *boxer-pathname-default*) string :from-end t)))))))) (boxer-eval::defboxer-primitive bu::default-directory () (boxer-eval::primitive-signal-error :obsolete-function "DEFAULT-DIRECTORY is an obsolete function, use CURRENT-DIRECTORY instead")) ;;; (defmethod file-box? ((box box)) (getf (slot-value box 'plist) :associated-file)) (defmethod mark-box-as-file ((box box) &optional filename) (setf (storage-chunk? box) t) (unless (null filename) (putprop box filename :associated-file)) ;; make sure other storage chunking properties are removed (when (getprop box :url) (removeprop box :url)) (when (null (getprop box :boxtop)) (putprop box :file :boxtop)) ;; clear the modified flag (set-border-style box (if (not (null (slot-value box 'exports))) :thick-dashed :thick))) (defmethod unmark-box-as-file ((box box)) (setf (storage-chunk? box) nil) (let ((filename (getprop box :associated-file))) ;; save away the filename in case we change our mine and ;; want to make it a file box again (unless (null filename) (putprop box filename :old-associated-file)) (removeprop box :associated-file) (when (eq (getprop box :boxtop) :file) (removeprop box :boxtop)) (set-border-style box (if (not (null (slot-value box 'exports))) :dashed nil)))) (defun current-file-box (&optional (where (if (box? boxer-eval::*lexical-variables-root*) boxer-eval::*lexical-variables-root* (point-box)) #|(outermost-box)|#)) (cond ((not (box? where)) nil) ((eq where *initial-box*) where) ((storage-chunk? where) where) (t (let ((sup (superior-box where))) (when (box? sup) (current-file-box sup)))))) (defvar *max-file-pathname-length* 20) (defun pretty-file-box-name (filename) (let* ((name (pathname-name filename)) (type (pathname-type filename)) (dirs (pathname-directory filename)) (rawhost (pathname-host filename)) (prettyhost (if (null rawhost) "" (format nil "~A:" rawhost))) (name-length (+ (length name) (if (typep type 'string) (length type) 0))) (ellipsis "") (included-dirs (with-collection (when (listp dirs) ; might be :unspecific (dolist (d (cdr dirs)) (incf name-length (length d)) (if (> name-length *max-file-pathname-length*) (progn (setq ellipsis #+mcl "...:" #-mcl ".../") (return)) (collect d))))))) (cond ((and (typep type 'string) (not (null included-dirs))) (format nil #+mcl "~A~{~A:~}~A~A.~A" #-mcl "~A~{~A/~}~A~A.~A" prettyhost included-dirs ellipsis name type)) ((typep type 'string) (format nil "~A.~A" name type)) ((not (null included-dirs)) (format nil #+mcl "~A {~{~A:~}~A}" #-mcl "~A {~{~A/~}~A}" name included-dirs ellipsis)) (t ; no type, no dirs (format nil "~A" name))))) ;; placeholder, should put in trimming to *max-file-pathname-length* (defun pretty-url-box-name (url) (slot-value url 'boxnet::Scheme-string)) (defun current-file-box-name (&optional (where (point-box) #|(outermost-box)|#)) (let ((cfb (current-file-box where))) (cond ((null cfb)) (t (let ((file (getprop cfb :associated-file))) (cond ((null file) "") (t (values (pretty-file-box-name file) file)))))))) (defvar *terse-file-status* t) (defvar *initial-file-status-string-length* 70) (defvar *file-status-string* (make-array *initial-file-status-string-length* :element-type 'character :fill-pointer 0)) (defun add-string-to-file-status (string) (let ((l (length string)) (max (-& (array-total-size *file-status-string*) 3))) ; room for "..." (dotimes (i l l) (if (=& (fill-pointer *file-status-string*) max) (dotimes (i 3 (return t)) (vector-push #\. *file-status-string*)) (vector-push (char string i) *file-status-string*))))) (defun clear-file-status-string () (setf (fill-pointer *file-status-string*) 0)) ; get box file props ;; returns (values origin-type file-format read-only?) (defun get-box-file-props (filebox) (let* ((file-format (getprop filebox :preferred-file-format)) (url (getprop filebox :url))) (values (if (not (null url)) (boxnet::file-status-line-string url) :disk) (or file-format ':box) (read-only-box? filebox) (file-modified? filebox)))) (defun current-file-status (box &optional vanilla?) (let ((filebox (current-file-box box))) (if (not (box? filebox)) "??????" (let* ((raw-name (slot-value filebox 'name)) (box-name (cond ((stringp raw-name) raw-name) ((null raw-name) "No Name") ((name-row? raw-name) (text-string raw-name)) (t "???"))) (url (getprop filebox :url)) (pathname (or (getprop filebox :associated-file) (when (and url (typep url 'boxnet::local-url)) (boxnet::local-url-pathname url))))) (multiple-value-bind (origin-type file-format read-only? fmodified?) (get-box-file-props filebox) #| ;; this is now handled (as it should be) in the menu-update #+mcl ;; dynamically adjust the file menu... (let ((save-item (find "Save" (slot-value *boxer-file-menu* 'ccl::item-list) :test #'(lambda (a b) (string-equal a (ccl::menu-item-title b))))) ;(save-box-as-item (find "Save Box As..." (slot-value *boxer-file-menu* ; 'ccl::item-list) ; :test #'(lambda (a b) ; (string-equal ; a (ccl::menu-item-title b))))) ) ;; grey out File menu items if they are redundant or not applicable ;; "Save" is not applicable if there is not an existing filename ;; or if the file box has not been modified... (if (or read-only? (null pathname) (not (file-modified? filebox))) (ccl::menu-item-disable save-item) (ccl::menu-item-enable save-item)) ;; "Save Box As..." is redundant with "Save As"if the ;; cursor is in the same box as the document box ; (if (eq filebox (point-box)) ; (ccl::menu-item-disable save-box-as-item) ; (ccl::menu-item-enable save-box-as-item)) ) |# ;; print into the *file-status-string* (clear-file-status-string) (catch 'status-string-end (flet ((add-string (string) (let ((result (add-string-to-file-status string))) (when (eq result t) (throw 'status-string-end nil))))) ;; first (maybe) indicate file modified status (when (and (not vanilla?) fmodified?) (add-string #+mcl "� " #-mcl "* ")) ;;; print +mcl the box name... (add-string "File Box: ") (add-string box-name) (add-string #+mcl " � " #-mcl " | ") ;; now add info about the where the box came from... (add-string "From: ") (unless (and (null pathname) (not (eq origin-type :network))) ;; leave the where field blank if we dont have a name... (let ((adjectives nil)) (when (and read-only? (not (eq origin-type :network))) (add-string (if *terse-file-status* "(RO) " "Read Only ")) (setq adjectives t)) (case origin-type (:network (if *terse-file-status* (add-string "(net) ") (add-string "Network ")) (setq adjectives t)) (:disk (when *terse-file-status* (add-string "(disk) ")))) (unless (eq file-format :box) (add-string (string-capitalize file-format)) (add-string " ") (setq adjectives t)) (when (and adjectives (not *terse-file-status*))(add-string "file ")) (cond ((not (null pathname)) (add-string (pathname-name pathname)) (let ((type (pathname-type pathname))) (unless (or (null type) (eq type :unspecific)) (add-string ".") (add-string type))) (add-string " ") (unless *terse-file-status* ;; skip directory if terse but print something... (let ((raw-dirs (pathname-directory pathname))) (add-string "{") (when (listp raw-dirs) ; could be :unspecific (dolist (dir (cdr raw-dirs)) (add-string dir) (add-string #+mcl ":" #-mcl "/"))) (add-string "}")))) ((eq origin-type :network) (add-string (boxnet::scheme-string url)))))))) *file-status-string*))))) (defvar *max-filename-length* 50) ;; pathnames derived from other platforms wont parse into directories correctly (defun truncated-filename (pathname) (unless (pathnamep pathname) (setq pathname (pathname pathname))) (let* ((dirs (pathname-directory pathname)) (name (pathname-name pathname)) (type (pathname-type pathname)) (lname (length name)) (ltype (length type)) (ellipsis? t) (endsize (cond ((and (null name) (or (null type) (eq type ':unspecific))) (setq ellipsis? nil) 0) ((or (null type) (eq type ':unspecific)) (+ 3 lname)) ((null name) (+ 3 ltype)) (t (+ 3 lname 1 ltype)))) (return-string (make-string *max-filename-length*)) (dirstop (max& 0 (- *max-filename-length* endsize))) (idx 0)) ;(declare (dynamic-extent return-string)) (flet ((add-char (&optional (char #+mcl #\: #-mcl #\/)) (when (= idx dirstop) (throw 'dir-exit nil)) (setf (char return-string idx) char) (incf idx)) (add-string (string &optional (throw? t)) (let ((end (length string))) (do ((i 0 (1+ i))) ((or (= i end) (= idx *max-filename-length*))) (when (and throw? (= idx dirstop)) (throw 'dir-exit nil)) (setf (char return-string idx) (char string i)) (incf idx)))) (add-ellipsis () (dotimes (i 3) (setf (char return-string idx) #\.) (incf idx)))) (when (eq (car dirs) :relative) (add-char)) (catch 'dir-exit (unless (zerop dirstop) (dolist (dir (cdr dirs) (setq ellipsis? nil)) (add-string dir) (add-char)))) (unless (null ellipsis?) (add-ellipsis)) (cond ((zerop dirstop) ;; this means the name.type is already longer than the alloted space (cond ((null type) (do ((nidx (+ (- lname *max-filename-length*) 3) (1+ nidx))) ((>= idx *max-filename-length*)) (setf (char return-string idx) (char name nidx)) (incf idx))) (t ;; truncated name (do ((nidx (+ (- lname *max-filename-length*) 3 1 ltype) (1+ nidx))) ((>= idx (- *max-filename-length* ltype 1))) (setf (char return-string idx) (char name nidx)) (incf idx)) (add-char #\.) ;; and now the type (do ((i 0 (1+ i))) ((or (= i ltype) (= idx *max-filename-length*))) (setf (char return-string idx) (char type i)) (incf idx))))) ((and (null name) (or (null type) (eq type ':unspecific)))) ((or (null type) (eq type ':unspecific)) (add-string name nil)) ((null name) (add-string type nil)) (t (add-string name nil) (add-char #\.) (add-string type nil)))) (if (< idx *max-filename-length*) (subseq return-string 0 idx) return-string))) ;; walk up (backwards up the list) the path looking for a match in the ;; superior dirs ;; NOTE: not quite right, we should modify the sup-pathname as well to prune lower level ;; directories which do not match (defun dmerge-dirs (path sup-path) (let ((merged-dirs nil) (sup-dirs (cdr (pathname-directory sup-path)))) (do* ((dirs (reverse (cdr (pathname-directory path))) (cdr dirs)) (dir (car dirs) (car dirs))) ((null dir) nil) (if (member dir sup-dirs :test #'string-equal) (return (append '(:relative) merged-dirs)) (push dir merged-dirs))))) ;; see if the file exists. ;; when not being strict check for ".box" or no "".box" (defun probe-search-file (pathname) (cond ((null *strict-box-paths*) (or (probe-file pathname) (probe-file (make-pathname :type (let ((current-type (pathname-type pathname))) (cond ((or (null current-type) (eq current-type :unspecific)) "box") ((string-equal current-type "box") :unspecific) (t current-type))) :defaults pathname)))) (t (probe-file pathname)))) ;; need to hack relative pathnames here... (defun fill-box-from-local-file (box) (catch 'cancel-boxer-file-dialog (let* ((raw-pathname (getprop box :associated-file)) (raw-dirs (and raw-pathname (pathname-directory raw-pathname))) (sup-box (superior-box box)) (sup-file-box (current-file-box sup-box)) (sup-pathname (getprop sup-file-box :associated-file)) (pathname (cond ((and (eq (car raw-dirs) :absolute) (probe-search-file raw-pathname))) ((and (or (eq (car raw-dirs) :relative) ;; if the relative path is just a name, ;; raw-dirs will be null (null raw-dirs)) (or *autoloading-namestring* sup-pathname) (let ((merged-pathname (merge-pathnames (make-pathname :directory raw-dirs :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) (or *autoloading-namestring* sup-pathname)))) (probe-search-file merged-pathname)))) ;; now try various simple guesses ((let ((merged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) sup-pathname)))) (and merged-pathname (probe-search-file merged-pathname)))) ((let ((autoload-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and autoload-pathname (probe-search-file autoload-pathname)))) ;; directory merging guesses... ((let ((dmerged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname sup-pathname) :name (pathname-name raw-pathname) :type (pathname-type raw-pathname)) sup-pathname)))) (and dmerged-pathname (probe-search-file dmerged-pathname)))) ((let ((admerged-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname *autoloading-namestring*) :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and admerged-pathname (probe-search-file admerged-pathname)))) ;; guesses are all wrong, so ask the user ((and *prompt-for-server-file-not-found* (not (null *autoloading-namestring*))) (boxer-open-lost-file-dialog :prompt "(While Autoloading) Can't find" :directory raw-pathname)) (*prompt-for-server-file-not-found* (boxer-open-lost-file-dialog :prompt "Can't find" :directory raw-pathname)) ;; nothing works, return the original pathname for error message (t raw-pathname))) ;; allow an out if cached pathname is not valid (filebox (read-internal-1 pathname)) (old-ds (display-style box))) (initialize-box-from-box box filebox) ;; the vanilla init will take the display style from the file box ;; if we are autoloading, we want to use the file's display style (unless (autoload-file? box) (case old-ds (:shrunk (shrink box)) (:supershrunk (boxer::supershrink box)))) ;; if the box is transparent, export it's bindings (unless (null (exports box)) ;; this is the relevant guts of boxer-eval::set-exports without the checks ;; and setting of the exports slots (which are already set from the file) ;; will break if we ever use a selective exporting mechanism which ;; doesn't look too probably at the moment (let ((superior-box (superior-box box))) (unless (null superior-box) (boxer-eval::propagate-all-exported-bindings box superior-box) (boxer-eval::export-inferior-properties box superior-box)))) ;; if there is a cached boxtop, remove it in favor of the one being ;; read in from the file (let ((cb (getprop box :cached-boxtop))) (unless (null cb) (when (graphics-sheet? cb) (let ((bm (graphics-sheet-bit-array cb))) (unless (null bm) (deallocate-bitmap bm)))) (removeprop box :cached-boxtop))) ;; this the old style boxtop caching.... (convert to new style) (let ((bp (getprop box :boxtop))) (cond ((graphics-sheet? bp) (putprop box :standard :boxtop)) ((null bp) ;; add :file boxtop here when converting from old style. THis ;; seems more economical than hairing up dump or load (putprop box :file :boxtop)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (when (box? box) ;(boxnet::read-box-postamble box) ;(part of the Boxer Server) no longer used (mark-box-as-file box pathname) (if (and (not (equal pathname raw-pathname)) ;; don't mark dirty if we just articulated a relative pathname ;; unless the directory path has actually changed (not (and (or (null (pathname-directory raw-pathname)) (eq (pathname-directory raw-pathname) :relative)) (subsetp (cdr (pathname-directory raw-pathname)) (cdr (pathname-directory pathname)))))) (mark-file-box-dirty box) (mark-file-box-clean box))) ;; record in place menu ? ; removed for UC "clean" implementation ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box))) ;;; In case redisplay breaks,. people can still do... (defun salvage-boxer-world (&optional (save-name "salvaged-world") (verbose t)) (let ((world-save-name (merge-pathnames save-name *boxer-pathname-default*))) ;; first make sure the name is ok (loop (when (yes-or-no-p "~%Save Your Boxer World in ~A ? " world-save-name) ;; we are happy with the name, then save it away ;; otherwise, prompt for a new name (format t "~%New File Name to Save in: ") (setq world-save-name (merge-pathnames (read-line) world-save-name)))) ;; then save it away verbosely (when verbose (format t "~%Dumping boxer world to ~A" world-save-name)) (dump-top-level-box *initial-box* world-save-name) ;; now verify (when verbose (format t "~%Verifying Saved file")) (load-binary-box-internal world-save-name) (format t "~%Boxer World Saved to ~A" world-save-name) (values))) ;;; spread it around (import 'salvage-boxer-world (find-package 'user)) (import 'salvage-boxer-world (find-package :boxer-window)) (import 'salvage-boxer-world (find-package :boxer-eval)) ;; might as well be paranoid... (import 'salvage-boxer-world (find-package :boxer-user)) ;;; (boxer-eval::defboxer-primitive bu::storage-name ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-vc (list (make-evrow-from-string (namestring file))))) ((not (null url)) (make-vc (list (make-evrow-from-string (boxnet::urlstring url))))) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-vc (list (make-evrow-from-string (namestring path)))))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (boxer-eval::defboxer-primitive bu::storage-info ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-file-storage-info-box file)) ((not (null url)) (make-url-storage-info-box url)) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-file-storage-info-box path))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (defun destructure-pathname (pathname) (values (pathname-host pathname) (pathname-device pathname) (pathname-directory pathname) (pathname-name pathname) (pathname-type pathname))) ;; consider making empty boxes for null fields instead of omitting entirely ;; 2/1/03 We should have empty boxes since people will be using TELL to ;; grab fields and we shoudl have something for the names to avoid errors (defun make-file-storage-info-box (pathname) (multiple-value-bind (host device directory name type) (destructure-pathname pathname) (make-file-storage-info-box-internal host device (car directory) (cdr directory) name type))) (defun make-file-storage-info-box-internal (host device dir-type dir name type) (make-vc (list (make-vc (unless (or (null host) (eq host :unspecific)) (list (make-evrow-from-string host))) 'data-box 'bu::Host) (make-vc (unless (or (null device) (eq device :unspecific)) (list (make-evrow-from-string device))) 'data-box 'bu::Device) (make-vc (list (make-evrow-from-string dir-type)) 'data-box 'bu::directory-type) (make-vc (mapcar #'(lambda (d) (make-evrow-from-string d)) dir) 'data-box 'bu::directory) (make-vc (unless (null name) (list (make-evrow-from-string name))) 'data-box 'bu::name) (make-vc (unless (or (null type) (eq type :unspecific)) (list (make-evrow-from-string type))) 'data-box 'bu::type)) 'data-box)) (defun make-url-storage-info-box (url) (make-vc (let ((url-info-sub-boxes nil)) (do* ((value-pairs (boxnet::url-values url) (cddr value-pairs)) (name (car value-pairs) (car value-pairs)) (value (cadr value-pairs) (cadr value-pairs))) ((null value-pairs)) (push (make-vc (list (make-evrow-from-string value)) 'data-box (intern-in-bu-package (string-upcase name))) url-info-sub-boxes)) (nreverse url-info-sub-boxes)))) ;; like destructure-pathname, returns (values host device directory name type) (defun destructure-file-info-box (file-info-box) (let* ((box (box-or-port-target file-info-box)) (host (lookup-variable-in-box-only box 'bu::host)) (device (lookup-variable-in-box-only box 'bu::device)) (dir-type (lookup-variable-in-box-only box 'bu::directory-type)) (dir (lookup-variable-in-box-only box 'bu::directory)) (name (lookup-variable-in-box-only box 'bu::name)) (type (lookup-variable-in-box-only box 'bu::type))) (values (if (empty-box? host) :unspecific (box-text-string host)) (if (empty-box? device) :unspecific (box-text-string device)) (cond ((string-equal (box-text-string dir-type) "RELATIVE") :relative) (t :absolute)) (with-collection (dolist (er (get-box-rows dir)) (collect (evrow-text-string er dir)))) (box-text-string name) (if (empty-box? type) :unspecific (box-text-string type))))) (boxer-eval::defboxer-primitive bu::file-info-to-file (file-info) (multiple-value-bind (host device dir-type dir name type) (destructure-file-info-box file-info) (make-vc (list (make-evrow-from-string (namestring (make-pathname :host host :device device :directory (list* dir-type dir) :name name :type type)))) 'data-box))) (boxer-eval::defboxer-primitive bu::file-to-file-info (filename) (let ((pathname-string (box-text-string filename))) (make-file-storage-info-box pathname-string))) (boxer-eval::defboxer-primitive bu::merge-file-info (info1 info2) (multiple-value-bind (host1 dev1 dir-type1 dir1 name1 type1) (destructure-file-info-box info1) (multiple-value-bind (host2 dev2 dir-type2 dir2 name2 type2) (destructure-file-info-box info2) (make-file-storage-info-box-internal (if (or (null host1) (eq host1 :unspecific)) host2 host1) (if (or (null dev1) (eq dev1 :unspecific)) dev2 dev1) (if (or (eq dir-type1 :absolute) (eq dir-type2 :absolute)) :absolute :relative) (cond ((eq dir-type1 :absolute) dir1) ((eq dir-type2 :absolute) (append dir2 dir1)) (t (append dir2 dir1))) (if (null name1) name2 name1) (if (or (null type1) (eq type1 :unspecific)) type2 type1))))) ;;; This is just a crock, but at least it will work on the Suns as long ;;; as there's only one Boxer per machine. (defun make-temporary-filename (info) (format nil "/tmp/boxer-~a" info)) (defun read-box-from-text-stream (stream) stream boxer-eval::*novalue*) ;;; ;;; COMPRESS-FILE. ;;; ;;; These are for saving space on unix filesystems. They should go away ;;; when Ed rewrites the file system make smaller files. ;;; The user can call COMPRESS-FILE. READ will try to uncompress a file ;;; if it doesn't exist. (defun compress-file (pathname) #+Unix (progn (make-backup-if-necessary (concatenate 'string (namestring pathname) ".Z")) (boxer-run-unix-program "compress" (list "-f" (namestring pathname)))) #-Unix (progn pathname nil)) (defun uncompress-file (pathname) #+Unix (boxer-run-unix-program "uncompress" (list (namestring pathname))) #-Unix (progn pathname nil)) (defun maybe-uncompress-file (pathname) #+Unix (when (and (null (probe-file pathname)) (probe-file (concatenate 'string (namestring pathname) ".Z"))) #+Lucid (uncompress-file pathname) #-Lucid nil) #-Unix (progn pathname nil)) #-mcl (boxer-eval::defboxer-primitive bu::compress-file ((boxer-eval::dont-copy name)) (let ((filename (if (numberp name) (format nil "~D" name) (box-text-string name)))) (if (null (probe-file filename)) (boxer-eval::signal-error :FILE-NOT-FOUND (boxer-eval::copy-thing name)) (let ((error-string (compress-file filename))) (if (null error-string) boxer-eval::*novalue* (boxer-eval::signal-error :COMPRESS-FILE error-string)))))) ;;; ;;; boxer-run-unix-program ;;; ;;; Returns NIL if succesful, otherwise a list of error strings. ;;; ;;; We have to run the program asynchronously in order to get the ;;; error output into a stream. ;;; Didn't do anything about stdout, though. (defun boxer-run-unix-program (program-name arguments) #+Unix (let ((error-result #+Lucid (multiple-value-bind (stream error-output-stream exit-status process-id) ;; We can't do both :error-output :stream ;; and :wait t, so we have to assume that the process ;; is finished when when we find out that the error-output-stream ;; is done. (system::run-program program-name :arguments arguments :wait nil :if-error-output-exists nil :error-output :stream) (declare (ignore stream process-id)) (if error-output-stream (prog1 (do* ((string (read-line error-output-stream nil nil) (read-line error-output-stream nil nil)) (result nil)) ((null string) (nreverse result)) (unless (null string) (push string result))) (close error-output-stream)) (format nil "Unknown Unix Error ~D" exit-status))) #-Lucid "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (if (stringp error-result) (boxer-eval::primitive-signal-error :UNIX-PROGRAM-ERROR error-result) nil)) #-Unix (progn program-name arguments "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (defun fix-file-alus (top-box &optional (sun->mac? t)) (labels ((fix-gl (gl) (setf (graphics-command-list-alu gl) (convert-file-alu (graphics-command-list-alu gl) sun->mac?)) (do-vector-contents (gc gl) (when (member (aref gc 0) '(0 32) :test #'=) ;; if it is an CHANGE-ALU command.... (setf (aref gc 1) (convert-file-alu (aref gc 1) sun->mac?))))) (fix-box (box) (let ((graphics-sheet (graphics-sheet box))) (when (not (null graphics-sheet)) (let ((gl (graphics-sheet-graphics-list graphics-sheet))) (unless (null gl) (fix-gl gl))))) (when (sprite-box? box) (let* ((turtle (slot-value box 'associated-turtle)) (shape (shape turtle)) (ws (slot-value turtle 'window-shape))) (fix-gl shape) (fix-gl ws))))) (fix-box top-box) (do-for-all-inferior-boxes-fast (inf-box top-box) (fix-box inf-box)))) ;; order is (sun-alu . mac-alu) (defvar *file-conversion-alu-alist* '((2 . 3) ; alu-andca (5 . 0) ; alu-seta (6 . 2) ; alu-xor (7 . 1) ; alu-ior (0 . 11))) ; alu-setz (defun convert-file-alu (old-alu sun->mac?) (if sun->mac? (or (cdr (assoc old-alu *file-conversion-alu-alist* :test #'=)) 0) (or (car (rassoc old-alu *file-conversion-alu-alist* :test #'=)) 5))) (boxer-eval::defboxer-primitive bu::fix-sun-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box)) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::fix-mac-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box) nil) boxer-eval::*novalue*)
true
;; -*- Mode:LISP; Syntax:Common-Lisp; Package:BOXER; -*- #| $Header: file-prims.lisp,v 1.0 90/01/24 22:11:51 boxer Exp $ $Log: file-prims.lisp,v $ ;;;Revision 1.0 90/01/24 22:11:51 boxer ;;;Initial revision ;;; Boxer Copyright 1985-2020 PI:NAME:<NAME>END_PI and the Estate of PI:NAME:<NAME>END_PI Portions of this code may be copyright 1982-1985 Massachusetts Institute of Technology. Those portions may be used for any purpose, including commercial ones, providing that notice of MIT copyright is retained. Licensed under the 3-Clause BSD license. You may not use this file except in compliance with this license. https://opensource.org/licenses/BSD-3-Clause +-Data--+ This file is part of the | BOXER | system +-------+ This file contains all of the boxer functions which use the file system. Modification History (most recent at top) 12/15/11 write-text-stream-internal changed to handle the :interpolate option *box-encountered-during-text-file-operation* changed to :interpolate new function write-text-stream-for-boxy-row 12/22/05 wrap ignore-errors around parts of check-valid-filename-for-primitive to cleanly handle illegal pathnames (e.g. from mistyped URL protocol fields) READ-INTERNAL checks for possible null pathname to catch this case 8/23/05 fill-box-from-local-file uses new probe-search-file to check for boxer files 8/06/05 fixed truncated-filename to handle names longer than *max-filename-length* also boosted *max-filename-length* to 50 10/06/04 extended storage-{name,info} to handle xrefs 8/27/04 copyright error message in mark-for-saving referred to wrong replacement name 7/16/04 Fixed Copyright Error message in MARk-FOR-SAVING 8/15/03 added show-file-info as diagnostic tool, set-boxer-file-info 4/19/03 merged current LW and MCL files 2/03/03 destructure-file-info-box, file-info-to-file, file-to-file-info & merge-file-info 2/01/03 changed make-file-storage-info-box to make empty boxes for fields which are either null or :unspecific 10/20/02 RECORD-FILE-BOX-PLACE & RECORD-URL-BOX-PLACE stubbified and removed from READ-INTERNAL & FILL-BOX-FROM-LOCAL-FILE in preparation for "UC clean" reimplementation 9/02/02 UC free version of MARK-FOR-SAVING, added TOGGLE-MODIFIED-FLAG 8/27/02 make-file-storage-info-box, VC names must be BU symbols instead of strings make-url-storage-info-box does the same via intern-in-bu-package 8/ 8/02 finished support functions for bu::storage-xxx 8/ 5/02 added bu::storage-name and bu::storage-info 10/ 7/01 status-line-save-format-string for use in save-internal 3/ 8/01 fill-box-from-local-file: relative pathname check should check for null dirs as well as :relative 2/14/01 merged current LW and MCL files 1/15/01 lispworks version for check-valid-filename-for-primitive 10/16/00 make-backup-if-necessary now checks for 31 char pathnames 10/10/00 make-backup-if-necessary for windows will keep the pathname type 11/14/99 removed file-namestring from fill-box-from-local-file because it loses when merging a typeless pathname. Replace by make-pathname with the type component defaulting to :unspecific for null pathname-type 10/15/99 simplified fill-box-from-local-file by using file-namestring 10/14/99 save-text-file processes the modified editor object queue save-text-file-internal now renders VC's into editor boxes 9/13/99 fill-box-from-local-file, don't mark the file box dirty for relative pathname fileboxes, unless the relative part is actually changed 6/25/99 extracted pretty-file-box-name for use in other places added pretty-url-box-name (temp version), record-file-box-place, and record-url-box-place use record-file-box-place in read-internal,fill-box-from-local-file 5/25/99 changed mark-box-as-file to not be so eager to convert to :file boxtop 5/17/99 check for filename before saving old-file-prop in unmark-box-as-file 5/12/99 added eval::*novalue* return value to mark-for-saving 4/25/99 {un}mark-box-as-file now adds/removes :file :boxtop property 4/14/99 use new calling conventions for write-boxer-file-info 3/26/99 bu::mark-for-saving added 2/12/99 save-generic error messages use OPEN as the name of the prim instead of READ 2/11/99 (defboxer-primitive bu::unfile-box 2/10/99 added unmark-box-as-file 12/15/98 changed various save functions to process the mutation queue before saving 10/ 1/98 fill-box-from-local-file probes for file in relative pathname clause also separate prompts for choose file dialog when file not found 9/29/98 save-generic sets read-only? flag both ways instead of only to T 9/13/98 OPEN changed to bash name slot of world boxes 5/27/98 added autoloading case to fill-box-from-local-file for relative paths changed read-internal-1 to give lisp error (which should be handled) for missing autoload 5/27/98 Started Logging Changes: source = boxer version 2.3alphaR1 |# (in-package :boxer) ;;;; the prims (boxer-eval::defboxer-primitive bu::save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::quietly-save () ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (cond ((box? boxer-eval::*lexical-variables-root*) (com-save-document nil T)) (t (boxer-eval::primitive-signal-error :file "You can only SAVE editor boxes")))) (boxer-eval::defboxer-primitive bu::save-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox (current-file-box))) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-save-document))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::save-box-as ((boxer-eval::dont-copy name)) ;; make sure the editor structure is up to date (process-editor-mutation-queue-within-eval) (if (not (box? boxer-eval::*lexical-variables-root*)) (boxer-eval::primitive-signal-error :file "You can only SAVE-AS editor boxes") (let ((savestring (box-text-string name)) (filebox boxer-eval::*lexical-variables-root*)) (cond ((url-string? savestring) ;; remove possible associated file here (removeprop filebox :associated-file) (putprop filebox (boxnet::make-url-from-string savestring t) :url)) (t (removeprop filebox :url) (putprop filebox (check-valid-filename-for-primitive savestring *boxer-pathname-default*) :associated-file))) (com-box-save-as nil boxer-eval::*lexical-variables-root*))) boxer-eval::*novalue*) ;; use TELL to direct (boxer-eval::defboxer-primitive bu::unfile-box () (com-unfile-document)) ;; Returns TRUE, or a box with a defined reason or else FALSE, ;; meaning "some other reason" (boxer-eval::defboxer-primitive bu::safe-to-save? () (let* ((box (current-file-box)) (raw-filename (getprop box :associated-file)) ;; careful, the filename might be relative (existing-filename (cond ((null raw-filename) nil) ((eq (car (pathname-directory raw-filename)) :absolute) raw-filename) (t ; must be relative (let* ((sup-file-box (current-file-box (superior-box box))) (sup-filename (getprop sup-file-box :associated-file))) (cond ((not (null sup-filename)) (merge-pathnames raw-filename sup-filename))))))) (fps (get-boxer-file-properties existing-filename))) (cond ((null existing-filename) (make-vc '((bu::no-filename)))) #-mcl ;; MACL probe-file loses on directories ((null (probe-file (make-pathname :directory (pathname-directory existing-filename)))) (make-vc '((bu::no-directory)))) #+mcl ;; on the mac, you can "lock" files... ((and (probe-file existing-filename) (ccl::file-locked-p existing-filename)) (make-vc '((bu::file-locked)))) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname ((and (not (null fps)) (not (null (file-write-date existing-filename))) (not (= (boxer-file-creation-date fps) (file-write-date existing-filename)))) (make-vc '((bu::file-is-newer)))) ((and (not (null fps)) (not (eq (boxer-file-box fps) box))) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (if (member-boxer-file-box box fps) (make-vc '((bu::newer-other-box))) ;; the distinction between these is that in the 2nd case, the box has ;; never been saved to that filename (make-vc '((bu::newer-other-box))))) (t boxer-eval::*true*)))) (defvar *automatic-file-compression-on* nil) (defvar *file-compress-minimum-length* (* 64 1024)) ;empirical ;; this is used to catch pathnames which won't even parse (defun quote-wild-char (string quote-char) (let* ((slength (length string)) (return-string (make-array (1+ slength) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i slength) (let ((char (char string i))) (when (char= char #\*) (vector-push-extend quote-char return-string)) (vector-push-extend char return-string))) return-string)) (defun check-valid-filename-for-primitive (filename &optional defaults allow-wild) (declare (ignore allow-wild)) (cond ((pathnamep filename) ;; If it is already a pathname leave it alone (this can happen if ;; the pathname has been returned from boxer-open-file-dialog) filename) (t (ignore-errors (if (null defaults) (pathname filename) (merge-pathnames filename defaults)))))) ;; tries to be smart about file type (defun save-generic (box filename &key format read-only? always-save?) (let* ((dest-pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*)) (fps (get-boxer-file-properties dest-pathname)) (file-format (or format (getprop box :preferred-file-format) :boxer))) ;; first perform various kinds of reality checking ;; ;; we can only save out top level boxes for now, I suppose it ;; it would be possible to run the printer to generate real structure ;; then save THAT out but it seems to be too much work for a very ;; LIMITED set of circumstances (unless (box? box) (boxer-eval::primitive-signal-error :file-error "Sorry, you can only save out top level boxes")) ;; then make sure the directory exists #-mcl ;; MACL probe-file loses on directories (unless (probe-file (make-pathname :directory (pathname-directory dest-pathname))) (boxer-eval::primitive-signal-error :file-error "The directory, " (namestring dest-pathname) ", does not exist")) ;; on the mac, you can "lock" files... #+mcl (when (and (probe-file dest-pathname) (ccl::file-locked-p dest-pathname)) (boxer-eval::primitive-signal-error :file-error "The file, " (namestring dest-pathname) ", is locked")) ;; make sure we were the last person to actually write it out and ;; that there isn't a conflict with another box pointing to the ;; same pathname (when (and (null always-save?) (not (null fps))) (cond ((and (not (null (file-write-date dest-pathname))) (not (= (boxer-file-creation-date fps) (file-write-date dest-pathname))) (not (file-overwrite-ok (format nil "~A, has been changed since last ~A. Save Anyway ?" (namestring dest-pathname) #+mcl "Open" #-mcl "READ")))) (throw 'cancel-boxer-file-dialog nil) ;; if we are going to query, then don't error out #| (boxer-eval::primitive-signal-error :file-overwrite-warning (make-box `(("The File:") (,(namestring dest-pathname)) ("has been changed since you last Read it") () ("Use REALLY-SAVE to save out changes"))))|# ) ((not (eq (boxer-file-box fps) box)) ;; the box doesn't match with the most current box for this file ;; there are several possibilities for this so we break it down: (unless (if (member-boxer-file-box box fps) (file-overwrite-ok "Another version of this box exists and has been saved more recently. Save anyway?") (file-overwrite-ok (format nil "The file, ~A, is associated with a different box. Save Anyway ?" (namestring dest-pathname)))) ;; dont error out if we bother to ask... (throw 'cancel-boxer-file-dialog nil) #| (boxer-eval::primitive-signal-error :file-overwrite-warning "The filename, " (namestring dest-pathname) ", is associated with a different box")|# )))) (setf (read-only-box? box) read-only?) ;; this should be changed to be more data driven like the file readers ;; need to make the appropriate file type save functions more uniform 1st (case file-format (:boxer (save-internal box dest-pathname)) (:text (save-text-file-internal box dest-pathname)) (t (save-internal box dest-pathname))) ;; dump some useful properties into the resource fork ;; (before) we record current file props since changing the resource fork ;; might also change the file write date #+mcl (write-boxer-file-info box dest-pathname) ;; if everything worked, then update the file properties so we don't ;; get an error the next time we try and save out the file (record-boxer-file-properties dest-pathname (file-write-date dest-pathname) (file-author dest-pathname) box) (mark-box-as-file box dest-pathname) ;; mark the box as unmodified (mark-file-box-clean box))) ;; got to be careful, the pathname might have "~"'s (especially from backup files) ;; also, try to keep the length limited to avoid odd window resizing bug in LWW (defun status-line-save-format-string (dest-pathname) (let* ((*max-file-pathname-length* 50) ; should be adaptive to width of name-pane (pretty-path (pretty-file-box-name dest-pathname))) (format nil "Saving ~A ~~D" (cond ((find #\~ pretty-path) (quote-tilde pretty-path)) (t pretty-path))))) (defun quote-tilde (string) (let* ((lstring (length string)) (newstring (make-array (+& 1 lstring) :element-type 'character :adjustable t :fill-pointer 0))) (dotimes (i lstring) (let ((char (char string i))) (cond ((char= char #\~) (vector-push-extend #\~ newstring) (vector-push-extend #\~ newstring)) (t (vector-push-extend char newstring))))) newstring)) (defun save-internal (box dest-pathname) (let* ((tmp-file-string (symbol-name (gensym))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) (unwind-protect (let ((*status-line-saving-format-string* (status-line-save-format-string dest-pathname))) ;; feedback (status-line-display 'saving-box (format nil "Saving ~A..." dest-pathname)) ;; actually dump the box (dump-top-level-box box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname)) (status-line-undisplay 'saving-box) (boxer-editor-message "~A box saved to ~A" (name-string box)(namestring dest-pathname)) ;; make sure the tmp-dest is gone (unless (null (probe-file tmp-dest)) (delete-file tmp-dest))) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) (when *automatic-file-compression-on* ;; Compress the file only if it's greater than ;; *file-compress-minimum-length*. Otherwise the time ;; it takes won't be worth it. (let ((length (with-open-file (stream dest-pathname :direction :input) (file-length stream)))) (if (> length *file-compress-minimum-length*) (compress-file dest-pathname)))))) (defun make-backup-if-necessary (dest-pathname) (when (probe-file dest-pathname) ;; looks like there already is a file with that name (rename-file dest-pathname ;; on windows systems, we have to preserve the pathname type #+win32 (merge-pathnames (concatenate 'string (pathname-name dest-pathname) *file-backup-suffix*) dest-pathname) #+mcl (let ((old-name (file-namestring dest-pathname))) ;; have to check for possible 31 char length (cond ((>= (length old-name) 31) (merge-pathnames (concatenate 'string (subseq old-name 0 30) *file-backup-suffix*) dest-pathname)) (t (concatenate 'string (namestring dest-pathname) *file-backup-suffix*)))) #-(or mcl win32) (concatenate 'string (namestring dest-pathname) *file-backup-suffix*) #+mcl :if-exists #+mcl :supersede))) ;; used to be READ (boxer-eval::defboxer-primitive bu::open ((boxer-eval::dont-copy file)) (let* ((filename (box-text-string file)) (box (read-internal filename))) ;; if the box was a world file, need to fix the NAME slot (multiple-value-bind (ro? world-box?) #+mcl (unless (url-string? filename) (boxer-file-info filename)) ;; looks in resource fork #-mcl (values nil nil) (declare (ignore ro?)) (when (or world-box? (and (stringp (slot-value box 'name)) (string= (slot-value box 'name) "WORLD"))) (setf (slot-value box 'name) nil))) box)) (boxer-eval::defboxer-primitive bu::READ ((boxer-eval::dont-copy filename)) filename (boxer-eval::primitive-signal-error :file "READ is an obsolete function, use OPEN instead")) #| (boxer-eval::defboxer-primitive bu::read-only ((boxer-eval::dont-copy filename)) (boxnet::read-only-internal (box-text-string filename))) |# ;; this can handle url strings as well as filenames... (defun read-internal (name) (if (url-string? name) (read-internal-url name) ;; can still be a bad filename here (bad URL spelling) (e.g. "htTtp://foo.bar") (let* ((pathname (check-valid-filename-for-primitive name *boxer-pathname-default*)) ;; note, we resolve the full pathname here instead of letting ;; read-internal-1 do the work so that we can have a complete ;; pathname available for the bookeeping operations which follow ;; a successful read-internal-1 (box (unless (null pathname) (read-internal-1 name pathname)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (cond ((box? box) ;(boxnet::read-box-postamble box) ;(Boxer Server stuff) no longer used (mark-box-as-file box pathname) (mark-file-box-clean box) ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box) (t (boxer-eval::primitive-signal-error :file-error "Unable to READ " name)))))) ;; Note: read-internal-1 does NOT do the bookeeping ops because some of ;; the bookkeeping operations rely on the EQness of the box and there ;; are some functions (like fill-box-from-server) which USE the result of ;; read-internal-1 to initialize another box in the editor. It is that ;; other box in the editor that the bookeeping operations need to keep ;; track of and it is in those higher up functions where the bookeeping must occur (defun read-internal-1 (filename &optional (pathname (check-valid-filename-for-primitive filename *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (if *in-autoload-environment* (error "Autoload File not found: ~A" (namestring pathname)) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname)))) (prog1 (let* ((ftype (file-type pathname)) ;; dispatch to special readers when appropriate ;; ALL special reader take a filename arg and return a box ;; ALL implementations should handle :boxer and :text types (box (let ((special-file-reader-function (get-special-file-reader ftype))) (cond ((null special-file-reader-function) (cond ((not (null *error-on-unknown-file-type*)) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) ((not (status-line-y-or-n-p (format nil "Unknown file type, ~A, load as Text ?" ftype))) (boxer-eval::primitive-signal-error :unknown-file-type "Don't know how to load a " ftype "file")) (t (read-text-file-internal pathname)))) (t (funcall special-file-reader-function pathname)))))) box) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)))))) (boxer-eval::defboxer-primitive bu::probe-file ((boxer-eval::dont-copy filename)) (let ((pathname (check-valid-filename-for-primitive (box-text-string filename) *boxer-pathname-default*))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (boxer-eval::boxer-boolean (probe-file pathname)))) (boxer-eval::defboxer-primitive bu::toggle-modified-flag () (when (box? boxer-eval::*lexical-variables-root*) (cond ((file-box-dirty? boxer-eval::*lexical-variables-root*) (mark-file-box-clean boxer-eval::*lexical-variables-root*)) (t (mark-file-box-dirty boxer-eval::*lexical-variables-root*))) (modified boxer-eval::*lexical-variables-root*) boxer-eval::*novalue*)) ;;; DIRECTORY (boxer-eval::defboxer-primitive bu::directory ((boxer-eval::dont-copy file-pattern)) (make-vc (or (mapcar #'(lambda (p) (make-evrow-from-entry (intern-in-bu-package (namestring p)))) (directory-internal (box-text-string file-pattern))) (list (make-empty-evrow))))) (defvar *default-directory-type* "box") (defun directory-internal (pattern-string) (let* ((pattern-pathname (check-valid-filename-for-primitive pattern-string (make-pathname :name :wild :type #-sun :unspecific #+sun *default-directory-type* :defaults *boxer-pathname-default*) t)) (directory-name (make-pathname :directory (pathname-directory pattern-pathname) ;; mac seems to need this, bare directory pathnames ;; return NIL #+mcl :name #+mcl ':wild))) (file-pattern-match? (make-pathname :name (pathname-name pattern-pathname) :type (pathname-type pattern-pathname)) (directory directory-name)))) ;; returns a list of pattern specs for file-pattern-match? ;; expects the pattern string to already have the directory ;; components stripped off ;; a pattern-spec is a CONS composed of a keyword type as the CAR ;; and a string as the CDR (defun parse-pathname-pattern (pp) (values (parse-pattern-component (pathname-name pp)) (parse-pattern-component (pathname-type pp)))) (defun parse-pattern-component (pattern) (let ((return-specs nil) (max-wild-place (when (stringp pattern) (1-& (length pattern))))) (cond ((or (eq pattern :wild) (eq pattern :unspecific) (= max-wild-place -1)) (push (cons :wild "") return-specs)) ((stringp pattern) (let ((wild-place 0)) (loop (let ((new-wild-place (position #\* pattern :start wild-place))) (cond ((and (null new-wild-place) (zerop wild-place)) ;; this means no wild cards (push (cons :whole pattern) return-specs) (return)) ((null new-wild-place) ;; no more wild cards, but some have ;; already been processed (push (cons :end (subseq pattern wild-place)) return-specs) (return)) ;; at this point we know we have found a wild card ;; somewhere in the pattern ((and (zerop wild-place) (zerop new-wild-place)) ;; the wild card has been found at the beginning (setq wild-place 1)) ((zerop wild-place) ;; just starting but wild card has been found (push (cons :begin (subseq pattern 0 new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) ((= wild-place new-wild-place) ;; this can happen if someone type "**" in the pattern (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place)))) (t (push (cons :inside (subseq pattern wild-place new-wild-place)) return-specs) (if (= new-wild-place max-wild-place) (return) (setq wild-place (1+& new-wild-place))))))))) (t (error "Pattern spec, ~A, is not a string or :WILD" pattern))) (nreverse return-specs))) ;; returns the subset of file-list which matches the pattern-string (defun file-pattern-match? (pattern file-list) (let ((return-list nil)) (multiple-value-bind (name-specs type-specs) (parse-pathname-pattern pattern) (dolist (file file-list) (when (and (component-pattern-match? name-specs (pathname-name file)) (component-pattern-match? type-specs (pathname-type file))) (push file return-list))) (nreverse return-list)))) (defun component-pattern-match? (pattern-specs comp) (let ((start 0) (pattern-match? t)) (dolist (spec pattern-specs) (case (car spec) (:wild (return)) (:whole (unless (string= comp (cdr spec)) (setq pattern-match? nil)) (return)) (:begin (let ((place (search (cdr spec) comp))) (cond ((and place (zerop& place)) (setq start (length (cdr spec)))) (t (setq pattern-match? nil) (return))))) (:end (let ((place (search (cdr spec) comp :from-end t :start2 start))) (unless (and place (=& place (-& (length comp) (length (cdr spec))))) (setq pattern-match? nil) (return)))) (:inside (let ((place (search (cdr spec) comp :start2 start))) (cond ((null place) (setq pattern-match? nil) (return)) (t (setq start (+ (length (cdr spec)) start)))))))) ;; if the pattern-match? flag is still true after all of ;; the pattern-specs have run, push the file onto the return list pattern-match?)) (boxer-eval::defboxer-primitive bu::delete-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (check-valid-filename-for-primitive filestring *boxer-pathname-default*))) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (delete-file pathname) boxer-eval::*novalue*)) ;;;; TEXT File Operations ;;; connect with the outside world. These may turn out to be useful ;;; for a longer period of time than the actual boxer file operations ;;; ;;; These should eventually be rewritten to use a string buffer for ;;; read-line and write-line so they don't keep CONSing string ;;; (boxer-eval::defboxer-primitive bu::read-text-file ((boxer-eval::dont-copy filename)) (let* ((filestring (box-text-string filename)) (pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring)))) (when (null (probe-file pathname)) (maybe-uncompress-file pathname)) (unless (probe-file pathname) (boxer-eval::primitive-signal-error :file-or-directory-not-found (namestring pathname))) (prog1 (read-text-file-internal pathname) ;; now handle file stickyness if we want to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name pathname))) (not (null (pathname-type pathname)))) (setq *boxer-pathname-default* pathname) ;; otherwise, use as much of the pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*))))))) ;;; a useful hack... (boxer-eval::defboxer-primitive bu::read-text-box-shrink ((dont-copy filename)) (boxer-eval::vpdl-push filename) (let ((result (bu::read-text-file))) (shrink result) result)) ;; we are guaranteed that pathname is valid (defun read-text-file-internal (pathname) (with-open-file (s pathname :direction ':input) (let ((return-box (read-text-stream-internal s))) (putprop return-box :text :preferred-file-format) return-box))) (defun read-text-stream-internal (stream) (let ((first-line (read-line stream nil nil))) (if (null first-line) (make-box '(())) (let* ((return-box (make-box (list (make-row-from-string first-line)))) (prev-row (first-inferior-row return-box))) (do ((current-line (read-line stream nil nil) (read-line stream nil nil))) ((null current-line) return-box) (let ((new-row (make-row-from-string current-line))) (insert-row-after-row return-box new-row prev-row) (setq prev-row new-row))))))) ;;; ':error means blow out, nil means do nothing (insert "[]") ;;; perhaps one day we should have ':interpolate (defvar *box-encountered-during-text-file-operation* :interpolate) (boxer-eval::defboxer-primitive bu::write-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) box filename ;; silence bound but not used compiler warnings (boxer-eval::primitive-signal-error :obsolete-function "WRITE-TEXT-FILE is an obsolete function, use SAVE-TEXT-FILE instead")) (boxer-eval::defboxer-primitive bu::save-text-file ((bu::port-to box) (boxer-eval::dont-copy filename)) (process-editor-mutation-queue-within-eval) (save-text-file-internal (box-or-port-target box) (box-text-string filename))) (defun save-text-file-internal (box filestring) (let* ((tmp-file-string (symbol-name (gensym))) ;should do something better (dest-pathname (make-pathname :directory (pathname-directory (check-valid-filename-for-primitive filestring *boxer-pathname-default*)) :defaults (check-valid-filename-for-primitive filestring))) (tmp-dest (merge-pathnames tmp-file-string dest-pathname))) ;; make sure we have an editor object (cond ((box? box)) ((virtual-copy? box) (setq box (make-editor-box-from-vc box))) (t (boxer-eval::primitive-signal-error :file-error "You can only save boxes"))) ;; actually dump the box (write-text-file-internal box tmp-dest) ;; now check to see if we need to make a backup (make-backup-if-necessary dest-pathname) ;; now move the freshly save file from the tmp-name to the dest name (rename-file tmp-dest dest-pathname) ;; now handle file name stickyness if we have to (unless (null *sticky-file-defaulting?*) ;; set the default pathname to be the current pathname ONLY after ;; we make sure that the current pathname has all the "important" ;; components, otherwise the default can become damaged in a way ;; that leaves it unchangeable (e.g. pathname-name becomes NIL ;; if the "default" was ".login") (if (and (not (null (pathname-name dest-pathname))) (not (null (pathname-type dest-pathname)))) (setq *boxer-pathname-default* dest-pathname) ;; otherwise, use as much of the dest-pathname as we can to set ;; the default (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory dest-pathname) :defaults *boxer-pathname-default*)))) boxer-eval::*novalue*)) (defun write-text-file-internal (box pathname) (with-open-file (fs pathname :direction ':output) (write-text-stream-internal box fs (namestring pathname)))) ;;; Warn Option should be at Boxer User level instead of Lisp level (defun write-text-stream-internal (box fs &optional pathname-string) (do-box-rows ((row box)) (multiple-value-bind (string box-p) (text-string row) (if (null box-p) (write-line string fs) (case *box-encountered-during-text-file-operation* (:interpolate (write-text-stream-for-boxy-row row fs)) (:warn (warn "Box encountered during text operation, writing \"[]\"") (write-line string fs)) (:error (boxer-eval::primitive-signal-error :box-encountered-while-writing-text-file pathname-string)) (t (write-line string fs))))))) (defun write-text-stream-for-boxy-row (row fs) (do-row-chas ((cha row)) (cond ((box? cha) (terpri fs) (write-char #\[ fs) (write-text-stream-internal cha fs) (write-char #\] fs) (terpri fs)) (t (write-char cha fs)))) (terpri fs)) ;;; all of this is being replaced by the box server ;;; leave here for possible inclusion in configurations ;;; where the server is not resident (boxer-eval::defboxer-primitive bu::com-enter-box () (com-enter-box)) ;; maybe we should put some sort of reality checking into this ? (boxer-eval::defboxer-primitive bu::set-current-directory ((boxer-eval::dont-copy directory)) (flet ((directory? (pathname) (and (probe-file pathname) (string-equal (directory-namestring pathname) (namestring pathname))))) (let* ((raw-pathname (check-valid-filename-for-primitive (box-text-string directory))) (dirs (pathname-directory raw-pathname)) (name (pathname-name raw-pathname)) (pathname (if (null name) raw-pathname (make-pathname :directory (append dirs (list name)))))) (if (directory? pathname) (setq *boxer-pathname-default* (make-pathname :directory (pathname-directory pathname) :defaults *boxer-pathname-default*)) (boxer-eval::primitive-signal-error :not-a-directory (namestring pathname))))) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::current-directory () (make-vc (list (make-evrow-from-entry (intern-in-bu-package (let ((string (namestring *boxer-pathname-default*))) (subseq string 0 (search (pathname-name *boxer-pathname-default*) string :from-end t)))))))) (boxer-eval::defboxer-primitive bu::default-directory () (boxer-eval::primitive-signal-error :obsolete-function "DEFAULT-DIRECTORY is an obsolete function, use CURRENT-DIRECTORY instead")) ;;; (defmethod file-box? ((box box)) (getf (slot-value box 'plist) :associated-file)) (defmethod mark-box-as-file ((box box) &optional filename) (setf (storage-chunk? box) t) (unless (null filename) (putprop box filename :associated-file)) ;; make sure other storage chunking properties are removed (when (getprop box :url) (removeprop box :url)) (when (null (getprop box :boxtop)) (putprop box :file :boxtop)) ;; clear the modified flag (set-border-style box (if (not (null (slot-value box 'exports))) :thick-dashed :thick))) (defmethod unmark-box-as-file ((box box)) (setf (storage-chunk? box) nil) (let ((filename (getprop box :associated-file))) ;; save away the filename in case we change our mine and ;; want to make it a file box again (unless (null filename) (putprop box filename :old-associated-file)) (removeprop box :associated-file) (when (eq (getprop box :boxtop) :file) (removeprop box :boxtop)) (set-border-style box (if (not (null (slot-value box 'exports))) :dashed nil)))) (defun current-file-box (&optional (where (if (box? boxer-eval::*lexical-variables-root*) boxer-eval::*lexical-variables-root* (point-box)) #|(outermost-box)|#)) (cond ((not (box? where)) nil) ((eq where *initial-box*) where) ((storage-chunk? where) where) (t (let ((sup (superior-box where))) (when (box? sup) (current-file-box sup)))))) (defvar *max-file-pathname-length* 20) (defun pretty-file-box-name (filename) (let* ((name (pathname-name filename)) (type (pathname-type filename)) (dirs (pathname-directory filename)) (rawhost (pathname-host filename)) (prettyhost (if (null rawhost) "" (format nil "~A:" rawhost))) (name-length (+ (length name) (if (typep type 'string) (length type) 0))) (ellipsis "") (included-dirs (with-collection (when (listp dirs) ; might be :unspecific (dolist (d (cdr dirs)) (incf name-length (length d)) (if (> name-length *max-file-pathname-length*) (progn (setq ellipsis #+mcl "...:" #-mcl ".../") (return)) (collect d))))))) (cond ((and (typep type 'string) (not (null included-dirs))) (format nil #+mcl "~A~{~A:~}~A~A.~A" #-mcl "~A~{~A/~}~A~A.~A" prettyhost included-dirs ellipsis name type)) ((typep type 'string) (format nil "~A.~A" name type)) ((not (null included-dirs)) (format nil #+mcl "~A {~{~A:~}~A}" #-mcl "~A {~{~A/~}~A}" name included-dirs ellipsis)) (t ; no type, no dirs (format nil "~A" name))))) ;; placeholder, should put in trimming to *max-file-pathname-length* (defun pretty-url-box-name (url) (slot-value url 'boxnet::Scheme-string)) (defun current-file-box-name (&optional (where (point-box) #|(outermost-box)|#)) (let ((cfb (current-file-box where))) (cond ((null cfb)) (t (let ((file (getprop cfb :associated-file))) (cond ((null file) "") (t (values (pretty-file-box-name file) file)))))))) (defvar *terse-file-status* t) (defvar *initial-file-status-string-length* 70) (defvar *file-status-string* (make-array *initial-file-status-string-length* :element-type 'character :fill-pointer 0)) (defun add-string-to-file-status (string) (let ((l (length string)) (max (-& (array-total-size *file-status-string*) 3))) ; room for "..." (dotimes (i l l) (if (=& (fill-pointer *file-status-string*) max) (dotimes (i 3 (return t)) (vector-push #\. *file-status-string*)) (vector-push (char string i) *file-status-string*))))) (defun clear-file-status-string () (setf (fill-pointer *file-status-string*) 0)) ; get box file props ;; returns (values origin-type file-format read-only?) (defun get-box-file-props (filebox) (let* ((file-format (getprop filebox :preferred-file-format)) (url (getprop filebox :url))) (values (if (not (null url)) (boxnet::file-status-line-string url) :disk) (or file-format ':box) (read-only-box? filebox) (file-modified? filebox)))) (defun current-file-status (box &optional vanilla?) (let ((filebox (current-file-box box))) (if (not (box? filebox)) "??????" (let* ((raw-name (slot-value filebox 'name)) (box-name (cond ((stringp raw-name) raw-name) ((null raw-name) "No Name") ((name-row? raw-name) (text-string raw-name)) (t "???"))) (url (getprop filebox :url)) (pathname (or (getprop filebox :associated-file) (when (and url (typep url 'boxnet::local-url)) (boxnet::local-url-pathname url))))) (multiple-value-bind (origin-type file-format read-only? fmodified?) (get-box-file-props filebox) #| ;; this is now handled (as it should be) in the menu-update #+mcl ;; dynamically adjust the file menu... (let ((save-item (find "Save" (slot-value *boxer-file-menu* 'ccl::item-list) :test #'(lambda (a b) (string-equal a (ccl::menu-item-title b))))) ;(save-box-as-item (find "Save Box As..." (slot-value *boxer-file-menu* ; 'ccl::item-list) ; :test #'(lambda (a b) ; (string-equal ; a (ccl::menu-item-title b))))) ) ;; grey out File menu items if they are redundant or not applicable ;; "Save" is not applicable if there is not an existing filename ;; or if the file box has not been modified... (if (or read-only? (null pathname) (not (file-modified? filebox))) (ccl::menu-item-disable save-item) (ccl::menu-item-enable save-item)) ;; "Save Box As..." is redundant with "Save As"if the ;; cursor is in the same box as the document box ; (if (eq filebox (point-box)) ; (ccl::menu-item-disable save-box-as-item) ; (ccl::menu-item-enable save-box-as-item)) ) |# ;; print into the *file-status-string* (clear-file-status-string) (catch 'status-string-end (flet ((add-string (string) (let ((result (add-string-to-file-status string))) (when (eq result t) (throw 'status-string-end nil))))) ;; first (maybe) indicate file modified status (when (and (not vanilla?) fmodified?) (add-string #+mcl "� " #-mcl "* ")) ;;; print +mcl the box name... (add-string "File Box: ") (add-string box-name) (add-string #+mcl " � " #-mcl " | ") ;; now add info about the where the box came from... (add-string "From: ") (unless (and (null pathname) (not (eq origin-type :network))) ;; leave the where field blank if we dont have a name... (let ((adjectives nil)) (when (and read-only? (not (eq origin-type :network))) (add-string (if *terse-file-status* "(RO) " "Read Only ")) (setq adjectives t)) (case origin-type (:network (if *terse-file-status* (add-string "(net) ") (add-string "Network ")) (setq adjectives t)) (:disk (when *terse-file-status* (add-string "(disk) ")))) (unless (eq file-format :box) (add-string (string-capitalize file-format)) (add-string " ") (setq adjectives t)) (when (and adjectives (not *terse-file-status*))(add-string "file ")) (cond ((not (null pathname)) (add-string (pathname-name pathname)) (let ((type (pathname-type pathname))) (unless (or (null type) (eq type :unspecific)) (add-string ".") (add-string type))) (add-string " ") (unless *terse-file-status* ;; skip directory if terse but print something... (let ((raw-dirs (pathname-directory pathname))) (add-string "{") (when (listp raw-dirs) ; could be :unspecific (dolist (dir (cdr raw-dirs)) (add-string dir) (add-string #+mcl ":" #-mcl "/"))) (add-string "}")))) ((eq origin-type :network) (add-string (boxnet::scheme-string url)))))))) *file-status-string*))))) (defvar *max-filename-length* 50) ;; pathnames derived from other platforms wont parse into directories correctly (defun truncated-filename (pathname) (unless (pathnamep pathname) (setq pathname (pathname pathname))) (let* ((dirs (pathname-directory pathname)) (name (pathname-name pathname)) (type (pathname-type pathname)) (lname (length name)) (ltype (length type)) (ellipsis? t) (endsize (cond ((and (null name) (or (null type) (eq type ':unspecific))) (setq ellipsis? nil) 0) ((or (null type) (eq type ':unspecific)) (+ 3 lname)) ((null name) (+ 3 ltype)) (t (+ 3 lname 1 ltype)))) (return-string (make-string *max-filename-length*)) (dirstop (max& 0 (- *max-filename-length* endsize))) (idx 0)) ;(declare (dynamic-extent return-string)) (flet ((add-char (&optional (char #+mcl #\: #-mcl #\/)) (when (= idx dirstop) (throw 'dir-exit nil)) (setf (char return-string idx) char) (incf idx)) (add-string (string &optional (throw? t)) (let ((end (length string))) (do ((i 0 (1+ i))) ((or (= i end) (= idx *max-filename-length*))) (when (and throw? (= idx dirstop)) (throw 'dir-exit nil)) (setf (char return-string idx) (char string i)) (incf idx)))) (add-ellipsis () (dotimes (i 3) (setf (char return-string idx) #\.) (incf idx)))) (when (eq (car dirs) :relative) (add-char)) (catch 'dir-exit (unless (zerop dirstop) (dolist (dir (cdr dirs) (setq ellipsis? nil)) (add-string dir) (add-char)))) (unless (null ellipsis?) (add-ellipsis)) (cond ((zerop dirstop) ;; this means the name.type is already longer than the alloted space (cond ((null type) (do ((nidx (+ (- lname *max-filename-length*) 3) (1+ nidx))) ((>= idx *max-filename-length*)) (setf (char return-string idx) (char name nidx)) (incf idx))) (t ;; truncated name (do ((nidx (+ (- lname *max-filename-length*) 3 1 ltype) (1+ nidx))) ((>= idx (- *max-filename-length* ltype 1))) (setf (char return-string idx) (char name nidx)) (incf idx)) (add-char #\.) ;; and now the type (do ((i 0 (1+ i))) ((or (= i ltype) (= idx *max-filename-length*))) (setf (char return-string idx) (char type i)) (incf idx))))) ((and (null name) (or (null type) (eq type ':unspecific)))) ((or (null type) (eq type ':unspecific)) (add-string name nil)) ((null name) (add-string type nil)) (t (add-string name nil) (add-char #\.) (add-string type nil)))) (if (< idx *max-filename-length*) (subseq return-string 0 idx) return-string))) ;; walk up (backwards up the list) the path looking for a match in the ;; superior dirs ;; NOTE: not quite right, we should modify the sup-pathname as well to prune lower level ;; directories which do not match (defun dmerge-dirs (path sup-path) (let ((merged-dirs nil) (sup-dirs (cdr (pathname-directory sup-path)))) (do* ((dirs (reverse (cdr (pathname-directory path))) (cdr dirs)) (dir (car dirs) (car dirs))) ((null dir) nil) (if (member dir sup-dirs :test #'string-equal) (return (append '(:relative) merged-dirs)) (push dir merged-dirs))))) ;; see if the file exists. ;; when not being strict check for ".box" or no "".box" (defun probe-search-file (pathname) (cond ((null *strict-box-paths*) (or (probe-file pathname) (probe-file (make-pathname :type (let ((current-type (pathname-type pathname))) (cond ((or (null current-type) (eq current-type :unspecific)) "box") ((string-equal current-type "box") :unspecific) (t current-type))) :defaults pathname)))) (t (probe-file pathname)))) ;; need to hack relative pathnames here... (defun fill-box-from-local-file (box) (catch 'cancel-boxer-file-dialog (let* ((raw-pathname (getprop box :associated-file)) (raw-dirs (and raw-pathname (pathname-directory raw-pathname))) (sup-box (superior-box box)) (sup-file-box (current-file-box sup-box)) (sup-pathname (getprop sup-file-box :associated-file)) (pathname (cond ((and (eq (car raw-dirs) :absolute) (probe-search-file raw-pathname))) ((and (or (eq (car raw-dirs) :relative) ;; if the relative path is just a name, ;; raw-dirs will be null (null raw-dirs)) (or *autoloading-namestring* sup-pathname) (let ((merged-pathname (merge-pathnames (make-pathname :directory raw-dirs :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) (or *autoloading-namestring* sup-pathname)))) (probe-search-file merged-pathname)))) ;; now try various simple guesses ((let ((merged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) sup-pathname)))) (and merged-pathname (probe-search-file merged-pathname)))) ((let ((autoload-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and autoload-pathname (probe-search-file autoload-pathname)))) ;; directory merging guesses... ((let ((dmerged-pathname (unless (null sup-pathname) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname sup-pathname) :name (pathname-name raw-pathname) :type (pathname-type raw-pathname)) sup-pathname)))) (and dmerged-pathname (probe-search-file dmerged-pathname)))) ((let ((admerged-pathname (unless (null *autoloading-namestring*) (merge-pathnames (make-pathname :directory (dmerge-dirs raw-pathname *autoloading-namestring*) :name (pathname-name raw-pathname) :type (or (pathname-type raw-pathname) :unspecific)) *autoloading-namestring*)))) (and admerged-pathname (probe-search-file admerged-pathname)))) ;; guesses are all wrong, so ask the user ((and *prompt-for-server-file-not-found* (not (null *autoloading-namestring*))) (boxer-open-lost-file-dialog :prompt "(While Autoloading) Can't find" :directory raw-pathname)) (*prompt-for-server-file-not-found* (boxer-open-lost-file-dialog :prompt "Can't find" :directory raw-pathname)) ;; nothing works, return the original pathname for error message (t raw-pathname))) ;; allow an out if cached pathname is not valid (filebox (read-internal-1 pathname)) (old-ds (display-style box))) (initialize-box-from-box box filebox) ;; the vanilla init will take the display style from the file box ;; if we are autoloading, we want to use the file's display style (unless (autoload-file? box) (case old-ds (:shrunk (shrink box)) (:supershrunk (boxer::supershrink box)))) ;; if the box is transparent, export it's bindings (unless (null (exports box)) ;; this is the relevant guts of boxer-eval::set-exports without the checks ;; and setting of the exports slots (which are already set from the file) ;; will break if we ever use a selective exporting mechanism which ;; doesn't look too probably at the moment (let ((superior-box (superior-box box))) (unless (null superior-box) (boxer-eval::propagate-all-exported-bindings box superior-box) (boxer-eval::export-inferior-properties box superior-box)))) ;; if there is a cached boxtop, remove it in favor of the one being ;; read in from the file (let ((cb (getprop box :cached-boxtop))) (unless (null cb) (when (graphics-sheet? cb) (let ((bm (graphics-sheet-bit-array cb))) (unless (null bm) (deallocate-bitmap bm)))) (removeprop box :cached-boxtop))) ;; this the old style boxtop caching.... (convert to new style) (let ((bp (getprop box :boxtop))) (cond ((graphics-sheet? bp) (putprop box :standard :boxtop)) ((null bp) ;; add :file boxtop here when converting from old style. THis ;; seems more economical than hairing up dump or load (putprop box :file :boxtop)))) ;; now do the box/file bookkeeping, ;; NOTE: It has to be here AFTER the initialize-box-from-box (when (box? box) ;(boxnet::read-box-postamble box) ;(part of the Boxer Server) no longer used (mark-box-as-file box pathname) (if (and (not (equal pathname raw-pathname)) ;; don't mark dirty if we just articulated a relative pathname ;; unless the directory path has actually changed (not (and (or (null (pathname-directory raw-pathname)) (eq (pathname-directory raw-pathname) :relative)) (subsetp (cdr (pathname-directory raw-pathname)) (cdr (pathname-directory pathname)))))) (mark-file-box-dirty box) (mark-file-box-clean box))) ;; record in place menu ? ; removed for UC "clean" implementation ;; keep track of the file properties so that we can check (record-boxer-file-properties pathname (file-write-date pathname) (file-author pathname) box) box))) ;;; In case redisplay breaks,. people can still do... (defun salvage-boxer-world (&optional (save-name "salvaged-world") (verbose t)) (let ((world-save-name (merge-pathnames save-name *boxer-pathname-default*))) ;; first make sure the name is ok (loop (when (yes-or-no-p "~%Save Your Boxer World in ~A ? " world-save-name) ;; we are happy with the name, then save it away ;; otherwise, prompt for a new name (format t "~%New File Name to Save in: ") (setq world-save-name (merge-pathnames (read-line) world-save-name)))) ;; then save it away verbosely (when verbose (format t "~%Dumping boxer world to ~A" world-save-name)) (dump-top-level-box *initial-box* world-save-name) ;; now verify (when verbose (format t "~%Verifying Saved file")) (load-binary-box-internal world-save-name) (format t "~%Boxer World Saved to ~A" world-save-name) (values))) ;;; spread it around (import 'salvage-boxer-world (find-package 'user)) (import 'salvage-boxer-world (find-package :boxer-window)) (import 'salvage-boxer-world (find-package :boxer-eval)) ;; might as well be paranoid... (import 'salvage-boxer-world (find-package :boxer-user)) ;;; (boxer-eval::defboxer-primitive bu::storage-name ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-vc (list (make-evrow-from-string (namestring file))))) ((not (null url)) (make-vc (list (make-evrow-from-string (boxnet::urlstring url))))) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-vc (list (make-evrow-from-string (namestring path)))))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (boxer-eval::defboxer-primitive bu::storage-info ((bu::port-to box)) (let ((target (box-or-port-target box))) (cond ((box? target) (let ((file (getprop target :associated-file)) (url (getprop target :url)) (xref (getprop target :xref))) (cond ((not (null file)) (make-file-storage-info-box file)) ((not (null url)) (make-url-storage-info-box url)) ((not (null xref)) (let ((path #+mcl (mac-file-ref-pathname xref) #-mcl nil)) (cond ((null path) (make-empty-vc)) (t (make-file-storage-info-box path))))) (t (make-empty-vc))))) (t (make-empty-vc))))) (defun destructure-pathname (pathname) (values (pathname-host pathname) (pathname-device pathname) (pathname-directory pathname) (pathname-name pathname) (pathname-type pathname))) ;; consider making empty boxes for null fields instead of omitting entirely ;; 2/1/03 We should have empty boxes since people will be using TELL to ;; grab fields and we shoudl have something for the names to avoid errors (defun make-file-storage-info-box (pathname) (multiple-value-bind (host device directory name type) (destructure-pathname pathname) (make-file-storage-info-box-internal host device (car directory) (cdr directory) name type))) (defun make-file-storage-info-box-internal (host device dir-type dir name type) (make-vc (list (make-vc (unless (or (null host) (eq host :unspecific)) (list (make-evrow-from-string host))) 'data-box 'bu::Host) (make-vc (unless (or (null device) (eq device :unspecific)) (list (make-evrow-from-string device))) 'data-box 'bu::Device) (make-vc (list (make-evrow-from-string dir-type)) 'data-box 'bu::directory-type) (make-vc (mapcar #'(lambda (d) (make-evrow-from-string d)) dir) 'data-box 'bu::directory) (make-vc (unless (null name) (list (make-evrow-from-string name))) 'data-box 'bu::name) (make-vc (unless (or (null type) (eq type :unspecific)) (list (make-evrow-from-string type))) 'data-box 'bu::type)) 'data-box)) (defun make-url-storage-info-box (url) (make-vc (let ((url-info-sub-boxes nil)) (do* ((value-pairs (boxnet::url-values url) (cddr value-pairs)) (name (car value-pairs) (car value-pairs)) (value (cadr value-pairs) (cadr value-pairs))) ((null value-pairs)) (push (make-vc (list (make-evrow-from-string value)) 'data-box (intern-in-bu-package (string-upcase name))) url-info-sub-boxes)) (nreverse url-info-sub-boxes)))) ;; like destructure-pathname, returns (values host device directory name type) (defun destructure-file-info-box (file-info-box) (let* ((box (box-or-port-target file-info-box)) (host (lookup-variable-in-box-only box 'bu::host)) (device (lookup-variable-in-box-only box 'bu::device)) (dir-type (lookup-variable-in-box-only box 'bu::directory-type)) (dir (lookup-variable-in-box-only box 'bu::directory)) (name (lookup-variable-in-box-only box 'bu::name)) (type (lookup-variable-in-box-only box 'bu::type))) (values (if (empty-box? host) :unspecific (box-text-string host)) (if (empty-box? device) :unspecific (box-text-string device)) (cond ((string-equal (box-text-string dir-type) "RELATIVE") :relative) (t :absolute)) (with-collection (dolist (er (get-box-rows dir)) (collect (evrow-text-string er dir)))) (box-text-string name) (if (empty-box? type) :unspecific (box-text-string type))))) (boxer-eval::defboxer-primitive bu::file-info-to-file (file-info) (multiple-value-bind (host device dir-type dir name type) (destructure-file-info-box file-info) (make-vc (list (make-evrow-from-string (namestring (make-pathname :host host :device device :directory (list* dir-type dir) :name name :type type)))) 'data-box))) (boxer-eval::defboxer-primitive bu::file-to-file-info (filename) (let ((pathname-string (box-text-string filename))) (make-file-storage-info-box pathname-string))) (boxer-eval::defboxer-primitive bu::merge-file-info (info1 info2) (multiple-value-bind (host1 dev1 dir-type1 dir1 name1 type1) (destructure-file-info-box info1) (multiple-value-bind (host2 dev2 dir-type2 dir2 name2 type2) (destructure-file-info-box info2) (make-file-storage-info-box-internal (if (or (null host1) (eq host1 :unspecific)) host2 host1) (if (or (null dev1) (eq dev1 :unspecific)) dev2 dev1) (if (or (eq dir-type1 :absolute) (eq dir-type2 :absolute)) :absolute :relative) (cond ((eq dir-type1 :absolute) dir1) ((eq dir-type2 :absolute) (append dir2 dir1)) (t (append dir2 dir1))) (if (null name1) name2 name1) (if (or (null type1) (eq type1 :unspecific)) type2 type1))))) ;;; This is just a crock, but at least it will work on the Suns as long ;;; as there's only one Boxer per machine. (defun make-temporary-filename (info) (format nil "/tmp/boxer-~a" info)) (defun read-box-from-text-stream (stream) stream boxer-eval::*novalue*) ;;; ;;; COMPRESS-FILE. ;;; ;;; These are for saving space on unix filesystems. They should go away ;;; when Ed rewrites the file system make smaller files. ;;; The user can call COMPRESS-FILE. READ will try to uncompress a file ;;; if it doesn't exist. (defun compress-file (pathname) #+Unix (progn (make-backup-if-necessary (concatenate 'string (namestring pathname) ".Z")) (boxer-run-unix-program "compress" (list "-f" (namestring pathname)))) #-Unix (progn pathname nil)) (defun uncompress-file (pathname) #+Unix (boxer-run-unix-program "uncompress" (list (namestring pathname))) #-Unix (progn pathname nil)) (defun maybe-uncompress-file (pathname) #+Unix (when (and (null (probe-file pathname)) (probe-file (concatenate 'string (namestring pathname) ".Z"))) #+Lucid (uncompress-file pathname) #-Lucid nil) #-Unix (progn pathname nil)) #-mcl (boxer-eval::defboxer-primitive bu::compress-file ((boxer-eval::dont-copy name)) (let ((filename (if (numberp name) (format nil "~D" name) (box-text-string name)))) (if (null (probe-file filename)) (boxer-eval::signal-error :FILE-NOT-FOUND (boxer-eval::copy-thing name)) (let ((error-string (compress-file filename))) (if (null error-string) boxer-eval::*novalue* (boxer-eval::signal-error :COMPRESS-FILE error-string)))))) ;;; ;;; boxer-run-unix-program ;;; ;;; Returns NIL if succesful, otherwise a list of error strings. ;;; ;;; We have to run the program asynchronously in order to get the ;;; error output into a stream. ;;; Didn't do anything about stdout, though. (defun boxer-run-unix-program (program-name arguments) #+Unix (let ((error-result #+Lucid (multiple-value-bind (stream error-output-stream exit-status process-id) ;; We can't do both :error-output :stream ;; and :wait t, so we have to assume that the process ;; is finished when when we find out that the error-output-stream ;; is done. (system::run-program program-name :arguments arguments :wait nil :if-error-output-exists nil :error-output :stream) (declare (ignore stream process-id)) (if error-output-stream (prog1 (do* ((string (read-line error-output-stream nil nil) (read-line error-output-stream nil nil)) (result nil)) ((null string) (nreverse result)) (unless (null string) (push string result))) (close error-output-stream)) (format nil "Unknown Unix Error ~D" exit-status))) #-Lucid "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (if (stringp error-result) (boxer-eval::primitive-signal-error :UNIX-PROGRAM-ERROR error-result) nil)) #-Unix (progn program-name arguments "BOXER-RUN-UNIX-PROGRAM not implemented on this system")) (defun fix-file-alus (top-box &optional (sun->mac? t)) (labels ((fix-gl (gl) (setf (graphics-command-list-alu gl) (convert-file-alu (graphics-command-list-alu gl) sun->mac?)) (do-vector-contents (gc gl) (when (member (aref gc 0) '(0 32) :test #'=) ;; if it is an CHANGE-ALU command.... (setf (aref gc 1) (convert-file-alu (aref gc 1) sun->mac?))))) (fix-box (box) (let ((graphics-sheet (graphics-sheet box))) (when (not (null graphics-sheet)) (let ((gl (graphics-sheet-graphics-list graphics-sheet))) (unless (null gl) (fix-gl gl))))) (when (sprite-box? box) (let* ((turtle (slot-value box 'associated-turtle)) (shape (shape turtle)) (ws (slot-value turtle 'window-shape))) (fix-gl shape) (fix-gl ws))))) (fix-box top-box) (do-for-all-inferior-boxes-fast (inf-box top-box) (fix-box inf-box)))) ;; order is (sun-alu . mac-alu) (defvar *file-conversion-alu-alist* '((2 . 3) ; alu-andca (5 . 0) ; alu-seta (6 . 2) ; alu-xor (7 . 1) ; alu-ior (0 . 11))) ; alu-setz (defun convert-file-alu (old-alu sun->mac?) (if sun->mac? (or (cdr (assoc old-alu *file-conversion-alu-alist* :test #'=)) 0) (or (car (rassoc old-alu *file-conversion-alu-alist* :test #'=)) 5))) (boxer-eval::defboxer-primitive bu::fix-sun-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box)) boxer-eval::*novalue*) (boxer-eval::defboxer-primitive bu::fix-mac-file-graphics ((bu::port-to box)) (fix-file-alus (box-or-port-target box) nil) boxer-eval::*novalue*)
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n\n(in-package \"VL\")\n;; (inclu", "end": 1390, "score": 0.9997191429138184, "start": 1379, "tag": "NAME", "value": "Jared Davis" }, { "context": "N THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n\n(in-package \"VL\")\n;; (include-book \"datatype-to", "end": 1410, "score": 0.9999345541000366, "start": 1392, "tag": "EMAIL", "value": "[email protected]" } ]
books/centaur/vl/mlib/hid-tools.lisp
jaredcdavis/acl2
1
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Jared Davis <[email protected]> (in-package "VL") ;; (include-book "datatype-tools") (include-book "scopestack") (include-book "expr-tools") (include-book "coretypes") (include-book "../util/sum-nats") (local (include-book "../util/arithmetic")) (local (include-book "centaur/misc/arith-equivs" :dir :system)) (local (in-theory (enable tag-reasoning))) (local (in-theory (disable (tau-system)))) (local (std::add-default-post-define-hook :fix)) (local (defthm equal-of-cons-rewrite (equal (equal x (cons a b)) (and (consp x) (equal (car x) a) (equal (cdr x) b))))) (defthm vl-genelement-kind-by-tag (implies (and (vl-genelement-p x) (equal (tag x) foo) (syntaxp (quotep foo))) (equal (vl-genelement-kind x) foo)) :hints(("Goal" :in-theory (enable tag vl-genelement-kind vl-genelement-p)))) (defxdoc following-hids :parents (hid-tools) :short "Functions for following hierarchical identifiers." :long "<p>Perhaps the most fundamental operation for a hierarchical identifier is figure out what it refers to. This turns out to be a surprisingly challenging and nuanced process.</p> <p>Our top-level routine for following hierarchical identifiers is @(see vl-follow-hidexpr). It is meant to make looking up hierarchical identifiers convenient despite these complications.</p> <p>We now describe some of these challenges and how @(see vl-follow-hidexpr) deals with them.</p> <dl> <dt>Datatypes versus Scopes</dt> <dd>Challenge: The same syntax is used to refer to both data structure members like @('myinst.opcode') and also to scopes like @('mysubmod.mywire'). However, structures and scopes are very different and need to be traversed in different ways.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows only the scope-based part of the HID. However, as one of our return values, we provide the tail of the hierarchical index that leads into this variable. For instance, in a case like @('foo.bar.myinst.opcode') where @('myinst') is an @('instruction_t') structure variable, we will follow only until the declaration of @('myinst') and then we will return @('myinst.opcode') as the tail.</dd> <dd>Tools that want to descend into structures will need to do so using the appropriate functions; for instance @(see BOZO) and @(see BOZO).</dd> <dt>Unclear Destination</dt> <dd>Challenge: Depending on the kind of analysis being done, we might want to continue or stop resolving at certain points. For instance, if we are trying to size a hierarchical identifier like @('myinterface.ready'), we probably want to follow through the interface all the way to the @('ready') signal. However, for light-weight variable use analysis, we may want to stop as soon as we hit an interface.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows the HID as far as possible, but returns a @(see vl-hidtrace-p) that includes not only the final declaration we arrive at, but also all intermediate points along the way. If you only care about the final destination (e.g., the @('ready') signal for sizing or similar) then you can get this final destination from the first @(see vl-hidstep-p) in the trace. But if you also want to know, e.g., that @('myinterface') has been used, this information can easily be extracted from the rest of the trace.</dd> <dt>Unresolved Parameters</dt> <dd>Challenge: Because of parameters, we may not be able to tell whether the indices in a hierarchical identifier are valid. For instance, if there is an array of module instances like @('mymod myarr [width-1:0] (...)') and we are trying to follow a hierarchical reference like @('foo.bar.myarr[7].baz'), then we will not know whether this is valid until we have resolved @('width').</dd> <dd>In some applications, e.g., for @(see lint)-like tools, it may be best to allow these potentially invalid indices. After all, we \"know\" that this reference is either invalid or is a reference to @('baz') within @('mymod'). In that case, we may well wish to assume that the index will be valid and just go on and find @('baz').</dd> <dd>However, some other applications have more stringent soundness constraints. If we are writing transforms that are meant to build conservative, safe, formal models of the Verilog code, we may instead want to insist that all of the indices have been resolved and cause an error if this is not the case.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) always tries to check that indices are in bounds and to cause errors when indices are clearly out of bounds. If we encounter indices that are potentially out of bounds, then we can do one of two things: <ul> <li>By default, we are permissive and assume the index will be in bounds.</li> <li>However, if @(':strictp') is enabled, we will cause an error.</li> </ul></dd> <dd>As a special note: we always require generate array indices to be resolved. See @(see vl-follow-hidexpr) for additional discussion.</dd> <dt>Error reporting</dt> <dd>Challenge: A HID may be invalid in many different ways. Any part of the HID may try to refer to a name that does not exist, and any index along the HID might be invalid. If an error occurs, we should provide enough detail to understand the problem.</dd> <dd>Our Approach: In the case of any error, @(see vl-follow-hidexpr) returns a message. Callers should put this message in the appropriate context so that the end-user can understand the nature and location of the problem.</dd> </dl>") (local (xdoc::set-default-parents following-hids)) (defprod vl-hidstep :short "A single step along the way of a hierarchical identifier." :long "<p>Some routines for @(see following-hids) produce traces of the items they encounter along the way. A <b>hidstep</b> structure represents a single step along a HID.</p>" :tag :vl-hidstep :layout :tree ((name stringp "Name from the hid") (index vl-maybe-expr-p "Instance array/genarray index, if present") (item vl-scopeitem-p "The item encountered along the path of the HID.") (ss vl-scopestack-p "The scope where this item was found."))) (fty::deflist vl-hidtrace :elt-type vl-hidstep :short "A list of @(see vl-hidstep) structures, typically all of the steps encountered along a HID.") (define vl-scopeexpr->hid ((x vl-scopeexpr-p)) :returns (hid vl-hidexpr-p) :short "Finds the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end x.hid :colon (vl-scopeexpr->hid x.rest)) /// (defret count-of-vl-scopeexpr->hid (< (vl-hidexpr-count hid) (vl-scopeexpr-count x)) :rule-classes :linear)) (define vl-scopeexpr-replace-hid ((x vl-scopeexpr-p) (new-hid vl-hidexpr-p)) :returns (new-x vl-scopeexpr-p) :short "Replaces the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) :verify-guards nil (vl-scopeexpr-case x :end (change-vl-scopeexpr-end x :hid new-hid) :colon (change-vl-scopeexpr-colon x :rest (vl-scopeexpr-replace-hid x.rest new-hid))) /// (verify-guards vl-scopeexpr-replace-hid)) (define vl-subhid-p ((inner vl-hidexpr-p) (outer vl-hidexpr-p)) :measure (vl-hidexpr-count outer) (if (vl-hidexpr-equiv inner outer) (vl-hidexpr-case outer :end t :dot (stringp (vl-hidindex->name outer.first))) (vl-hidexpr-case outer :dot (vl-subhid-p inner outer.rest) :otherwise nil))) (define vl-hid-prefix-for-subhid ((outer vl-hidexpr-p) (inner vl-hidexpr-p)) :guard (vl-subhid-p inner outer) :returns (prefix-hid vl-hidexpr-p) :measure (vl-hidexpr-count outer) :verify-guards nil (vl-hidexpr-case outer :end (vl-hidexpr-fix outer) ;; must be the inner one since it's the last :dot (if (vl-hidexpr-equiv inner outer) (make-vl-hidexpr-end :name (vl-hidindex->name outer.first)) (make-vl-hidexpr-dot :first outer.first :rest (vl-hid-prefix-for-subhid outer.rest inner)))) /// (verify-guards vl-hid-prefix-for-subhid :hints (("goal" :expand ((vl-subhid-p inner outer) (vl-subhid-p inner inner)))))) (define vl-follow-hidexpr-error :short "Report an error while following a HID." ((short vl-msg-p "Brief description of the error.") (ss vl-scopestack-p "Detailed context for the error.") &key ((origx vl-scopeexpr-p "Original, full HID being resolved.") 'origx) ((x vl-hidexpr-p "Current place in the HID.") 'x)) :returns (msg vl-msg-p) :long "<p>This is smart in a few ways: it distinguishes between ordinary identifiers and hierarchical identifiers in the error type, and avoids providing excessive context if we haven't gotten anywhere down into the HID yet.</p>" (b* ((x (vl-hidexpr-fix x)) (origx (vl-scopeexpr-fix origx)) (short (vl-msg-fix short)) (endp (vl-scopeexpr-case origx :end)) ((when (and endp (equal x (vl-scopeexpr-end->hid origx)))) ;; Omit detailed context since we haven't gotten anywhere yet. (vmsg "error resolving ~a1: ~@2." nil origx short))) (vmsg "error resolving ~a1: ~@2.~%~ (Failed to resolve ~a3 in ~s4)." nil origx short x (vl-scopestack->path ss)))) (define vl-follow-hidexpr-dimcheck :short "Check an array index against the corresponding array bounds." ((name stringp "Name being the array, for better errors.") (index vl-expr-p "An index into an array.") (dim vl-packeddimension-p "Bounds from the corresponding declaration.") &key (strictp booleanp "Require indices to be resolved?")) :returns (err (iff (vl-msg-p err) err)) :long "<p>In strict mode, we require that the @('index') and the array dimensions all be resolved and that the index be in range.</p> <p>In non-strict mode, we tolerate unresolved indices and declaration bounds. Note that we still do bounds checking if the indices and array bounds happen to be resolved.</p>" (b* ((dim (vl-packeddimension-fix dim)) ((when (vl-packeddimension-case dim :unsized)) ;; Bounds checking doesn't make sense in this case, so we'll just ;; regard this as fine. nil) (dim (vl-packeddimension->range dim)) ((unless (vl-expr-resolved-p index)) (if strictp (vmsg "unresolved array index") nil)) ((unless (vl-range-resolved-p dim)) (if strictp (vmsg "unresolved bounds on declaration of ~s0" (string-fix name)) nil)) ((vl-range dim)) (idxval (vl-resolved->val index)) (msbval (vl-resolved->val dim.msb)) (lsbval (vl-resolved->val dim.lsb)) (minval (min msbval lsbval)) (maxval (max msbval lsbval)) ((unless (and (<= minval idxval) (<= idxval maxval))) (vmsg "array index ~x0 out of bounds (~x1 to ~x2)" idxval minval maxval))) nil)) (define vl-follow-hidexpr-dimscheck-aux :parents (vl-follow-hidexpr-dimscheck) :short "Main loop to check each index/dimension pair." :prepwork ((local (defthm vl-exprlist-fix-of-atom (implies (not (consp x)) (equal (vl-exprlist-fix x) nil))))) ((name stringp) (indices vl-exprlist-p) (dims vl-packeddimensionlist-p) &key (strictp booleanp)) :guard (same-lengthp indices dims) :returns (err (iff (vl-msg-p err) err)) (if (atom indices) nil (or (vl-follow-hidexpr-dimcheck name (car indices) (car dims) :strictp strictp) (vl-follow-hidexpr-dimscheck-aux name (cdr indices) (cdr dims) :strictp strictp)))) (define vl-follow-hidexpr-dimscheck :short "Check array indices against the corresponding array bounds." ((name stringp) (indices vl-exprlist-p "Indices from the HID piece we're following. I.e., if we are resolving @('foo[3][4][5].bar'), this would be @('(3 4 5)') as an expression list.") (dims vl-packeddimensionlist-p "Corresponding dimensions from the declaration, i.e., if @('foo') is declared as a @('logic [7:0][15:0][3:0]'), then this would be the list of @('([7:0] [15:0] [3:0])').") &key (strictp booleanp "Should we require every index to be resolved?")) :returns (err (iff (vl-msg-p err) err)) (b* ((name (string-fix name)) ((when (atom dims)) (if (atom indices) nil (vmsg "indexing into non-array ~s0" name))) ((when (atom indices)) (vmsg "no indices given for array ~s0" name)) ((when (same-lengthp indices dims)) (vl-follow-hidexpr-dimscheck-aux name indices dims :strictp strictp)) (found (len indices)) (need (len dims)) ((when (< found need)) (vmsg "too many indices for array ~s0" name))) (vmsg "not enough indices for array ~s0" name))) (define vl-genarrayblocklist-find-block :short "Find the block from a generate array corresponding to some index." ((idx integerp) (x vl-genarrayblocklist-p)) :returns (blk (iff (vl-genarrayblock-p blk) blk)) (cond ((atom x) nil) ((eql (vl-genarrayblock->index (car x)) (lifix idx)) (vl-genarrayblock-fix (car x))) (t (vl-genarrayblocklist-find-block idx (cdr x))))) (local (defthm stringp-when-hidname-and-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (with-output :evisc (:gag-mode (evisc-tuple 3 4 nil nil) :term nil) :off (event) (define vl-follow-hidexpr-aux :parents (vl-follow-hidexpr) :short "Core routine for following hierarchical identifiers." ((x vl-hidexpr-p "HID expression fragment that we are following.") (trace vl-hidtrace-p "Accumulator for the trace until now.") (ss vl-scopestack-p "Current scopestack we're working from.") &key (strictp booleanp) ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx)) :returns (mv (err (iff (vl-msg-p err) err) "A @(see vl-msg-p) on any error.") (new-trace vl-hidtrace-p "On success, a nonempty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final item and scopestack.") (tail vl-hidexpr-p "Remainder of @('x') after arriving at the declaration.")) :long "<p>See @(see vl-follow-hidexpr) for detailed discussion. This @('-aux') function does most of the work, but for instance it doesn't deal with top-level hierarchical identifiers.</p>" :measure (vl-hidexpr-count x) :prepwork ((local (defthm vl-scope-p-when-vl-module-p-strong (implies (or (vl-module-p x) (vl-interface-p x)) (vl-scope-p x)))) (local (in-theory (disable double-containment tag-reasoning))) (local (defthm vl-maybe-expr-p-of-car-exprlist (implies (vl-exprlist-p x) (vl-maybe-expr-p (car x)))))) :hooks ((:fix :hints(("Goal" :expand ((:free (trace ss strictp) (vl-follow-hidexpr-aux x trace ss :strictp strictp)) (:free (trace ss strictp) (vl-follow-hidexpr-aux (vl-expr-fix x) trace ss :strictp strictp))))))) (b* ((trace (vl-hidtrace-fix trace)) (x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error (vmsg "$root is not yet supported") ss) trace x)) ((mv item item-ss) (vl-scopestack-find-item/ss name1 ss)) ((unless item) (mv (vl-follow-hidexpr-error (vmsg "item not found") ss) trace x)) ((when (or (eq (tag item) :vl-vardecl) (eq (tag item) :vl-paramdecl))) ;; Found the declaration we want. We aren't going to go any further: ;; there may be additional HID indexing stuff left, but if so it's just ;; array or structure indexing for the tail. (b* ((trace (cons (make-vl-hidstep :name name1 :item item ;; No indices -- they belong to ;; the variable :ss item-ss) trace))) (mv nil trace x))) ;; From here on out, if the trace is good and the index exists, the ;; trace includes that index. (trace (cons (make-vl-hidstep :name name1 :item item :index (car indices) :ss item-ss) trace)) ((when (or (eq (tag item) :vl-fundecl) (eq (tag item) :vl-taskdecl))) (if (eq kind :end) ;; Plain reference to, e.g., foo.bar.myfun. This is OK -- you ;; might be writing something like ``logic foo = submod.fn(arg)'' (mv nil trace x) ;; Indexed or dotted reference like foo.bar.myfun[3] or ;; foo.bar.myfun[3].baz or foo.bar.myfun.baz, none of which seem to ;; really be reasonable as things to refer to hierarchically. (mv (vl-follow-hidexpr-error (vmsg (if (eq (tag item) :vl-fundecl) "hierarchical reference into function" "hierarchical reference into task")) item-ss) trace x))) ((when (eq (tag item) :vl-modinst)) (b* (((vl-modinst item)) (dims (and item.range (list (vl-range->packeddimension item.range)))) ;; Start by checking for sensible array indexing. (err (vl-follow-hidexpr-dimscheck name1 indices dims :strictp strictp)) ((when err) (mv (vl-follow-hidexpr-error err item-ss) trace x)) ((when (eq kind :end)) ;; Reference to foo.bar.myinst with no more indexing into myinst. ;; This might not make a lot of sense for a module instance, but ;; it probably *does* make sense for an interface instance. It ;; seems reasonable to just say this is OK and let the caller ;; figure out what to do with the module instance. (mv nil trace x)) ;; Else we're indexing through the instance. We need to go look ;; up the submodule and recur. ((mv mod mod-ss) (vl-scopestack-find-definition/ss item.modname item-ss)) ((unless mod) (mv (vl-follow-hidexpr-error (vmsg "reference through missing module ~s0" item.modname) item-ss) trace x)) (modtag (tag mod)) ((when (eq modtag :vl-udp)) (mv (vl-follow-hidexpr-error (vmsg "reference through primitive ~s0" item.modname) item-ss) trace x)) ((unless (or (eq modtag :vl-module) (eq modtag :vl-interface))) (mv (vl-follow-hidexpr-error (vmsg "module instance ~s0 of ~s1: invalid type ~x2???" name1 item.modname modtag) item-ss) trace x)) (next-ss ;; The MOD-SS is just the scopestack for where the module is ;; defined, which in practice will be the top level scope. ;; The next part of the HID needs to be looked up from within ;; MOD, so we need to actually go into the module. (vl-scopestack-push mod mod-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-interfaceport)) (b* (((vl-interfaceport item)) ((when (or (consp indices) (consp item.udims))) ;; BOZO. What kind of index checking do we want to do? Probably ;; it is ok to index only partly into an interface port, because ;; if it's okay to have an array of interfaces coming in, then ;; it's probably ok to stick an array of interfaces into a ;; submodule, etc. So maybe we need to just check that we have ;; no more indices than are allowed, and then check ranges on any ;; indices that we do happen to have... (mv (vl-follow-hidexpr-error "BOZO implement support for interface arrays." item-ss) trace x)) ((when (eq kind :end)) ;; Stopping at this interface port. Unlike module instances, ;; this seems OK. The interface port itself acts like a ;; variable. (mv nil trace x)) ((mv iface iface-ss) (vl-scopestack-find-definition/ss item.ifname item-ss)) ((unless iface) (mv (vl-follow-hidexpr-error (vmsg "reference through missing interface ~s0" item.ifname) item-ss) trace x)) (iftag (tag iface)) ((unless (eq iftag :vl-interface)) (mv (vl-follow-hidexpr-error (vmsg "interface port ~s0 of interface ~s1: invalid type ~x2???" name1 item.ifname iftag) item-ss) trace x)) (next-ss (vl-scopestack-push iface iface-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genblock)) (b* (((when (consp indices)) ;; Doesn't make any sense: this is a single, named generate ;; block, not an array, so we shouldn't try to index into it. (mv (vl-follow-hidexpr-error "array indices on reference to generate block" item-ss) trace x)) ((when (eq kind :end)) ;; Doesn't make any sense: referring to foo.bar.myblock all by ;; itself. (mv (vl-follow-hidexpr-error "reference to generate block" item-ss) trace x)) ;; Else we have something like foo.bar.myblock.mywire or whatever. ;; This is fine, we just need to go into the generate block. (genblob (vl-sort-genelements (vl-genblock->elems item) :scopetype :vl-genblock :name (vl-genblock->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genarray)) (b* (((when (eq kind :end)) ;; Doesn't make any sense. Either this is a raw reference to the ;; array like foo.bar.mygenarray, or is an indexed reference to ;; something like foo.bar.mygenarray[3], but in either case it ;; would be referring to a whole generate block or to an array of ;; generate blocks, not something inside those blocks. (mv (vl-follow-hidexpr-error "reference to generate array" item-ss) trace x)) ((unless (consp indices)) ;; Something like foo.bar.mygenarray.baz, but mygenarray is an ;; array so this doesn't make any sense. (mv (vl-follow-hidexpr-error "reference through generate array must have an array index" item-ss) trace x)) ((unless (atom (rest indices))) ;; Something like foo.bar.mygenarray[3][4].baz, but we should ;; only ever have single-dimensional generate arrays, right? (mv (vl-follow-hidexpr-error "too many indices through generate array" item-ss) trace x)) (index-expr (first indices)) ((unless (vl-expr-resolved-p index-expr)) ;; Something like foo.bar.mygenarray[width-1].baz. We tolerate ;; this in the case of module instances, but for generates it is ;; not safe because we could have something like: ;; ;; genvar i; ;; for(i = 1; i < 10; ++i) begin : mygenarray ;; wire [i-1:0] baz; ;; ... ;; end ;; ;; in which case the actual declaration of baz depends on the ;; particular block of the generate that we happen to be in. (mv (vl-follow-hidexpr-error "unresolved index into generate array" item-ss) trace x)) (blocknum (vl-resolved->val index-expr)) (block (vl-genarrayblocklist-find-block blocknum (vl-genarray->blocks item))) ((unless block) ;; Something like foo.bar.mygenarray[8].baz when the array only ;; goes from 3:7 or whatever. (mv (vl-follow-hidexpr-error (vmsg "invalid index into generate array: ~x0" blocknum) item-ss) trace x)) (genblob (vl-sort-genelements (vl-genarrayblock->elems block) :scopetype :vl-genarrayblock :name (vl-genarray->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-typedef)) (b* (((when (eq kind :end)) ;; This seems ok; we might refer to a type by name in a few ;; places. It may or may not be ok to refer to foo.bar_t, but ;; it's definitely ok to refer to foopkg::bar_t. (mv nil trace x))) ;; I don't think this makes sense? Can you refer to a type name? BOZO ;; maybe this makes sense for things like $bits(mystruct_t.foo) or ;; something like that? If so it may still be that we don't want to ;; deal with this in the aux function, but rather it should be ;; something that the top-level wrapper deals with. (mv (vl-follow-hidexpr-error "hierarchical reference through typedef" item-ss) trace x))) ((when (or (eq (tag item) :vl-genif) (eq (tag item) :vl-gencase) (eq (tag item) :vl-genloop) (eq (tag item) :vl-genbase))) ;; I don't think any of these are supposed to have names and, ;; accordingly, it shouldn't make sense to have looked one up. (mv (vl-follow-hidexpr-error (vmsg "hierarchical reference to ~x0" (tag item)) item-ss) trace x)) ((when (eq (tag item) :vl-gateinst)) ;; Since gate instances are "opaque" there is clearly no way we can go ;; through a gate instance. Moreover, we don't think a gate instance ;; could be meaningfully addressed in any other way. So, we just ;; regard any reference to a gate as invalid. (mv (vl-follow-hidexpr-error "hierarchical reference to gate instance" item-ss) trace x))) (mv (impossible) trace x)) /// (more-returns (new-trace (implies (or (consp trace) (not err)) (consp new-trace)) :name consp-of-vl-follow-hidexpr-aux.new-trace)) (defret vl-follow-hidexpr-no-index-on-first (implies (not err) (not (vl-hidstep->index (car new-trace))))) (defthm context-irrelevance-of-vl-follow-hidexpr-aux (implies (syntaxp (not (equal origx (list 'quote (with-guard-checking :none (vl-scopeexpr-fix nil)))))) (b* (((mv err1 trace1 tail1) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)) ((mv err2 trace2 tail2) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx (vl-scopeexpr-fix nil)))) (and (equal trace1 trace2) (equal tail1 tail2) (iff err1 err2)))) :hints ((acl2::just-induct-and-expand (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx) :expand-others ((:free (ctx strictp origx) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (defret count-of-vl-follow-hidexpr-aux.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr-aux (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p) :induct (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (deftagsum vl-scopecontext (:local ((levels natp :rule-classes :type-prescription "How many levels up from the current scope was the item found"))) (:root ()) (:package ((pkg vl-package-p))) (:module ((mod vl-module-p)))) (deftagsum vl-select (:field ((name stringp "The name of the field we're selecting"))) (:index ((val vl-expr-p "The index we're selecting")))) (defprod vl-selstep ((select vl-select-p "The field or index being selected") (type vl-datatype-p "The datatype of the element we've selected") (caveat "Signedness caveat for this indexing operation. Signals a disagreement between implementations on the signedness of the result. See @(see vl-datatype-remove-dim). Only important if this is the outermost selstep.") ;; (ss vl-scopestack-p "The scopestack in which the datatype was declared or ;; typedef'd") )) (fty::deflist vl-seltrace :elt-type vl-selstep :elementp-of-nil nil) (define vl-seltrace-index-count ((x vl-seltrace-p)) :returns (count natp :rule-classes :type-prescription) (if (atom x) 0 (+ (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field 0 :index 1)) (vl-seltrace-index-count (cdr x))))) (define vl-seltrace->indices ((x vl-seltrace-p)) :returns (indices vl-exprlist-p) (if (atom x) nil (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field (vl-seltrace->indices (cdr x)) :index (cons x1.select.val (vl-seltrace->indices (cdr x)))))) /// (defret len-of-vl-seltrace->indices (equal (len indices) (vl-seltrace-index-count x)) :hints(("Goal" :in-theory (enable vl-seltrace-index-count)))) (defthm vl-seltrace-indices-of-append (equal (vl-seltrace->indices (append x y)) (append (vl-seltrace->indices x) (vl-seltrace->indices y)))) (defthm vl-seltrace-indices-of-rev (equal (vl-seltrace->indices (rev x)) (rev (vl-seltrace->indices x))))) (defprod vl-operandinfo ((context vl-scopecontext-p "The context in which the HID base was found") (prefixname vl-scopeexpr-p "The scopeexpr, not including the possible data selects.") (hidtrace vl-hidtrace-p "The follow-hids trace, i.e. the trace of instances/blocks in which the base variable is located") (hidtype vl-datatype-p "The datatype of the final element of the hidtrace.") (seltrace vl-seltrace-p "The select trace, i.e. the types/scopestacks of all the fields/indices we've selected into") (part vl-partselect-p "The final partselect") (type vl-datatype-p "The final datatype of the object, after partselecting."))) (local (defthm nesting-level-of-vl-scopestack-find-item/context (<= (vl-scopestack-nesting-level (mv-nth 1 (vl-scopestack-find-item/context name ss))) (vl-scopestack-nesting-level ss)) :hints(("Goal" :in-theory (enable vl-scopestack-find-item/context vl-scopestack-nesting-level))) :rule-classes :linear)) (define vl-follow-hidexpr :short "Follow a HID to find the associated declaration." ((x vl-hidexpr-p "Hierarchical identifier to follow.") (ss vl-scopestack-p "Scopestack where the HID originates.") &key ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx) (strictp booleanp "Require all array indices and bounds to be resolved?")) :guard-debug t :returns (mv (err (iff (vl-msg-p err) err) "A message on any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext object describing where this hid is rooted.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) :long "<p>Prerequisite: see @(see following-hids) for considerable discussion about the goals and design of this function.</p> <p>This is our top-level routine for following hierarchical identifiers. It understands how to resolve both top-level hierarchical identifiers like @('topmodule.foo.bar') and downward identifiers like @('submodname.foo.bar').</p> <p>We try to follow @('x'), which must be a proper @(see vl-hidexpr-p), to whatever @(see vl-scopeitem) it refers to. This can fail for many reasons, e.g., any piece of @('x') might refer to a name that doesn't exist, might have inappropriate array indices, etc. In case of failure, @('err') is a good @(see vl-msg-p) and the other results are <b>not sensible</b> and should not be relied on.</p> <h5>Trace</h5> <p>We return a @(see vl-hidtrace-p) that records, in ``backwards'' order, the steps that we took to resolve @('x'). That is: if we are resolving @('foo.bar.baz'), then the first step in the trace will be the declaration for @('baz'), and the last step in the trace will be the lookup for @('foo'). In other words, the first step in the trace corresponds to the ``final'' declaration that @('x') refers to. Many applications won't care about the rest of the trace beyond its first step. However, the rest of the trace may be useful if you are trying to deal with, e.g., all of the interfaces along the hierarchical identifier.</p> <h5>Tail</h5> <p>The trace we return stops at variable declarations. This may be confusing because, in Verilog, the same @('.') syntax is used to index through the module hierarchy and to index through structures. To make this concrete, suppose we have something like:</p> @({ typedef struct { logic fastMode; ...; } opcode_t; typedef struct { opcode_t opcode; ... } instruction_t; module bar (...) ; instruction_t instruction1; ... endmodule module foo (...) ; bar mybar(...) ; ... endmodule module main (...) ; foo myfoo(...) ; ... $display(\"fastMode is %b\", myfoo.mybar.instruction1.opcode.fastMode); endmodule }) <p>When we follow @('myfoo.mybar.instruction1.opcode.fastMode'), our trace will <b>only go to @('instruction1')</b>, because the @('.opcode.fastMode') part is structure indexing, not scope indexing.</p> <p>To account for this, we return not only the @('trace') but also the @('tail') of the hierarchical identifier that remains where we stop. For instance, in this case the @('tail') would be @('instruction1.opcode.fastMode').</p>" (b* ((x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) (trace nil) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error "$root isn't supported yet" ss) trace nil x)) ((mv item ctx-ss pkg-name) (vl-scopestack-find-item/context name1 ss)) ((when item) (b* (((mv err trace tail) (vl-follow-hidexpr-aux x nil ss :strictp strictp)) ((when err) (mv err trace nil tail)) ((mv err context) (cond (pkg-name (b* ((pkg (vl-scopestack-find-package pkg-name ss)) ((unless pkg) (mv (vmsg "Programming error: found item in ~ package ~s0 but couldn't find package" pkg-name) nil))) (mv nil (make-vl-scopecontext-package :pkg pkg)))) ((vl-scopestack-case ctx-ss :global) (mv nil (make-vl-scopecontext-root))) (t (mv nil (make-vl-scopecontext-local :levels (- (vl-scopestack-nesting-level ss) (vl-scopestack-nesting-level ctx-ss)))))))) (mv err trace context tail))) ((when (eq kind :end)) ;; Item was not found AND it is not of the form foo.bar, so we do NOT ;; want to interpret it as any sort of reference to a top-level module. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Otherwise, might be a valid reference into a top-level module? (design (vl-scopestack->design ss)) ((unless design) ;; We must be using a phony scopestack. We have no way of knowing what ;; the top-level modules are so we have no idea if this is valid. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) (mods (vl-design->mods design)) (toplevel (vl-modulelist-toplevel mods)) ((unless (member-equal name1 toplevel)) (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Successfully found a top-level module with the first index name. ((when (consp indices)) ;; Something like topmod[3].foo.bar, doesn't make any sense. (mv (vl-follow-hidexpr-error "array indices into top level module" ss) trace nil x)) (mod (vl-find-module name1 mods)) (mod-ss (vl-scopestack-init design)) ;; BOZO how should the fact that we have followed a top-level hierarchical ;; identifier present itself in the trace? We would like to perhaps add a ;; trace step along the lines of: ;; ;; (cons (make-vl-hidstep :item mod :ss mod-ss) trace) ;; ;; But that is not possible because the ITEM for a trace needs to be a ;; scopeitem, and a module is not a scopeitem. ;; ;; We might eventually want to extend the notion of traces to be able to ;; record this sort of thing. For now, out of sheer pragmatism, I think ;; it seems pretty reasonable to just not bother to record the first ;; step. (next-ss (vl-scopestack-push mod mod-ss)) ((mv err trace tail) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp)) (context (make-vl-scopecontext-module :mod mod))) (mv err trace context tail)) /// (defret consp-of-vl-follow-hidexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-hidexpr.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p))))) (define vl-follow-scopeexpr :short "Follow a scope expression to find the associated declaration." ((x vl-scopeexpr-p "Scope expression to follow.") (ss vl-scopestack-p "Scopestack where the lookup originates.") &key (strictp booleanp "Require all array indices and bounds to be resolved?")) :returns (mv (err (iff (vl-msg-p err) err) "A message for any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext showing where the hid is found.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) (vl-scopeexpr-case x :end (vl-follow-hidexpr x.hid ss :strictp strictp :origx x) :colon (b* ((x (vl-scopeexpr-fix x)) ((unless (stringp x.first)) (mv (vmsg "~a0: The scope modifier '~x1' is not yet supported." x (case x.first (:vl-local "local") (:vl-$unit "$unit") (otherwise "??UNKNOWN??"))) nil nil (vl-scopeexpr->hid x))) ((mv package pkg-ss) (vl-scopestack-find-package/ss x.first ss)) ((unless package) (mv (vmsg "~a0: Package ~s1 not found.." x x.first) nil nil (vl-scopeexpr->hid x))) (pkg-ss (vl-scopestack-push package pkg-ss)) ((unless (vl-scopeexpr-case x.rest :end)) (mv (vmsg "~a0: Multiple levels of :: operators are ~ not yet supported." x) nil nil (vl-scopeexpr->hid x))) ((mv err trace context tail) (vl-follow-hidexpr (vl-scopeexpr-end->hid x.rest) pkg-ss :strictp strictp :origx x)) ((when err) (mv err trace context tail)) ((unless (vl-scopecontext-case context :local)) (mv nil trace context tail))) (mv nil trace (make-vl-scopecontext-package :pkg package) tail))) /// (defret consp-of-vl-follow-scopeexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-scopeexpr.tail (< (vl-hidexpr-count tail) (vl-scopeexpr-count x)) :rule-classes :linear) (defret vl-subhid-p-of-vl-follow-scopeexpr (implies (not err) (vl-subhid-p tail (vl-scopeexpr->hid x))) :hints(("Goal" :in-theory (enable vl-scopeexpr->hid))))) ;; ------ (defxdoc datatype-tools :parents (mlib) :short "Functions for working with datatypes.") (local (xdoc::set-default-parents datatype-tools)) (defines vl-datatype-resolved-p (define vl-datatype-resolved-p ((x vl-datatype-p)) :measure (vl-datatype-count x) (vl-datatype-case x :vl-coretype t :vl-struct (vl-structmemberlist-resolved-p x.members) :vl-union (vl-structmemberlist-resolved-p x.members) :vl-enum (vl-datatype-resolved-p x.basetype) :vl-usertype (and x.res (vl-datatype-resolved-p x.res)))) (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p)) :measure (vl-structmemberlist-count x) (if (atom x) t (and (vl-datatype-resolved-p (vl-structmember->type (car x))) (vl-structmemberlist-resolved-p (cdr x))))) /// (deffixequiv-mutual vl-datatype-resolved-p) (defthm vl-datatype-resolved-p-of-make-coretype (vl-datatype-resolved-p (vl-coretype name signedp pdims udims))) (defthm vl-datatype-resolved-p-of-make-struct (equal (vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("goal" :expand ((vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-union (equal (vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("Goal" :expand ((vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-enum (equal (vl-datatype-resolved-p (vl-enum basetype items pdims udims)) (vl-datatype-resolved-p basetype)) :hints (("goal" :expand (vl-datatype-resolved-p (vl-enum basetype items pdims udims))))) (defthm vl-datatype-resolved-p-of-make-usertype (equal (vl-datatype-resolved-p (vl-usertype name res pdims udims)) (and res (vl-datatype-resolved-p res))) :hints (("Goal" :expand (vl-datatype-resolved-p (vl-usertype name res pdims udims))))) (defthm vl-structmemberlist-resolved-p-of-struct-members (implies (and (vl-datatype-case x :vl-struct) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-struct->members x)))) (defthm vl-structmemberlist-resolved-p-of-union-members (implies (and (vl-datatype-case x :vl-union) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-union->members x)))) (defthm vl-datatype-resolved-p-of-enum-basetype (implies (and (vl-datatype-case x :vl-enum) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p (vl-enum->basetype x)))) (defthm vl-datatype-resolved-p-of-usertype-basetype (implies (and (vl-datatype-case x :vl-usertype) (vl-datatype-resolved-p x)) (and (vl-datatype-resolved-p (vl-usertype->res x)) (vl-usertype->res x)))) (defthm vl-structmemberlist-resolved-p-of-cons (equal (vl-structmemberlist-resolved-p (cons a b)) (and (vl-datatype-resolved-p (vl-structmember->type a)) (vl-structmemberlist-resolved-p b)))) (defthm vl-datatype-resolved-p-of-car-structmember-type (implies (vl-structmemberlist-resolved-p x) (vl-datatype-resolved-p (vl-structmember->type (car x))))) (defthm vl-structmemberlist-resolved-p-of-cdr (implies (vl-structmemberlist-resolved-p x) (vl-structmemberlist-resolved-p (cdr x)))) (defthm vl-datatype-resolved-p-of-update-dims (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p (vl-datatype-update-dims pdims udims x))) :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) (fty::defalist vl-typeoverride :key-type vl-scopeexpr :val-type vl-datatype :short "Alist mapping names to datatypes, used to store resolutions of parameter types that have been computed but not yet put in the design." :long "<p>The names may be of various different kinds of objects, meaning slightly different things:</p> <ul> <li>A value parameter name maps to the type of the parameter value</li> <li>A type parameter name maps to the resolved type that is that parameter's value</li> <li>A typedef name maps to the resolved type</li> <li>A function name maps to the resolved return type of the function.</li> </ul>") (defines vl-datatype-usertype-resolve (define vl-datatype-usertype-resolve ((x vl-datatype-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :verify-guards nil :measure (two-nats-measure rec-limit (vl-datatype-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-datatype-p)) (b* ((x (vl-datatype-fix x))) (vl-datatype-case x :vl-coretype (mv nil x) :vl-struct (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-struct x :members members))) :vl-union (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-union x :members members))) :vl-enum (b* (((mv err basetype) (vl-datatype-usertype-resolve x.basetype ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-enum x :basetype basetype))) :vl-usertype (b* (((when (and x.res (vl-datatype-resolved-p x.res))) (mv nil x)) ((mv err def) (vl-usertype-lookup x.name ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-usertype x :res def)))))) (define vl-structmemberlist-usertype-resolve ((x vl-structmemberlist-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-structmemberlist-p)) (b* (((when (atom x)) (mv nil nil)) ((mv err1 type1) (vl-datatype-usertype-resolve (vl-structmember->type (car x)) ss :typeov typeov :rec-limit rec-limit)) ((mv err2 rest) (vl-structmemberlist-usertype-resolve (cdr x) ss :typeov typeov :rec-limit rec-limit))) (mv (or err1 err2) (cons (change-vl-structmember (car x) :type type1) rest)))) (define vl-usertype-lookup ((x vl-scopeexpr-p "The usertype name to look up") (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :short "Looks up a usertype name and returns its definition if successful." :measure (two-nats-measure rec-limit 0) :returns (mv (err (iff (vl-msg-p err) err) "Error message if unsuccessful") (type (and (vl-maybe-datatype-p type) (implies (not err) (vl-datatype-p type))) "Fully resolved type, if successful")) (b* ((x (vl-scopeexpr-fix x)) (typeov (vl-typeoverride-fix typeov)) (hid (vl-scopeexpr->hid x)) ;; BOZO Maybe we should use a different type than scopeexpr for a usertype name ((unless (vl-hidexpr-case hid :end)) (mv (vmsg "Type names cannot be specified with dotted ~ paths, only package scopes: ~a1" nil x) nil)) (look (hons-get x typeov)) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: unresolved override type") nil))) ((mv err trace ?context ?tail) (vl-follow-scopeexpr x ss)) ((when err) (mv err nil)) ((vl-hidstep ref) (car trace)) ((when (eq (tag ref.item) :vl-typedef)) (b* (((vl-typedef item) ref.item) ((when (zp rec-limit)) (mv (vmsg "Recursion limit ran out looking up ~ usertype ~a0" x) nil))) (vl-datatype-usertype-resolve item.type ref.ss :typeov nil ;; different scope! :rec-limit (1- rec-limit)))) ((when (eq (tag ref.item) :vl-paramdecl)) (b* (((vl-paramdecl item) ref.item)) (vl-paramtype-case item.type :vl-typeparam (if (and item.type.default (vl-datatype-resolved-p item.type.default)) (mv nil item.type.default) (mv (vmsg "Reference to unresolved type parameter ~a0" item) nil)) :otherwise (mv (vmsg "Reference to data parameter ~a0 as type" item) nil))))) (mv (vmsg "Didn't find a typedef ~a1, instead found ~a2" nil x ref.item) nil))) /// (verify-guards vl-datatype-usertype-resolve-fn) (defthm vl-datatype-usertype-resolve-nonnil (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit)) :hints (("goal" :use ((:instance (:theorem (implies (not x) (not (vl-datatype-p x)))) (x (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) :in-theory (disable vl-datatype-usertype-resolve))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) (defthm vl-usertype-lookup-nonnil (b* (((mv err res) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) res)) :hints (("goal" :use ((:instance return-type-of-vl-usertype-lookup-fn.type)) :in-theory (disable return-type-of-vl-usertype-lookup-fn.type))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))))) (defthm-vl-datatype-usertype-resolve-flag (defthm vl-datatype-resolved-p-of-vl-datatype-usertype-resolve (b* (((mv err new-x) (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p new-x))) :hints('(:expand ((vl-datatype-resolved-p x)))) :flag vl-datatype-usertype-resolve) (defthm vl-structmemberlist-resolved-p-of-vl-structmemberlist-usertype-resolve (b* (((mv err new-x) (vl-structmemberlist-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-structmemberlist-resolved-p new-x))) ;; :hints('(:in-theory (enable vl-structmemberlist-resolved-p))) :flag vl-structmemberlist-usertype-resolve) (defthm vl-datatype-resolved-p-of-vl-usertype-lookup (b* (((mv err type) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p type))) :flag vl-usertype-lookup)) (deffixequiv-mutual vl-datatype-usertype-resolve)) ;; (define vl-usertype-resolve ((x vl-scopeexpr-p "The usertype name to look up") ;; (ss vl-scopestack-p) ;; &key ((rec-limit natp) '1000)) ;; :short "Looks up a usertype name recursively, stopping and and returning its ;; definition when it is a non-usertype or has dimensions." ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Error message if unsuccessful") ;; (type (iff (vl-datatype-p type) (not err)) ;; "Resolved type, if successful") ;; (scope vl-scopestack-p ;; "Scopestack for the context in which the type was defined ;; (only sensible if successful)")) ;; :measure (nfix rec-limit) ;; (b* (((mv err def new-ss) ;; (vl-usertype-lookup x ss)) ;; ((when err) (mv err def new-ss)) ;; ((unless (vl-datatype-case def :vl-usertype)) ;; (mv nil def new-ss)) ;; ((vl-usertype def)) ;; ((when (or (consp def.pdims) (consp def.udims))) ;; (mv nil def new-ss)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out looking up usertype ~a0" def) nil new-ss))) ;; (vl-usertype-resolve def.name new-ss :rec-limit (1- rec-limit))) ;; /// ;; (defret vl-usertype-resolve-result-has-dims ;; (implies (and (not err) ;; (vl-datatype-case type :vl-usertype) ;; (not (consp (vl-datatype->udims type)))) ;; (consp (vl-datatype->pdims type))))) ;; (define vl-usertype-resolve ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; (rec-limit natp)) ;; :guard (vl-datatype-case x :vl-usertype) ;; :short "Resolves a datatype of usertype kind to a concrete ;; datatype, i.e. anything but a user typename." ;; :long "<p>The input is guarded to be a usertype. If it is defined as another ;; usertype (possibly with packed/unpacked dimensions), then we recur until it is ;; defined as something other than a usertype. However, the final type may still ;; have usertypes within it, i.e. as struct/union member types.</p> ;; <p>Also returns the scopestack representing the scope in which the ;; final type declaration was found.</p> ;; <p>This function is strict with respect to packed vs. unpacked dimensions; ;; i.e., if a usertype is defined as having unpacked dimensions, it will warn if ;; any packed dimensions are applied to that type. Arguably this check should be ;; done elsewhere, in which case this function could ignore the distinction ;; between packed and unpacked dimensions. However, it is important to preserve ;; the order of dimensions, and it's not clear how to handle cases that mix the ;; two: packed dimensions are always treated as \"inner\" or \"most rapidly ;; varying\" dimensions. So if we have (illegal) nested typedefs that place ;; unpacked dimensions inside of packed dimensions, we have no way to express that ;; as a single, usertype-free datatype, unless we change some packed dimensions ;; into unpacked ones or vice versa:</p> ;; @({ ;; typedef logic t1 [5:1]; // unpacked dimension ;; typedef t1 [3:0] t2; // packed dimension applied to unpacked datatype ;; typedef logic [3:0] t3 [5:1]; // not the same as t2 ;; typedef logic [5:1] [3:0] t4; // same dimensions as t2, but all dimensions packed ;; typedef logic t5 [5:1] [3:0]; // same dimensions as t2, but all dimensions unpacked ;; }) ;; <p>We don't have this problem for the (also illegal) case where packed ;; dimensions are applied to an unpacked structure or union, so we don't warn in ;; this case; this should be checked separately.</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p) ;; (scope vl-scopestack-p)) ;; :measure (nfix rec-limit) ;; :verify-guards nil ;; (b* ((ss (vl-scopestack-fix ss)) ;; (x (vl-datatype-fix x)) ;; ((vl-usertype x)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Rec-limit ran out: recursively defined ~ ;; datatype? ~a1" ;; nil x.name) ;; x ss)) ;; ((unless (vl-hidexpr-case (vl-scopeexpr->hid x.name) :end)) ;; (mv (vmsg "Type names cannot be specified with dotted ~ ;; paths, only package scopes: ~a1" ;; nil x.name) ;; x ss)) ;; ((mv err trace ?tail) ;; (vl-follow-scopeexpr x.name ss)) ;; ((when err) ;; (mv err x ss)) ;; ((vl-hidstep ref) (car trace)) ;; ((unless (eq (tag ref.item) :vl-typedef)) ;; (mv (vmsg "Didn't find a typedef ~a1, instead ~ ;; found ~a2" ;; nil x.name ref.item) ;; x ss)) ;; ((vl-typedef item) ref.item) ;; ((mv warning subtype final-ss) ;; (if (vl-datatype-case item.type :vl-usertype) ;; (vl-usertype-resolve item.type ref.ss (1- rec-limit)) ;; (mv nil item.type ref.ss))) ;; ((when warning) ;; (mv warning x ss)) ;; (sub-udims (vl-datatype->udims subtype)) ;; ((when (and (consp x.pdims) (consp (vl-datatype->udims item.type)))) ;; ;; Bad case: we have unpacked dimensions from the inner call but ;; ;; we're trying to add packed ones. Warn and return x. ;; (mv (vmsg "Usertype ~a1 was declared with packed ~ ;; dimensions, but its definition ~a2 already ~ ;; has unpacked dimensions." ;; x item.type) ;; x ss)) ;; (subtype (mbe :logic (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; :exec ;; (if (or x.udims x.pdims) ;; (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; subtype)))) ;; (mv nil subtype final-ss)) ;; /// ;; (verify-guards vl-usertype-resolve)) ;; (defines vl-datatype-usertype-elim ;; :verify-guards nil ;; (define vl-datatype-usertype-elim ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) '1000)) ;; :measure (two-nats-measure rec-limit (vl-datatype-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p)) ;; :prepwork ((local (in-theory (disable nfix)))) ;; :short "Resolves all usertypes within a datatype, recursively." ;; :long "<p>A recursion limit is needed in case a usertype is defined in ;; terms of itself.</p> ;; <p>Always returns a datatype; however, when a warning is present, it may still ;; contain usertypes.</p> ;; <p>An example to work through: suppose we want to resolve the usertype memchunk ;; into a usertype-free datatype --</p> ;; @({ ;; typedef logic [3:0] mynibble; ;; typedef mynibble [7:0] my32; ;; typedef my32 [0:3] membank [63:0]; ;; // error: since membank now has unpacked dims, we can't give it more packed dims: ;; // typedef membank [3:0] memchunk; ;; // this works: ;; typedef membank memchunk [3:0]; ;; })" ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; :vl-coretype (mv nil x) ;; :vl-enum (mv nil x) ;; bozo ;; :vl-usertype ;; (b* (((mv warning newx newss) (vl-usertype-resolve x ss)) ;; ((when warning) (mv warning newx)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out: ~a1" ;; nil x.name) ;; newx))) ;; (vl-datatype-usertype-elim newx newss :rec-limit (1- rec-limit))) ;; :vl-struct ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-struct x :members members))) ;; (mv warning newx)) ;; :vl-union ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-union x :members members))) ;; (mv warning newx))))) ;; (define vl-structmembers-usertype-elim ((x vl-structmemberlist-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) 'rec-limit)) ;; :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (newx vl-structmemberlist-p)) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((mv warning type1) (vl-datatype-usertype-elim ;; (vl-structmember->type (car x)) ss ;; rec-limit)) ;; (first (change-vl-structmember (car x) :type type1)) ;; ((when warning) (mv warning (cons first (vl-structmemberlist-fix (cdr x))))) ;; ((mv warning membs2) (vl-structmembers-usertype-elim (cdr x) ss rec-limit))) ;; (mv warning (cons first membs2)))) ;; /// ;; (deffixequiv-mutual vl-datatype-usertype-elim) ;; (verify-guards vl-datatype-usertype-elim)) (define vl-datatype->structmembers ((x vl-datatype-p)) :short "Finds the struct members of x when it is a struct or union." :returns (mv ok (members vl-structmemberlist-p)) (vl-datatype-case x :vl-struct (mv t x.members) :vl-union (mv t x.members) :otherwise (mv nil nil)) /// (defthm vl-structmemberlist-resolved-p-of-vl-datatype->structmembers (implies (vl-datatype-resolved-p x) (vl-structmemberlist-resolved-p (mv-nth 1 (vl-datatype->structmembers x)))) :hints(("Goal" :in-theory (enable vl-datatype->structmembers))))) (define vl-find-structmember ((name stringp) (membs vl-structmemberlist-p)) :returns (memb (iff (vl-structmember-p memb) memb)) (if (atom membs) nil (if (equal (string-fix name) (vl-structmember->name (car membs))) (vl-structmember-fix (car membs)) (vl-find-structmember name (cdr membs)))) /// (defthm vl-datatype-resolved-p-of-find-structmember (implies (and (vl-structmemberlist-resolved-p members) (vl-find-structmember name members)) (vl-datatype-resolved-p (vl-structmember->type (vl-find-structmember name members)))) :hints(("Goal" :in-theory (enable vl-structmemberlist-resolved-p))))) (define vl-packeddimensionlist-resolved-p ((x vl-packeddimensionlist-p)) :short "Returns true if all sized packed dimensions are resolved." (b* (((when (atom x)) t) (x1 (car x))) (and (vl-packeddimension-case x1 :unsized t :range (vl-range-resolved-p x1.range)) (vl-packeddimensionlist-resolved-p (cdr x))))) (define vl-packeddimensionlist-total-size ((x vl-packeddimensionlist-p)) :short "Given a packeddimensionlist like [5:0][3:1][0:8], multiplies the dimensions together to get the total number of bits, or returns nil if there are unsized dimensions." :guard (vl-packeddimensionlist-resolved-p x) :verify-guards nil :returns (size maybe-posp :rule-classes :type-prescription) (b* (((when (atom x)) 1) (rest (vl-packeddimensionlist-total-size (cdr x))) ((unless rest) nil) (first (car x)) ((when (vl-packeddimension-case first :unsized)) nil) (range (vl-packeddimension->range first))) (* (vl-range-size range) rest)) /// (verify-guards vl-packeddimensionlist-total-size :hints (("goal" :in-theory (enable vl-packeddimensionlist-resolved-p))))) (define vl-packeddimension-size ((x vl-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if (vl-packeddimension-case x :unsized) (mv nil nil) (b* ((range (vl-packeddimension->range x))) (if (vl-range-resolved-p range) (mv nil (vl-range-size range)) (mv t nil))))) (define vl-maybe-packeddimension-size ((x vl-maybe-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if x (vl-packeddimension-size x) (mv nil nil))) (fty::deflist maybe-nat-list :elt-type maybe-natp) (defines vl-datatype-size :prepwork ((local (in-theory (disable all-equalp stringp-when-true-listp default-*-1 integerp-when-natp natp-when-posp rationalp-implies-acl2-numberp acl2::member-when-atom acl2::posp-redefinition rationalp-when-integerp double-containment member-equal-when-member-equal-of-cdr-under-iff equal-of-cons-rewrite))) (std::set-returnspec-mrec-default-hints ((acl2::just-expand-mrec-default-hint 'std::fnname id nil world)))) (define vl-datatype-size ((x vl-datatype-p "The datatype to size")) :short "Computes the number of bits in the datatype." :long "<p>This works for unpacked datatypes as well as packed ones; you should check separately that the datatype is packed if that is what you want. Returns nil without error if given a datatype that has no fixed bit size, e.g. if it contains a real number or has unsized dimensions. We produce an error message if a usertype is not found, if the recursion limit runs out, or if unresolved dimensions are present.</p>" :measure (vl-datatype-count x) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err)) (size maybe-natp :rule-classes :type-prescription)) :verify-guards nil (b* ((x (vl-datatype-fix x)) (udims (vl-datatype->udims x)) (pdims (vl-datatype->pdims x)) ((unless (vl-packeddimensionlist-resolved-p udims)) (mv (vmsg "Unresolved unpacked dimensions: ~a0" (vl-datatype-update-dims nil (append-without-guard udims pdims) x)) nil)) ((unless (vl-packeddimensionlist-resolved-p pdims)) (mv (vmsg "Unresolved packed dimensions: ~a0" x) nil)) (udim-size (vl-packeddimensionlist-total-size udims)) (pdim-size (vl-packeddimensionlist-total-size pdims)) (dim-size (and udim-size pdim-size (* udim-size pdim-size)))) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.size dim-size (* typinfo.size dim-size))))) (:vl-struct (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (sum-nats widths) dim-size))))) (:vl-union (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (max-nats widths) dim-size))))) (:vl-enum (b* (((mv err sub-size) (vl-datatype-size x.basetype)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size))))) (:vl-usertype (b* (((unless (mbt (and x.res t))) (mv (vmsg "Usertype unresolved: ~a0" x) nil)) ((mv err sub-size) (vl-datatype-size x.res)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size)))))))) (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) :returns (mv (err (iff (vl-msg-p err) err)) (sizes maybe-nat-list-p)) :guard (vl-structmemberlist-resolved-p x) :measure (vl-structmemberlist-count x) (b* (((when (atom x)) (mv nil nil)) ((mv err1 size1) (vl-datatype-size (vl-structmember->type (car x)))) ((mv err2 size2) (vl-structmemberlist-sizes (cdr x)))) (mv (or err1 err2) (cons size1 size2))) /// (defret len-of-vl-structmemberlist-sizes (equal (len sizes) (len x)) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x))))) (defret true-listp-of-vl-structmemberlist-sizes (true-listp sizes) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x)))) :rule-classes :type-prescription)) /// (local (defthm nat-listp-when-maybe-nat-list-p (implies (and (maybe-nat-list-p x) (not (member nil x))) (nat-listp x)) :hints(("Goal" :in-theory (enable maybe-nat-list-p))))) (verify-guards vl-datatype-size) (deffixequiv-mutual vl-datatype-size)) (define vl-maybe-usertype-resolve ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :returns (new-x vl-datatype-p) :measure (vl-datatype-count x) (b* ((x (vl-datatype-fix x)) ((when (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)))) x)) (vl-datatype-case x :vl-usertype (if x.res (vl-maybe-usertype-resolve x.res) x) :otherwise x)) /// (defret vl-datatype-count-of-vl-maybe-usertype-resolve (<= (vl-datatype-count new-x) (vl-datatype-count x)) :rule-classes :linear) (defret vl-datatype-resolved-p-of-vl-maybe-usertype-resolve (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x))) (local (defret vl-maybe-usertype-resolve-nonnil new-x :rule-classes :type-prescription)) (defret not-usertype-of-vl-maybe-usertype-resolve (implies (and (not (consp (vl-datatype->pdims new-x))) (not (consp (vl-datatype->udims new-x))) (vl-datatype-resolved-p x)) (not (equal (vl-datatype-kind new-x) :vl-usertype))) :rule-classes ((:forward-chaining :trigger-terms ((vl-datatype-kind (vl-maybe-usertype-resolve x))))))) (define vl-datatype-packedp ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :short "Decide whether the datatype is packed or not." :long "<p>A shallow check; e.g. we don't check for invalid things such as a packed struct with a member that's an unpacked array.</p> <p>Note that the question of whether something is packed is subtly different from the question of whether you can select from it: namely, simple bit types such as @('logic') are packed but not selectable.</p>" :returns (packedp) (b* ((x (vl-maybe-usertype-resolve x)) ((when (consp (vl-datatype->udims x))) nil) ((when (consp (vl-datatype->pdims x))) t)) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) (and xinfo.size t)) :vl-struct x.packedp :vl-union x.packedp :vl-enum t :vl-usertype (impossible)))) (define vl-datatype-signedness ((x vl-datatype-p)) :short "Decide whether the datatype is signed or not." :long "<p>Returns NIL if there isn't an appropriate signedness, as in an unpacked or non-integer type. This function never fails, as such, but in some cases where implementations disagree on the correct signedness, we return a flag to signal that there is a caveat about that signedness.</p> <p>This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, NCV treats the array as unsigned, but VCS treats it as signed. The SV spec only touches on this to say (from Sec. 7.4.1, Packed Arrays):</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [20:0] btest; assign btest = b; }) <p>In NCVerilog, btest has the value @('0ffff'), indicating that @('b') (as a whole) is considered unsigned; in VCS, btest has the value @('fffff'), indicating that @('b') is considered signed.</p> " :guard (vl-datatype-resolved-p x) :measure (vl-datatype-count x) :returns (mv (caveat-flag) (signedness vl-maybe-exprtype-p)) (b* (((when (consp (vl-datatype->udims x))) (mv nil nil))) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.takes-signingp (if x.signedp :vl-signed :vl-unsigned)))) :vl-struct (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-union (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-enum (vl-datatype-signedness x.basetype) :vl-usertype (b* (((unless (mbt (and x.res t))) (mv nil nil)) ((mv caveat ans1) (vl-datatype-signedness x.res)) ((when (and (consp (vl-datatype->pdims x)) (eq ans1 :vl-signed))) (mv t :vl-unsigned))) (mv caveat ans1))))) ;; (defines vl-datatype-check-resolved ;; (define vl-datatype-check-resolved ((x vl-datatype-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-datatype-count x) ;; :short "Returns an explanatory message if the datatype has a problem that would ;; prevent its size from being measured." ;; :long "<p>Packedp indicates whether we require it to be a packed (i.e., ;; vector) datatype.</p>" ;; (b* ((x (vl-datatype-fix x)) ;; (udims (vl-datatype->udims x)) ;; ((when (and packedp (consp udims))) ;; (vmsg "~a0: unpacked dimensions in packed context" x)) ;; ((unless (vl-packeddimensionlist-resolved-p udims)) ;; (vmsg "~a0 has unresolved unpacked dimensions" x)) ;; (pdims (vl-datatype->pdims x)) ;; ((unless (vl-packeddimensionlist-resolved-p pdims)) ;; (vmsg "~a0 has unresolved packed dimensions" x)) ;; (packedp (or (consp pdims) packedp))) ;; (vl-datatype-case x ;; :vl-coretype ;; (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name)) ;; ((when (and packedp (not xinfo.size))) ;; (vmsg "~a0: non-packed coretype" x))) ;; nil) ;; :vl-struct ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty struct" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked struct in packed context" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-union ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty union" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked union" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-enum ;; (vmsg "~a0: enum types not yet supported" x) ;; :vl-usertype ;; (vmsg "~a0: datatype not resolved" x)))) ;; (define vl-structmemberlist-check-resolved ((x vl-structmemberlist-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (or (vl-datatype-check-resolved (vl-structmember->type (car x)) packedp) ;; (vl-structmemberlist-check-resolved (cdr x) packedp)))) ;; /// ;; (deffixequiv-mutual vl-datatype-check-resolved) ;; (deffixequiv-mutual vl-datatype-check-resolved ;; :args ((packedp booleanp))) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-datatype-check-resolved x t))) ;; (not (vl-datatype-check-resolved x packedp))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-structmemberlist-check-resolved x t))) ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; :flag vl-structmemberlist-check-resolved)) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-implies-unpacked ;; (implies (not (vl-datatype-check-resolved x packedp)) ;; (not (vl-datatype-check-resolved x nil))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-implies-unpacked ;; (implies (not (vl-structmemberlist-check-resolved x packedp)) ;; (not (vl-structmemberlist-check-resolved x nil))) ;; :flag vl-structmemberlist-check-resolved))) ;; (define vl-datatype-resolved-p ((x vl-datatype-p) ;; (packedp)) ;; :enabled t ;; (not (vl-datatype-check-resolved x packedp))) ;; (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p) ;; (packedp)) ;; :enabled t ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; (defines vl-packed-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-packed-datatype-size ;; :short "Get the size for any packed data type." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) and be ;; packed or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :guard (vl-datatype-resolved-p x t) ;; :returns ;; (size posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((totalsize (vl-packeddimensionlist-total-size x.pdims)) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) ;; (lposfix (* typinfo.size totalsize)))) ;; (:vl-struct ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (sum-nats widths))))) ;; (:vl-union ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (max-nats widths))))) ;; (:otherwise (lposfix (impossible)))))) ;; (define vl-packed-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x t) ;; :returns (sizes (pos-listp sizes)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-packed-datatype-size (vl-structmember->type (car x))) ;; (vl-packed-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-packed-datatype-size-flag ;; (defthm len-of-vl-packed-structmemberlist-sizes ;; (b* ((sizes (vl-packed-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-packed-structmemberlist-sizes x)))) ;; :flag vl-packed-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (verify-guards vl-packed-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x t) ;; (vl-structmemberlist-check-resolved x t))))) ;; (deffixequiv-mutual vl-packed-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-datatype-size ;; ((x vl-datatype-p)) ;; :short "Get the size for any datatype, even unpacked, that is made up of packed ;; elements." ;; :long "<p>We return NIL if there are non-bit datatypes like @('real').</p>" ;; :guard (vl-datatype-resolved-p x nil) ;; :returns ;; (size maybe-posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x)) ;; (x.pdims (vl-datatype->pdims x)) ;; (x.udims (vl-datatype->udims x)) ;; (pdimsize (vl-packeddimensionlist-total-size x.pdims)) ;; (udimsize (vl-packeddimensionlist-total-size x.udims))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) nil)) ;; (lposfix (* typinfo.size pdimsize udimsize)))) ;; (:vl-struct ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (sum-nats widths) pdimsize udimsize)))) ;; (:vl-union ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (max-nats widths) pdimsize udimsize)))) ;; ;; BOZO enums ;; (:otherwise nil)))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x nil) ;; :returns (sizes maybe-pos-list-p) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-datatype-size (vl-structmember->type (car x))) ;; (vl-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* ((sizes (vl-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-structmemberlist-sizes x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (local (defthm pos-listp-when-not-member-nil ;; (implies (and (maybe-pos-list-p x) ;; (not (member nil x))) ;; (pos-listp x)) ;; :hints(("Goal" :in-theory (enable member))))) ;; (verify-guards vl-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x nil) ;; (vl-structmemberlist-check-resolved x nil))))) ;; (deffixequiv-mutual vl-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite not)))) ;; (define vl-datatype-size ;; :short "Get the size for a data type, including unpacked dimensions." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :returns ;; (mv (err (iff (vl-msg-p err) err)) ;; (size (implies (not err) (posp size)) :rule-classes :type-prescription)) ;; :measure (vl-datatype-count x) ;; (b* (((fun (fail reason args)) ;; (mv (make-vl-msg :msg reason ;; :args args) ;; nil)) ;; ((fun (success width)) (mv nil width)) ;; (x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((udim-size (vl-packeddimensionlist-total-size x.udims)) ;; (pdim-size (vl-packeddimensionlist-total-size x.pdims)) ;; ((unless (and udim-size pdim-size)) ;; (fail "Dimensions of vector type ~a0 not resolvd" ;; (list x))) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) ;; ;; Something like a real, shortreal, void, realtime, chandle, etc. ;; (fail "bad coretype ~a0" (list x)))) ;; (success (* typinfo.size pdim-size udim-size)))) ;; (:vl-struct ;; (b* (;; bozo is there a correct thing to do for a struct with no members? ;; ((unless (consp x.members)) (fail "empty struct: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of struct type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (sum-nats widths))))) ;; (:vl-union ;; (b* (;; bozo is there a correct thing to do for a union with no members? ;; ((unless (consp x.members)) (fail "empty union: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of union type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (max-nats widths))))) ;; (:vl-enum ;; need to compute size from the base type? ;; (fail "bozo: implement enum range" nil)) ;; (:vl-usertype ;; (fail "unresolved usertype: ~a0" (list x.name)))))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (sizes (and (pos-listp sizes) ;; (implies (not err) ;; (equal (consp sizes) (consp x)))))) ;; :measure (vl-structmemberlist-count x) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((vl-structmember first) (vl-structmember-fix (car x))) ;; ((mv warning size) (vl-datatype-size first.type)) ;; ((when warning) (mv warning nil)) ;; ((mv warning rest) (vl-structmemberlist-sizes (cdr x))) ;; ((when warning) (mv warning nil))) ;; (mv nil (cons size rest)))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* (((mv warning sizes) (vl-structmemberlist-sizes x))) ;; (implies (not warning) ;; (equal (len sizes) (len x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (verify-guards vl-datatype-size) ;; (deffixequiv-mutual vl-datatype-size)) ;; (define vl-datatype-exprtype ;; :parents (datatype-tools vl-expr-typedecide) ;; :short "Get the self-determined signedness of a datatype." ;; ((x vl-datatype-p)) ;; :returns ;; (type vl-maybe-exprtype-p ;; "On success: the self-determined signedness (exprtype) of this expression. ;; Note that some expressions (e.g., real numbers, unpacked types) have ;; exprtype NIL.") ;; :long "<p>BOZO This is tricky with packed arrays etc.; I'm not sure we've ;; taken time yet to understand all the rules.</p>" ;; (b* (((when (consp (vl-datatype->udims x))) ;; nil)) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((when typinfo.takes-signingp) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (success nil))) ;; (:vl-enum ;; just need to look at the base type, right? ;; (fail "bozo: implement enum typing")) ;; (:vl-struct ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed struct") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-union ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed union") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-usertype ;; ;; BOZO maybe some day extend this to be able to do lookups, but maybe ;; ;; just depend on usertype-elim ;; (fail "vl-datatype-exprtype can't handle unresolved usertypes"))))) (define vl-datatype-select-ok ((x vl-datatype-p)) :parents (datatype-tools) :short "Determines whether this datatype can be selected." :long "<p>The input datatype should not have packed or unpacked dimensions; if it does, then it's definitely OK to index into it (though it's only a select if it's the last packed dimension). The input datatype should have usertypes resolved.</p>" :guard (vl-datatype-resolved-p x) :returns (ok) :measure (vl-datatype-count x) (b* ((x (vl-maybe-usertype-resolve x))) (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) ;; Checks whether this is an integer atom type. If it's an integer ;; vector type, it's only selectable if it has dims. (and xinfo.size (not (eql xinfo.size 1))))) (:vl-struct x.packedp) (:vl-union x.packedp) (:vl-enum ;; NOTE: This is a little nonsensical, but simulators seem to treat enums ;; as if they were always 1-dimensional vectors, even in the case of ;; typedef enum logic {a, b} foo ; ;; which you might think would be a 0-dimensional thing. t) (:vl-usertype (impossible)))))) (define vl-datatype-dims-count ((x vl-datatype-p)) :short "Gives the number of packed plus unpacked dimensions on a datatype." :returns (ndims natp :rule-classes :type-prescription) (+ (len (vl-datatype->udims x)) (len (vl-datatype->pdims x)))) (define vl-datatype-set-unsigned ((x vl-datatype-p)) :short "Removes any explicit signed indicator from a datatype." :long "<p>This is rather specific in purpose and generally shouldn't be used. The case where it is useful is when we are indexing into an (explicitly signed) packed array; this means that the whole array is signed, but not the selected parts. So we strip the signed qualifier off of the type when we index into packed dimensions. (This doesn't apply to usertypes that are defined as signed types! If we index down to such a type, it IS signed, but any packed array of such a type is not. So we don't need to descend into usertypes or somehow mark them as unsigned. We just have to know that a usertype with one or more packed dimensions counts as unsigned.)</p>" :returns (new-x vl-datatype-p) (vl-datatype-case x :vl-coretype (mbe :logic (change-vl-coretype x :signedp nil) :exec (if x.signedp (change-vl-coretype x :signedp nil) x)) :vl-struct (mbe :logic (change-vl-struct x :signedp nil) :exec (if x.signedp (change-vl-struct x :signedp nil) x)) :vl-union (mbe :logic (change-vl-union x :signedp nil) :exec (if x.signedp (change-vl-union x :signedp nil) x)) :otherwise (vl-datatype-fix x)) /// (defret vl-datatype-resolved-p-of-set-unsigned (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x)))) ;; (define vl-datatype-indexing-dimension ((x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :returns (dim (iff (vl-packeddimension-p dim) dim)) ;; (b* ((udims (vl-datatype->udims x)) ;; ((when (consp udims)) (car udims)) ;; (pdims (vl-datatype->pdims x)) ;; ((when (consp pdims)) (car pdims)) (define vl-datatype-remove-dim ((x vl-datatype-p)) :short "Get the type of a variable of type @('x') after an indexing operation is applied to it." :long " <p>The caveat flag returned identifies a case where implementations disagree on the signedness of the resulting type. This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, if we index into an object down to the usertype, NCV treats the resulting object as signed, but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation is correct: from Sec. 7.4.1, Packed Arrays:</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [7:0] btest; assign btest = b[1]; }) <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is considered signed; in VCS, btest has the value @('0f'), indicating that @('b[1]') is considered unsigned.</p>" :prepwork ((local (in-theory (disable not equal-of-cons-rewrite equal-of-vl-usertype acl2::len-when-atom acl2::true-listp-of-nthcdr acl2::true-listp-when-string-listp-rewrite acl2::true-listp-when-symbol-listp-rewrite acl2::nfix-when-not-natp acl2::zp-open acl2::consp-under-iff-when-true-listp acl2::list-fix-under-iff acl2::append-when-not-consp acl2::list-fix-when-len-zero acl2::take-of-len-free double-containment)))) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") (caveat-flag "Indicates caveat about possible signedness ambiguities") (new-x (implies (not err) (vl-datatype-p new-x)) "Datatype after indexing") (dim (implies (not err) (vl-packeddimension-p dim)) "Dimension removed from the datatype")) (b* ((x (vl-maybe-usertype-resolve x)) (udims (vl-datatype->udims x)) ((when (consp udims)) (mv nil nil (vl-datatype-update-udims (cdr udims) x) (car udims))) (pdims (vl-datatype->pdims x)) ((when (consp pdims)) (b* ((x (vl-datatype-set-unsigned x)) ((when (or (vl-datatype-case x :vl-usertype) (consp (cdr pdims)))) ;; (unless (and (eql n np) ;; (not (vl-datatype-case x :vl-usertype)))) (mv nil nil (vl-datatype-update-dims (cdr pdims) nil ;; no udims x) (car pdims))) (new-x (vl-datatype-update-dims nil nil x)) ((mv & signedness) (vl-datatype-signedness new-x))) (mv nil (eq signedness :vl-signed) new-x (car pdims)))) ((unless (vl-datatype-packedp x)) (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) nil nil nil)) ((mv err size) (vl-datatype-size x)) ((when err) (mv err nil nil nil)) ((unless (posp size)) (mv (vmsg "Index applied to ~s0 packed type: ~a1" (if size "unsizeable" "zero-sized") x) nil nil nil)) ((when (and (vl-datatype-case x :vl-coretype) (eql size 1))) (mv (vmsg "Index applied to bit type ~a0" x) nil nil nil)) (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) :lsb (vl-make-index 0))))) (mv nil nil (make-vl-coretype :name :vl-logic) dim)) /// (defret vl-datatype-resolved-p-of-remove-dim (implies (and (not err) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p new-x))) (defret no-error-when-pdims (implies (consp (vl-datatype->pdims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve)))) (defret no-error-when-udims (implies (consp (vl-datatype->udims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve))))) (define vl-selstep-usertypes-ok ((x vl-selstep-p)) (b* (((vl-selstep x))) (vl-datatype-resolved-p x.type))) (define vl-seltrace-usertypes-ok ((x vl-seltrace-p)) (if (atom x) t (and (vl-selstep-usertypes-ok (car x)) (vl-seltrace-usertypes-ok (cdr x)))) /// (defthm vl-seltrace-usertypes-ok-of-append (implies (and (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok y)) (vl-seltrace-usertypes-ok (append x y)))) (defthm vl-seltrace-usertypes-ok-of-rev (implies (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok (rev x)))) (defthm vl-datatype-resolved-p-of-first-seltrace (implies (and (vl-seltrace-usertypes-ok x) (consp x)) (vl-datatype-resolved-p (vl-selstep->type (car x)))) :hints(("Goal" :in-theory (enable vl-selstep-usertypes-ok))))) (define vl-follow-array-indices ((x vl-exprlist-p) (type vl-datatype-p)) :returns (mv (err (iff (vl-msg-p err) err)) (trace vl-seltrace-p)) :guard (vl-datatype-resolved-p type) (b* (((when (atom x)) (mv nil nil)) ((mv err caveat newtype &) (vl-datatype-remove-dim type)) ((when err) (mv err nil)) ((mv err rest) (vl-follow-array-indices (cdr x) newtype)) ((when err) (mv err nil))) (mv nil (cons (make-vl-selstep :select (make-vl-select-index :val (car x)) :type newtype :caveat caveat) rest))) /// (defret vl-seltrace-usertypes-ok-of-follow-array-indices (implies (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (defret true-listp-of-vl-follow-array-indices-trace (true-listp trace) :rule-classes :type-prescription) (defret vl-seltrace->indices-of-vl-follow-array-indices (implies (not err) (equal (vl-seltrace->indices trace) (vl-exprlist-fix x))) :hints(("Goal" :in-theory (enable vl-seltrace->indices)))) (defret consp-of-vl-follow-array-indices (implies (not err) (equal (consp trace) (consp x)))) (defret len-of-vl-follow-array-indices (implies (not err) (equal (len trace) (len x))))) ;; (define vl-datatype-remove-dims ((n natp) ;; (x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :short "Get the type of a variable of type @('x') after @('n') indexing ;; operations are applied to it." ;; :long " ;; <p>The caveat flag returned identifies a case where implementations disagree on ;; the signedness of the resulting type. This caveat occurs when we have packed ;; dimensions on a usertype that is declared as signed. In this case, if we index ;; into an object down to the usertype, NCV treats the resulting object as signed, ;; but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation ;; is correct: from Sec. 7.4.1, Packed Arrays:</p> ;; <blockquote> If a packed array is declared as signed, then the array viewed as ;; a single vector shall be signed. The individual elements of the array are ;; unsigned unless they are of a named type declared as signed. A partselect of a ;; packed array shall be unsigned.</blockquote> ;; <p>An example:</p> ;; @({ ;; typedef logic signed [3:0] squad; ;; squad [3:0] b; ;; assign b = 16'hffff; ;; logic [7:0] btest; ;; assign btest = b[1]; ;; }) ;; <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is ;; considered signed; in VCS, btest has the value @('0f'), indicating that ;; @('b[1]') is considered unsigned.</p>" ;; :prepwork ;; ((local (in-theory (disable not equal-of-cons-rewrite ;; equal-of-vl-usertype ;; acl2::len-when-atom ;; acl2::true-listp-of-nthcdr ;; acl2::true-listp-when-string-listp-rewrite ;; acl2::true-listp-when-symbol-listp-rewrite ;; acl2::nfix-when-not-natp ;; acl2::zp-open ;; acl2::consp-under-iff-when-true-listp ;; acl2::list-fix-under-iff ;; acl2::append-when-not-consp ;; acl2::list-fix-when-len-zero ;; acl2::take-of-len-free ;; double-containment)))) ;; :guard (not (vl-datatype-check-usertypes x ss)) ;; :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") ;; (caveat-flag "Indicates caveat about possible signedness ambiguities") ;; (new-x (implies (not err) (vl-datatype-p new-x)) ;; "Datatype after indexing") ;; (dims vl-packeddimensionlist-p) ;; (new-ss vl-scopestack-p "Scopestack where the most recently looked-up ;; usertype was defined -- this is the scopestack ;; needed to look up the next usertype that ;; might remain in the new type.")) ;; :measure (two-nats-measure ;; n ;; (if (and (vl-datatype-case x :vl-usertype) ;; (not (consp (vl-datatype->udims x))) ;; (not (consp (vl-datatype->pdims x)))) ;; 1 0)) ;; (b* ((x (vl-datatype-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; (udims (redundant-list-fix (vl-datatype->udims x))) ;; (pdims (redundant-list-fix (vl-datatype->pdims x))) ;; (nu (len udims)) ;; (n (lnfix n)) ;; ((when (<= n nu)) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (nthcdr n udims) x) ;; (take n udims) ;; ss)) ;; (n (- n nu)) ;; (np (len pdims)) ;; ((when (<= n np)) ;; (b* ((x (vl-datatype-set-unsigned x)) ;; (dims (append udims (take n pdims))) ;; ((when (or (vl-datatype-case x :vl-usertype) ;; (< n np))) ;; ;; (unless (and (eql n np) ;; ;; (not (vl-datatype-case x :vl-usertype)))) ;; (mv nil nil ;; (vl-datatype-update-dims ;; (nthcdr n pdims) ;; nil ;; no udims ;; x) ;; dims ;; ss)) ;; (new-x (vl-datatype-update-dims nil nil x)) ;; ((mv & signedness) (vl-datatype-signedness new-x ss))) ;; (mv nil (eq signedness :vl-signed) new-x dims ss))) ;; (n (- n np))) ;; (vl-datatype-case x ;; :vl-usertype ;; (b* (((mv err def new-ss) (vl-usertype-resolve x.name ss)) ;; ((when err) (mv err nil nil (append udims pdims) new-ss)) ;; ((mv err caveat new-x rest-dims new-ss) ;; (vl-datatype-remove-dims n def new-ss))) ;; (mv err caveat new-x (append udims pdims rest-dims) new-ss)) ;; :otherwise ;; (b* ((x (vl-datatype-update-dims nil nil x)) ;; ((unless (vl-datatype-packedp x ss)) ;; (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) ;; nil nil (append udims pdims) ss)) ;; ((unless (eql n 1)) ;; (mv (vmsg "Too many indices applied to packed non-array ~a0" x) nil nil (append udims pdims) ss)) ;; ((mv err size) (vl-datatype-size x ss)) ;; ((when err) ;; (mv err nil nil (append udims pdims) ss)) ;; ((unless (posp size)) ;; (mv (vmsg "Index applied to ~s0 packed type: ~a1" ;; (if size "unsizeable" "zero-sized") x) ;; nil nil (append udims pdims) ss)) ;; ((when (and (vl-datatype-case x :vl-coretype) ;; (eql size 1))) ;; (mv (vmsg "Index applied to bit type ~a0" x) nil nil (append udims pdims) ss)) ;; (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))))) ;; (mv nil nil ;; (make-vl-coretype :name :vl-logic) ;; (append udims pdims (list dim)) ;; ss)))) ;; /// ;; (defret vl-datatype-check-usertypes-of-remove-dims ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes new-x new-ss :rec-limit rec-limit))) ;; :hints (("goal" :induct t :in-theory (enable vl-datatype-check-usertypes)))) ;; (defret vl-datatype-remove-dims-true-listp-dims ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret vl-datatype-remove-dims-dims-length ;; (implies (not err) ;; (equal (len dims) ;; (nfix n)))) ;; (verify-guards vl-datatype-remove-dims ;; :hints ((and stable-under-simplificationp ;; '(:expand ((:free (rec-limit) ;; (vl-datatype-check-usertypes x ss :rec-limit rec-limit))))))) ;; (local ;; (defthm vl-datatype-update-dims-compose ;; (equal (vl-datatype-update-dims ;; pdims udims ;; (vl-datatype-update-dims ;; pdims1 udims1 x)) ;; (vl-datatype-update-dims ;; pdims udims x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) ;; (local (Defthm append-of-nil ;; (equal (append nil x) x) ;; :hints(("Goal" :in-theory (enable append))))) ;; (local (defthm list-fix-of-nthcdr ;; (equal (list-fix (nthcdr n x)) ;; (nthcdr n (list-fix x))))) ;; (local (in-theory (disable acl2::nthcdr-of-list-fix))) ;; (local (defthm append-take-take-nthcdr ;; (equal (append (take n a) ;; (take m (nthcdr n a))) ;; (take (+ (nfix n) (nfix m)) a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a)) ;; a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (defthm append-take-take-nthcdr-1 ;; (equal (append (take n a) ;; (take m (nthcdr n a)) ;; x) ;; (append (take (+ (nfix n) (nfix m)) a) x)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr-1 ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a) ;; x) ;; (append a x))) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (in-theory (disable ACL2::INEQUALITY-WITH-NFIX-HYP-1))) ;; ;; (local (defthm nfix-linear ;; ;; (<= 0 (nfix n)) ;; ;; :rule-classes :linear)) ;; (local (defthm vl-datatype-kind-of-set-unsigned ;; (equal (vl-datatype-kind (vl-datatype-set-unsigned x)) ;; (vl-datatype-kind x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (defthm packedp-update-dims-of-set-unsigned ;; (equal (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss) ;; (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss)) ;; :hints(("Goal" :in-theory (enable vl-datatype-packedp ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm size-update-dims-of-set-unsigned ;; (b* (((mv err1 size1) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss)) ;; ((mv err2 size2) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss))) ;; (and (iff err1 err2) ;; (equal size1 size2))) ;; :hints(("Goal" :in-theory (enable vl-datatype-size ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm vl-usertype->name-of-update-dims ;; (equal (vl-usertype->name (vl-datatype-update-dims pdims udims x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-usertype->name-of-set-unsigned ;; (equal (vl-usertype->name (vl-datatype-set-unsigned x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-datatype-set-unsigned-of-update-dims ;; (Equal (vl-datatype-set-unsigned ;; (vl-datatype-update-dims pdims udims x)) ;; (vl-datatype-update-dims pdims udims (vl-datatype-set-unsigned x))) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-datatype-update-dims))))) ;; (local (Defthm vl-datatype-set-unsigned-idempotent ;; (equal (vl-datatype-set-unsigned (vl-datatype-set-unsigned x)) ;; (vl-datatype-set-unsigned x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (in-theory (disable vl-datatype-fix-when-vl-coretype ;; vl-datatype-fix-when-vl-struct ;; vl-datatype-fix-when-vl-union ;; vl-datatype-fix-when-vl-enum ;; vl-datatype-fix-when-vl-usertype))) ;; (local (defthm <=-when-equal ;; (implies (equal a b) ;; (<= a b)))) ;; (defthm vl-datatype-remove-dims-compose ;; (b* (((mv err ?caveat new-x dims new-ss) ;; (vl-datatype-remove-dims (+ (nfix n) (nfix m)) x ss)) ;; ((mv err1 ?caveat1 new-x1 dims1 new-ss1) ;; (vl-datatype-remove-dims n x ss)) ;; ((mv err2 ?caveat2 new-x2 dims2 new-ss2) ;; (vl-datatype-remove-dims m new-x1 new-ss1))) ;; (implies (not err) ;; (and (not err1) ;; (not err2) ;; ;; (equal caveat2 caveat) ;; (equal new-x2 new-x) ;; (equal new-ss2 new-ss) ;; (list-equiv (append dims1 dims2) dims)))) ;; :hints (("goal" :induct (vl-datatype-remove-dims n x ss) ;; :in-theory (disable (:d vl-datatype-remove-dims)) ;; :expand ((:free (n) (vl-datatype-remove-dims n x ss)) ;; (:free (x ss) ;; (vl-datatype-remove-dims 1 x ss)) ;; ;; (:free (x) (vl-datatype-size (vl-datatype-update-dims nil nil x) ss)) ;; )) ;; ;; (and stable-under-simplificationp ;; ;; '(:in-theory (enable ;; ;; vl-datatype-update-dims ;; ;; vl-datatype-set-unsigned ;; ;; vl-datatype-packedp))) ;; (and stable-under-simplificationp ;; '(:expand ((:free (x ss) ;; (vl-datatype-remove-dims m x ss))))) ;; ))) ;; (define vl-hidindex-datatype-resolve-dims ((x vl-hidindex-p) ;; (type vl-datatype-p)) ;; :short "Given the indices of some expression, e.g. foo[5][3], and the ;; datatype of foo, return the datatype of the whole expression." ;; :long "<p>Note: we don't check whether indices are in bounds or anything, ;; just whether the number of indices is less than or equal the number of ;; total (unpacked plus packed) dimensions.</p> ;; <p>We produce a non-fatal warning because we're not sure in what contexts this ;; will be used.</p> ;; <p>Example: Suppose our datatype is from a typedef</p> ;; @({ ;; typedef bit [3:0] [4:2] foo [0:6] [0:8]; ;; }) ;; <p>that is, it has one unpacked dimension @('[0:6]') and two packed dimensions. ;; Suppose our expression is @('bar[5][7][2]'), where bar is of type foo. Then we ;; should return @('bit[4:2]') as our resolved datatype, with no unpacked ;; dimensions, because the first two indices correspond to the unpacked dimension ;; and the second to the first packed dimension. On the other hand if we had ;; @('bar[5]'), we should return @('bit') with packed dimensions @('[3:0][4:2]') ;; and unpacked dimension @('[0:8]').</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type1 (iff (vl-datatype-p type1) (not warning)))) ;; (b* ((idxcount (len (vl-hidindex->indices x))) ;; (type (vl-datatype-fix type)) ;; (x (vl-hidindex-fix x)) ;; (unpacked-dims (vl-datatype->udims type)) ;; (packed-dims (vl-datatype->pdims type)) ;; (nunpacked (len unpacked-dims)) ;; ((when (<= idxcount nunpacked)) ;; (mv nil (vl-datatype-update-udims ;; (nthcdr idxcount (redundant-list-fix unpacked-dims)) type))) ;; (remaining-idxcount (- idxcount nunpacked)) ;; ((unless (<= remaining-idxcount (len packed-dims))) ;; (mv (make-vl-warning :type :vl-too-many-indices ;; :msg "Too many indices on expression ~a0 ~ ;; relative to dimensions of type ~a1." ;; :args (list x type) ;; :fn __function__) ;; nil)) ;; (type (vl-datatype-update-dims ;; (nthcdr remaining-idxcount (redundant-list-fix packed-dims)) ;; nil ;; udims ;; type))) ;; (mv nil type))) ;; Have a HID, and know (for the base name) the type (unresolved) and unpacked ;; dims. ;; Resolve the type. ;; If the hid is an ID, return the type and dims. ;; Resolve the indices of the base part against the unpacked/packed dims. If we ;; end up still having dims remaining, fail. ;; If the type is not a struct or union type, fail. ;; Find the next name in the HID among the structmembers. If not found, fail. ;; Recur with the rest of the HID and the type/unpacked dims of the member. ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (final-type (implies (not err) (vl-datatype-p final-type)))) ;; (b* (((mv type ss) ;; (if (vl-datatype-case type :vl-usertype) ;; (b* (((mv & type ss) (vl-usertype-resolve type ss))) ;; (mv type ss)) ;; (mv type ss))) ;; ((mv name1 indices rest) ;; (vl-hidexpr-case x ;; :end (mv x.name nil nil) ;; :dot (b* (((vl-hidindex x.first))) ;; (mv x.first.name x.first.indices x.rest)))) ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and (atom (vl-datatype->udims type)) ;; (atom (vl-datatype->pdims type)) ;; ok)) ;; (mv (vmsg "Can't get field ~s0 from non-struct/union type ~a1" ;; name1 type) ;; nil)) ;; (member (vl-find-structmember name1 members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil)) ;; (membtype (vl-structmember->type member)) (define vl-hidexpr-index-count ((x vl-hidexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end 0 :dot (+ (len (vl-hidindex->indices x.first)) (vl-hidexpr-index-count x.rest)))) (define vl-scopeexpr-index-count ((x vl-scopeexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-index-count x.hid) :colon (vl-scopeexpr-index-count x.rest))) (define vl-follow-data-selects ((x vl-hidexpr-p) (type vl-datatype-p) (trace vl-seltrace-p "Accumulator")) :short "Given a HID expression denoting a variable of the input type, create a trace showing the type of each field select/indexing operation." :long "<p>Implementation notes: This function only </p>" :returns (mv (err (iff (vl-msg-p err) err)) (seltrace vl-seltrace-p)) :measure (vl-hidexpr-count x) :guard (vl-datatype-resolved-p type) :verify-guards nil ;; Resolve the type and dims. (b* ((type (vl-datatype-fix type)) ;; (name1 (vl-hidexpr-case x ;; :end x.name ;; :dot (vl-hidindex->name x.first))) ;; (frame (make-vl-selstep ;; :select (make-vl-select-field :name name1) ;; :type type ;; :ss ss)) ;; (trace (cons frame (vl-seltrace-fix trace))) (trace (vl-seltrace-fix trace)) ((when (vl-hidexpr-case x :end)) ;; We just have an ID. It has already been added to the trace (or else ;; it is just a plain variable and the outer hidtrace has its type info). (mv nil trace)) ;; Cancel the indices of the first element of the HID with the unpacked ;; and packed dims of the type. ;; Note: We have at least one more dot in this HID, so if we don't have ;; a struct or union at the end of this, we have a problem. ((vl-hidexpr-dot x)) ((mv err rev-idxtrace) (vl-follow-array-indices (vl-hidindex->indices x.first) type)) ((when err) (mv err nil)) (trace (revappend rev-idxtrace trace)) (type (if (consp rev-idxtrace) (vl-selstep->type (car trace)) type)) (type (vl-maybe-usertype-resolve type)) ;; Next we're going to dot-index into the datatype, so get its ;; structmembers, making sure it's a struct. ((mv ok members) (vl-datatype->structmembers type)) (nextname (vl-hidexpr-case x.rest :end x.rest.name :dot (vl-hidindex->name x.rest.first))) ;; Look up the member corresponding to the next name in the hid. ((unless (and ok (atom (vl-datatype->udims type)) (atom (vl-datatype->pdims type)))) (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" nextname (vl-datatype-update-dims (append-without-guard (vl-datatype->udims type) (vl-datatype->pdims type)) nil type)) nil)) ((when (eq nextname :vl-$root)) (mv (vmsg "Can't use $root to index into a data structure: ~a0" (vl-hidexpr-fix x)) nil)) (member (vl-find-structmember nextname members)) ((unless member) (mv (vmsg "Dot-indexing failed: struct/union member ~ ~s0 not found in type ~a1" nextname (vl-datatype-fix type)) nil)) (membtype (vl-structmember->type member)) (next-frame (make-vl-selstep :select (make-vl-select-field :name nextname) :type membtype)) (trace (cons next-frame trace))) (vl-follow-data-selects x.rest membtype trace)) /// (verify-guards vl-follow-data-selects) (defret vl-seltrace-usertypes-ok-of-vl-follow-data-selects (implies (and (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) (vl-seltrace-usertypes-ok seltrace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (local (in-theory (disable acl2::car-of-append acl2::consp-under-iff-when-true-listp))) (defret vl-seltrace-indices-of-vl-follow-data-selects (implies (not err) (equal (vl-seltrace->indices seltrace) (revappend (vl-hidexpr->subexprs x) (vl-seltrace->indices trace)))) :hints(("Goal" :in-theory (enable vl-seltrace->indices vl-hidexpr->subexprs))))) ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Given a HID expression that indexes into a datatype, find the type ;; of the expression." ;; :long " <p>A helpful invariant to remember when thinking about this function: ;; The type input of a given call of this function belong to the base (leftmost) ;; variable in the HID.</p> ;; <p>Example: Suppose we have the following type declarations</p> ;; @({ ;; typedef struct packed { logic [3:0] foo; } [4:0] foostruct; ;; typedef union { foostruct [5:0] bar; logic [2:0] baz; } bunion [0:6]; ;; typedef struct { bunion fa [0:8], logic [1:0] ba; } bstruct; ;; bstruct myvar [8:0]; ;; }) ;; <p>For this example, we'll write a type with both packed an unpacked dimensions ;; with an underscore between the packed and unpacked dims.</p> ;; <p>A bunion is a type consisting of an unpacked array of 7 elements ;; each of which may either be a packed array of 6 foostructs (a packed structure ;; containing one 4-bit logic field) or a 3-bit logic; a bstruct is a struct ;; containing an unpacked array of 9 bunions and an additional 2-bit logic field; ;; and myvar is an unpacked array of 9 bstructs.</p> ;; <p>Suppose our expression is @('myvar[1].fa[8][4].bar[3][4].foo').</p> ;; <ul> ;; <li>First, before calling this function we look up the type of myvar. We get a ;; vardecl, which has a type @('bstruct _ [8:0]'). Then we're ready to run.</li> ;; <li>Outermost call: We resolve the type bstruct to its struct definition. We ;; cancel our index with the single array dimension, leaving just the struct. We ;; find the element fa inside the struct, and ;; recur on the remainder of our expression, @('fa[8][4].bar[3][4].foo'), with the ;; structmember's type, @('bunion _ [0:8]').</li> ;; <li> We resolve the bunion type to the union, and append the unpacked ;; dimensions of the type and the element to get @('[0:8][0:6]'). We then check ;; the indices from the expression against this type and unpacked dimensions, ;; which results in just the bare union type (the definition of bunion, but ;; without its unpacked dimension @('[0:6]')). We find the element bar inside the ;; union and recur: @('bar[3][4].foo'), type @('foostruct[5:0]').</li> ;; <li> We resolve the type foostruct to its struct type, and append the packed ;; dimensions to get @('[5:0][4:0]'). We then check the indices from the ;; expression, which results in cancelling out the dimension to obtain just the ;; bare struct. We find the element foo of the struct and recur on that.</li> ;; <li>Finally, we have just the atom @('foo') as our expression, so we return the ;; type @('logic[3:0]').</li> </ul>" ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :verify-guards nil ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (restype (iff (vl-datatype-p restype) (not err))) ;; (dims vl-packeddimensionlist-p ;; "Dimensions of indices along the way") ;; (final-ss vl-scopestack-p "Scopestack in which the last usertype was found")) ;; ;; Resolve the type and dims. ;; (b* ((type (vl-datatype-fix type)) ;; (ss (vl-scopestack-fix ss)) ;; ((when (vl-hidexpr-case x :end)) ;; ;; We just have an ID. Return the resolved type. ;; (mv nil type nil ss)) ;; ;; Cancel the indices of the first element of the HID with the unpacked ;; ;; and packed dims of the type. ;; ;; Note: We have at least one more dot in this HID, so if we don't have ;; ;; a struct or union at the end of this, we have a problem. ;; ((vl-hidexpr-dot x)) ;; (nindices (len (vl-hidindex->indices x.first))) ;; ((mv err ?caveat idxtype dims ss) ;; ;; Ignore the caveat because we're going dot-index into the new type at ;; ;; least once more. ;; (vl-datatype-remove-dims nindices type ss)) ;; ((when err) (mv err nil nil ss)) ;; ((mv baretype ss) (vl-maybe-usertype-resolve idxtype ss)) ;; ;; Next we're going to dot-index into the datatype, so get its ;; ;; structmembers, making sure it's a struct. ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and ok ;; (atom (vl-datatype->udims baretype)) ;; (atom (vl-datatype->pdims baretype)))) ;; (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" ;; (vl-datatype-update-dims (append-without-guard ;; (vl-datatype->udims baretype) ;; (vl-datatype->pdims baretype)) ;; nil baretype)) ;; nil nil ss)) ;; ;; Look up the member corresponding to the next name in the hid. ;; (nextname (vl-hidexpr-case x.rest ;; :end x.rest.name ;; :dot (vl-hidindex->name x.rest.first))) ;; (member (vl-find-structmember nextname members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil nil ss)) ;; (membtype (vl-structmember->type member)) ;; ((mv err type rest-dims ss) ;; (vl-hidexpr-traverse-datatype x.rest membtype ss))) ;; (mv err type (append dims rest-dims) ss)) ;; /// ;; (defret true-listp-dims-of-vl-hidexpr-traverse-datatype ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-hidexpr-traverse-datatype ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count x))) ;; :hints(("Goal" :in-theory (enable vl-hidexpr-index-count)))) ;; ;; bozo move these two theorems ;; (defthm vl-structmemberlist-check-usertypes-of-vl-datatype->structmembers ;; (b* (((mv ok members) (vl-datatype->structmembers x))) ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; ok) ;; (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)))) ;; :hints(("Goal" :in-theory (enable vl-datatype->structmembers ;; vl-datatype-check-usertypes)))) ;; (defthm vl-datatype-check-usertypes-of-find-structmember ;; (implies (and (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)) ;; (vl-find-structmember name members)) ;; (not (vl-datatype-check-usertypes ;; (vl-structmember->type (vl-find-structmember name members)) ;; ss :rec-limit rec-limit))) ;; :hints(("Goal" :in-theory (enable vl-structmemberlist-check-usertypes ;; vl-find-structmember)))) ;; (verify-guards vl-hidexpr-traverse-datatype) ;; (defret vl-datatype-check-usertypes-of-vl-hidexpr-traverse-datatype ;; (implies (and (not (vl-datatype-check-usertypes type ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes restype final-ss :rec-limit rec-limit))))) ;; (define vl-scopeexpr-find-type ((x vl-scopeexpr-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Looks up a HID in a scopestack and looks for a declaration, returning ;; the type if found, and the scopestack relative to that type." ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (iff (vl-datatype-p type) (not err))) ;; (dims vl-packeddimensionlist-p) ;; (type-ss vl-scopestack-p)) ;; (b* ((x (vl-scopeexpr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv err trace tail) (vl-follow-scopeexpr x ss)) ;; ((when err) (mv err nil nil ss)) ;; ((vl-hidstep step1) (car trace)) ;; ((when (eq (tag step1.item) :vl-vardecl)) ;; ;; check its datatype ;; (b* (((vl-vardecl step1.item)) ;; (err (vl-datatype-check-usertypes step1.item.type step1.ss)) ;; ((when err) (mv err nil nil step1.ss))) ;; (vl-hidexpr-traverse-datatype tail step1.item.type step1.ss)))) ;; (mv (vmsg "Failed to find a type for ~s1 because we ~ ;; didn't find a vardecl but rather a ~x2" ;; nil x (tag step1.item)) ;; nil nil ss)) ;; /// ;; (defret true-listp-dims-of-vl-scopeexpr-find-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count (mv-nth 2 (vl-follow-scopeexpr x ss))))) ;; :hints(("Goal" :in-theory (enable vl-scopeexpr-index-count)))) ;; (defret vl-datatype-check-usertypes-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret follow-scopeexpr-when-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (mv-nth 0 (vl-follow-scopeexpr x ss)))))) (define vl-partselect-width ((x vl-partselect-p)) :guard (not (vl-partselect-case x :none)) :returns (mv (err (iff (vl-msg-p err) err)) (width (implies (not err) (posp width)) :rule-classes :type-prescription)) (b* ((x (vl-partselect-fix x))) (vl-partselect-case x :range (b* (((unless (and (vl-expr-resolved-p x.msb) (vl-expr-resolved-p x.lsb))) (mv (vmsg "Unresolved partselect: ~a0" x) nil)) (msb (vl-resolved->val x.msb)) (lsb (vl-resolved->val x.lsb))) ;; BOZO We might want to check here whether the msb/lsb are ;; correctly ascending/descending. Not the core mission, though. (mv nil (+ 1 (abs (- msb lsb))))) :plusminus (b* (((unless (vl-expr-resolved-p x.width)) (mv (vmsg "Unresolved partselect width: ~a0" x) nil)) (width (vl-resolved->val x.width)) ((when (eql width 0)) (mv (vmsg "Zero-width partselect not allowed: ~a0" x) nil))) (mv nil width)) :otherwise (mv (vmsg "Impossible") (impossible))))) (define vl-operandinfo-usertypes-ok ((x vl-operandinfo-p)) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace))) /// (defthm vl-operandinfo-usertypes-ok-implies (implies (vl-operandinfo-usertypes-ok x) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace)))))) (define vl-operandinfo-index-count ((x vl-operandinfo-p)) :returns (count natp :rule-classes :type-prescription) ;; Gives the number of indices (b* (((vl-operandinfo x))) (+ (vl-seltrace-index-count x.seltrace) (vl-partselect-case x.part :none 0 :otherwise 2)))) (define vl-operandinfo->indices ((x vl-operandinfo-p)) :returns (indices vl-exprlist-p) (b* (((vl-operandinfo x))) (append (vl-partselect-case x.part :none nil :range (list x.part.msb x.part.lsb) :plusminus (list x.part.base x.part.width)) (vl-seltrace->indices x.seltrace))) /// (defret len-of-vl-operandinfo->indices (equal (len indices) (vl-operandinfo-index-count x)) :hints(("Goal" :in-theory (enable vl-operandinfo-index-count))))) (defthm vl-exprlist-count-of-append (equal (vl-exprlist-count (append a b)) (+ -1 (vl-exprlist-count a) (vl-exprlist-count b))) :hints(("Goal" :in-theory (enable vl-exprlist-count append)))) (defthm vl-exprlist-count-of-rev (equal (vl-exprlist-count (rev x)) (vl-exprlist-count x)) :hints(("Goal" :in-theory (enable vl-exprlist-count rev)))) (define vl-datatype-resolve-selects ((type vl-datatype-p) (tail vl-hidexpr-p) (indices vl-exprlist-p) (part vl-partselect-p)) :returns (mv (err (iff (vl-msg-p err) err)) (seltrace (implies (not err) (vl-seltrace-p seltrace))) (finaltype (implies (not err) (vl-datatype-p finaltype)))) :guard (vl-datatype-resolved-p type) (b* (((mv err seltrace) (vl-follow-data-selects tail type nil)) ((when err) (mv err nil nil)) (type (vl-datatype-fix type)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((mv err rev-idxtrace) (vl-follow-array-indices indices seltype)) ((when err) (mv err nil nil)) (seltrace (revappend rev-idxtrace seltrace)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((when (vl-partselect-case part :none)) (mv nil seltrace seltype)) ((mv err ?caveat single-type &) (vl-datatype-remove-dim seltype)) ((when err) (mv err nil nil)) ((mv err width) (vl-partselect-width part)) ((when err) (mv err nil nil)) (new-dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) (packedp (vl-datatype-packedp seltype)) (psel-type (if packedp (vl-datatype-update-pdims (cons new-dim (vl-datatype->pdims single-type)) single-type) (vl-datatype-update-udims (cons new-dim (vl-datatype->udims single-type)) single-type)))) (mv nil seltrace psel-type)) /// (defret vl-seltrace-usertypes-ok-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-seltrace-usertypes-ok seltrace))) (defret vl-datatype-resolved-p-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-datatype-resolved-p finaltype))) (defret vl-seltrace-count-of-vl-datatype-resolve-selects (implies (not err) (< (vl-exprlist-count (vl-seltrace->indices seltrace)) (+ (vl-exprlist-count indices) (vl-hidexpr-count tail)))) :rule-classes :linear)) (define vl-index-expr-typetrace ((x vl-expr-p "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical identifier with 0 or more array selects and a possible partselect.") (ss vl-scopestack-p "Scopestack where @('x') is referenced.") (typeov vl-typeoverride-p)) :guard (vl-expr-case x :vl-index) :returns (mv (err (iff (vl-msg-p err) err) "Success indicator, we fail if we can't follow the HID or this isn't an appropriate expression.") (opinfo (implies (not err) (vl-operandinfo-p opinfo)))) :prepwork ((local (defthm natp-abs (implies (integerp x) (natp (abs x))) :rule-classes :type-prescription)) (local (in-theory (disable abs)))) (b* (((vl-index x) (vl-expr-fix x)) (ss (vl-scopestack-fix ss)) ((mv err hidtrace context tail) (vl-follow-scopeexpr x.scope ss)) ((when err) (mv err nil)) ((vl-hidstep hidstep) (car hidtrace)) ;; Suppose x is foo.bar.baz.fum[0][1][3:2]. ;; Suppose foo.bar is the actual vardecl, and .baz.fum are selects into it. ;; We want to see if foo.bar has a cached resolved type. ;; Compute foo.bar. (prefix-name (vl-scopeexpr-replace-hid x.scope (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ((mv err type) (b* ((look (hons-get prefix-name (vl-typeoverride-fix typeov))) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: Type override was unresolved") nil)))) (case (tag hidstep.item) (:vl-vardecl (b* ((type1 (vl-vardecl->type hidstep.item))) (vl-datatype-usertype-resolve type1 hidstep.ss :typeov typeov))) (:vl-paramdecl (b* (((vl-paramdecl decl) hidstep.item)) (vl-paramtype-case decl.type :vl-explicitvalueparam (if (vl-datatype-resolved-p decl.type.type) (mv nil decl.type.type) (mv (vmsg "Reference to parameter with unresolved type: ~a0" x) nil)) :otherwise (mv (vmsg "Bad parameter reference: ~a0" x) nil)))) (otherwise (mv (vmsg "~a0: instead of a vardecl, found ~a1" x hidstep.item) nil))))) ((when err) (mv err nil)) ((mv err seltrace final-type) (vl-datatype-resolve-selects type tail x.indices x.part)) ((when err) (mv err nil))) (mv nil (make-vl-operandinfo :context context :prefixname prefix-name :hidtrace hidtrace :hidtype type :seltrace seltrace :part x.part :type final-type))) ;; ((mv err seltrace) (vl-follow-data-selects tail type nil)) ;; ((when err) (mv err nil)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; ((mv err rev-idxtrace) ;; (vl-follow-array-indices x.indices seltype)) ;; ((when err) (mv err nil)) ;; (seltrace (revappend rev-idxtrace seltrace)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; (prefix-name (vl-scopeexpr-replace-hid ;; x.scope ;; (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ;; ((when (vl-partselect-case x.part :none)) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type seltype))) ;; ((mv err ?caveat single-type &) ;; (vl-datatype-remove-dim seltype)) ;; ((when err) (mv err nil)) ;; ((mv err width) (vl-partselect-width x.part)) ;; ((when err) (mv err nil)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (packedp (vl-datatype-packedp seltype)) ;; (psel-type (if packedp ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type)))) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type psel-type))) /// (defret vl-seltrace-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-seltrace-usertypes-ok (vl-operandinfo->seltrace opinfo)))) (defret consp-hidtrace-of-vl-index-expr-typetrace (implies (not err) (consp (vl-operandinfo->hidtrace opinfo)))) ;; (defret vl-hidtrace-top-is-vardecl-or-paramdecl-of-vl-index-expr-typetrace ;; (implies (and (not err) ;; (not (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-paramdecl))) ;; (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-vardecl))) (defret vl-datatype-usertypes-ok-of-vl-index-expr-typetrace-type (implies (not err) (vl-datatype-resolved-p (vl-operandinfo->type opinfo)))) (defret vl-operandinfo-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-operandinfo-usertypes-ok opinfo)) :hints(("Goal" :in-theory (enable vl-operandinfo-usertypes-ok)))) (defret follow-scopeexpr-when-vl-index-expr-type (implies (not err) (b* (((vl-index x))) (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss)))))) (defret index-count-of-vl-index-expr-typetrace (implies (and (not err) (equal (vl-expr-kind x) :vl-index)) (< (vl-exprlist-count (vl-operandinfo->indices opinfo)) (vl-expr-count x))) :hints(("Goal" :in-theory (enable vl-operandinfo->indices vl-exprlist-count vl-partselect-count vl-plusminus-count vl-range-count) :expand ((vl-expr-count x)))) :rule-classes :linear)) ;; (define vl-index-expr-typetrace ;; ((x vl-expr-p ;; "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical ;; identifier with 0 or more array selects and a possible partselect.") ;; (ss vl-scopestack-p ;; "Scopestack where @('x') is referenced.")) ;; :guard (vl-expr-case x :vl-index) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (caveat-flg) ;; (type (implies (not err) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.") ;; (dims vl-packeddimensionlist-p ;; "Dimensions corresponding to the array indices in the expression") ;; (type-ss vl-scopestack-p ;; "Scopestack relative to the type returned.")) ;; :prepwork ((local (defthm natp-abs ;; (implies (integerp x) ;; (natp (abs x))) ;; :rule-classes :type-prescription)) ;; (local (in-theory (disable abs)))) ;; (b* (((vl-index x) (vl-expr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv warning type sdims type-ss) (vl-scopeexpr-find-type x.scope ss)) ;; ((when warning) (mv warning nil nil nil ss)) ;; (has-partselect (vl-partselect-case x.part ;; :none nil ;; :otherwise t)) ;; ((mv err caveat-flg reduced-type idims reduced-ss) ;; (vl-datatype-remove-dims (len x.indices) type type-ss)) ;; ((when err) (mv err nil nil nil reduced-ss)) ;; ((unless has-partselect) ;; (mv nil ;; caveat-flg ;; reduced-type ;; (append sdims idims) ;; reduced-ss)) ;; ;; Take off one more dimension, and then add a dimension the width of ;; ;; the partselect. ;; ;; Caveat-flag doesn't apply because implementations seem to agree that ;; ;; partselects are always unsigned. ;; ((mv err ?caveat-flg single-type psdims single-ss) ;; (vl-datatype-remove-dims 1 reduced-type reduced-ss)) ;; ((when err) ;; (mv err nil nil nil single-ss)) ;; ((mv err width) ;; (vl-partselect-width x.part)) ;; ((when err) (mv err nil nil nil single-ss)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range ;; :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (dims (append sdims idims psdims)) ;; ;; The result is now width many elements of ;; ;; type single-type. So we add a dimension [width-1:0] back onto ;; ;; reduced-type. However, we need to know whether it should be an ;; ;; unpacked or packed dimension: the way to determine this is whether ;; ;; the last dimension selected was packed or unpacked. ;; (packedp (vl-datatype-packedp reduced-type reduced-ss)) ;; ((when packedp) ;; (mv nil nil ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; dims ;; single-ss))) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type) ;; dims ;; single-ss)) ;; /// ;; (defret vl-datatype-check-usertypes-of-vl-index-expr-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret true-listp-dims-of-vl-index-expr-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-index-expr-type ;; (implies (not err) ;; (equal (len dims) ;; (b* (((vl-index x))) ;; (+ (len x.indices) ;; (vl-partselect-case x.part :none 0 :otherwise 1) ;; (vl-hidexpr-index-count ;; (mv-nth 2 (vl-follow-scopeexpr x.scope ss)))))))) ;; (defret follow-scopeexpr-when-vl-index-expr-type ;; (implies (not err) ;; (b* (((vl-index x))) ;; (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss))))))) #|| (trace$ #!vl (vl-index-find-type :entry (list 'vl-index-find-type (with-local-ps (vl-pp-expr x)) ;; (if (equal (vl-pps-expr x) "popcounts[30]") ;; (break$) ;; nil) ) :exit (cons 'vl-index-find-type (b* (((list warning type) values)) (list type (with-local-ps (if warning (vl-print-warnings (list warning)) (vl-ps-seq (vl-pp-datatype type) (vl-print " udims: ") (vl-pp-packeddimensionlist (vl-datatype->udims type)))))))))) ||# ;; (define vl-index-find-type ;; ((x vl-expr-p "Should be a hid (perhaps just an ID), perhaps with some indexing ;; operators applied to it, i.e., bitselect or index operators but ;; not part-select operators. So for instance: @('foo, foo.bar, ;; foo.bar[3], foo.bar[3][4][5]')") ;; (ss vl-scopestack-p "Scopestack where @('x') occurs.") ;; (ctx acl2::any-p)) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (type (implies (not warning) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.")) ;; :prepwork ((local (in-theory (disable default-car ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :verify-guards nil ;; :measure (vl-expr-count x) ;; (b* ((x (vl-expr-fix x)) ;; ((when (or (vl-atom-p x) ;; (not (member (vl-nonatom->op x) ;; '(:vl-index :vl-bitselect))))) ;; (b* (((unless (vl-hidexpr-p x)) ;; (mv (make-vl-warning ;; :type :vl-bad-index-expr ;; :msg "~a0: An index operator was applied to a bad subexpression, ~a1." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning type) (vl-hidexpr-find-type x ss ctx)) ;; ((when warning) (mv warning nil))) ;; (mv nil type))) ;; ((vl-nonatom x)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; ((when (consp udims)) ;; ;; We could check here that the index is in bounds, but maybe that ;; ;; should more appropriately be done elsewhere. ;; (mv nil (vl-datatype-update-udims (cdr udims) sub-type))) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((when (consp pdims)) ;; ;; An index operator applied to packed dimensions makes the datatype unsigned. ;; (mv nil (vl-datatype-update-pdims (cdr pdims) (vl-datatype-set-unsigned sub-type)))) ;; ;; If there are no dimensions, the index has to be a bitselect; check ;; ;; whether this is ok. ;; ((when (vl-datatype-bitselect-ok sub-type)) ;; ;; We have a bitselect of some packed non-array type. The result is ;; ;; therefore an unsigned single bit. ;; (mv nil ;; (make-vl-coretype :name :vl-logic)))) ;; (mv (make-vl-warning :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because ~ ;; it has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; /// ;; (verify-guards vl-index-find-type ;; :hints(("Goal" :in-theory (e/d (acl2::member-of-cons) ;; (vl-index-find-type))))) ;; (defthm context-irrelevance-of-vl-index-find-type ;; (implies (syntaxp (not (equal ctx ''nil))) ;; (b* (((mv err1 type1) (vl-index-find-type x ss ctx)) ;; ((mv err2 type2) (vl-index-find-type x ss nil))) ;; (and (iff err1 err2) ;; (equal type1 type2)))))) ;; (define vl-partselect-type-top-dimension-replacement ((dim vl-packeddimension-p) ;; (x vl-expr-p) ;; (ctx vl-context-p)) ;; :guard-hints ((and stable-under-simplificationp ;; '(:in-theory (enable acl2::member-of-cons)))) ;; :guard (and (not (vl-atom-p x)) ;; (member (vl-nonatom->op x) ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (range (implies (not warning) (vl-range-p range)))) ;; (b* (((vl-nonatom x)) ;; (x (vl-expr-fix x)) ;; (dim (vl-packeddimension-fix dim)) ;; (ctx (vl-context-fix ctx)) ;; ((when (or (eq dim :vl-unsized-dimension) ;; (not (vl-range-resolved-p dim)))) ;; (mv (make-vl-warning :type :vl-partselect-type-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; most significant dimension of the type of ~ ;; ~a2 was unsized or non-constant." ;; :args (list ctx x (first x.args)) ;; :fn __function__) ;; nil)) ;; ((unless (and (vl-expr-resolved-p (third x.args)) ;; (or (not (member x.op '(:vl-partselect-colon ;; :vl-select-colon))) ;; (vl-expr-resolved-p (second x.args))))) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; partselect has non-constant indices." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((when (member x.op '(:vl-select-colon :vl-partselect-colon))) ;; (mv nil (make-vl-range :msb (second x.args) :lsb (third x.args)))) ;; (width (vl-resolved->val (third x.args))) ;; ((unless (posp width)) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Zero width in partselect operator?" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((unless (vl-expr-resolved-p (second x.args))) ;; (mv nil (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) ;; ;; The second argument is resolved, so set the range as specified. ;; (m-or-lsb (vl-resolved->val (second x.args))) ;; (backward-range-p (< (vl-resolved->val (vl-range->msb dim)) ;; (vl-resolved->val (vl-range->lsb dim)))) ;; (greater-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; (+ m-or-lsb width -1) ;; m-or-lsb)) ;; (lesser-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; m-or-lsb ;; (+ m-or-lsb (- width) 1))) ;; ((when (< lesser-idx 0)) ;; (mv (make-vl-warning :type :vl-partselect-index-error ;; :msg "~a0: Partselect ~s1 operator yields negative index: ~a2" ;; :args (list ctx (if (eq x.op :vl-partselect-pluscolon) ;; "+:" "-:") ;; x) ;; :fn __function__) ;; nil)) ;; (range (make-vl-range :msb (vl-make-index (if backward-range-p lesser-idx greater-idx)) ;; :lsb (vl-make-index (if backward-range-p greater-idx lesser-idx))))) ;; (mv nil range)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-type-top-dimension-replacement ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x nil))) ;; (iff (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x nil))))))) ;; (define vl-partselect-expr-type ((x vl-expr-p) ;; (ss vl-scopestack-p) ;; (ctx vl-context-p "context")) ;; :guard (not (eq (vl-expr-kind x) :atom)) ;; :guard-hints (("goal" :in-theory (enable acl2::member-of-cons))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (implies (not warning) (vl-datatype-p type)))) ;; :prepwork ((local (in-theory (disable default-car default-cdr ;; vl-expr-resolved-p-of-car-when-vl-exprlist-resolved-p ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :measure (vl-expr-count x) ;; (b* ((ctx (vl-context-fix ctx)) ;; ((vl-nonatom x) (vl-expr-fix x)) ;; ((unless (member x.op ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; (mv (make-vl-warning :type :vl-programming-error ;; :msg "~a0: called vl-partselect-selfsize on non-partselect expr ~a1" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((unless (or (consp udims) (consp pdims))) ;; (b* (((unless (vl-datatype-bitselect-ok sub-type)) ;; (mv (make-vl-warning ;; :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because it ~ ;; has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; ((mv warning size) (vl-datatype-size sub-type)) ;; ((when warning) (mv warning nil)) ;; ;; The type is some packed thing, and we have its size. As long ;; ;; as the partselect is in range, we'll just return a new logic ;; ;; with the correct dimension on it. ;; (range (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement range x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (make-vl-coretype :name :vl-logic ;; :pdims (list new-dim1)))) ;; (mv nil new-type))) ;; (dim1 (if (consp udims) (car udims) (car pdims))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement dim1 x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (vl-datatype-update-dims ;; (if (consp udims) pdims (cons new-dim1 (cdr pdims))) ;; (and (consp udims) (cons new-dim1 (cdr udims))) ;; sub-type)) ;; ;; packed types become unsigned ;; (new-type (if (consp udims) new-type (vl-datatype-set-unsigned new-type)))) ;; (mv nil new-type)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-expr-type ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 1 (vl-partselect-expr-type x ss nil))) ;; (iff (mv-nth 0 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 0 (vl-partselect-expr-type x ss nil))))))) ;; 99% sure this is deprecated ;; (define vl-hid-range ;; :short "Try to look up a range for a HID, which may have been installed by ;; @(see vl-expr-follow-hids)." ;; ((x vl-expr-p "This should generally be the top-level HID expression.")) ;; :guard (not (vl-atom-p x)) ;; :returns (mv (successp booleanp :rule-classes :type-prescription) ;; (range vl-maybe-range-p ;; :hints(("Goal" :in-theory (disable (force)))))) ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; (mv nil nil)) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((when (and (not left) (not right))) ;; ;; It's resolved, there's just no range. ;; (mv t nil)) ;; ((unless (and left right)) ;; ;; Maybe this should be a programming error? ;; (mv nil nil)) ;; ;; Dumb hackery for unconditional return theorem ;; (left (mbe :logic (if (vl-expr-p left) ;; left ;; (vl-make-index 0)) ;; :exec left)) ;; (right (mbe :logic (if (vl-expr-p right) ;; right ;; (vl-make-index 0)) ;; :exec right)) ;; (range (make-vl-range :msb left :lsb right))) ;; (mv t range)) ;; /// ;; (defthm vl-hid-range-of-copy-atts ;; (equal (vl-hid-range (vl-nonatom op (vl-nonatom->atts x) args fw ft)) ;; (vl-hid-range x)))) ;; (define vl-hid-rangeatts ;; :short "Extend the attributes for a HID with range information." ;; ;; BOZO we should probably be using this in vl-expr-follow-hids. ;; ((range vl-maybe-range-p) ;; (atts vl-atts-p "the rest of the atts")) ;; :guard (vl-maybe-range-resolved-p range) ;; :returns (new-atts vl-atts-p) ;; (b* ((atts (vl-atts-fix atts)) ;; (atts (if range ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" (vl-range->msb range)) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" (vl-range->lsb range)) ;; atts) ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" nil) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" nil) ;; atts)))) ;; (cons (list "VL_HID_RESOLVED_RANGE_P") atts)) ;; /// ;; (defthm vl-hid-range-of-vl-hid-rangeatts ;; (implies range ;; (equal (vl-hid-range (vl-nonatom op (vl-hid-rangeatts range atts) args fw ft)) ;; (mv t (vl-range-fix range)))) ;; :hints(("Goal" :in-theory (e/d (vl-hid-range)))))) ;; (define vl-hid-width ;; :short "Try to return the width of a HID, using range attribute information ;; that may have been installed by @(see vl-expr-follow-hids)." ;; ((x vl-expr-p)) ;; :guard (not (vl-atom-p x)) ;; :enabled t ;; :guard-hints (("goal" :in-theory (enable vl-hid-range ;; vl-maybe-range-resolved-p ;; vl-maybe-range-size ;; vl-range-resolved-p ;; vl-range-size ;; vl-width-from-difference ;; ))) ;; :returns (width maybe-posp :rule-classes :type-prescription) ;; (mbe :logic (b* (((mv ok range) (vl-hid-range x))) ;; (and ok ;; (vl-maybe-range-resolved-p range) ;; (vl-maybe-range-size range))) ;; :exec ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; nil) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((unless (or (and (not left) (not right)) ;; (and left (vl-expr-resolved-p left) ;; right (vl-expr-resolved-p right)))) ;; nil)) ;; (if left ;; (vl-width-from-difference ;; (- (vl-resolved->val left) (vl-resolved->val right))) ;; 1)))) (define vl-hidindex-resolved-p ((x vl-hidindex-p)) :returns (bool) :short "Determines if every index in a @(see vl-hidindex-p) is resolved." :measure (vl-expr-count x) (vl-exprlist-resolved-p (vl-hidindex->indices x)) ;; (b* (((when (vl-atom-p x)) ;; t) ;; ((vl-nonatom x) x)) ;; (and (mbt (eq x.op :vl-index)) ;; (vl-hidindex-resolved-p (first x.args)) ;; (vl-expr-resolved-p (second x.args)))) /// ;; (defthm vl-hidindex-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidindex-resolved-p x))) (deffixequiv vl-hidindex-resolved-p) ;; (defthm vl-hidindex-resolved-p-of-make-vl-nonatom ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-expr-resolved-p (second args)))) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :in-theory (e/d (vl-arity-fix) ((force))) ;; :expand ((:free (atts args finalwidth finaltype) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))))))) ;; (defthmd vl-nonatom->op-when-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (equal (vl-nonatom->op x) :vl-index))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-expr-resolved-p-of-arg2-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-expr-resolved-p (second (vl-nonatom->args x))))) ) (define vl-hidexpr-resolved-p ((x vl-hidexpr-p)) ;; :prepwork ((local (in-theory (enable vl-nonatom->op-when-hidindex-resolved-p)))) :returns (bool) :short "Determines if every index throughout a @(see vl-hidexpr-p) is resolved." :guard-debug t :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end t :dot (and (vl-hidindex-resolved-p x.first) (vl-hidexpr-resolved-p x.rest))) /// (defthm vl-hidexpr-resolved-p-when-endp (implies (vl-hidexpr-case x :end) (vl-hidexpr-resolved-p x))) (defthm vl-hidexpr-resolved-p-of-vl-hidexpr-dot ;; Really I should be using something like a of-cons rule here, but without ;; a constructor... (equal (vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)) (and (vl-hidindex-resolved-p first) (vl-hidexpr-resolved-p rest))) :hints (("goal" :Expand ((vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)))))) (defthm vl-hidexpr-resolved-p-implies-dot (implies (and (vl-hidexpr-resolved-p x) (vl-hidexpr-case x :dot)) (and (vl-hidindex-resolved-p (vl-hidexpr-dot->first x)) (vl-hidexpr-resolved-p (vl-hidexpr-dot->rest x))))) ;; (defthm vl-hidexpr-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidexpr-resolved-p x))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-arg2-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidexpr-resolved-p (second (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-make-vl-nonatom-for-dot ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-hidexpr-resolved-p (second args)))) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :expand (:free (atts args finalwidth finaltype) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :in-theory (e/d (vl-arity-fix) ((force)))))) ) (define vl-scopeexpr-resolved-p ((x vl-scopeexpr-p)) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-resolved-p x.hid) :colon (vl-scopeexpr-resolved-p x.rest))) (define vl-flatten-hidindex-aux ((indices vl-exprlist-p) acc) :guard (vl-exprlist-resolved-p indices) :parents (vl-flatten-hidindex) :returns (new-acc character-listp :hyp (character-listp acc)) (b* (((when (atom indices)) acc) (acc (cons #\[ acc)) (acc (revappend (str::natchars (vl-resolved->val (car indices))) acc)) (acc (cons #\] acc))) (vl-flatten-hidindex-aux (cdr indices) acc))) (define vl-flatten-hidindex ((x vl-hidindex-p)) :guard (vl-hidindex-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a @(see vl-hidindex-p) into a string like @('\"bar[3][4][5]\"')." :measure (vl-expr-count x) :guard-hints(("Goal" :in-theory (enable vl-hidindex-resolved-p))) (b* ((name (vl-hidindex->name x)) (name (if (eq name :vl-$root) "$root" name)) (indices (vl-hidindex->indices x)) ((when (atom indices)) name) (acc nil) (acc (str::revappend-chars name acc)) (acc (vl-flatten-hidindex-aux indices acc))) (str::rchars-to-string acc))) (define vl-flatten-hidexpr ((x vl-hidexpr-p)) :guard (vl-hidexpr-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a hierarchical identifier expression into a string like @('foo.bar[3][4][5].baz')." :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end x.name :dot (cat (vl-flatten-hidindex x.first) "." (vl-flatten-hidexpr x.rest)))) ;; (define vl-explode-hidindex ;; :short "Explode a (resolved) @(see vl-hidindex-p) into a flat list of ;; its components." ;; ((x vl-expr-p "The hidindex to explode, e.g., @('foo[3][4][5]')")) ;; :guard (and (vl-hidindex-p x) ;; (vl-hidindex-resolved-p x)) ;; :returns (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" 3 4 5)').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x) ;; (from (vl-explode-hidindex (first x.args))) ;; (idx (vl-resolved->val (second x.args)))) ;; (append from (list idx)))) ;; (define vl-explode-hid ;; :short "Explode a (resolved) @(see vl-hidexpr-p) into a flat list of its ;; components." ;; ((x vl-expr-p "The hidexpr to explode, e.g., foo.bar[2][3].baz.")) ;; :guard (and (vl-hidexpr-p x) ;; (vl-hidexpr-resolved-p x)) ;; :returns ;; (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" \"bar\" 2 3 \"baz\")').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x)) ;; (append (vl-explode-hidindex (first x.args)) ;; (vl-explode-hid (second x.args)))))
4804
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> (in-package "VL") ;; (include-book "datatype-tools") (include-book "scopestack") (include-book "expr-tools") (include-book "coretypes") (include-book "../util/sum-nats") (local (include-book "../util/arithmetic")) (local (include-book "centaur/misc/arith-equivs" :dir :system)) (local (in-theory (enable tag-reasoning))) (local (in-theory (disable (tau-system)))) (local (std::add-default-post-define-hook :fix)) (local (defthm equal-of-cons-rewrite (equal (equal x (cons a b)) (and (consp x) (equal (car x) a) (equal (cdr x) b))))) (defthm vl-genelement-kind-by-tag (implies (and (vl-genelement-p x) (equal (tag x) foo) (syntaxp (quotep foo))) (equal (vl-genelement-kind x) foo)) :hints(("Goal" :in-theory (enable tag vl-genelement-kind vl-genelement-p)))) (defxdoc following-hids :parents (hid-tools) :short "Functions for following hierarchical identifiers." :long "<p>Perhaps the most fundamental operation for a hierarchical identifier is figure out what it refers to. This turns out to be a surprisingly challenging and nuanced process.</p> <p>Our top-level routine for following hierarchical identifiers is @(see vl-follow-hidexpr). It is meant to make looking up hierarchical identifiers convenient despite these complications.</p> <p>We now describe some of these challenges and how @(see vl-follow-hidexpr) deals with them.</p> <dl> <dt>Datatypes versus Scopes</dt> <dd>Challenge: The same syntax is used to refer to both data structure members like @('myinst.opcode') and also to scopes like @('mysubmod.mywire'). However, structures and scopes are very different and need to be traversed in different ways.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows only the scope-based part of the HID. However, as one of our return values, we provide the tail of the hierarchical index that leads into this variable. For instance, in a case like @('foo.bar.myinst.opcode') where @('myinst') is an @('instruction_t') structure variable, we will follow only until the declaration of @('myinst') and then we will return @('myinst.opcode') as the tail.</dd> <dd>Tools that want to descend into structures will need to do so using the appropriate functions; for instance @(see BOZO) and @(see BOZO).</dd> <dt>Unclear Destination</dt> <dd>Challenge: Depending on the kind of analysis being done, we might want to continue or stop resolving at certain points. For instance, if we are trying to size a hierarchical identifier like @('myinterface.ready'), we probably want to follow through the interface all the way to the @('ready') signal. However, for light-weight variable use analysis, we may want to stop as soon as we hit an interface.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows the HID as far as possible, but returns a @(see vl-hidtrace-p) that includes not only the final declaration we arrive at, but also all intermediate points along the way. If you only care about the final destination (e.g., the @('ready') signal for sizing or similar) then you can get this final destination from the first @(see vl-hidstep-p) in the trace. But if you also want to know, e.g., that @('myinterface') has been used, this information can easily be extracted from the rest of the trace.</dd> <dt>Unresolved Parameters</dt> <dd>Challenge: Because of parameters, we may not be able to tell whether the indices in a hierarchical identifier are valid. For instance, if there is an array of module instances like @('mymod myarr [width-1:0] (...)') and we are trying to follow a hierarchical reference like @('foo.bar.myarr[7].baz'), then we will not know whether this is valid until we have resolved @('width').</dd> <dd>In some applications, e.g., for @(see lint)-like tools, it may be best to allow these potentially invalid indices. After all, we \"know\" that this reference is either invalid or is a reference to @('baz') within @('mymod'). In that case, we may well wish to assume that the index will be valid and just go on and find @('baz').</dd> <dd>However, some other applications have more stringent soundness constraints. If we are writing transforms that are meant to build conservative, safe, formal models of the Verilog code, we may instead want to insist that all of the indices have been resolved and cause an error if this is not the case.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) always tries to check that indices are in bounds and to cause errors when indices are clearly out of bounds. If we encounter indices that are potentially out of bounds, then we can do one of two things: <ul> <li>By default, we are permissive and assume the index will be in bounds.</li> <li>However, if @(':strictp') is enabled, we will cause an error.</li> </ul></dd> <dd>As a special note: we always require generate array indices to be resolved. See @(see vl-follow-hidexpr) for additional discussion.</dd> <dt>Error reporting</dt> <dd>Challenge: A HID may be invalid in many different ways. Any part of the HID may try to refer to a name that does not exist, and any index along the HID might be invalid. If an error occurs, we should provide enough detail to understand the problem.</dd> <dd>Our Approach: In the case of any error, @(see vl-follow-hidexpr) returns a message. Callers should put this message in the appropriate context so that the end-user can understand the nature and location of the problem.</dd> </dl>") (local (xdoc::set-default-parents following-hids)) (defprod vl-hidstep :short "A single step along the way of a hierarchical identifier." :long "<p>Some routines for @(see following-hids) produce traces of the items they encounter along the way. A <b>hidstep</b> structure represents a single step along a HID.</p>" :tag :vl-hidstep :layout :tree ((name stringp "Name from the hid") (index vl-maybe-expr-p "Instance array/genarray index, if present") (item vl-scopeitem-p "The item encountered along the path of the HID.") (ss vl-scopestack-p "The scope where this item was found."))) (fty::deflist vl-hidtrace :elt-type vl-hidstep :short "A list of @(see vl-hidstep) structures, typically all of the steps encountered along a HID.") (define vl-scopeexpr->hid ((x vl-scopeexpr-p)) :returns (hid vl-hidexpr-p) :short "Finds the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end x.hid :colon (vl-scopeexpr->hid x.rest)) /// (defret count-of-vl-scopeexpr->hid (< (vl-hidexpr-count hid) (vl-scopeexpr-count x)) :rule-classes :linear)) (define vl-scopeexpr-replace-hid ((x vl-scopeexpr-p) (new-hid vl-hidexpr-p)) :returns (new-x vl-scopeexpr-p) :short "Replaces the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) :verify-guards nil (vl-scopeexpr-case x :end (change-vl-scopeexpr-end x :hid new-hid) :colon (change-vl-scopeexpr-colon x :rest (vl-scopeexpr-replace-hid x.rest new-hid))) /// (verify-guards vl-scopeexpr-replace-hid)) (define vl-subhid-p ((inner vl-hidexpr-p) (outer vl-hidexpr-p)) :measure (vl-hidexpr-count outer) (if (vl-hidexpr-equiv inner outer) (vl-hidexpr-case outer :end t :dot (stringp (vl-hidindex->name outer.first))) (vl-hidexpr-case outer :dot (vl-subhid-p inner outer.rest) :otherwise nil))) (define vl-hid-prefix-for-subhid ((outer vl-hidexpr-p) (inner vl-hidexpr-p)) :guard (vl-subhid-p inner outer) :returns (prefix-hid vl-hidexpr-p) :measure (vl-hidexpr-count outer) :verify-guards nil (vl-hidexpr-case outer :end (vl-hidexpr-fix outer) ;; must be the inner one since it's the last :dot (if (vl-hidexpr-equiv inner outer) (make-vl-hidexpr-end :name (vl-hidindex->name outer.first)) (make-vl-hidexpr-dot :first outer.first :rest (vl-hid-prefix-for-subhid outer.rest inner)))) /// (verify-guards vl-hid-prefix-for-subhid :hints (("goal" :expand ((vl-subhid-p inner outer) (vl-subhid-p inner inner)))))) (define vl-follow-hidexpr-error :short "Report an error while following a HID." ((short vl-msg-p "Brief description of the error.") (ss vl-scopestack-p "Detailed context for the error.") &key ((origx vl-scopeexpr-p "Original, full HID being resolved.") 'origx) ((x vl-hidexpr-p "Current place in the HID.") 'x)) :returns (msg vl-msg-p) :long "<p>This is smart in a few ways: it distinguishes between ordinary identifiers and hierarchical identifiers in the error type, and avoids providing excessive context if we haven't gotten anywhere down into the HID yet.</p>" (b* ((x (vl-hidexpr-fix x)) (origx (vl-scopeexpr-fix origx)) (short (vl-msg-fix short)) (endp (vl-scopeexpr-case origx :end)) ((when (and endp (equal x (vl-scopeexpr-end->hid origx)))) ;; Omit detailed context since we haven't gotten anywhere yet. (vmsg "error resolving ~a1: ~@2." nil origx short))) (vmsg "error resolving ~a1: ~@2.~%~ (Failed to resolve ~a3 in ~s4)." nil origx short x (vl-scopestack->path ss)))) (define vl-follow-hidexpr-dimcheck :short "Check an array index against the corresponding array bounds." ((name stringp "Name being the array, for better errors.") (index vl-expr-p "An index into an array.") (dim vl-packeddimension-p "Bounds from the corresponding declaration.") &key (strictp booleanp "Require indices to be resolved?")) :returns (err (iff (vl-msg-p err) err)) :long "<p>In strict mode, we require that the @('index') and the array dimensions all be resolved and that the index be in range.</p> <p>In non-strict mode, we tolerate unresolved indices and declaration bounds. Note that we still do bounds checking if the indices and array bounds happen to be resolved.</p>" (b* ((dim (vl-packeddimension-fix dim)) ((when (vl-packeddimension-case dim :unsized)) ;; Bounds checking doesn't make sense in this case, so we'll just ;; regard this as fine. nil) (dim (vl-packeddimension->range dim)) ((unless (vl-expr-resolved-p index)) (if strictp (vmsg "unresolved array index") nil)) ((unless (vl-range-resolved-p dim)) (if strictp (vmsg "unresolved bounds on declaration of ~s0" (string-fix name)) nil)) ((vl-range dim)) (idxval (vl-resolved->val index)) (msbval (vl-resolved->val dim.msb)) (lsbval (vl-resolved->val dim.lsb)) (minval (min msbval lsbval)) (maxval (max msbval lsbval)) ((unless (and (<= minval idxval) (<= idxval maxval))) (vmsg "array index ~x0 out of bounds (~x1 to ~x2)" idxval minval maxval))) nil)) (define vl-follow-hidexpr-dimscheck-aux :parents (vl-follow-hidexpr-dimscheck) :short "Main loop to check each index/dimension pair." :prepwork ((local (defthm vl-exprlist-fix-of-atom (implies (not (consp x)) (equal (vl-exprlist-fix x) nil))))) ((name stringp) (indices vl-exprlist-p) (dims vl-packeddimensionlist-p) &key (strictp booleanp)) :guard (same-lengthp indices dims) :returns (err (iff (vl-msg-p err) err)) (if (atom indices) nil (or (vl-follow-hidexpr-dimcheck name (car indices) (car dims) :strictp strictp) (vl-follow-hidexpr-dimscheck-aux name (cdr indices) (cdr dims) :strictp strictp)))) (define vl-follow-hidexpr-dimscheck :short "Check array indices against the corresponding array bounds." ((name stringp) (indices vl-exprlist-p "Indices from the HID piece we're following. I.e., if we are resolving @('foo[3][4][5].bar'), this would be @('(3 4 5)') as an expression list.") (dims vl-packeddimensionlist-p "Corresponding dimensions from the declaration, i.e., if @('foo') is declared as a @('logic [7:0][15:0][3:0]'), then this would be the list of @('([7:0] [15:0] [3:0])').") &key (strictp booleanp "Should we require every index to be resolved?")) :returns (err (iff (vl-msg-p err) err)) (b* ((name (string-fix name)) ((when (atom dims)) (if (atom indices) nil (vmsg "indexing into non-array ~s0" name))) ((when (atom indices)) (vmsg "no indices given for array ~s0" name)) ((when (same-lengthp indices dims)) (vl-follow-hidexpr-dimscheck-aux name indices dims :strictp strictp)) (found (len indices)) (need (len dims)) ((when (< found need)) (vmsg "too many indices for array ~s0" name))) (vmsg "not enough indices for array ~s0" name))) (define vl-genarrayblocklist-find-block :short "Find the block from a generate array corresponding to some index." ((idx integerp) (x vl-genarrayblocklist-p)) :returns (blk (iff (vl-genarrayblock-p blk) blk)) (cond ((atom x) nil) ((eql (vl-genarrayblock->index (car x)) (lifix idx)) (vl-genarrayblock-fix (car x))) (t (vl-genarrayblocklist-find-block idx (cdr x))))) (local (defthm stringp-when-hidname-and-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (with-output :evisc (:gag-mode (evisc-tuple 3 4 nil nil) :term nil) :off (event) (define vl-follow-hidexpr-aux :parents (vl-follow-hidexpr) :short "Core routine for following hierarchical identifiers." ((x vl-hidexpr-p "HID expression fragment that we are following.") (trace vl-hidtrace-p "Accumulator for the trace until now.") (ss vl-scopestack-p "Current scopestack we're working from.") &key (strictp booleanp) ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx)) :returns (mv (err (iff (vl-msg-p err) err) "A @(see vl-msg-p) on any error.") (new-trace vl-hidtrace-p "On success, a nonempty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final item and scopestack.") (tail vl-hidexpr-p "Remainder of @('x') after arriving at the declaration.")) :long "<p>See @(see vl-follow-hidexpr) for detailed discussion. This @('-aux') function does most of the work, but for instance it doesn't deal with top-level hierarchical identifiers.</p>" :measure (vl-hidexpr-count x) :prepwork ((local (defthm vl-scope-p-when-vl-module-p-strong (implies (or (vl-module-p x) (vl-interface-p x)) (vl-scope-p x)))) (local (in-theory (disable double-containment tag-reasoning))) (local (defthm vl-maybe-expr-p-of-car-exprlist (implies (vl-exprlist-p x) (vl-maybe-expr-p (car x)))))) :hooks ((:fix :hints(("Goal" :expand ((:free (trace ss strictp) (vl-follow-hidexpr-aux x trace ss :strictp strictp)) (:free (trace ss strictp) (vl-follow-hidexpr-aux (vl-expr-fix x) trace ss :strictp strictp))))))) (b* ((trace (vl-hidtrace-fix trace)) (x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error (vmsg "$root is not yet supported") ss) trace x)) ((mv item item-ss) (vl-scopestack-find-item/ss name1 ss)) ((unless item) (mv (vl-follow-hidexpr-error (vmsg "item not found") ss) trace x)) ((when (or (eq (tag item) :vl-vardecl) (eq (tag item) :vl-paramdecl))) ;; Found the declaration we want. We aren't going to go any further: ;; there may be additional HID indexing stuff left, but if so it's just ;; array or structure indexing for the tail. (b* ((trace (cons (make-vl-hidstep :name name1 :item item ;; No indices -- they belong to ;; the variable :ss item-ss) trace))) (mv nil trace x))) ;; From here on out, if the trace is good and the index exists, the ;; trace includes that index. (trace (cons (make-vl-hidstep :name name1 :item item :index (car indices) :ss item-ss) trace)) ((when (or (eq (tag item) :vl-fundecl) (eq (tag item) :vl-taskdecl))) (if (eq kind :end) ;; Plain reference to, e.g., foo.bar.myfun. This is OK -- you ;; might be writing something like ``logic foo = submod.fn(arg)'' (mv nil trace x) ;; Indexed or dotted reference like foo.bar.myfun[3] or ;; foo.bar.myfun[3].baz or foo.bar.myfun.baz, none of which seem to ;; really be reasonable as things to refer to hierarchically. (mv (vl-follow-hidexpr-error (vmsg (if (eq (tag item) :vl-fundecl) "hierarchical reference into function" "hierarchical reference into task")) item-ss) trace x))) ((when (eq (tag item) :vl-modinst)) (b* (((vl-modinst item)) (dims (and item.range (list (vl-range->packeddimension item.range)))) ;; Start by checking for sensible array indexing. (err (vl-follow-hidexpr-dimscheck name1 indices dims :strictp strictp)) ((when err) (mv (vl-follow-hidexpr-error err item-ss) trace x)) ((when (eq kind :end)) ;; Reference to foo.bar.myinst with no more indexing into myinst. ;; This might not make a lot of sense for a module instance, but ;; it probably *does* make sense for an interface instance. It ;; seems reasonable to just say this is OK and let the caller ;; figure out what to do with the module instance. (mv nil trace x)) ;; Else we're indexing through the instance. We need to go look ;; up the submodule and recur. ((mv mod mod-ss) (vl-scopestack-find-definition/ss item.modname item-ss)) ((unless mod) (mv (vl-follow-hidexpr-error (vmsg "reference through missing module ~s0" item.modname) item-ss) trace x)) (modtag (tag mod)) ((when (eq modtag :vl-udp)) (mv (vl-follow-hidexpr-error (vmsg "reference through primitive ~s0" item.modname) item-ss) trace x)) ((unless (or (eq modtag :vl-module) (eq modtag :vl-interface))) (mv (vl-follow-hidexpr-error (vmsg "module instance ~s0 of ~s1: invalid type ~x2???" name1 item.modname modtag) item-ss) trace x)) (next-ss ;; The MOD-SS is just the scopestack for where the module is ;; defined, which in practice will be the top level scope. ;; The next part of the HID needs to be looked up from within ;; MOD, so we need to actually go into the module. (vl-scopestack-push mod mod-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-interfaceport)) (b* (((vl-interfaceport item)) ((when (or (consp indices) (consp item.udims))) ;; BOZO. What kind of index checking do we want to do? Probably ;; it is ok to index only partly into an interface port, because ;; if it's okay to have an array of interfaces coming in, then ;; it's probably ok to stick an array of interfaces into a ;; submodule, etc. So maybe we need to just check that we have ;; no more indices than are allowed, and then check ranges on any ;; indices that we do happen to have... (mv (vl-follow-hidexpr-error "BOZO implement support for interface arrays." item-ss) trace x)) ((when (eq kind :end)) ;; Stopping at this interface port. Unlike module instances, ;; this seems OK. The interface port itself acts like a ;; variable. (mv nil trace x)) ((mv iface iface-ss) (vl-scopestack-find-definition/ss item.ifname item-ss)) ((unless iface) (mv (vl-follow-hidexpr-error (vmsg "reference through missing interface ~s0" item.ifname) item-ss) trace x)) (iftag (tag iface)) ((unless (eq iftag :vl-interface)) (mv (vl-follow-hidexpr-error (vmsg "interface port ~s0 of interface ~s1: invalid type ~x2???" name1 item.ifname iftag) item-ss) trace x)) (next-ss (vl-scopestack-push iface iface-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genblock)) (b* (((when (consp indices)) ;; Doesn't make any sense: this is a single, named generate ;; block, not an array, so we shouldn't try to index into it. (mv (vl-follow-hidexpr-error "array indices on reference to generate block" item-ss) trace x)) ((when (eq kind :end)) ;; Doesn't make any sense: referring to foo.bar.myblock all by ;; itself. (mv (vl-follow-hidexpr-error "reference to generate block" item-ss) trace x)) ;; Else we have something like foo.bar.myblock.mywire or whatever. ;; This is fine, we just need to go into the generate block. (genblob (vl-sort-genelements (vl-genblock->elems item) :scopetype :vl-genblock :name (vl-genblock->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genarray)) (b* (((when (eq kind :end)) ;; Doesn't make any sense. Either this is a raw reference to the ;; array like foo.bar.mygenarray, or is an indexed reference to ;; something like foo.bar.mygenarray[3], but in either case it ;; would be referring to a whole generate block or to an array of ;; generate blocks, not something inside those blocks. (mv (vl-follow-hidexpr-error "reference to generate array" item-ss) trace x)) ((unless (consp indices)) ;; Something like foo.bar.mygenarray.baz, but mygenarray is an ;; array so this doesn't make any sense. (mv (vl-follow-hidexpr-error "reference through generate array must have an array index" item-ss) trace x)) ((unless (atom (rest indices))) ;; Something like foo.bar.mygenarray[3][4].baz, but we should ;; only ever have single-dimensional generate arrays, right? (mv (vl-follow-hidexpr-error "too many indices through generate array" item-ss) trace x)) (index-expr (first indices)) ((unless (vl-expr-resolved-p index-expr)) ;; Something like foo.bar.mygenarray[width-1].baz. We tolerate ;; this in the case of module instances, but for generates it is ;; not safe because we could have something like: ;; ;; genvar i; ;; for(i = 1; i < 10; ++i) begin : mygenarray ;; wire [i-1:0] baz; ;; ... ;; end ;; ;; in which case the actual declaration of baz depends on the ;; particular block of the generate that we happen to be in. (mv (vl-follow-hidexpr-error "unresolved index into generate array" item-ss) trace x)) (blocknum (vl-resolved->val index-expr)) (block (vl-genarrayblocklist-find-block blocknum (vl-genarray->blocks item))) ((unless block) ;; Something like foo.bar.mygenarray[8].baz when the array only ;; goes from 3:7 or whatever. (mv (vl-follow-hidexpr-error (vmsg "invalid index into generate array: ~x0" blocknum) item-ss) trace x)) (genblob (vl-sort-genelements (vl-genarrayblock->elems block) :scopetype :vl-genarrayblock :name (vl-genarray->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-typedef)) (b* (((when (eq kind :end)) ;; This seems ok; we might refer to a type by name in a few ;; places. It may or may not be ok to refer to foo.bar_t, but ;; it's definitely ok to refer to foopkg::bar_t. (mv nil trace x))) ;; I don't think this makes sense? Can you refer to a type name? BOZO ;; maybe this makes sense for things like $bits(mystruct_t.foo) or ;; something like that? If so it may still be that we don't want to ;; deal with this in the aux function, but rather it should be ;; something that the top-level wrapper deals with. (mv (vl-follow-hidexpr-error "hierarchical reference through typedef" item-ss) trace x))) ((when (or (eq (tag item) :vl-genif) (eq (tag item) :vl-gencase) (eq (tag item) :vl-genloop) (eq (tag item) :vl-genbase))) ;; I don't think any of these are supposed to have names and, ;; accordingly, it shouldn't make sense to have looked one up. (mv (vl-follow-hidexpr-error (vmsg "hierarchical reference to ~x0" (tag item)) item-ss) trace x)) ((when (eq (tag item) :vl-gateinst)) ;; Since gate instances are "opaque" there is clearly no way we can go ;; through a gate instance. Moreover, we don't think a gate instance ;; could be meaningfully addressed in any other way. So, we just ;; regard any reference to a gate as invalid. (mv (vl-follow-hidexpr-error "hierarchical reference to gate instance" item-ss) trace x))) (mv (impossible) trace x)) /// (more-returns (new-trace (implies (or (consp trace) (not err)) (consp new-trace)) :name consp-of-vl-follow-hidexpr-aux.new-trace)) (defret vl-follow-hidexpr-no-index-on-first (implies (not err) (not (vl-hidstep->index (car new-trace))))) (defthm context-irrelevance-of-vl-follow-hidexpr-aux (implies (syntaxp (not (equal origx (list 'quote (with-guard-checking :none (vl-scopeexpr-fix nil)))))) (b* (((mv err1 trace1 tail1) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)) ((mv err2 trace2 tail2) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx (vl-scopeexpr-fix nil)))) (and (equal trace1 trace2) (equal tail1 tail2) (iff err1 err2)))) :hints ((acl2::just-induct-and-expand (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx) :expand-others ((:free (ctx strictp origx) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (defret count-of-vl-follow-hidexpr-aux.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr-aux (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p) :induct (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (deftagsum vl-scopecontext (:local ((levels natp :rule-classes :type-prescription "How many levels up from the current scope was the item found"))) (:root ()) (:package ((pkg vl-package-p))) (:module ((mod vl-module-p)))) (deftagsum vl-select (:field ((name stringp "The name of the field we're selecting"))) (:index ((val vl-expr-p "The index we're selecting")))) (defprod vl-selstep ((select vl-select-p "The field or index being selected") (type vl-datatype-p "The datatype of the element we've selected") (caveat "Signedness caveat for this indexing operation. Signals a disagreement between implementations on the signedness of the result. See @(see vl-datatype-remove-dim). Only important if this is the outermost selstep.") ;; (ss vl-scopestack-p "The scopestack in which the datatype was declared or ;; typedef'd") )) (fty::deflist vl-seltrace :elt-type vl-selstep :elementp-of-nil nil) (define vl-seltrace-index-count ((x vl-seltrace-p)) :returns (count natp :rule-classes :type-prescription) (if (atom x) 0 (+ (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field 0 :index 1)) (vl-seltrace-index-count (cdr x))))) (define vl-seltrace->indices ((x vl-seltrace-p)) :returns (indices vl-exprlist-p) (if (atom x) nil (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field (vl-seltrace->indices (cdr x)) :index (cons x1.select.val (vl-seltrace->indices (cdr x)))))) /// (defret len-of-vl-seltrace->indices (equal (len indices) (vl-seltrace-index-count x)) :hints(("Goal" :in-theory (enable vl-seltrace-index-count)))) (defthm vl-seltrace-indices-of-append (equal (vl-seltrace->indices (append x y)) (append (vl-seltrace->indices x) (vl-seltrace->indices y)))) (defthm vl-seltrace-indices-of-rev (equal (vl-seltrace->indices (rev x)) (rev (vl-seltrace->indices x))))) (defprod vl-operandinfo ((context vl-scopecontext-p "The context in which the HID base was found") (prefixname vl-scopeexpr-p "The scopeexpr, not including the possible data selects.") (hidtrace vl-hidtrace-p "The follow-hids trace, i.e. the trace of instances/blocks in which the base variable is located") (hidtype vl-datatype-p "The datatype of the final element of the hidtrace.") (seltrace vl-seltrace-p "The select trace, i.e. the types/scopestacks of all the fields/indices we've selected into") (part vl-partselect-p "The final partselect") (type vl-datatype-p "The final datatype of the object, after partselecting."))) (local (defthm nesting-level-of-vl-scopestack-find-item/context (<= (vl-scopestack-nesting-level (mv-nth 1 (vl-scopestack-find-item/context name ss))) (vl-scopestack-nesting-level ss)) :hints(("Goal" :in-theory (enable vl-scopestack-find-item/context vl-scopestack-nesting-level))) :rule-classes :linear)) (define vl-follow-hidexpr :short "Follow a HID to find the associated declaration." ((x vl-hidexpr-p "Hierarchical identifier to follow.") (ss vl-scopestack-p "Scopestack where the HID originates.") &key ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx) (strictp booleanp "Require all array indices and bounds to be resolved?")) :guard-debug t :returns (mv (err (iff (vl-msg-p err) err) "A message on any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext object describing where this hid is rooted.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) :long "<p>Prerequisite: see @(see following-hids) for considerable discussion about the goals and design of this function.</p> <p>This is our top-level routine for following hierarchical identifiers. It understands how to resolve both top-level hierarchical identifiers like @('topmodule.foo.bar') and downward identifiers like @('submodname.foo.bar').</p> <p>We try to follow @('x'), which must be a proper @(see vl-hidexpr-p), to whatever @(see vl-scopeitem) it refers to. This can fail for many reasons, e.g., any piece of @('x') might refer to a name that doesn't exist, might have inappropriate array indices, etc. In case of failure, @('err') is a good @(see vl-msg-p) and the other results are <b>not sensible</b> and should not be relied on.</p> <h5>Trace</h5> <p>We return a @(see vl-hidtrace-p) that records, in ``backwards'' order, the steps that we took to resolve @('x'). That is: if we are resolving @('foo.bar.baz'), then the first step in the trace will be the declaration for @('baz'), and the last step in the trace will be the lookup for @('foo'). In other words, the first step in the trace corresponds to the ``final'' declaration that @('x') refers to. Many applications won't care about the rest of the trace beyond its first step. However, the rest of the trace may be useful if you are trying to deal with, e.g., all of the interfaces along the hierarchical identifier.</p> <h5>Tail</h5> <p>The trace we return stops at variable declarations. This may be confusing because, in Verilog, the same @('.') syntax is used to index through the module hierarchy and to index through structures. To make this concrete, suppose we have something like:</p> @({ typedef struct { logic fastMode; ...; } opcode_t; typedef struct { opcode_t opcode; ... } instruction_t; module bar (...) ; instruction_t instruction1; ... endmodule module foo (...) ; bar mybar(...) ; ... endmodule module main (...) ; foo myfoo(...) ; ... $display(\"fastMode is %b\", myfoo.mybar.instruction1.opcode.fastMode); endmodule }) <p>When we follow @('myfoo.mybar.instruction1.opcode.fastMode'), our trace will <b>only go to @('instruction1')</b>, because the @('.opcode.fastMode') part is structure indexing, not scope indexing.</p> <p>To account for this, we return not only the @('trace') but also the @('tail') of the hierarchical identifier that remains where we stop. For instance, in this case the @('tail') would be @('instruction1.opcode.fastMode').</p>" (b* ((x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) (trace nil) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error "$root isn't supported yet" ss) trace nil x)) ((mv item ctx-ss pkg-name) (vl-scopestack-find-item/context name1 ss)) ((when item) (b* (((mv err trace tail) (vl-follow-hidexpr-aux x nil ss :strictp strictp)) ((when err) (mv err trace nil tail)) ((mv err context) (cond (pkg-name (b* ((pkg (vl-scopestack-find-package pkg-name ss)) ((unless pkg) (mv (vmsg "Programming error: found item in ~ package ~s0 but couldn't find package" pkg-name) nil))) (mv nil (make-vl-scopecontext-package :pkg pkg)))) ((vl-scopestack-case ctx-ss :global) (mv nil (make-vl-scopecontext-root))) (t (mv nil (make-vl-scopecontext-local :levels (- (vl-scopestack-nesting-level ss) (vl-scopestack-nesting-level ctx-ss)))))))) (mv err trace context tail))) ((when (eq kind :end)) ;; Item was not found AND it is not of the form foo.bar, so we do NOT ;; want to interpret it as any sort of reference to a top-level module. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Otherwise, might be a valid reference into a top-level module? (design (vl-scopestack->design ss)) ((unless design) ;; We must be using a phony scopestack. We have no way of knowing what ;; the top-level modules are so we have no idea if this is valid. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) (mods (vl-design->mods design)) (toplevel (vl-modulelist-toplevel mods)) ((unless (member-equal name1 toplevel)) (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Successfully found a top-level module with the first index name. ((when (consp indices)) ;; Something like topmod[3].foo.bar, doesn't make any sense. (mv (vl-follow-hidexpr-error "array indices into top level module" ss) trace nil x)) (mod (vl-find-module name1 mods)) (mod-ss (vl-scopestack-init design)) ;; BOZO how should the fact that we have followed a top-level hierarchical ;; identifier present itself in the trace? We would like to perhaps add a ;; trace step along the lines of: ;; ;; (cons (make-vl-hidstep :item mod :ss mod-ss) trace) ;; ;; But that is not possible because the ITEM for a trace needs to be a ;; scopeitem, and a module is not a scopeitem. ;; ;; We might eventually want to extend the notion of traces to be able to ;; record this sort of thing. For now, out of sheer pragmatism, I think ;; it seems pretty reasonable to just not bother to record the first ;; step. (next-ss (vl-scopestack-push mod mod-ss)) ((mv err trace tail) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp)) (context (make-vl-scopecontext-module :mod mod))) (mv err trace context tail)) /// (defret consp-of-vl-follow-hidexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-hidexpr.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p))))) (define vl-follow-scopeexpr :short "Follow a scope expression to find the associated declaration." ((x vl-scopeexpr-p "Scope expression to follow.") (ss vl-scopestack-p "Scopestack where the lookup originates.") &key (strictp booleanp "Require all array indices and bounds to be resolved?")) :returns (mv (err (iff (vl-msg-p err) err) "A message for any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext showing where the hid is found.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) (vl-scopeexpr-case x :end (vl-follow-hidexpr x.hid ss :strictp strictp :origx x) :colon (b* ((x (vl-scopeexpr-fix x)) ((unless (stringp x.first)) (mv (vmsg "~a0: The scope modifier '~x1' is not yet supported." x (case x.first (:vl-local "local") (:vl-$unit "$unit") (otherwise "??UNKNOWN??"))) nil nil (vl-scopeexpr->hid x))) ((mv package pkg-ss) (vl-scopestack-find-package/ss x.first ss)) ((unless package) (mv (vmsg "~a0: Package ~s1 not found.." x x.first) nil nil (vl-scopeexpr->hid x))) (pkg-ss (vl-scopestack-push package pkg-ss)) ((unless (vl-scopeexpr-case x.rest :end)) (mv (vmsg "~a0: Multiple levels of :: operators are ~ not yet supported." x) nil nil (vl-scopeexpr->hid x))) ((mv err trace context tail) (vl-follow-hidexpr (vl-scopeexpr-end->hid x.rest) pkg-ss :strictp strictp :origx x)) ((when err) (mv err trace context tail)) ((unless (vl-scopecontext-case context :local)) (mv nil trace context tail))) (mv nil trace (make-vl-scopecontext-package :pkg package) tail))) /// (defret consp-of-vl-follow-scopeexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-scopeexpr.tail (< (vl-hidexpr-count tail) (vl-scopeexpr-count x)) :rule-classes :linear) (defret vl-subhid-p-of-vl-follow-scopeexpr (implies (not err) (vl-subhid-p tail (vl-scopeexpr->hid x))) :hints(("Goal" :in-theory (enable vl-scopeexpr->hid))))) ;; ------ (defxdoc datatype-tools :parents (mlib) :short "Functions for working with datatypes.") (local (xdoc::set-default-parents datatype-tools)) (defines vl-datatype-resolved-p (define vl-datatype-resolved-p ((x vl-datatype-p)) :measure (vl-datatype-count x) (vl-datatype-case x :vl-coretype t :vl-struct (vl-structmemberlist-resolved-p x.members) :vl-union (vl-structmemberlist-resolved-p x.members) :vl-enum (vl-datatype-resolved-p x.basetype) :vl-usertype (and x.res (vl-datatype-resolved-p x.res)))) (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p)) :measure (vl-structmemberlist-count x) (if (atom x) t (and (vl-datatype-resolved-p (vl-structmember->type (car x))) (vl-structmemberlist-resolved-p (cdr x))))) /// (deffixequiv-mutual vl-datatype-resolved-p) (defthm vl-datatype-resolved-p-of-make-coretype (vl-datatype-resolved-p (vl-coretype name signedp pdims udims))) (defthm vl-datatype-resolved-p-of-make-struct (equal (vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("goal" :expand ((vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-union (equal (vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("Goal" :expand ((vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-enum (equal (vl-datatype-resolved-p (vl-enum basetype items pdims udims)) (vl-datatype-resolved-p basetype)) :hints (("goal" :expand (vl-datatype-resolved-p (vl-enum basetype items pdims udims))))) (defthm vl-datatype-resolved-p-of-make-usertype (equal (vl-datatype-resolved-p (vl-usertype name res pdims udims)) (and res (vl-datatype-resolved-p res))) :hints (("Goal" :expand (vl-datatype-resolved-p (vl-usertype name res pdims udims))))) (defthm vl-structmemberlist-resolved-p-of-struct-members (implies (and (vl-datatype-case x :vl-struct) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-struct->members x)))) (defthm vl-structmemberlist-resolved-p-of-union-members (implies (and (vl-datatype-case x :vl-union) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-union->members x)))) (defthm vl-datatype-resolved-p-of-enum-basetype (implies (and (vl-datatype-case x :vl-enum) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p (vl-enum->basetype x)))) (defthm vl-datatype-resolved-p-of-usertype-basetype (implies (and (vl-datatype-case x :vl-usertype) (vl-datatype-resolved-p x)) (and (vl-datatype-resolved-p (vl-usertype->res x)) (vl-usertype->res x)))) (defthm vl-structmemberlist-resolved-p-of-cons (equal (vl-structmemberlist-resolved-p (cons a b)) (and (vl-datatype-resolved-p (vl-structmember->type a)) (vl-structmemberlist-resolved-p b)))) (defthm vl-datatype-resolved-p-of-car-structmember-type (implies (vl-structmemberlist-resolved-p x) (vl-datatype-resolved-p (vl-structmember->type (car x))))) (defthm vl-structmemberlist-resolved-p-of-cdr (implies (vl-structmemberlist-resolved-p x) (vl-structmemberlist-resolved-p (cdr x)))) (defthm vl-datatype-resolved-p-of-update-dims (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p (vl-datatype-update-dims pdims udims x))) :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) (fty::defalist vl-typeoverride :key-type vl-scopeexpr :val-type vl-datatype :short "Alist mapping names to datatypes, used to store resolutions of parameter types that have been computed but not yet put in the design." :long "<p>The names may be of various different kinds of objects, meaning slightly different things:</p> <ul> <li>A value parameter name maps to the type of the parameter value</li> <li>A type parameter name maps to the resolved type that is that parameter's value</li> <li>A typedef name maps to the resolved type</li> <li>A function name maps to the resolved return type of the function.</li> </ul>") (defines vl-datatype-usertype-resolve (define vl-datatype-usertype-resolve ((x vl-datatype-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :verify-guards nil :measure (two-nats-measure rec-limit (vl-datatype-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-datatype-p)) (b* ((x (vl-datatype-fix x))) (vl-datatype-case x :vl-coretype (mv nil x) :vl-struct (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-struct x :members members))) :vl-union (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-union x :members members))) :vl-enum (b* (((mv err basetype) (vl-datatype-usertype-resolve x.basetype ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-enum x :basetype basetype))) :vl-usertype (b* (((when (and x.res (vl-datatype-resolved-p x.res))) (mv nil x)) ((mv err def) (vl-usertype-lookup x.name ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-usertype x :res def)))))) (define vl-structmemberlist-usertype-resolve ((x vl-structmemberlist-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-structmemberlist-p)) (b* (((when (atom x)) (mv nil nil)) ((mv err1 type1) (vl-datatype-usertype-resolve (vl-structmember->type (car x)) ss :typeov typeov :rec-limit rec-limit)) ((mv err2 rest) (vl-structmemberlist-usertype-resolve (cdr x) ss :typeov typeov :rec-limit rec-limit))) (mv (or err1 err2) (cons (change-vl-structmember (car x) :type type1) rest)))) (define vl-usertype-lookup ((x vl-scopeexpr-p "The usertype name to look up") (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :short "Looks up a usertype name and returns its definition if successful." :measure (two-nats-measure rec-limit 0) :returns (mv (err (iff (vl-msg-p err) err) "Error message if unsuccessful") (type (and (vl-maybe-datatype-p type) (implies (not err) (vl-datatype-p type))) "Fully resolved type, if successful")) (b* ((x (vl-scopeexpr-fix x)) (typeov (vl-typeoverride-fix typeov)) (hid (vl-scopeexpr->hid x)) ;; BOZO Maybe we should use a different type than scopeexpr for a usertype name ((unless (vl-hidexpr-case hid :end)) (mv (vmsg "Type names cannot be specified with dotted ~ paths, only package scopes: ~a1" nil x) nil)) (look (hons-get x typeov)) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: unresolved override type") nil))) ((mv err trace ?context ?tail) (vl-follow-scopeexpr x ss)) ((when err) (mv err nil)) ((vl-hidstep ref) (car trace)) ((when (eq (tag ref.item) :vl-typedef)) (b* (((vl-typedef item) ref.item) ((when (zp rec-limit)) (mv (vmsg "Recursion limit ran out looking up ~ usertype ~a0" x) nil))) (vl-datatype-usertype-resolve item.type ref.ss :typeov nil ;; different scope! :rec-limit (1- rec-limit)))) ((when (eq (tag ref.item) :vl-paramdecl)) (b* (((vl-paramdecl item) ref.item)) (vl-paramtype-case item.type :vl-typeparam (if (and item.type.default (vl-datatype-resolved-p item.type.default)) (mv nil item.type.default) (mv (vmsg "Reference to unresolved type parameter ~a0" item) nil)) :otherwise (mv (vmsg "Reference to data parameter ~a0 as type" item) nil))))) (mv (vmsg "Didn't find a typedef ~a1, instead found ~a2" nil x ref.item) nil))) /// (verify-guards vl-datatype-usertype-resolve-fn) (defthm vl-datatype-usertype-resolve-nonnil (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit)) :hints (("goal" :use ((:instance (:theorem (implies (not x) (not (vl-datatype-p x)))) (x (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) :in-theory (disable vl-datatype-usertype-resolve))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) (defthm vl-usertype-lookup-nonnil (b* (((mv err res) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) res)) :hints (("goal" :use ((:instance return-type-of-vl-usertype-lookup-fn.type)) :in-theory (disable return-type-of-vl-usertype-lookup-fn.type))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))))) (defthm-vl-datatype-usertype-resolve-flag (defthm vl-datatype-resolved-p-of-vl-datatype-usertype-resolve (b* (((mv err new-x) (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p new-x))) :hints('(:expand ((vl-datatype-resolved-p x)))) :flag vl-datatype-usertype-resolve) (defthm vl-structmemberlist-resolved-p-of-vl-structmemberlist-usertype-resolve (b* (((mv err new-x) (vl-structmemberlist-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-structmemberlist-resolved-p new-x))) ;; :hints('(:in-theory (enable vl-structmemberlist-resolved-p))) :flag vl-structmemberlist-usertype-resolve) (defthm vl-datatype-resolved-p-of-vl-usertype-lookup (b* (((mv err type) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p type))) :flag vl-usertype-lookup)) (deffixequiv-mutual vl-datatype-usertype-resolve)) ;; (define vl-usertype-resolve ((x vl-scopeexpr-p "The usertype name to look up") ;; (ss vl-scopestack-p) ;; &key ((rec-limit natp) '1000)) ;; :short "Looks up a usertype name recursively, stopping and and returning its ;; definition when it is a non-usertype or has dimensions." ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Error message if unsuccessful") ;; (type (iff (vl-datatype-p type) (not err)) ;; "Resolved type, if successful") ;; (scope vl-scopestack-p ;; "Scopestack for the context in which the type was defined ;; (only sensible if successful)")) ;; :measure (nfix rec-limit) ;; (b* (((mv err def new-ss) ;; (vl-usertype-lookup x ss)) ;; ((when err) (mv err def new-ss)) ;; ((unless (vl-datatype-case def :vl-usertype)) ;; (mv nil def new-ss)) ;; ((vl-usertype def)) ;; ((when (or (consp def.pdims) (consp def.udims))) ;; (mv nil def new-ss)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out looking up usertype ~a0" def) nil new-ss))) ;; (vl-usertype-resolve def.name new-ss :rec-limit (1- rec-limit))) ;; /// ;; (defret vl-usertype-resolve-result-has-dims ;; (implies (and (not err) ;; (vl-datatype-case type :vl-usertype) ;; (not (consp (vl-datatype->udims type)))) ;; (consp (vl-datatype->pdims type))))) ;; (define vl-usertype-resolve ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; (rec-limit natp)) ;; :guard (vl-datatype-case x :vl-usertype) ;; :short "Resolves a datatype of usertype kind to a concrete ;; datatype, i.e. anything but a user typename." ;; :long "<p>The input is guarded to be a usertype. If it is defined as another ;; usertype (possibly with packed/unpacked dimensions), then we recur until it is ;; defined as something other than a usertype. However, the final type may still ;; have usertypes within it, i.e. as struct/union member types.</p> ;; <p>Also returns the scopestack representing the scope in which the ;; final type declaration was found.</p> ;; <p>This function is strict with respect to packed vs. unpacked dimensions; ;; i.e., if a usertype is defined as having unpacked dimensions, it will warn if ;; any packed dimensions are applied to that type. Arguably this check should be ;; done elsewhere, in which case this function could ignore the distinction ;; between packed and unpacked dimensions. However, it is important to preserve ;; the order of dimensions, and it's not clear how to handle cases that mix the ;; two: packed dimensions are always treated as \"inner\" or \"most rapidly ;; varying\" dimensions. So if we have (illegal) nested typedefs that place ;; unpacked dimensions inside of packed dimensions, we have no way to express that ;; as a single, usertype-free datatype, unless we change some packed dimensions ;; into unpacked ones or vice versa:</p> ;; @({ ;; typedef logic t1 [5:1]; // unpacked dimension ;; typedef t1 [3:0] t2; // packed dimension applied to unpacked datatype ;; typedef logic [3:0] t3 [5:1]; // not the same as t2 ;; typedef logic [5:1] [3:0] t4; // same dimensions as t2, but all dimensions packed ;; typedef logic t5 [5:1] [3:0]; // same dimensions as t2, but all dimensions unpacked ;; }) ;; <p>We don't have this problem for the (also illegal) case where packed ;; dimensions are applied to an unpacked structure or union, so we don't warn in ;; this case; this should be checked separately.</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p) ;; (scope vl-scopestack-p)) ;; :measure (nfix rec-limit) ;; :verify-guards nil ;; (b* ((ss (vl-scopestack-fix ss)) ;; (x (vl-datatype-fix x)) ;; ((vl-usertype x)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Rec-limit ran out: recursively defined ~ ;; datatype? ~a1" ;; nil x.name) ;; x ss)) ;; ((unless (vl-hidexpr-case (vl-scopeexpr->hid x.name) :end)) ;; (mv (vmsg "Type names cannot be specified with dotted ~ ;; paths, only package scopes: ~a1" ;; nil x.name) ;; x ss)) ;; ((mv err trace ?tail) ;; (vl-follow-scopeexpr x.name ss)) ;; ((when err) ;; (mv err x ss)) ;; ((vl-hidstep ref) (car trace)) ;; ((unless (eq (tag ref.item) :vl-typedef)) ;; (mv (vmsg "Didn't find a typedef ~a1, instead ~ ;; found ~a2" ;; nil x.name ref.item) ;; x ss)) ;; ((vl-typedef item) ref.item) ;; ((mv warning subtype final-ss) ;; (if (vl-datatype-case item.type :vl-usertype) ;; (vl-usertype-resolve item.type ref.ss (1- rec-limit)) ;; (mv nil item.type ref.ss))) ;; ((when warning) ;; (mv warning x ss)) ;; (sub-udims (vl-datatype->udims subtype)) ;; ((when (and (consp x.pdims) (consp (vl-datatype->udims item.type)))) ;; ;; Bad case: we have unpacked dimensions from the inner call but ;; ;; we're trying to add packed ones. Warn and return x. ;; (mv (vmsg "Usertype ~a1 was declared with packed ~ ;; dimensions, but its definition ~a2 already ~ ;; has unpacked dimensions." ;; x item.type) ;; x ss)) ;; (subtype (mbe :logic (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; :exec ;; (if (or x.udims x.pdims) ;; (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; subtype)))) ;; (mv nil subtype final-ss)) ;; /// ;; (verify-guards vl-usertype-resolve)) ;; (defines vl-datatype-usertype-elim ;; :verify-guards nil ;; (define vl-datatype-usertype-elim ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) '1000)) ;; :measure (two-nats-measure rec-limit (vl-datatype-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p)) ;; :prepwork ((local (in-theory (disable nfix)))) ;; :short "Resolves all usertypes within a datatype, recursively." ;; :long "<p>A recursion limit is needed in case a usertype is defined in ;; terms of itself.</p> ;; <p>Always returns a datatype; however, when a warning is present, it may still ;; contain usertypes.</p> ;; <p>An example to work through: suppose we want to resolve the usertype memchunk ;; into a usertype-free datatype --</p> ;; @({ ;; typedef logic [3:0] mynibble; ;; typedef mynibble [7:0] my32; ;; typedef my32 [0:3] membank [63:0]; ;; // error: since membank now has unpacked dims, we can't give it more packed dims: ;; // typedef membank [3:0] memchunk; ;; // this works: ;; typedef membank memchunk [3:0]; ;; })" ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; :vl-coretype (mv nil x) ;; :vl-enum (mv nil x) ;; bozo ;; :vl-usertype ;; (b* (((mv warning newx newss) (vl-usertype-resolve x ss)) ;; ((when warning) (mv warning newx)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out: ~a1" ;; nil x.name) ;; newx))) ;; (vl-datatype-usertype-elim newx newss :rec-limit (1- rec-limit))) ;; :vl-struct ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-struct x :members members))) ;; (mv warning newx)) ;; :vl-union ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-union x :members members))) ;; (mv warning newx))))) ;; (define vl-structmembers-usertype-elim ((x vl-structmemberlist-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) 'rec-limit)) ;; :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (newx vl-structmemberlist-p)) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((mv warning type1) (vl-datatype-usertype-elim ;; (vl-structmember->type (car x)) ss ;; rec-limit)) ;; (first (change-vl-structmember (car x) :type type1)) ;; ((when warning) (mv warning (cons first (vl-structmemberlist-fix (cdr x))))) ;; ((mv warning membs2) (vl-structmembers-usertype-elim (cdr x) ss rec-limit))) ;; (mv warning (cons first membs2)))) ;; /// ;; (deffixequiv-mutual vl-datatype-usertype-elim) ;; (verify-guards vl-datatype-usertype-elim)) (define vl-datatype->structmembers ((x vl-datatype-p)) :short "Finds the struct members of x when it is a struct or union." :returns (mv ok (members vl-structmemberlist-p)) (vl-datatype-case x :vl-struct (mv t x.members) :vl-union (mv t x.members) :otherwise (mv nil nil)) /// (defthm vl-structmemberlist-resolved-p-of-vl-datatype->structmembers (implies (vl-datatype-resolved-p x) (vl-structmemberlist-resolved-p (mv-nth 1 (vl-datatype->structmembers x)))) :hints(("Goal" :in-theory (enable vl-datatype->structmembers))))) (define vl-find-structmember ((name stringp) (membs vl-structmemberlist-p)) :returns (memb (iff (vl-structmember-p memb) memb)) (if (atom membs) nil (if (equal (string-fix name) (vl-structmember->name (car membs))) (vl-structmember-fix (car membs)) (vl-find-structmember name (cdr membs)))) /// (defthm vl-datatype-resolved-p-of-find-structmember (implies (and (vl-structmemberlist-resolved-p members) (vl-find-structmember name members)) (vl-datatype-resolved-p (vl-structmember->type (vl-find-structmember name members)))) :hints(("Goal" :in-theory (enable vl-structmemberlist-resolved-p))))) (define vl-packeddimensionlist-resolved-p ((x vl-packeddimensionlist-p)) :short "Returns true if all sized packed dimensions are resolved." (b* (((when (atom x)) t) (x1 (car x))) (and (vl-packeddimension-case x1 :unsized t :range (vl-range-resolved-p x1.range)) (vl-packeddimensionlist-resolved-p (cdr x))))) (define vl-packeddimensionlist-total-size ((x vl-packeddimensionlist-p)) :short "Given a packeddimensionlist like [5:0][3:1][0:8], multiplies the dimensions together to get the total number of bits, or returns nil if there are unsized dimensions." :guard (vl-packeddimensionlist-resolved-p x) :verify-guards nil :returns (size maybe-posp :rule-classes :type-prescription) (b* (((when (atom x)) 1) (rest (vl-packeddimensionlist-total-size (cdr x))) ((unless rest) nil) (first (car x)) ((when (vl-packeddimension-case first :unsized)) nil) (range (vl-packeddimension->range first))) (* (vl-range-size range) rest)) /// (verify-guards vl-packeddimensionlist-total-size :hints (("goal" :in-theory (enable vl-packeddimensionlist-resolved-p))))) (define vl-packeddimension-size ((x vl-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if (vl-packeddimension-case x :unsized) (mv nil nil) (b* ((range (vl-packeddimension->range x))) (if (vl-range-resolved-p range) (mv nil (vl-range-size range)) (mv t nil))))) (define vl-maybe-packeddimension-size ((x vl-maybe-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if x (vl-packeddimension-size x) (mv nil nil))) (fty::deflist maybe-nat-list :elt-type maybe-natp) (defines vl-datatype-size :prepwork ((local (in-theory (disable all-equalp stringp-when-true-listp default-*-1 integerp-when-natp natp-when-posp rationalp-implies-acl2-numberp acl2::member-when-atom acl2::posp-redefinition rationalp-when-integerp double-containment member-equal-when-member-equal-of-cdr-under-iff equal-of-cons-rewrite))) (std::set-returnspec-mrec-default-hints ((acl2::just-expand-mrec-default-hint 'std::fnname id nil world)))) (define vl-datatype-size ((x vl-datatype-p "The datatype to size")) :short "Computes the number of bits in the datatype." :long "<p>This works for unpacked datatypes as well as packed ones; you should check separately that the datatype is packed if that is what you want. Returns nil without error if given a datatype that has no fixed bit size, e.g. if it contains a real number or has unsized dimensions. We produce an error message if a usertype is not found, if the recursion limit runs out, or if unresolved dimensions are present.</p>" :measure (vl-datatype-count x) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err)) (size maybe-natp :rule-classes :type-prescription)) :verify-guards nil (b* ((x (vl-datatype-fix x)) (udims (vl-datatype->udims x)) (pdims (vl-datatype->pdims x)) ((unless (vl-packeddimensionlist-resolved-p udims)) (mv (vmsg "Unresolved unpacked dimensions: ~a0" (vl-datatype-update-dims nil (append-without-guard udims pdims) x)) nil)) ((unless (vl-packeddimensionlist-resolved-p pdims)) (mv (vmsg "Unresolved packed dimensions: ~a0" x) nil)) (udim-size (vl-packeddimensionlist-total-size udims)) (pdim-size (vl-packeddimensionlist-total-size pdims)) (dim-size (and udim-size pdim-size (* udim-size pdim-size)))) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.size dim-size (* typinfo.size dim-size))))) (:vl-struct (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (sum-nats widths) dim-size))))) (:vl-union (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (max-nats widths) dim-size))))) (:vl-enum (b* (((mv err sub-size) (vl-datatype-size x.basetype)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size))))) (:vl-usertype (b* (((unless (mbt (and x.res t))) (mv (vmsg "Usertype unresolved: ~a0" x) nil)) ((mv err sub-size) (vl-datatype-size x.res)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size)))))))) (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) :returns (mv (err (iff (vl-msg-p err) err)) (sizes maybe-nat-list-p)) :guard (vl-structmemberlist-resolved-p x) :measure (vl-structmemberlist-count x) (b* (((when (atom x)) (mv nil nil)) ((mv err1 size1) (vl-datatype-size (vl-structmember->type (car x)))) ((mv err2 size2) (vl-structmemberlist-sizes (cdr x)))) (mv (or err1 err2) (cons size1 size2))) /// (defret len-of-vl-structmemberlist-sizes (equal (len sizes) (len x)) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x))))) (defret true-listp-of-vl-structmemberlist-sizes (true-listp sizes) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x)))) :rule-classes :type-prescription)) /// (local (defthm nat-listp-when-maybe-nat-list-p (implies (and (maybe-nat-list-p x) (not (member nil x))) (nat-listp x)) :hints(("Goal" :in-theory (enable maybe-nat-list-p))))) (verify-guards vl-datatype-size) (deffixequiv-mutual vl-datatype-size)) (define vl-maybe-usertype-resolve ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :returns (new-x vl-datatype-p) :measure (vl-datatype-count x) (b* ((x (vl-datatype-fix x)) ((when (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)))) x)) (vl-datatype-case x :vl-usertype (if x.res (vl-maybe-usertype-resolve x.res) x) :otherwise x)) /// (defret vl-datatype-count-of-vl-maybe-usertype-resolve (<= (vl-datatype-count new-x) (vl-datatype-count x)) :rule-classes :linear) (defret vl-datatype-resolved-p-of-vl-maybe-usertype-resolve (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x))) (local (defret vl-maybe-usertype-resolve-nonnil new-x :rule-classes :type-prescription)) (defret not-usertype-of-vl-maybe-usertype-resolve (implies (and (not (consp (vl-datatype->pdims new-x))) (not (consp (vl-datatype->udims new-x))) (vl-datatype-resolved-p x)) (not (equal (vl-datatype-kind new-x) :vl-usertype))) :rule-classes ((:forward-chaining :trigger-terms ((vl-datatype-kind (vl-maybe-usertype-resolve x))))))) (define vl-datatype-packedp ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :short "Decide whether the datatype is packed or not." :long "<p>A shallow check; e.g. we don't check for invalid things such as a packed struct with a member that's an unpacked array.</p> <p>Note that the question of whether something is packed is subtly different from the question of whether you can select from it: namely, simple bit types such as @('logic') are packed but not selectable.</p>" :returns (packedp) (b* ((x (vl-maybe-usertype-resolve x)) ((when (consp (vl-datatype->udims x))) nil) ((when (consp (vl-datatype->pdims x))) t)) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) (and xinfo.size t)) :vl-struct x.packedp :vl-union x.packedp :vl-enum t :vl-usertype (impossible)))) (define vl-datatype-signedness ((x vl-datatype-p)) :short "Decide whether the datatype is signed or not." :long "<p>Returns NIL if there isn't an appropriate signedness, as in an unpacked or non-integer type. This function never fails, as such, but in some cases where implementations disagree on the correct signedness, we return a flag to signal that there is a caveat about that signedness.</p> <p>This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, NCV treats the array as unsigned, but VCS treats it as signed. The SV spec only touches on this to say (from Sec. 7.4.1, Packed Arrays):</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [20:0] btest; assign btest = b; }) <p>In NCVerilog, btest has the value @('0ffff'), indicating that @('b') (as a whole) is considered unsigned; in VCS, btest has the value @('fffff'), indicating that @('b') is considered signed.</p> " :guard (vl-datatype-resolved-p x) :measure (vl-datatype-count x) :returns (mv (caveat-flag) (signedness vl-maybe-exprtype-p)) (b* (((when (consp (vl-datatype->udims x))) (mv nil nil))) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.takes-signingp (if x.signedp :vl-signed :vl-unsigned)))) :vl-struct (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-union (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-enum (vl-datatype-signedness x.basetype) :vl-usertype (b* (((unless (mbt (and x.res t))) (mv nil nil)) ((mv caveat ans1) (vl-datatype-signedness x.res)) ((when (and (consp (vl-datatype->pdims x)) (eq ans1 :vl-signed))) (mv t :vl-unsigned))) (mv caveat ans1))))) ;; (defines vl-datatype-check-resolved ;; (define vl-datatype-check-resolved ((x vl-datatype-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-datatype-count x) ;; :short "Returns an explanatory message if the datatype has a problem that would ;; prevent its size from being measured." ;; :long "<p>Packedp indicates whether we require it to be a packed (i.e., ;; vector) datatype.</p>" ;; (b* ((x (vl-datatype-fix x)) ;; (udims (vl-datatype->udims x)) ;; ((when (and packedp (consp udims))) ;; (vmsg "~a0: unpacked dimensions in packed context" x)) ;; ((unless (vl-packeddimensionlist-resolved-p udims)) ;; (vmsg "~a0 has unresolved unpacked dimensions" x)) ;; (pdims (vl-datatype->pdims x)) ;; ((unless (vl-packeddimensionlist-resolved-p pdims)) ;; (vmsg "~a0 has unresolved packed dimensions" x)) ;; (packedp (or (consp pdims) packedp))) ;; (vl-datatype-case x ;; :vl-coretype ;; (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name)) ;; ((when (and packedp (not xinfo.size))) ;; (vmsg "~a0: non-packed coretype" x))) ;; nil) ;; :vl-struct ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty struct" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked struct in packed context" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-union ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty union" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked union" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-enum ;; (vmsg "~a0: enum types not yet supported" x) ;; :vl-usertype ;; (vmsg "~a0: datatype not resolved" x)))) ;; (define vl-structmemberlist-check-resolved ((x vl-structmemberlist-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (or (vl-datatype-check-resolved (vl-structmember->type (car x)) packedp) ;; (vl-structmemberlist-check-resolved (cdr x) packedp)))) ;; /// ;; (deffixequiv-mutual vl-datatype-check-resolved) ;; (deffixequiv-mutual vl-datatype-check-resolved ;; :args ((packedp booleanp))) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-datatype-check-resolved x t))) ;; (not (vl-datatype-check-resolved x packedp))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-structmemberlist-check-resolved x t))) ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; :flag vl-structmemberlist-check-resolved)) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-implies-unpacked ;; (implies (not (vl-datatype-check-resolved x packedp)) ;; (not (vl-datatype-check-resolved x nil))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-implies-unpacked ;; (implies (not (vl-structmemberlist-check-resolved x packedp)) ;; (not (vl-structmemberlist-check-resolved x nil))) ;; :flag vl-structmemberlist-check-resolved))) ;; (define vl-datatype-resolved-p ((x vl-datatype-p) ;; (packedp)) ;; :enabled t ;; (not (vl-datatype-check-resolved x packedp))) ;; (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p) ;; (packedp)) ;; :enabled t ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; (defines vl-packed-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-packed-datatype-size ;; :short "Get the size for any packed data type." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) and be ;; packed or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :guard (vl-datatype-resolved-p x t) ;; :returns ;; (size posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((totalsize (vl-packeddimensionlist-total-size x.pdims)) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) ;; (lposfix (* typinfo.size totalsize)))) ;; (:vl-struct ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (sum-nats widths))))) ;; (:vl-union ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (max-nats widths))))) ;; (:otherwise (lposfix (impossible)))))) ;; (define vl-packed-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x t) ;; :returns (sizes (pos-listp sizes)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-packed-datatype-size (vl-structmember->type (car x))) ;; (vl-packed-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-packed-datatype-size-flag ;; (defthm len-of-vl-packed-structmemberlist-sizes ;; (b* ((sizes (vl-packed-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-packed-structmemberlist-sizes x)))) ;; :flag vl-packed-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (verify-guards vl-packed-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x t) ;; (vl-structmemberlist-check-resolved x t))))) ;; (deffixequiv-mutual vl-packed-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-datatype-size ;; ((x vl-datatype-p)) ;; :short "Get the size for any datatype, even unpacked, that is made up of packed ;; elements." ;; :long "<p>We return NIL if there are non-bit datatypes like @('real').</p>" ;; :guard (vl-datatype-resolved-p x nil) ;; :returns ;; (size maybe-posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x)) ;; (x.pdims (vl-datatype->pdims x)) ;; (x.udims (vl-datatype->udims x)) ;; (pdimsize (vl-packeddimensionlist-total-size x.pdims)) ;; (udimsize (vl-packeddimensionlist-total-size x.udims))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) nil)) ;; (lposfix (* typinfo.size pdimsize udimsize)))) ;; (:vl-struct ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (sum-nats widths) pdimsize udimsize)))) ;; (:vl-union ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (max-nats widths) pdimsize udimsize)))) ;; ;; BOZO enums ;; (:otherwise nil)))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x nil) ;; :returns (sizes maybe-pos-list-p) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-datatype-size (vl-structmember->type (car x))) ;; (vl-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* ((sizes (vl-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-structmemberlist-sizes x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (local (defthm pos-listp-when-not-member-nil ;; (implies (and (maybe-pos-list-p x) ;; (not (member nil x))) ;; (pos-listp x)) ;; :hints(("Goal" :in-theory (enable member))))) ;; (verify-guards vl-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x nil) ;; (vl-structmemberlist-check-resolved x nil))))) ;; (deffixequiv-mutual vl-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite not)))) ;; (define vl-datatype-size ;; :short "Get the size for a data type, including unpacked dimensions." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :returns ;; (mv (err (iff (vl-msg-p err) err)) ;; (size (implies (not err) (posp size)) :rule-classes :type-prescription)) ;; :measure (vl-datatype-count x) ;; (b* (((fun (fail reason args)) ;; (mv (make-vl-msg :msg reason ;; :args args) ;; nil)) ;; ((fun (success width)) (mv nil width)) ;; (x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((udim-size (vl-packeddimensionlist-total-size x.udims)) ;; (pdim-size (vl-packeddimensionlist-total-size x.pdims)) ;; ((unless (and udim-size pdim-size)) ;; (fail "Dimensions of vector type ~a0 not resolvd" ;; (list x))) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) ;; ;; Something like a real, shortreal, void, realtime, chandle, etc. ;; (fail "bad coretype ~a0" (list x)))) ;; (success (* typinfo.size pdim-size udim-size)))) ;; (:vl-struct ;; (b* (;; bozo is there a correct thing to do for a struct with no members? ;; ((unless (consp x.members)) (fail "empty struct: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of struct type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (sum-nats widths))))) ;; (:vl-union ;; (b* (;; bozo is there a correct thing to do for a union with no members? ;; ((unless (consp x.members)) (fail "empty union: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of union type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (max-nats widths))))) ;; (:vl-enum ;; need to compute size from the base type? ;; (fail "bozo: implement enum range" nil)) ;; (:vl-usertype ;; (fail "unresolved usertype: ~a0" (list x.name)))))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (sizes (and (pos-listp sizes) ;; (implies (not err) ;; (equal (consp sizes) (consp x)))))) ;; :measure (vl-structmemberlist-count x) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((vl-structmember first) (vl-structmember-fix (car x))) ;; ((mv warning size) (vl-datatype-size first.type)) ;; ((when warning) (mv warning nil)) ;; ((mv warning rest) (vl-structmemberlist-sizes (cdr x))) ;; ((when warning) (mv warning nil))) ;; (mv nil (cons size rest)))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* (((mv warning sizes) (vl-structmemberlist-sizes x))) ;; (implies (not warning) ;; (equal (len sizes) (len x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (verify-guards vl-datatype-size) ;; (deffixequiv-mutual vl-datatype-size)) ;; (define vl-datatype-exprtype ;; :parents (datatype-tools vl-expr-typedecide) ;; :short "Get the self-determined signedness of a datatype." ;; ((x vl-datatype-p)) ;; :returns ;; (type vl-maybe-exprtype-p ;; "On success: the self-determined signedness (exprtype) of this expression. ;; Note that some expressions (e.g., real numbers, unpacked types) have ;; exprtype NIL.") ;; :long "<p>BOZO This is tricky with packed arrays etc.; I'm not sure we've ;; taken time yet to understand all the rules.</p>" ;; (b* (((when (consp (vl-datatype->udims x))) ;; nil)) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((when typinfo.takes-signingp) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (success nil))) ;; (:vl-enum ;; just need to look at the base type, right? ;; (fail "bozo: implement enum typing")) ;; (:vl-struct ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed struct") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-union ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed union") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-usertype ;; ;; BOZO maybe some day extend this to be able to do lookups, but maybe ;; ;; just depend on usertype-elim ;; (fail "vl-datatype-exprtype can't handle unresolved usertypes"))))) (define vl-datatype-select-ok ((x vl-datatype-p)) :parents (datatype-tools) :short "Determines whether this datatype can be selected." :long "<p>The input datatype should not have packed or unpacked dimensions; if it does, then it's definitely OK to index into it (though it's only a select if it's the last packed dimension). The input datatype should have usertypes resolved.</p>" :guard (vl-datatype-resolved-p x) :returns (ok) :measure (vl-datatype-count x) (b* ((x (vl-maybe-usertype-resolve x))) (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) ;; Checks whether this is an integer atom type. If it's an integer ;; vector type, it's only selectable if it has dims. (and xinfo.size (not (eql xinfo.size 1))))) (:vl-struct x.packedp) (:vl-union x.packedp) (:vl-enum ;; NOTE: This is a little nonsensical, but simulators seem to treat enums ;; as if they were always 1-dimensional vectors, even in the case of ;; typedef enum logic {a, b} foo ; ;; which you might think would be a 0-dimensional thing. t) (:vl-usertype (impossible)))))) (define vl-datatype-dims-count ((x vl-datatype-p)) :short "Gives the number of packed plus unpacked dimensions on a datatype." :returns (ndims natp :rule-classes :type-prescription) (+ (len (vl-datatype->udims x)) (len (vl-datatype->pdims x)))) (define vl-datatype-set-unsigned ((x vl-datatype-p)) :short "Removes any explicit signed indicator from a datatype." :long "<p>This is rather specific in purpose and generally shouldn't be used. The case where it is useful is when we are indexing into an (explicitly signed) packed array; this means that the whole array is signed, but not the selected parts. So we strip the signed qualifier off of the type when we index into packed dimensions. (This doesn't apply to usertypes that are defined as signed types! If we index down to such a type, it IS signed, but any packed array of such a type is not. So we don't need to descend into usertypes or somehow mark them as unsigned. We just have to know that a usertype with one or more packed dimensions counts as unsigned.)</p>" :returns (new-x vl-datatype-p) (vl-datatype-case x :vl-coretype (mbe :logic (change-vl-coretype x :signedp nil) :exec (if x.signedp (change-vl-coretype x :signedp nil) x)) :vl-struct (mbe :logic (change-vl-struct x :signedp nil) :exec (if x.signedp (change-vl-struct x :signedp nil) x)) :vl-union (mbe :logic (change-vl-union x :signedp nil) :exec (if x.signedp (change-vl-union x :signedp nil) x)) :otherwise (vl-datatype-fix x)) /// (defret vl-datatype-resolved-p-of-set-unsigned (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x)))) ;; (define vl-datatype-indexing-dimension ((x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :returns (dim (iff (vl-packeddimension-p dim) dim)) ;; (b* ((udims (vl-datatype->udims x)) ;; ((when (consp udims)) (car udims)) ;; (pdims (vl-datatype->pdims x)) ;; ((when (consp pdims)) (car pdims)) (define vl-datatype-remove-dim ((x vl-datatype-p)) :short "Get the type of a variable of type @('x') after an indexing operation is applied to it." :long " <p>The caveat flag returned identifies a case where implementations disagree on the signedness of the resulting type. This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, if we index into an object down to the usertype, NCV treats the resulting object as signed, but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation is correct: from Sec. 7.4.1, Packed Arrays:</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [7:0] btest; assign btest = b[1]; }) <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is considered signed; in VCS, btest has the value @('0f'), indicating that @('b[1]') is considered unsigned.</p>" :prepwork ((local (in-theory (disable not equal-of-cons-rewrite equal-of-vl-usertype acl2::len-when-atom acl2::true-listp-of-nthcdr acl2::true-listp-when-string-listp-rewrite acl2::true-listp-when-symbol-listp-rewrite acl2::nfix-when-not-natp acl2::zp-open acl2::consp-under-iff-when-true-listp acl2::list-fix-under-iff acl2::append-when-not-consp acl2::list-fix-when-len-zero acl2::take-of-len-free double-containment)))) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") (caveat-flag "Indicates caveat about possible signedness ambiguities") (new-x (implies (not err) (vl-datatype-p new-x)) "Datatype after indexing") (dim (implies (not err) (vl-packeddimension-p dim)) "Dimension removed from the datatype")) (b* ((x (vl-maybe-usertype-resolve x)) (udims (vl-datatype->udims x)) ((when (consp udims)) (mv nil nil (vl-datatype-update-udims (cdr udims) x) (car udims))) (pdims (vl-datatype->pdims x)) ((when (consp pdims)) (b* ((x (vl-datatype-set-unsigned x)) ((when (or (vl-datatype-case x :vl-usertype) (consp (cdr pdims)))) ;; (unless (and (eql n np) ;; (not (vl-datatype-case x :vl-usertype)))) (mv nil nil (vl-datatype-update-dims (cdr pdims) nil ;; no udims x) (car pdims))) (new-x (vl-datatype-update-dims nil nil x)) ((mv & signedness) (vl-datatype-signedness new-x))) (mv nil (eq signedness :vl-signed) new-x (car pdims)))) ((unless (vl-datatype-packedp x)) (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) nil nil nil)) ((mv err size) (vl-datatype-size x)) ((when err) (mv err nil nil nil)) ((unless (posp size)) (mv (vmsg "Index applied to ~s0 packed type: ~a1" (if size "unsizeable" "zero-sized") x) nil nil nil)) ((when (and (vl-datatype-case x :vl-coretype) (eql size 1))) (mv (vmsg "Index applied to bit type ~a0" x) nil nil nil)) (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) :lsb (vl-make-index 0))))) (mv nil nil (make-vl-coretype :name :vl-logic) dim)) /// (defret vl-datatype-resolved-p-of-remove-dim (implies (and (not err) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p new-x))) (defret no-error-when-pdims (implies (consp (vl-datatype->pdims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve)))) (defret no-error-when-udims (implies (consp (vl-datatype->udims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve))))) (define vl-selstep-usertypes-ok ((x vl-selstep-p)) (b* (((vl-selstep x))) (vl-datatype-resolved-p x.type))) (define vl-seltrace-usertypes-ok ((x vl-seltrace-p)) (if (atom x) t (and (vl-selstep-usertypes-ok (car x)) (vl-seltrace-usertypes-ok (cdr x)))) /// (defthm vl-seltrace-usertypes-ok-of-append (implies (and (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok y)) (vl-seltrace-usertypes-ok (append x y)))) (defthm vl-seltrace-usertypes-ok-of-rev (implies (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok (rev x)))) (defthm vl-datatype-resolved-p-of-first-seltrace (implies (and (vl-seltrace-usertypes-ok x) (consp x)) (vl-datatype-resolved-p (vl-selstep->type (car x)))) :hints(("Goal" :in-theory (enable vl-selstep-usertypes-ok))))) (define vl-follow-array-indices ((x vl-exprlist-p) (type vl-datatype-p)) :returns (mv (err (iff (vl-msg-p err) err)) (trace vl-seltrace-p)) :guard (vl-datatype-resolved-p type) (b* (((when (atom x)) (mv nil nil)) ((mv err caveat newtype &) (vl-datatype-remove-dim type)) ((when err) (mv err nil)) ((mv err rest) (vl-follow-array-indices (cdr x) newtype)) ((when err) (mv err nil))) (mv nil (cons (make-vl-selstep :select (make-vl-select-index :val (car x)) :type newtype :caveat caveat) rest))) /// (defret vl-seltrace-usertypes-ok-of-follow-array-indices (implies (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (defret true-listp-of-vl-follow-array-indices-trace (true-listp trace) :rule-classes :type-prescription) (defret vl-seltrace->indices-of-vl-follow-array-indices (implies (not err) (equal (vl-seltrace->indices trace) (vl-exprlist-fix x))) :hints(("Goal" :in-theory (enable vl-seltrace->indices)))) (defret consp-of-vl-follow-array-indices (implies (not err) (equal (consp trace) (consp x)))) (defret len-of-vl-follow-array-indices (implies (not err) (equal (len trace) (len x))))) ;; (define vl-datatype-remove-dims ((n natp) ;; (x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :short "Get the type of a variable of type @('x') after @('n') indexing ;; operations are applied to it." ;; :long " ;; <p>The caveat flag returned identifies a case where implementations disagree on ;; the signedness of the resulting type. This caveat occurs when we have packed ;; dimensions on a usertype that is declared as signed. In this case, if we index ;; into an object down to the usertype, NCV treats the resulting object as signed, ;; but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation ;; is correct: from Sec. 7.4.1, Packed Arrays:</p> ;; <blockquote> If a packed array is declared as signed, then the array viewed as ;; a single vector shall be signed. The individual elements of the array are ;; unsigned unless they are of a named type declared as signed. A partselect of a ;; packed array shall be unsigned.</blockquote> ;; <p>An example:</p> ;; @({ ;; typedef logic signed [3:0] squad; ;; squad [3:0] b; ;; assign b = 16'hffff; ;; logic [7:0] btest; ;; assign btest = b[1]; ;; }) ;; <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is ;; considered signed; in VCS, btest has the value @('0f'), indicating that ;; @('b[1]') is considered unsigned.</p>" ;; :prepwork ;; ((local (in-theory (disable not equal-of-cons-rewrite ;; equal-of-vl-usertype ;; acl2::len-when-atom ;; acl2::true-listp-of-nthcdr ;; acl2::true-listp-when-string-listp-rewrite ;; acl2::true-listp-when-symbol-listp-rewrite ;; acl2::nfix-when-not-natp ;; acl2::zp-open ;; acl2::consp-under-iff-when-true-listp ;; acl2::list-fix-under-iff ;; acl2::append-when-not-consp ;; acl2::list-fix-when-len-zero ;; acl2::take-of-len-free ;; double-containment)))) ;; :guard (not (vl-datatype-check-usertypes x ss)) ;; :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") ;; (caveat-flag "Indicates caveat about possible signedness ambiguities") ;; (new-x (implies (not err) (vl-datatype-p new-x)) ;; "Datatype after indexing") ;; (dims vl-packeddimensionlist-p) ;; (new-ss vl-scopestack-p "Scopestack where the most recently looked-up ;; usertype was defined -- this is the scopestack ;; needed to look up the next usertype that ;; might remain in the new type.")) ;; :measure (two-nats-measure ;; n ;; (if (and (vl-datatype-case x :vl-usertype) ;; (not (consp (vl-datatype->udims x))) ;; (not (consp (vl-datatype->pdims x)))) ;; 1 0)) ;; (b* ((x (vl-datatype-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; (udims (redundant-list-fix (vl-datatype->udims x))) ;; (pdims (redundant-list-fix (vl-datatype->pdims x))) ;; (nu (len udims)) ;; (n (lnfix n)) ;; ((when (<= n nu)) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (nthcdr n udims) x) ;; (take n udims) ;; ss)) ;; (n (- n nu)) ;; (np (len pdims)) ;; ((when (<= n np)) ;; (b* ((x (vl-datatype-set-unsigned x)) ;; (dims (append udims (take n pdims))) ;; ((when (or (vl-datatype-case x :vl-usertype) ;; (< n np))) ;; ;; (unless (and (eql n np) ;; ;; (not (vl-datatype-case x :vl-usertype)))) ;; (mv nil nil ;; (vl-datatype-update-dims ;; (nthcdr n pdims) ;; nil ;; no udims ;; x) ;; dims ;; ss)) ;; (new-x (vl-datatype-update-dims nil nil x)) ;; ((mv & signedness) (vl-datatype-signedness new-x ss))) ;; (mv nil (eq signedness :vl-signed) new-x dims ss))) ;; (n (- n np))) ;; (vl-datatype-case x ;; :vl-usertype ;; (b* (((mv err def new-ss) (vl-usertype-resolve x.name ss)) ;; ((when err) (mv err nil nil (append udims pdims) new-ss)) ;; ((mv err caveat new-x rest-dims new-ss) ;; (vl-datatype-remove-dims n def new-ss))) ;; (mv err caveat new-x (append udims pdims rest-dims) new-ss)) ;; :otherwise ;; (b* ((x (vl-datatype-update-dims nil nil x)) ;; ((unless (vl-datatype-packedp x ss)) ;; (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) ;; nil nil (append udims pdims) ss)) ;; ((unless (eql n 1)) ;; (mv (vmsg "Too many indices applied to packed non-array ~a0" x) nil nil (append udims pdims) ss)) ;; ((mv err size) (vl-datatype-size x ss)) ;; ((when err) ;; (mv err nil nil (append udims pdims) ss)) ;; ((unless (posp size)) ;; (mv (vmsg "Index applied to ~s0 packed type: ~a1" ;; (if size "unsizeable" "zero-sized") x) ;; nil nil (append udims pdims) ss)) ;; ((when (and (vl-datatype-case x :vl-coretype) ;; (eql size 1))) ;; (mv (vmsg "Index applied to bit type ~a0" x) nil nil (append udims pdims) ss)) ;; (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))))) ;; (mv nil nil ;; (make-vl-coretype :name :vl-logic) ;; (append udims pdims (list dim)) ;; ss)))) ;; /// ;; (defret vl-datatype-check-usertypes-of-remove-dims ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes new-x new-ss :rec-limit rec-limit))) ;; :hints (("goal" :induct t :in-theory (enable vl-datatype-check-usertypes)))) ;; (defret vl-datatype-remove-dims-true-listp-dims ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret vl-datatype-remove-dims-dims-length ;; (implies (not err) ;; (equal (len dims) ;; (nfix n)))) ;; (verify-guards vl-datatype-remove-dims ;; :hints ((and stable-under-simplificationp ;; '(:expand ((:free (rec-limit) ;; (vl-datatype-check-usertypes x ss :rec-limit rec-limit))))))) ;; (local ;; (defthm vl-datatype-update-dims-compose ;; (equal (vl-datatype-update-dims ;; pdims udims ;; (vl-datatype-update-dims ;; pdims1 udims1 x)) ;; (vl-datatype-update-dims ;; pdims udims x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) ;; (local (Defthm append-of-nil ;; (equal (append nil x) x) ;; :hints(("Goal" :in-theory (enable append))))) ;; (local (defthm list-fix-of-nthcdr ;; (equal (list-fix (nthcdr n x)) ;; (nthcdr n (list-fix x))))) ;; (local (in-theory (disable acl2::nthcdr-of-list-fix))) ;; (local (defthm append-take-take-nthcdr ;; (equal (append (take n a) ;; (take m (nthcdr n a))) ;; (take (+ (nfix n) (nfix m)) a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a)) ;; a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (defthm append-take-take-nthcdr-1 ;; (equal (append (take n a) ;; (take m (nthcdr n a)) ;; x) ;; (append (take (+ (nfix n) (nfix m)) a) x)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr-1 ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a) ;; x) ;; (append a x))) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (in-theory (disable ACL2::INEQUALITY-WITH-NFIX-HYP-1))) ;; ;; (local (defthm nfix-linear ;; ;; (<= 0 (nfix n)) ;; ;; :rule-classes :linear)) ;; (local (defthm vl-datatype-kind-of-set-unsigned ;; (equal (vl-datatype-kind (vl-datatype-set-unsigned x)) ;; (vl-datatype-kind x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (defthm packedp-update-dims-of-set-unsigned ;; (equal (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss) ;; (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss)) ;; :hints(("Goal" :in-theory (enable vl-datatype-packedp ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm size-update-dims-of-set-unsigned ;; (b* (((mv err1 size1) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss)) ;; ((mv err2 size2) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss))) ;; (and (iff err1 err2) ;; (equal size1 size2))) ;; :hints(("Goal" :in-theory (enable vl-datatype-size ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm vl-usertype->name-of-update-dims ;; (equal (vl-usertype->name (vl-datatype-update-dims pdims udims x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-usertype->name-of-set-unsigned ;; (equal (vl-usertype->name (vl-datatype-set-unsigned x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-datatype-set-unsigned-of-update-dims ;; (Equal (vl-datatype-set-unsigned ;; (vl-datatype-update-dims pdims udims x)) ;; (vl-datatype-update-dims pdims udims (vl-datatype-set-unsigned x))) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-datatype-update-dims))))) ;; (local (Defthm vl-datatype-set-unsigned-idempotent ;; (equal (vl-datatype-set-unsigned (vl-datatype-set-unsigned x)) ;; (vl-datatype-set-unsigned x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (in-theory (disable vl-datatype-fix-when-vl-coretype ;; vl-datatype-fix-when-vl-struct ;; vl-datatype-fix-when-vl-union ;; vl-datatype-fix-when-vl-enum ;; vl-datatype-fix-when-vl-usertype))) ;; (local (defthm <=-when-equal ;; (implies (equal a b) ;; (<= a b)))) ;; (defthm vl-datatype-remove-dims-compose ;; (b* (((mv err ?caveat new-x dims new-ss) ;; (vl-datatype-remove-dims (+ (nfix n) (nfix m)) x ss)) ;; ((mv err1 ?caveat1 new-x1 dims1 new-ss1) ;; (vl-datatype-remove-dims n x ss)) ;; ((mv err2 ?caveat2 new-x2 dims2 new-ss2) ;; (vl-datatype-remove-dims m new-x1 new-ss1))) ;; (implies (not err) ;; (and (not err1) ;; (not err2) ;; ;; (equal caveat2 caveat) ;; (equal new-x2 new-x) ;; (equal new-ss2 new-ss) ;; (list-equiv (append dims1 dims2) dims)))) ;; :hints (("goal" :induct (vl-datatype-remove-dims n x ss) ;; :in-theory (disable (:d vl-datatype-remove-dims)) ;; :expand ((:free (n) (vl-datatype-remove-dims n x ss)) ;; (:free (x ss) ;; (vl-datatype-remove-dims 1 x ss)) ;; ;; (:free (x) (vl-datatype-size (vl-datatype-update-dims nil nil x) ss)) ;; )) ;; ;; (and stable-under-simplificationp ;; ;; '(:in-theory (enable ;; ;; vl-datatype-update-dims ;; ;; vl-datatype-set-unsigned ;; ;; vl-datatype-packedp))) ;; (and stable-under-simplificationp ;; '(:expand ((:free (x ss) ;; (vl-datatype-remove-dims m x ss))))) ;; ))) ;; (define vl-hidindex-datatype-resolve-dims ((x vl-hidindex-p) ;; (type vl-datatype-p)) ;; :short "Given the indices of some expression, e.g. foo[5][3], and the ;; datatype of foo, return the datatype of the whole expression." ;; :long "<p>Note: we don't check whether indices are in bounds or anything, ;; just whether the number of indices is less than or equal the number of ;; total (unpacked plus packed) dimensions.</p> ;; <p>We produce a non-fatal warning because we're not sure in what contexts this ;; will be used.</p> ;; <p>Example: Suppose our datatype is from a typedef</p> ;; @({ ;; typedef bit [3:0] [4:2] foo [0:6] [0:8]; ;; }) ;; <p>that is, it has one unpacked dimension @('[0:6]') and two packed dimensions. ;; Suppose our expression is @('bar[5][7][2]'), where bar is of type foo. Then we ;; should return @('bit[4:2]') as our resolved datatype, with no unpacked ;; dimensions, because the first two indices correspond to the unpacked dimension ;; and the second to the first packed dimension. On the other hand if we had ;; @('bar[5]'), we should return @('bit') with packed dimensions @('[3:0][4:2]') ;; and unpacked dimension @('[0:8]').</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type1 (iff (vl-datatype-p type1) (not warning)))) ;; (b* ((idxcount (len (vl-hidindex->indices x))) ;; (type (vl-datatype-fix type)) ;; (x (vl-hidindex-fix x)) ;; (unpacked-dims (vl-datatype->udims type)) ;; (packed-dims (vl-datatype->pdims type)) ;; (nunpacked (len unpacked-dims)) ;; ((when (<= idxcount nunpacked)) ;; (mv nil (vl-datatype-update-udims ;; (nthcdr idxcount (redundant-list-fix unpacked-dims)) type))) ;; (remaining-idxcount (- idxcount nunpacked)) ;; ((unless (<= remaining-idxcount (len packed-dims))) ;; (mv (make-vl-warning :type :vl-too-many-indices ;; :msg "Too many indices on expression ~a0 ~ ;; relative to dimensions of type ~a1." ;; :args (list x type) ;; :fn __function__) ;; nil)) ;; (type (vl-datatype-update-dims ;; (nthcdr remaining-idxcount (redundant-list-fix packed-dims)) ;; nil ;; udims ;; type))) ;; (mv nil type))) ;; Have a HID, and know (for the base name) the type (unresolved) and unpacked ;; dims. ;; Resolve the type. ;; If the hid is an ID, return the type and dims. ;; Resolve the indices of the base part against the unpacked/packed dims. If we ;; end up still having dims remaining, fail. ;; If the type is not a struct or union type, fail. ;; Find the next name in the HID among the structmembers. If not found, fail. ;; Recur with the rest of the HID and the type/unpacked dims of the member. ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (final-type (implies (not err) (vl-datatype-p final-type)))) ;; (b* (((mv type ss) ;; (if (vl-datatype-case type :vl-usertype) ;; (b* (((mv & type ss) (vl-usertype-resolve type ss))) ;; (mv type ss)) ;; (mv type ss))) ;; ((mv name1 indices rest) ;; (vl-hidexpr-case x ;; :end (mv x.name nil nil) ;; :dot (b* (((vl-hidindex x.first))) ;; (mv x.first.name x.first.indices x.rest)))) ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and (atom (vl-datatype->udims type)) ;; (atom (vl-datatype->pdims type)) ;; ok)) ;; (mv (vmsg "Can't get field ~s0 from non-struct/union type ~a1" ;; name1 type) ;; nil)) ;; (member (vl-find-structmember name1 members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil)) ;; (membtype (vl-structmember->type member)) (define vl-hidexpr-index-count ((x vl-hidexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end 0 :dot (+ (len (vl-hidindex->indices x.first)) (vl-hidexpr-index-count x.rest)))) (define vl-scopeexpr-index-count ((x vl-scopeexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-index-count x.hid) :colon (vl-scopeexpr-index-count x.rest))) (define vl-follow-data-selects ((x vl-hidexpr-p) (type vl-datatype-p) (trace vl-seltrace-p "Accumulator")) :short "Given a HID expression denoting a variable of the input type, create a trace showing the type of each field select/indexing operation." :long "<p>Implementation notes: This function only </p>" :returns (mv (err (iff (vl-msg-p err) err)) (seltrace vl-seltrace-p)) :measure (vl-hidexpr-count x) :guard (vl-datatype-resolved-p type) :verify-guards nil ;; Resolve the type and dims. (b* ((type (vl-datatype-fix type)) ;; (name1 (vl-hidexpr-case x ;; :end x.name ;; :dot (vl-hidindex->name x.first))) ;; (frame (make-vl-selstep ;; :select (make-vl-select-field :name name1) ;; :type type ;; :ss ss)) ;; (trace (cons frame (vl-seltrace-fix trace))) (trace (vl-seltrace-fix trace)) ((when (vl-hidexpr-case x :end)) ;; We just have an ID. It has already been added to the trace (or else ;; it is just a plain variable and the outer hidtrace has its type info). (mv nil trace)) ;; Cancel the indices of the first element of the HID with the unpacked ;; and packed dims of the type. ;; Note: We have at least one more dot in this HID, so if we don't have ;; a struct or union at the end of this, we have a problem. ((vl-hidexpr-dot x)) ((mv err rev-idxtrace) (vl-follow-array-indices (vl-hidindex->indices x.first) type)) ((when err) (mv err nil)) (trace (revappend rev-idxtrace trace)) (type (if (consp rev-idxtrace) (vl-selstep->type (car trace)) type)) (type (vl-maybe-usertype-resolve type)) ;; Next we're going to dot-index into the datatype, so get its ;; structmembers, making sure it's a struct. ((mv ok members) (vl-datatype->structmembers type)) (nextname (vl-hidexpr-case x.rest :end x.rest.name :dot (vl-hidindex->name x.rest.first))) ;; Look up the member corresponding to the next name in the hid. ((unless (and ok (atom (vl-datatype->udims type)) (atom (vl-datatype->pdims type)))) (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" nextname (vl-datatype-update-dims (append-without-guard (vl-datatype->udims type) (vl-datatype->pdims type)) nil type)) nil)) ((when (eq nextname :vl-$root)) (mv (vmsg "Can't use $root to index into a data structure: ~a0" (vl-hidexpr-fix x)) nil)) (member (vl-find-structmember nextname members)) ((unless member) (mv (vmsg "Dot-indexing failed: struct/union member ~ ~s0 not found in type ~a1" nextname (vl-datatype-fix type)) nil)) (membtype (vl-structmember->type member)) (next-frame (make-vl-selstep :select (make-vl-select-field :name nextname) :type membtype)) (trace (cons next-frame trace))) (vl-follow-data-selects x.rest membtype trace)) /// (verify-guards vl-follow-data-selects) (defret vl-seltrace-usertypes-ok-of-vl-follow-data-selects (implies (and (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) (vl-seltrace-usertypes-ok seltrace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (local (in-theory (disable acl2::car-of-append acl2::consp-under-iff-when-true-listp))) (defret vl-seltrace-indices-of-vl-follow-data-selects (implies (not err) (equal (vl-seltrace->indices seltrace) (revappend (vl-hidexpr->subexprs x) (vl-seltrace->indices trace)))) :hints(("Goal" :in-theory (enable vl-seltrace->indices vl-hidexpr->subexprs))))) ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Given a HID expression that indexes into a datatype, find the type ;; of the expression." ;; :long " <p>A helpful invariant to remember when thinking about this function: ;; The type input of a given call of this function belong to the base (leftmost) ;; variable in the HID.</p> ;; <p>Example: Suppose we have the following type declarations</p> ;; @({ ;; typedef struct packed { logic [3:0] foo; } [4:0] foostruct; ;; typedef union { foostruct [5:0] bar; logic [2:0] baz; } bunion [0:6]; ;; typedef struct { bunion fa [0:8], logic [1:0] ba; } bstruct; ;; bstruct myvar [8:0]; ;; }) ;; <p>For this example, we'll write a type with both packed an unpacked dimensions ;; with an underscore between the packed and unpacked dims.</p> ;; <p>A bunion is a type consisting of an unpacked array of 7 elements ;; each of which may either be a packed array of 6 foostructs (a packed structure ;; containing one 4-bit logic field) or a 3-bit logic; a bstruct is a struct ;; containing an unpacked array of 9 bunions and an additional 2-bit logic field; ;; and myvar is an unpacked array of 9 bstructs.</p> ;; <p>Suppose our expression is @('myvar[1].fa[8][4].bar[3][4].foo').</p> ;; <ul> ;; <li>First, before calling this function we look up the type of myvar. We get a ;; vardecl, which has a type @('bstruct _ [8:0]'). Then we're ready to run.</li> ;; <li>Outermost call: We resolve the type bstruct to its struct definition. We ;; cancel our index with the single array dimension, leaving just the struct. We ;; find the element fa inside the struct, and ;; recur on the remainder of our expression, @('fa[8][4].bar[3][4].foo'), with the ;; structmember's type, @('bunion _ [0:8]').</li> ;; <li> We resolve the bunion type to the union, and append the unpacked ;; dimensions of the type and the element to get @('[0:8][0:6]'). We then check ;; the indices from the expression against this type and unpacked dimensions, ;; which results in just the bare union type (the definition of bunion, but ;; without its unpacked dimension @('[0:6]')). We find the element bar inside the ;; union and recur: @('bar[3][4].foo'), type @('foostruct[5:0]').</li> ;; <li> We resolve the type foostruct to its struct type, and append the packed ;; dimensions to get @('[5:0][4:0]'). We then check the indices from the ;; expression, which results in cancelling out the dimension to obtain just the ;; bare struct. We find the element foo of the struct and recur on that.</li> ;; <li>Finally, we have just the atom @('foo') as our expression, so we return the ;; type @('logic[3:0]').</li> </ul>" ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :verify-guards nil ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (restype (iff (vl-datatype-p restype) (not err))) ;; (dims vl-packeddimensionlist-p ;; "Dimensions of indices along the way") ;; (final-ss vl-scopestack-p "Scopestack in which the last usertype was found")) ;; ;; Resolve the type and dims. ;; (b* ((type (vl-datatype-fix type)) ;; (ss (vl-scopestack-fix ss)) ;; ((when (vl-hidexpr-case x :end)) ;; ;; We just have an ID. Return the resolved type. ;; (mv nil type nil ss)) ;; ;; Cancel the indices of the first element of the HID with the unpacked ;; ;; and packed dims of the type. ;; ;; Note: We have at least one more dot in this HID, so if we don't have ;; ;; a struct or union at the end of this, we have a problem. ;; ((vl-hidexpr-dot x)) ;; (nindices (len (vl-hidindex->indices x.first))) ;; ((mv err ?caveat idxtype dims ss) ;; ;; Ignore the caveat because we're going dot-index into the new type at ;; ;; least once more. ;; (vl-datatype-remove-dims nindices type ss)) ;; ((when err) (mv err nil nil ss)) ;; ((mv baretype ss) (vl-maybe-usertype-resolve idxtype ss)) ;; ;; Next we're going to dot-index into the datatype, so get its ;; ;; structmembers, making sure it's a struct. ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and ok ;; (atom (vl-datatype->udims baretype)) ;; (atom (vl-datatype->pdims baretype)))) ;; (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" ;; (vl-datatype-update-dims (append-without-guard ;; (vl-datatype->udims baretype) ;; (vl-datatype->pdims baretype)) ;; nil baretype)) ;; nil nil ss)) ;; ;; Look up the member corresponding to the next name in the hid. ;; (nextname (vl-hidexpr-case x.rest ;; :end x.rest.name ;; :dot (vl-hidindex->name x.rest.first))) ;; (member (vl-find-structmember nextname members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil nil ss)) ;; (membtype (vl-structmember->type member)) ;; ((mv err type rest-dims ss) ;; (vl-hidexpr-traverse-datatype x.rest membtype ss))) ;; (mv err type (append dims rest-dims) ss)) ;; /// ;; (defret true-listp-dims-of-vl-hidexpr-traverse-datatype ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-hidexpr-traverse-datatype ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count x))) ;; :hints(("Goal" :in-theory (enable vl-hidexpr-index-count)))) ;; ;; bozo move these two theorems ;; (defthm vl-structmemberlist-check-usertypes-of-vl-datatype->structmembers ;; (b* (((mv ok members) (vl-datatype->structmembers x))) ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; ok) ;; (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)))) ;; :hints(("Goal" :in-theory (enable vl-datatype->structmembers ;; vl-datatype-check-usertypes)))) ;; (defthm vl-datatype-check-usertypes-of-find-structmember ;; (implies (and (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)) ;; (vl-find-structmember name members)) ;; (not (vl-datatype-check-usertypes ;; (vl-structmember->type (vl-find-structmember name members)) ;; ss :rec-limit rec-limit))) ;; :hints(("Goal" :in-theory (enable vl-structmemberlist-check-usertypes ;; vl-find-structmember)))) ;; (verify-guards vl-hidexpr-traverse-datatype) ;; (defret vl-datatype-check-usertypes-of-vl-hidexpr-traverse-datatype ;; (implies (and (not (vl-datatype-check-usertypes type ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes restype final-ss :rec-limit rec-limit))))) ;; (define vl-scopeexpr-find-type ((x vl-scopeexpr-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Looks up a HID in a scopestack and looks for a declaration, returning ;; the type if found, and the scopestack relative to that type." ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (iff (vl-datatype-p type) (not err))) ;; (dims vl-packeddimensionlist-p) ;; (type-ss vl-scopestack-p)) ;; (b* ((x (vl-scopeexpr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv err trace tail) (vl-follow-scopeexpr x ss)) ;; ((when err) (mv err nil nil ss)) ;; ((vl-hidstep step1) (car trace)) ;; ((when (eq (tag step1.item) :vl-vardecl)) ;; ;; check its datatype ;; (b* (((vl-vardecl step1.item)) ;; (err (vl-datatype-check-usertypes step1.item.type step1.ss)) ;; ((when err) (mv err nil nil step1.ss))) ;; (vl-hidexpr-traverse-datatype tail step1.item.type step1.ss)))) ;; (mv (vmsg "Failed to find a type for ~s1 because we ~ ;; didn't find a vardecl but rather a ~x2" ;; nil x (tag step1.item)) ;; nil nil ss)) ;; /// ;; (defret true-listp-dims-of-vl-scopeexpr-find-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count (mv-nth 2 (vl-follow-scopeexpr x ss))))) ;; :hints(("Goal" :in-theory (enable vl-scopeexpr-index-count)))) ;; (defret vl-datatype-check-usertypes-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret follow-scopeexpr-when-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (mv-nth 0 (vl-follow-scopeexpr x ss)))))) (define vl-partselect-width ((x vl-partselect-p)) :guard (not (vl-partselect-case x :none)) :returns (mv (err (iff (vl-msg-p err) err)) (width (implies (not err) (posp width)) :rule-classes :type-prescription)) (b* ((x (vl-partselect-fix x))) (vl-partselect-case x :range (b* (((unless (and (vl-expr-resolved-p x.msb) (vl-expr-resolved-p x.lsb))) (mv (vmsg "Unresolved partselect: ~a0" x) nil)) (msb (vl-resolved->val x.msb)) (lsb (vl-resolved->val x.lsb))) ;; BOZO We might want to check here whether the msb/lsb are ;; correctly ascending/descending. Not the core mission, though. (mv nil (+ 1 (abs (- msb lsb))))) :plusminus (b* (((unless (vl-expr-resolved-p x.width)) (mv (vmsg "Unresolved partselect width: ~a0" x) nil)) (width (vl-resolved->val x.width)) ((when (eql width 0)) (mv (vmsg "Zero-width partselect not allowed: ~a0" x) nil))) (mv nil width)) :otherwise (mv (vmsg "Impossible") (impossible))))) (define vl-operandinfo-usertypes-ok ((x vl-operandinfo-p)) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace))) /// (defthm vl-operandinfo-usertypes-ok-implies (implies (vl-operandinfo-usertypes-ok x) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace)))))) (define vl-operandinfo-index-count ((x vl-operandinfo-p)) :returns (count natp :rule-classes :type-prescription) ;; Gives the number of indices (b* (((vl-operandinfo x))) (+ (vl-seltrace-index-count x.seltrace) (vl-partselect-case x.part :none 0 :otherwise 2)))) (define vl-operandinfo->indices ((x vl-operandinfo-p)) :returns (indices vl-exprlist-p) (b* (((vl-operandinfo x))) (append (vl-partselect-case x.part :none nil :range (list x.part.msb x.part.lsb) :plusminus (list x.part.base x.part.width)) (vl-seltrace->indices x.seltrace))) /// (defret len-of-vl-operandinfo->indices (equal (len indices) (vl-operandinfo-index-count x)) :hints(("Goal" :in-theory (enable vl-operandinfo-index-count))))) (defthm vl-exprlist-count-of-append (equal (vl-exprlist-count (append a b)) (+ -1 (vl-exprlist-count a) (vl-exprlist-count b))) :hints(("Goal" :in-theory (enable vl-exprlist-count append)))) (defthm vl-exprlist-count-of-rev (equal (vl-exprlist-count (rev x)) (vl-exprlist-count x)) :hints(("Goal" :in-theory (enable vl-exprlist-count rev)))) (define vl-datatype-resolve-selects ((type vl-datatype-p) (tail vl-hidexpr-p) (indices vl-exprlist-p) (part vl-partselect-p)) :returns (mv (err (iff (vl-msg-p err) err)) (seltrace (implies (not err) (vl-seltrace-p seltrace))) (finaltype (implies (not err) (vl-datatype-p finaltype)))) :guard (vl-datatype-resolved-p type) (b* (((mv err seltrace) (vl-follow-data-selects tail type nil)) ((when err) (mv err nil nil)) (type (vl-datatype-fix type)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((mv err rev-idxtrace) (vl-follow-array-indices indices seltype)) ((when err) (mv err nil nil)) (seltrace (revappend rev-idxtrace seltrace)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((when (vl-partselect-case part :none)) (mv nil seltrace seltype)) ((mv err ?caveat single-type &) (vl-datatype-remove-dim seltype)) ((when err) (mv err nil nil)) ((mv err width) (vl-partselect-width part)) ((when err) (mv err nil nil)) (new-dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) (packedp (vl-datatype-packedp seltype)) (psel-type (if packedp (vl-datatype-update-pdims (cons new-dim (vl-datatype->pdims single-type)) single-type) (vl-datatype-update-udims (cons new-dim (vl-datatype->udims single-type)) single-type)))) (mv nil seltrace psel-type)) /// (defret vl-seltrace-usertypes-ok-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-seltrace-usertypes-ok seltrace))) (defret vl-datatype-resolved-p-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-datatype-resolved-p finaltype))) (defret vl-seltrace-count-of-vl-datatype-resolve-selects (implies (not err) (< (vl-exprlist-count (vl-seltrace->indices seltrace)) (+ (vl-exprlist-count indices) (vl-hidexpr-count tail)))) :rule-classes :linear)) (define vl-index-expr-typetrace ((x vl-expr-p "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical identifier with 0 or more array selects and a possible partselect.") (ss vl-scopestack-p "Scopestack where @('x') is referenced.") (typeov vl-typeoverride-p)) :guard (vl-expr-case x :vl-index) :returns (mv (err (iff (vl-msg-p err) err) "Success indicator, we fail if we can't follow the HID or this isn't an appropriate expression.") (opinfo (implies (not err) (vl-operandinfo-p opinfo)))) :prepwork ((local (defthm natp-abs (implies (integerp x) (natp (abs x))) :rule-classes :type-prescription)) (local (in-theory (disable abs)))) (b* (((vl-index x) (vl-expr-fix x)) (ss (vl-scopestack-fix ss)) ((mv err hidtrace context tail) (vl-follow-scopeexpr x.scope ss)) ((when err) (mv err nil)) ((vl-hidstep hidstep) (car hidtrace)) ;; Suppose x is foo.bar.baz.fum[0][1][3:2]. ;; Suppose foo.bar is the actual vardecl, and .baz.fum are selects into it. ;; We want to see if foo.bar has a cached resolved type. ;; Compute foo.bar. (prefix-name (vl-scopeexpr-replace-hid x.scope (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ((mv err type) (b* ((look (hons-get prefix-name (vl-typeoverride-fix typeov))) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: Type override was unresolved") nil)))) (case (tag hidstep.item) (:vl-vardecl (b* ((type1 (vl-vardecl->type hidstep.item))) (vl-datatype-usertype-resolve type1 hidstep.ss :typeov typeov))) (:vl-paramdecl (b* (((vl-paramdecl decl) hidstep.item)) (vl-paramtype-case decl.type :vl-explicitvalueparam (if (vl-datatype-resolved-p decl.type.type) (mv nil decl.type.type) (mv (vmsg "Reference to parameter with unresolved type: ~a0" x) nil)) :otherwise (mv (vmsg "Bad parameter reference: ~a0" x) nil)))) (otherwise (mv (vmsg "~a0: instead of a vardecl, found ~a1" x hidstep.item) nil))))) ((when err) (mv err nil)) ((mv err seltrace final-type) (vl-datatype-resolve-selects type tail x.indices x.part)) ((when err) (mv err nil))) (mv nil (make-vl-operandinfo :context context :prefixname prefix-name :hidtrace hidtrace :hidtype type :seltrace seltrace :part x.part :type final-type))) ;; ((mv err seltrace) (vl-follow-data-selects tail type nil)) ;; ((when err) (mv err nil)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; ((mv err rev-idxtrace) ;; (vl-follow-array-indices x.indices seltype)) ;; ((when err) (mv err nil)) ;; (seltrace (revappend rev-idxtrace seltrace)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; (prefix-name (vl-scopeexpr-replace-hid ;; x.scope ;; (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ;; ((when (vl-partselect-case x.part :none)) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type seltype))) ;; ((mv err ?caveat single-type &) ;; (vl-datatype-remove-dim seltype)) ;; ((when err) (mv err nil)) ;; ((mv err width) (vl-partselect-width x.part)) ;; ((when err) (mv err nil)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (packedp (vl-datatype-packedp seltype)) ;; (psel-type (if packedp ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type)))) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type psel-type))) /// (defret vl-seltrace-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-seltrace-usertypes-ok (vl-operandinfo->seltrace opinfo)))) (defret consp-hidtrace-of-vl-index-expr-typetrace (implies (not err) (consp (vl-operandinfo->hidtrace opinfo)))) ;; (defret vl-hidtrace-top-is-vardecl-or-paramdecl-of-vl-index-expr-typetrace ;; (implies (and (not err) ;; (not (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-paramdecl))) ;; (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-vardecl))) (defret vl-datatype-usertypes-ok-of-vl-index-expr-typetrace-type (implies (not err) (vl-datatype-resolved-p (vl-operandinfo->type opinfo)))) (defret vl-operandinfo-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-operandinfo-usertypes-ok opinfo)) :hints(("Goal" :in-theory (enable vl-operandinfo-usertypes-ok)))) (defret follow-scopeexpr-when-vl-index-expr-type (implies (not err) (b* (((vl-index x))) (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss)))))) (defret index-count-of-vl-index-expr-typetrace (implies (and (not err) (equal (vl-expr-kind x) :vl-index)) (< (vl-exprlist-count (vl-operandinfo->indices opinfo)) (vl-expr-count x))) :hints(("Goal" :in-theory (enable vl-operandinfo->indices vl-exprlist-count vl-partselect-count vl-plusminus-count vl-range-count) :expand ((vl-expr-count x)))) :rule-classes :linear)) ;; (define vl-index-expr-typetrace ;; ((x vl-expr-p ;; "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical ;; identifier with 0 or more array selects and a possible partselect.") ;; (ss vl-scopestack-p ;; "Scopestack where @('x') is referenced.")) ;; :guard (vl-expr-case x :vl-index) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (caveat-flg) ;; (type (implies (not err) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.") ;; (dims vl-packeddimensionlist-p ;; "Dimensions corresponding to the array indices in the expression") ;; (type-ss vl-scopestack-p ;; "Scopestack relative to the type returned.")) ;; :prepwork ((local (defthm natp-abs ;; (implies (integerp x) ;; (natp (abs x))) ;; :rule-classes :type-prescription)) ;; (local (in-theory (disable abs)))) ;; (b* (((vl-index x) (vl-expr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv warning type sdims type-ss) (vl-scopeexpr-find-type x.scope ss)) ;; ((when warning) (mv warning nil nil nil ss)) ;; (has-partselect (vl-partselect-case x.part ;; :none nil ;; :otherwise t)) ;; ((mv err caveat-flg reduced-type idims reduced-ss) ;; (vl-datatype-remove-dims (len x.indices) type type-ss)) ;; ((when err) (mv err nil nil nil reduced-ss)) ;; ((unless has-partselect) ;; (mv nil ;; caveat-flg ;; reduced-type ;; (append sdims idims) ;; reduced-ss)) ;; ;; Take off one more dimension, and then add a dimension the width of ;; ;; the partselect. ;; ;; Caveat-flag doesn't apply because implementations seem to agree that ;; ;; partselects are always unsigned. ;; ((mv err ?caveat-flg single-type psdims single-ss) ;; (vl-datatype-remove-dims 1 reduced-type reduced-ss)) ;; ((when err) ;; (mv err nil nil nil single-ss)) ;; ((mv err width) ;; (vl-partselect-width x.part)) ;; ((when err) (mv err nil nil nil single-ss)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range ;; :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (dims (append sdims idims psdims)) ;; ;; The result is now width many elements of ;; ;; type single-type. So we add a dimension [width-1:0] back onto ;; ;; reduced-type. However, we need to know whether it should be an ;; ;; unpacked or packed dimension: the way to determine this is whether ;; ;; the last dimension selected was packed or unpacked. ;; (packedp (vl-datatype-packedp reduced-type reduced-ss)) ;; ((when packedp) ;; (mv nil nil ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; dims ;; single-ss))) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type) ;; dims ;; single-ss)) ;; /// ;; (defret vl-datatype-check-usertypes-of-vl-index-expr-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret true-listp-dims-of-vl-index-expr-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-index-expr-type ;; (implies (not err) ;; (equal (len dims) ;; (b* (((vl-index x))) ;; (+ (len x.indices) ;; (vl-partselect-case x.part :none 0 :otherwise 1) ;; (vl-hidexpr-index-count ;; (mv-nth 2 (vl-follow-scopeexpr x.scope ss)))))))) ;; (defret follow-scopeexpr-when-vl-index-expr-type ;; (implies (not err) ;; (b* (((vl-index x))) ;; (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss))))))) #|| (trace$ #!vl (vl-index-find-type :entry (list 'vl-index-find-type (with-local-ps (vl-pp-expr x)) ;; (if (equal (vl-pps-expr x) "popcounts[30]") ;; (break$) ;; nil) ) :exit (cons 'vl-index-find-type (b* (((list warning type) values)) (list type (with-local-ps (if warning (vl-print-warnings (list warning)) (vl-ps-seq (vl-pp-datatype type) (vl-print " udims: ") (vl-pp-packeddimensionlist (vl-datatype->udims type)))))))))) ||# ;; (define vl-index-find-type ;; ((x vl-expr-p "Should be a hid (perhaps just an ID), perhaps with some indexing ;; operators applied to it, i.e., bitselect or index operators but ;; not part-select operators. So for instance: @('foo, foo.bar, ;; foo.bar[3], foo.bar[3][4][5]')") ;; (ss vl-scopestack-p "Scopestack where @('x') occurs.") ;; (ctx acl2::any-p)) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (type (implies (not warning) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.")) ;; :prepwork ((local (in-theory (disable default-car ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :verify-guards nil ;; :measure (vl-expr-count x) ;; (b* ((x (vl-expr-fix x)) ;; ((when (or (vl-atom-p x) ;; (not (member (vl-nonatom->op x) ;; '(:vl-index :vl-bitselect))))) ;; (b* (((unless (vl-hidexpr-p x)) ;; (mv (make-vl-warning ;; :type :vl-bad-index-expr ;; :msg "~a0: An index operator was applied to a bad subexpression, ~a1." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning type) (vl-hidexpr-find-type x ss ctx)) ;; ((when warning) (mv warning nil))) ;; (mv nil type))) ;; ((vl-nonatom x)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; ((when (consp udims)) ;; ;; We could check here that the index is in bounds, but maybe that ;; ;; should more appropriately be done elsewhere. ;; (mv nil (vl-datatype-update-udims (cdr udims) sub-type))) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((when (consp pdims)) ;; ;; An index operator applied to packed dimensions makes the datatype unsigned. ;; (mv nil (vl-datatype-update-pdims (cdr pdims) (vl-datatype-set-unsigned sub-type)))) ;; ;; If there are no dimensions, the index has to be a bitselect; check ;; ;; whether this is ok. ;; ((when (vl-datatype-bitselect-ok sub-type)) ;; ;; We have a bitselect of some packed non-array type. The result is ;; ;; therefore an unsigned single bit. ;; (mv nil ;; (make-vl-coretype :name :vl-logic)))) ;; (mv (make-vl-warning :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because ~ ;; it has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; /// ;; (verify-guards vl-index-find-type ;; :hints(("Goal" :in-theory (e/d (acl2::member-of-cons) ;; (vl-index-find-type))))) ;; (defthm context-irrelevance-of-vl-index-find-type ;; (implies (syntaxp (not (equal ctx ''nil))) ;; (b* (((mv err1 type1) (vl-index-find-type x ss ctx)) ;; ((mv err2 type2) (vl-index-find-type x ss nil))) ;; (and (iff err1 err2) ;; (equal type1 type2)))))) ;; (define vl-partselect-type-top-dimension-replacement ((dim vl-packeddimension-p) ;; (x vl-expr-p) ;; (ctx vl-context-p)) ;; :guard-hints ((and stable-under-simplificationp ;; '(:in-theory (enable acl2::member-of-cons)))) ;; :guard (and (not (vl-atom-p x)) ;; (member (vl-nonatom->op x) ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (range (implies (not warning) (vl-range-p range)))) ;; (b* (((vl-nonatom x)) ;; (x (vl-expr-fix x)) ;; (dim (vl-packeddimension-fix dim)) ;; (ctx (vl-context-fix ctx)) ;; ((when (or (eq dim :vl-unsized-dimension) ;; (not (vl-range-resolved-p dim)))) ;; (mv (make-vl-warning :type :vl-partselect-type-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; most significant dimension of the type of ~ ;; ~a2 was unsized or non-constant." ;; :args (list ctx x (first x.args)) ;; :fn __function__) ;; nil)) ;; ((unless (and (vl-expr-resolved-p (third x.args)) ;; (or (not (member x.op '(:vl-partselect-colon ;; :vl-select-colon))) ;; (vl-expr-resolved-p (second x.args))))) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; partselect has non-constant indices." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((when (member x.op '(:vl-select-colon :vl-partselect-colon))) ;; (mv nil (make-vl-range :msb (second x.args) :lsb (third x.args)))) ;; (width (vl-resolved->val (third x.args))) ;; ((unless (posp width)) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Zero width in partselect operator?" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((unless (vl-expr-resolved-p (second x.args))) ;; (mv nil (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) ;; ;; The second argument is resolved, so set the range as specified. ;; (m-or-lsb (vl-resolved->val (second x.args))) ;; (backward-range-p (< (vl-resolved->val (vl-range->msb dim)) ;; (vl-resolved->val (vl-range->lsb dim)))) ;; (greater-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; (+ m-or-lsb width -1) ;; m-or-lsb)) ;; (lesser-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; m-or-lsb ;; (+ m-or-lsb (- width) 1))) ;; ((when (< lesser-idx 0)) ;; (mv (make-vl-warning :type :vl-partselect-index-error ;; :msg "~a0: Partselect ~s1 operator yields negative index: ~a2" ;; :args (list ctx (if (eq x.op :vl-partselect-pluscolon) ;; "+:" "-:") ;; x) ;; :fn __function__) ;; nil)) ;; (range (make-vl-range :msb (vl-make-index (if backward-range-p lesser-idx greater-idx)) ;; :lsb (vl-make-index (if backward-range-p greater-idx lesser-idx))))) ;; (mv nil range)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-type-top-dimension-replacement ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x nil))) ;; (iff (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x nil))))))) ;; (define vl-partselect-expr-type ((x vl-expr-p) ;; (ss vl-scopestack-p) ;; (ctx vl-context-p "context")) ;; :guard (not (eq (vl-expr-kind x) :atom)) ;; :guard-hints (("goal" :in-theory (enable acl2::member-of-cons))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (implies (not warning) (vl-datatype-p type)))) ;; :prepwork ((local (in-theory (disable default-car default-cdr ;; vl-expr-resolved-p-of-car-when-vl-exprlist-resolved-p ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :measure (vl-expr-count x) ;; (b* ((ctx (vl-context-fix ctx)) ;; ((vl-nonatom x) (vl-expr-fix x)) ;; ((unless (member x.op ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; (mv (make-vl-warning :type :vl-programming-error ;; :msg "~a0: called vl-partselect-selfsize on non-partselect expr ~a1" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((unless (or (consp udims) (consp pdims))) ;; (b* (((unless (vl-datatype-bitselect-ok sub-type)) ;; (mv (make-vl-warning ;; :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because it ~ ;; has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; ((mv warning size) (vl-datatype-size sub-type)) ;; ((when warning) (mv warning nil)) ;; ;; The type is some packed thing, and we have its size. As long ;; ;; as the partselect is in range, we'll just return a new logic ;; ;; with the correct dimension on it. ;; (range (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement range x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (make-vl-coretype :name :vl-logic ;; :pdims (list new-dim1)))) ;; (mv nil new-type))) ;; (dim1 (if (consp udims) (car udims) (car pdims))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement dim1 x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (vl-datatype-update-dims ;; (if (consp udims) pdims (cons new-dim1 (cdr pdims))) ;; (and (consp udims) (cons new-dim1 (cdr udims))) ;; sub-type)) ;; ;; packed types become unsigned ;; (new-type (if (consp udims) new-type (vl-datatype-set-unsigned new-type)))) ;; (mv nil new-type)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-expr-type ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 1 (vl-partselect-expr-type x ss nil))) ;; (iff (mv-nth 0 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 0 (vl-partselect-expr-type x ss nil))))))) ;; 99% sure this is deprecated ;; (define vl-hid-range ;; :short "Try to look up a range for a HID, which may have been installed by ;; @(see vl-expr-follow-hids)." ;; ((x vl-expr-p "This should generally be the top-level HID expression.")) ;; :guard (not (vl-atom-p x)) ;; :returns (mv (successp booleanp :rule-classes :type-prescription) ;; (range vl-maybe-range-p ;; :hints(("Goal" :in-theory (disable (force)))))) ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; (mv nil nil)) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((when (and (not left) (not right))) ;; ;; It's resolved, there's just no range. ;; (mv t nil)) ;; ((unless (and left right)) ;; ;; Maybe this should be a programming error? ;; (mv nil nil)) ;; ;; Dumb hackery for unconditional return theorem ;; (left (mbe :logic (if (vl-expr-p left) ;; left ;; (vl-make-index 0)) ;; :exec left)) ;; (right (mbe :logic (if (vl-expr-p right) ;; right ;; (vl-make-index 0)) ;; :exec right)) ;; (range (make-vl-range :msb left :lsb right))) ;; (mv t range)) ;; /// ;; (defthm vl-hid-range-of-copy-atts ;; (equal (vl-hid-range (vl-nonatom op (vl-nonatom->atts x) args fw ft)) ;; (vl-hid-range x)))) ;; (define vl-hid-rangeatts ;; :short "Extend the attributes for a HID with range information." ;; ;; BOZO we should probably be using this in vl-expr-follow-hids. ;; ((range vl-maybe-range-p) ;; (atts vl-atts-p "the rest of the atts")) ;; :guard (vl-maybe-range-resolved-p range) ;; :returns (new-atts vl-atts-p) ;; (b* ((atts (vl-atts-fix atts)) ;; (atts (if range ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" (vl-range->msb range)) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" (vl-range->lsb range)) ;; atts) ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" nil) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" nil) ;; atts)))) ;; (cons (list "VL_HID_RESOLVED_RANGE_P") atts)) ;; /// ;; (defthm vl-hid-range-of-vl-hid-rangeatts ;; (implies range ;; (equal (vl-hid-range (vl-nonatom op (vl-hid-rangeatts range atts) args fw ft)) ;; (mv t (vl-range-fix range)))) ;; :hints(("Goal" :in-theory (e/d (vl-hid-range)))))) ;; (define vl-hid-width ;; :short "Try to return the width of a HID, using range attribute information ;; that may have been installed by @(see vl-expr-follow-hids)." ;; ((x vl-expr-p)) ;; :guard (not (vl-atom-p x)) ;; :enabled t ;; :guard-hints (("goal" :in-theory (enable vl-hid-range ;; vl-maybe-range-resolved-p ;; vl-maybe-range-size ;; vl-range-resolved-p ;; vl-range-size ;; vl-width-from-difference ;; ))) ;; :returns (width maybe-posp :rule-classes :type-prescription) ;; (mbe :logic (b* (((mv ok range) (vl-hid-range x))) ;; (and ok ;; (vl-maybe-range-resolved-p range) ;; (vl-maybe-range-size range))) ;; :exec ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; nil) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((unless (or (and (not left) (not right)) ;; (and left (vl-expr-resolved-p left) ;; right (vl-expr-resolved-p right)))) ;; nil)) ;; (if left ;; (vl-width-from-difference ;; (- (vl-resolved->val left) (vl-resolved->val right))) ;; 1)))) (define vl-hidindex-resolved-p ((x vl-hidindex-p)) :returns (bool) :short "Determines if every index in a @(see vl-hidindex-p) is resolved." :measure (vl-expr-count x) (vl-exprlist-resolved-p (vl-hidindex->indices x)) ;; (b* (((when (vl-atom-p x)) ;; t) ;; ((vl-nonatom x) x)) ;; (and (mbt (eq x.op :vl-index)) ;; (vl-hidindex-resolved-p (first x.args)) ;; (vl-expr-resolved-p (second x.args)))) /// ;; (defthm vl-hidindex-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidindex-resolved-p x))) (deffixequiv vl-hidindex-resolved-p) ;; (defthm vl-hidindex-resolved-p-of-make-vl-nonatom ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-expr-resolved-p (second args)))) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :in-theory (e/d (vl-arity-fix) ((force))) ;; :expand ((:free (atts args finalwidth finaltype) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))))))) ;; (defthmd vl-nonatom->op-when-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (equal (vl-nonatom->op x) :vl-index))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-expr-resolved-p-of-arg2-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-expr-resolved-p (second (vl-nonatom->args x))))) ) (define vl-hidexpr-resolved-p ((x vl-hidexpr-p)) ;; :prepwork ((local (in-theory (enable vl-nonatom->op-when-hidindex-resolved-p)))) :returns (bool) :short "Determines if every index throughout a @(see vl-hidexpr-p) is resolved." :guard-debug t :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end t :dot (and (vl-hidindex-resolved-p x.first) (vl-hidexpr-resolved-p x.rest))) /// (defthm vl-hidexpr-resolved-p-when-endp (implies (vl-hidexpr-case x :end) (vl-hidexpr-resolved-p x))) (defthm vl-hidexpr-resolved-p-of-vl-hidexpr-dot ;; Really I should be using something like a of-cons rule here, but without ;; a constructor... (equal (vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)) (and (vl-hidindex-resolved-p first) (vl-hidexpr-resolved-p rest))) :hints (("goal" :Expand ((vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)))))) (defthm vl-hidexpr-resolved-p-implies-dot (implies (and (vl-hidexpr-resolved-p x) (vl-hidexpr-case x :dot)) (and (vl-hidindex-resolved-p (vl-hidexpr-dot->first x)) (vl-hidexpr-resolved-p (vl-hidexpr-dot->rest x))))) ;; (defthm vl-hidexpr-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidexpr-resolved-p x))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-arg2-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidexpr-resolved-p (second (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-make-vl-nonatom-for-dot ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-hidexpr-resolved-p (second args)))) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :expand (:free (atts args finalwidth finaltype) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :in-theory (e/d (vl-arity-fix) ((force)))))) ) (define vl-scopeexpr-resolved-p ((x vl-scopeexpr-p)) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-resolved-p x.hid) :colon (vl-scopeexpr-resolved-p x.rest))) (define vl-flatten-hidindex-aux ((indices vl-exprlist-p) acc) :guard (vl-exprlist-resolved-p indices) :parents (vl-flatten-hidindex) :returns (new-acc character-listp :hyp (character-listp acc)) (b* (((when (atom indices)) acc) (acc (cons #\[ acc)) (acc (revappend (str::natchars (vl-resolved->val (car indices))) acc)) (acc (cons #\] acc))) (vl-flatten-hidindex-aux (cdr indices) acc))) (define vl-flatten-hidindex ((x vl-hidindex-p)) :guard (vl-hidindex-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a @(see vl-hidindex-p) into a string like @('\"bar[3][4][5]\"')." :measure (vl-expr-count x) :guard-hints(("Goal" :in-theory (enable vl-hidindex-resolved-p))) (b* ((name (vl-hidindex->name x)) (name (if (eq name :vl-$root) "$root" name)) (indices (vl-hidindex->indices x)) ((when (atom indices)) name) (acc nil) (acc (str::revappend-chars name acc)) (acc (vl-flatten-hidindex-aux indices acc))) (str::rchars-to-string acc))) (define vl-flatten-hidexpr ((x vl-hidexpr-p)) :guard (vl-hidexpr-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a hierarchical identifier expression into a string like @('foo.bar[3][4][5].baz')." :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end x.name :dot (cat (vl-flatten-hidindex x.first) "." (vl-flatten-hidexpr x.rest)))) ;; (define vl-explode-hidindex ;; :short "Explode a (resolved) @(see vl-hidindex-p) into a flat list of ;; its components." ;; ((x vl-expr-p "The hidindex to explode, e.g., @('foo[3][4][5]')")) ;; :guard (and (vl-hidindex-p x) ;; (vl-hidindex-resolved-p x)) ;; :returns (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" 3 4 5)').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x) ;; (from (vl-explode-hidindex (first x.args))) ;; (idx (vl-resolved->val (second x.args)))) ;; (append from (list idx)))) ;; (define vl-explode-hid ;; :short "Explode a (resolved) @(see vl-hidexpr-p) into a flat list of its ;; components." ;; ((x vl-expr-p "The hidexpr to explode, e.g., foo.bar[2][3].baz.")) ;; :guard (and (vl-hidexpr-p x) ;; (vl-hidexpr-resolved-p x)) ;; :returns ;; (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" \"bar\" 2 3 \"baz\")').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x)) ;; (append (vl-explode-hidindex (first x.args)) ;; (vl-explode-hid (second x.args)))))
true
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "VL") ;; (include-book "datatype-tools") (include-book "scopestack") (include-book "expr-tools") (include-book "coretypes") (include-book "../util/sum-nats") (local (include-book "../util/arithmetic")) (local (include-book "centaur/misc/arith-equivs" :dir :system)) (local (in-theory (enable tag-reasoning))) (local (in-theory (disable (tau-system)))) (local (std::add-default-post-define-hook :fix)) (local (defthm equal-of-cons-rewrite (equal (equal x (cons a b)) (and (consp x) (equal (car x) a) (equal (cdr x) b))))) (defthm vl-genelement-kind-by-tag (implies (and (vl-genelement-p x) (equal (tag x) foo) (syntaxp (quotep foo))) (equal (vl-genelement-kind x) foo)) :hints(("Goal" :in-theory (enable tag vl-genelement-kind vl-genelement-p)))) (defxdoc following-hids :parents (hid-tools) :short "Functions for following hierarchical identifiers." :long "<p>Perhaps the most fundamental operation for a hierarchical identifier is figure out what it refers to. This turns out to be a surprisingly challenging and nuanced process.</p> <p>Our top-level routine for following hierarchical identifiers is @(see vl-follow-hidexpr). It is meant to make looking up hierarchical identifiers convenient despite these complications.</p> <p>We now describe some of these challenges and how @(see vl-follow-hidexpr) deals with them.</p> <dl> <dt>Datatypes versus Scopes</dt> <dd>Challenge: The same syntax is used to refer to both data structure members like @('myinst.opcode') and also to scopes like @('mysubmod.mywire'). However, structures and scopes are very different and need to be traversed in different ways.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows only the scope-based part of the HID. However, as one of our return values, we provide the tail of the hierarchical index that leads into this variable. For instance, in a case like @('foo.bar.myinst.opcode') where @('myinst') is an @('instruction_t') structure variable, we will follow only until the declaration of @('myinst') and then we will return @('myinst.opcode') as the tail.</dd> <dd>Tools that want to descend into structures will need to do so using the appropriate functions; for instance @(see BOZO) and @(see BOZO).</dd> <dt>Unclear Destination</dt> <dd>Challenge: Depending on the kind of analysis being done, we might want to continue or stop resolving at certain points. For instance, if we are trying to size a hierarchical identifier like @('myinterface.ready'), we probably want to follow through the interface all the way to the @('ready') signal. However, for light-weight variable use analysis, we may want to stop as soon as we hit an interface.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) follows the HID as far as possible, but returns a @(see vl-hidtrace-p) that includes not only the final declaration we arrive at, but also all intermediate points along the way. If you only care about the final destination (e.g., the @('ready') signal for sizing or similar) then you can get this final destination from the first @(see vl-hidstep-p) in the trace. But if you also want to know, e.g., that @('myinterface') has been used, this information can easily be extracted from the rest of the trace.</dd> <dt>Unresolved Parameters</dt> <dd>Challenge: Because of parameters, we may not be able to tell whether the indices in a hierarchical identifier are valid. For instance, if there is an array of module instances like @('mymod myarr [width-1:0] (...)') and we are trying to follow a hierarchical reference like @('foo.bar.myarr[7].baz'), then we will not know whether this is valid until we have resolved @('width').</dd> <dd>In some applications, e.g., for @(see lint)-like tools, it may be best to allow these potentially invalid indices. After all, we \"know\" that this reference is either invalid or is a reference to @('baz') within @('mymod'). In that case, we may well wish to assume that the index will be valid and just go on and find @('baz').</dd> <dd>However, some other applications have more stringent soundness constraints. If we are writing transforms that are meant to build conservative, safe, formal models of the Verilog code, we may instead want to insist that all of the indices have been resolved and cause an error if this is not the case.</dd> <dd>Our Approach: @(see vl-follow-hidexpr) always tries to check that indices are in bounds and to cause errors when indices are clearly out of bounds. If we encounter indices that are potentially out of bounds, then we can do one of two things: <ul> <li>By default, we are permissive and assume the index will be in bounds.</li> <li>However, if @(':strictp') is enabled, we will cause an error.</li> </ul></dd> <dd>As a special note: we always require generate array indices to be resolved. See @(see vl-follow-hidexpr) for additional discussion.</dd> <dt>Error reporting</dt> <dd>Challenge: A HID may be invalid in many different ways. Any part of the HID may try to refer to a name that does not exist, and any index along the HID might be invalid. If an error occurs, we should provide enough detail to understand the problem.</dd> <dd>Our Approach: In the case of any error, @(see vl-follow-hidexpr) returns a message. Callers should put this message in the appropriate context so that the end-user can understand the nature and location of the problem.</dd> </dl>") (local (xdoc::set-default-parents following-hids)) (defprod vl-hidstep :short "A single step along the way of a hierarchical identifier." :long "<p>Some routines for @(see following-hids) produce traces of the items they encounter along the way. A <b>hidstep</b> structure represents a single step along a HID.</p>" :tag :vl-hidstep :layout :tree ((name stringp "Name from the hid") (index vl-maybe-expr-p "Instance array/genarray index, if present") (item vl-scopeitem-p "The item encountered along the path of the HID.") (ss vl-scopestack-p "The scope where this item was found."))) (fty::deflist vl-hidtrace :elt-type vl-hidstep :short "A list of @(see vl-hidstep) structures, typically all of the steps encountered along a HID.") (define vl-scopeexpr->hid ((x vl-scopeexpr-p)) :returns (hid vl-hidexpr-p) :short "Finds the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end x.hid :colon (vl-scopeexpr->hid x.rest)) /// (defret count-of-vl-scopeexpr->hid (< (vl-hidexpr-count hid) (vl-scopeexpr-count x)) :rule-classes :linear)) (define vl-scopeexpr-replace-hid ((x vl-scopeexpr-p) (new-hid vl-hidexpr-p)) :returns (new-x vl-scopeexpr-p) :short "Replaces the hidexpr nested inside the scopeexpr." :measure (vl-scopeexpr-count x) :verify-guards nil (vl-scopeexpr-case x :end (change-vl-scopeexpr-end x :hid new-hid) :colon (change-vl-scopeexpr-colon x :rest (vl-scopeexpr-replace-hid x.rest new-hid))) /// (verify-guards vl-scopeexpr-replace-hid)) (define vl-subhid-p ((inner vl-hidexpr-p) (outer vl-hidexpr-p)) :measure (vl-hidexpr-count outer) (if (vl-hidexpr-equiv inner outer) (vl-hidexpr-case outer :end t :dot (stringp (vl-hidindex->name outer.first))) (vl-hidexpr-case outer :dot (vl-subhid-p inner outer.rest) :otherwise nil))) (define vl-hid-prefix-for-subhid ((outer vl-hidexpr-p) (inner vl-hidexpr-p)) :guard (vl-subhid-p inner outer) :returns (prefix-hid vl-hidexpr-p) :measure (vl-hidexpr-count outer) :verify-guards nil (vl-hidexpr-case outer :end (vl-hidexpr-fix outer) ;; must be the inner one since it's the last :dot (if (vl-hidexpr-equiv inner outer) (make-vl-hidexpr-end :name (vl-hidindex->name outer.first)) (make-vl-hidexpr-dot :first outer.first :rest (vl-hid-prefix-for-subhid outer.rest inner)))) /// (verify-guards vl-hid-prefix-for-subhid :hints (("goal" :expand ((vl-subhid-p inner outer) (vl-subhid-p inner inner)))))) (define vl-follow-hidexpr-error :short "Report an error while following a HID." ((short vl-msg-p "Brief description of the error.") (ss vl-scopestack-p "Detailed context for the error.") &key ((origx vl-scopeexpr-p "Original, full HID being resolved.") 'origx) ((x vl-hidexpr-p "Current place in the HID.") 'x)) :returns (msg vl-msg-p) :long "<p>This is smart in a few ways: it distinguishes between ordinary identifiers and hierarchical identifiers in the error type, and avoids providing excessive context if we haven't gotten anywhere down into the HID yet.</p>" (b* ((x (vl-hidexpr-fix x)) (origx (vl-scopeexpr-fix origx)) (short (vl-msg-fix short)) (endp (vl-scopeexpr-case origx :end)) ((when (and endp (equal x (vl-scopeexpr-end->hid origx)))) ;; Omit detailed context since we haven't gotten anywhere yet. (vmsg "error resolving ~a1: ~@2." nil origx short))) (vmsg "error resolving ~a1: ~@2.~%~ (Failed to resolve ~a3 in ~s4)." nil origx short x (vl-scopestack->path ss)))) (define vl-follow-hidexpr-dimcheck :short "Check an array index against the corresponding array bounds." ((name stringp "Name being the array, for better errors.") (index vl-expr-p "An index into an array.") (dim vl-packeddimension-p "Bounds from the corresponding declaration.") &key (strictp booleanp "Require indices to be resolved?")) :returns (err (iff (vl-msg-p err) err)) :long "<p>In strict mode, we require that the @('index') and the array dimensions all be resolved and that the index be in range.</p> <p>In non-strict mode, we tolerate unresolved indices and declaration bounds. Note that we still do bounds checking if the indices and array bounds happen to be resolved.</p>" (b* ((dim (vl-packeddimension-fix dim)) ((when (vl-packeddimension-case dim :unsized)) ;; Bounds checking doesn't make sense in this case, so we'll just ;; regard this as fine. nil) (dim (vl-packeddimension->range dim)) ((unless (vl-expr-resolved-p index)) (if strictp (vmsg "unresolved array index") nil)) ((unless (vl-range-resolved-p dim)) (if strictp (vmsg "unresolved bounds on declaration of ~s0" (string-fix name)) nil)) ((vl-range dim)) (idxval (vl-resolved->val index)) (msbval (vl-resolved->val dim.msb)) (lsbval (vl-resolved->val dim.lsb)) (minval (min msbval lsbval)) (maxval (max msbval lsbval)) ((unless (and (<= minval idxval) (<= idxval maxval))) (vmsg "array index ~x0 out of bounds (~x1 to ~x2)" idxval minval maxval))) nil)) (define vl-follow-hidexpr-dimscheck-aux :parents (vl-follow-hidexpr-dimscheck) :short "Main loop to check each index/dimension pair." :prepwork ((local (defthm vl-exprlist-fix-of-atom (implies (not (consp x)) (equal (vl-exprlist-fix x) nil))))) ((name stringp) (indices vl-exprlist-p) (dims vl-packeddimensionlist-p) &key (strictp booleanp)) :guard (same-lengthp indices dims) :returns (err (iff (vl-msg-p err) err)) (if (atom indices) nil (or (vl-follow-hidexpr-dimcheck name (car indices) (car dims) :strictp strictp) (vl-follow-hidexpr-dimscheck-aux name (cdr indices) (cdr dims) :strictp strictp)))) (define vl-follow-hidexpr-dimscheck :short "Check array indices against the corresponding array bounds." ((name stringp) (indices vl-exprlist-p "Indices from the HID piece we're following. I.e., if we are resolving @('foo[3][4][5].bar'), this would be @('(3 4 5)') as an expression list.") (dims vl-packeddimensionlist-p "Corresponding dimensions from the declaration, i.e., if @('foo') is declared as a @('logic [7:0][15:0][3:0]'), then this would be the list of @('([7:0] [15:0] [3:0])').") &key (strictp booleanp "Should we require every index to be resolved?")) :returns (err (iff (vl-msg-p err) err)) (b* ((name (string-fix name)) ((when (atom dims)) (if (atom indices) nil (vmsg "indexing into non-array ~s0" name))) ((when (atom indices)) (vmsg "no indices given for array ~s0" name)) ((when (same-lengthp indices dims)) (vl-follow-hidexpr-dimscheck-aux name indices dims :strictp strictp)) (found (len indices)) (need (len dims)) ((when (< found need)) (vmsg "too many indices for array ~s0" name))) (vmsg "not enough indices for array ~s0" name))) (define vl-genarrayblocklist-find-block :short "Find the block from a generate array corresponding to some index." ((idx integerp) (x vl-genarrayblocklist-p)) :returns (blk (iff (vl-genarrayblock-p blk) blk)) (cond ((atom x) nil) ((eql (vl-genarrayblock->index (car x)) (lifix idx)) (vl-genarrayblock-fix (car x))) (t (vl-genarrayblocklist-find-block idx (cdr x))))) (local (defthm stringp-when-hidname-and-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (with-output :evisc (:gag-mode (evisc-tuple 3 4 nil nil) :term nil) :off (event) (define vl-follow-hidexpr-aux :parents (vl-follow-hidexpr) :short "Core routine for following hierarchical identifiers." ((x vl-hidexpr-p "HID expression fragment that we are following.") (trace vl-hidtrace-p "Accumulator for the trace until now.") (ss vl-scopestack-p "Current scopestack we're working from.") &key (strictp booleanp) ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx)) :returns (mv (err (iff (vl-msg-p err) err) "A @(see vl-msg-p) on any error.") (new-trace vl-hidtrace-p "On success, a nonempty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final item and scopestack.") (tail vl-hidexpr-p "Remainder of @('x') after arriving at the declaration.")) :long "<p>See @(see vl-follow-hidexpr) for detailed discussion. This @('-aux') function does most of the work, but for instance it doesn't deal with top-level hierarchical identifiers.</p>" :measure (vl-hidexpr-count x) :prepwork ((local (defthm vl-scope-p-when-vl-module-p-strong (implies (or (vl-module-p x) (vl-interface-p x)) (vl-scope-p x)))) (local (in-theory (disable double-containment tag-reasoning))) (local (defthm vl-maybe-expr-p-of-car-exprlist (implies (vl-exprlist-p x) (vl-maybe-expr-p (car x)))))) :hooks ((:fix :hints(("Goal" :expand ((:free (trace ss strictp) (vl-follow-hidexpr-aux x trace ss :strictp strictp)) (:free (trace ss strictp) (vl-follow-hidexpr-aux (vl-expr-fix x) trace ss :strictp strictp))))))) (b* ((trace (vl-hidtrace-fix trace)) (x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error (vmsg "$root is not yet supported") ss) trace x)) ((mv item item-ss) (vl-scopestack-find-item/ss name1 ss)) ((unless item) (mv (vl-follow-hidexpr-error (vmsg "item not found") ss) trace x)) ((when (or (eq (tag item) :vl-vardecl) (eq (tag item) :vl-paramdecl))) ;; Found the declaration we want. We aren't going to go any further: ;; there may be additional HID indexing stuff left, but if so it's just ;; array or structure indexing for the tail. (b* ((trace (cons (make-vl-hidstep :name name1 :item item ;; No indices -- they belong to ;; the variable :ss item-ss) trace))) (mv nil trace x))) ;; From here on out, if the trace is good and the index exists, the ;; trace includes that index. (trace (cons (make-vl-hidstep :name name1 :item item :index (car indices) :ss item-ss) trace)) ((when (or (eq (tag item) :vl-fundecl) (eq (tag item) :vl-taskdecl))) (if (eq kind :end) ;; Plain reference to, e.g., foo.bar.myfun. This is OK -- you ;; might be writing something like ``logic foo = submod.fn(arg)'' (mv nil trace x) ;; Indexed or dotted reference like foo.bar.myfun[3] or ;; foo.bar.myfun[3].baz or foo.bar.myfun.baz, none of which seem to ;; really be reasonable as things to refer to hierarchically. (mv (vl-follow-hidexpr-error (vmsg (if (eq (tag item) :vl-fundecl) "hierarchical reference into function" "hierarchical reference into task")) item-ss) trace x))) ((when (eq (tag item) :vl-modinst)) (b* (((vl-modinst item)) (dims (and item.range (list (vl-range->packeddimension item.range)))) ;; Start by checking for sensible array indexing. (err (vl-follow-hidexpr-dimscheck name1 indices dims :strictp strictp)) ((when err) (mv (vl-follow-hidexpr-error err item-ss) trace x)) ((when (eq kind :end)) ;; Reference to foo.bar.myinst with no more indexing into myinst. ;; This might not make a lot of sense for a module instance, but ;; it probably *does* make sense for an interface instance. It ;; seems reasonable to just say this is OK and let the caller ;; figure out what to do with the module instance. (mv nil trace x)) ;; Else we're indexing through the instance. We need to go look ;; up the submodule and recur. ((mv mod mod-ss) (vl-scopestack-find-definition/ss item.modname item-ss)) ((unless mod) (mv (vl-follow-hidexpr-error (vmsg "reference through missing module ~s0" item.modname) item-ss) trace x)) (modtag (tag mod)) ((when (eq modtag :vl-udp)) (mv (vl-follow-hidexpr-error (vmsg "reference through primitive ~s0" item.modname) item-ss) trace x)) ((unless (or (eq modtag :vl-module) (eq modtag :vl-interface))) (mv (vl-follow-hidexpr-error (vmsg "module instance ~s0 of ~s1: invalid type ~x2???" name1 item.modname modtag) item-ss) trace x)) (next-ss ;; The MOD-SS is just the scopestack for where the module is ;; defined, which in practice will be the top level scope. ;; The next part of the HID needs to be looked up from within ;; MOD, so we need to actually go into the module. (vl-scopestack-push mod mod-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-interfaceport)) (b* (((vl-interfaceport item)) ((when (or (consp indices) (consp item.udims))) ;; BOZO. What kind of index checking do we want to do? Probably ;; it is ok to index only partly into an interface port, because ;; if it's okay to have an array of interfaces coming in, then ;; it's probably ok to stick an array of interfaces into a ;; submodule, etc. So maybe we need to just check that we have ;; no more indices than are allowed, and then check ranges on any ;; indices that we do happen to have... (mv (vl-follow-hidexpr-error "BOZO implement support for interface arrays." item-ss) trace x)) ((when (eq kind :end)) ;; Stopping at this interface port. Unlike module instances, ;; this seems OK. The interface port itself acts like a ;; variable. (mv nil trace x)) ((mv iface iface-ss) (vl-scopestack-find-definition/ss item.ifname item-ss)) ((unless iface) (mv (vl-follow-hidexpr-error (vmsg "reference through missing interface ~s0" item.ifname) item-ss) trace x)) (iftag (tag iface)) ((unless (eq iftag :vl-interface)) (mv (vl-follow-hidexpr-error (vmsg "interface port ~s0 of interface ~s1: invalid type ~x2???" name1 item.ifname iftag) item-ss) trace x)) (next-ss (vl-scopestack-push iface iface-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genblock)) (b* (((when (consp indices)) ;; Doesn't make any sense: this is a single, named generate ;; block, not an array, so we shouldn't try to index into it. (mv (vl-follow-hidexpr-error "array indices on reference to generate block" item-ss) trace x)) ((when (eq kind :end)) ;; Doesn't make any sense: referring to foo.bar.myblock all by ;; itself. (mv (vl-follow-hidexpr-error "reference to generate block" item-ss) trace x)) ;; Else we have something like foo.bar.myblock.mywire or whatever. ;; This is fine, we just need to go into the generate block. (genblob (vl-sort-genelements (vl-genblock->elems item) :scopetype :vl-genblock :name (vl-genblock->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-genarray)) (b* (((when (eq kind :end)) ;; Doesn't make any sense. Either this is a raw reference to the ;; array like foo.bar.mygenarray, or is an indexed reference to ;; something like foo.bar.mygenarray[3], but in either case it ;; would be referring to a whole generate block or to an array of ;; generate blocks, not something inside those blocks. (mv (vl-follow-hidexpr-error "reference to generate array" item-ss) trace x)) ((unless (consp indices)) ;; Something like foo.bar.mygenarray.baz, but mygenarray is an ;; array so this doesn't make any sense. (mv (vl-follow-hidexpr-error "reference through generate array must have an array index" item-ss) trace x)) ((unless (atom (rest indices))) ;; Something like foo.bar.mygenarray[3][4].baz, but we should ;; only ever have single-dimensional generate arrays, right? (mv (vl-follow-hidexpr-error "too many indices through generate array" item-ss) trace x)) (index-expr (first indices)) ((unless (vl-expr-resolved-p index-expr)) ;; Something like foo.bar.mygenarray[width-1].baz. We tolerate ;; this in the case of module instances, but for generates it is ;; not safe because we could have something like: ;; ;; genvar i; ;; for(i = 1; i < 10; ++i) begin : mygenarray ;; wire [i-1:0] baz; ;; ... ;; end ;; ;; in which case the actual declaration of baz depends on the ;; particular block of the generate that we happen to be in. (mv (vl-follow-hidexpr-error "unresolved index into generate array" item-ss) trace x)) (blocknum (vl-resolved->val index-expr)) (block (vl-genarrayblocklist-find-block blocknum (vl-genarray->blocks item))) ((unless block) ;; Something like foo.bar.mygenarray[8].baz when the array only ;; goes from 3:7 or whatever. (mv (vl-follow-hidexpr-error (vmsg "invalid index into generate array: ~x0" blocknum) item-ss) trace x)) (genblob (vl-sort-genelements (vl-genarrayblock->elems block) :scopetype :vl-genarrayblock :name (vl-genarray->name item))) (next-ss (vl-scopestack-push genblob item-ss))) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp))) ((when (eq (tag item) :vl-typedef)) (b* (((when (eq kind :end)) ;; This seems ok; we might refer to a type by name in a few ;; places. It may or may not be ok to refer to foo.bar_t, but ;; it's definitely ok to refer to foopkg::bar_t. (mv nil trace x))) ;; I don't think this makes sense? Can you refer to a type name? BOZO ;; maybe this makes sense for things like $bits(mystruct_t.foo) or ;; something like that? If so it may still be that we don't want to ;; deal with this in the aux function, but rather it should be ;; something that the top-level wrapper deals with. (mv (vl-follow-hidexpr-error "hierarchical reference through typedef" item-ss) trace x))) ((when (or (eq (tag item) :vl-genif) (eq (tag item) :vl-gencase) (eq (tag item) :vl-genloop) (eq (tag item) :vl-genbase))) ;; I don't think any of these are supposed to have names and, ;; accordingly, it shouldn't make sense to have looked one up. (mv (vl-follow-hidexpr-error (vmsg "hierarchical reference to ~x0" (tag item)) item-ss) trace x)) ((when (eq (tag item) :vl-gateinst)) ;; Since gate instances are "opaque" there is clearly no way we can go ;; through a gate instance. Moreover, we don't think a gate instance ;; could be meaningfully addressed in any other way. So, we just ;; regard any reference to a gate as invalid. (mv (vl-follow-hidexpr-error "hierarchical reference to gate instance" item-ss) trace x))) (mv (impossible) trace x)) /// (more-returns (new-trace (implies (or (consp trace) (not err)) (consp new-trace)) :name consp-of-vl-follow-hidexpr-aux.new-trace)) (defret vl-follow-hidexpr-no-index-on-first (implies (not err) (not (vl-hidstep->index (car new-trace))))) (defthm context-irrelevance-of-vl-follow-hidexpr-aux (implies (syntaxp (not (equal origx (list 'quote (with-guard-checking :none (vl-scopeexpr-fix nil)))))) (b* (((mv err1 trace1 tail1) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)) ((mv err2 trace2 tail2) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx (vl-scopeexpr-fix nil)))) (and (equal trace1 trace2) (equal tail1 tail2) (iff err1 err2)))) :hints ((acl2::just-induct-and-expand (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx) :expand-others ((:free (ctx strictp origx) (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (defret count-of-vl-follow-hidexpr-aux.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr-aux (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p) :induct (vl-follow-hidexpr-aux x trace ss :strictp strictp :origx origx)))))) (deftagsum vl-scopecontext (:local ((levels natp :rule-classes :type-prescription "How many levels up from the current scope was the item found"))) (:root ()) (:package ((pkg vl-package-p))) (:module ((mod vl-module-p)))) (deftagsum vl-select (:field ((name stringp "The name of the field we're selecting"))) (:index ((val vl-expr-p "The index we're selecting")))) (defprod vl-selstep ((select vl-select-p "The field or index being selected") (type vl-datatype-p "The datatype of the element we've selected") (caveat "Signedness caveat for this indexing operation. Signals a disagreement between implementations on the signedness of the result. See @(see vl-datatype-remove-dim). Only important if this is the outermost selstep.") ;; (ss vl-scopestack-p "The scopestack in which the datatype was declared or ;; typedef'd") )) (fty::deflist vl-seltrace :elt-type vl-selstep :elementp-of-nil nil) (define vl-seltrace-index-count ((x vl-seltrace-p)) :returns (count natp :rule-classes :type-prescription) (if (atom x) 0 (+ (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field 0 :index 1)) (vl-seltrace-index-count (cdr x))))) (define vl-seltrace->indices ((x vl-seltrace-p)) :returns (indices vl-exprlist-p) (if (atom x) nil (b* (((vl-selstep x1) (car x))) (vl-select-case x1.select :field (vl-seltrace->indices (cdr x)) :index (cons x1.select.val (vl-seltrace->indices (cdr x)))))) /// (defret len-of-vl-seltrace->indices (equal (len indices) (vl-seltrace-index-count x)) :hints(("Goal" :in-theory (enable vl-seltrace-index-count)))) (defthm vl-seltrace-indices-of-append (equal (vl-seltrace->indices (append x y)) (append (vl-seltrace->indices x) (vl-seltrace->indices y)))) (defthm vl-seltrace-indices-of-rev (equal (vl-seltrace->indices (rev x)) (rev (vl-seltrace->indices x))))) (defprod vl-operandinfo ((context vl-scopecontext-p "The context in which the HID base was found") (prefixname vl-scopeexpr-p "The scopeexpr, not including the possible data selects.") (hidtrace vl-hidtrace-p "The follow-hids trace, i.e. the trace of instances/blocks in which the base variable is located") (hidtype vl-datatype-p "The datatype of the final element of the hidtrace.") (seltrace vl-seltrace-p "The select trace, i.e. the types/scopestacks of all the fields/indices we've selected into") (part vl-partselect-p "The final partselect") (type vl-datatype-p "The final datatype of the object, after partselecting."))) (local (defthm nesting-level-of-vl-scopestack-find-item/context (<= (vl-scopestack-nesting-level (mv-nth 1 (vl-scopestack-find-item/context name ss))) (vl-scopestack-nesting-level ss)) :hints(("Goal" :in-theory (enable vl-scopestack-find-item/context vl-scopestack-nesting-level))) :rule-classes :linear)) (define vl-follow-hidexpr :short "Follow a HID to find the associated declaration." ((x vl-hidexpr-p "Hierarchical identifier to follow.") (ss vl-scopestack-p "Scopestack where the HID originates.") &key ((origx vl-scopeexpr-p "Original version of X, for better error messages.") 'origx) (strictp booleanp "Require all array indices and bounds to be resolved?")) :guard-debug t :returns (mv (err (iff (vl-msg-p err) err) "A message on any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext object describing where this hid is rooted.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) :long "<p>Prerequisite: see @(see following-hids) for considerable discussion about the goals and design of this function.</p> <p>This is our top-level routine for following hierarchical identifiers. It understands how to resolve both top-level hierarchical identifiers like @('topmodule.foo.bar') and downward identifiers like @('submodname.foo.bar').</p> <p>We try to follow @('x'), which must be a proper @(see vl-hidexpr-p), to whatever @(see vl-scopeitem) it refers to. This can fail for many reasons, e.g., any piece of @('x') might refer to a name that doesn't exist, might have inappropriate array indices, etc. In case of failure, @('err') is a good @(see vl-msg-p) and the other results are <b>not sensible</b> and should not be relied on.</p> <h5>Trace</h5> <p>We return a @(see vl-hidtrace-p) that records, in ``backwards'' order, the steps that we took to resolve @('x'). That is: if we are resolving @('foo.bar.baz'), then the first step in the trace will be the declaration for @('baz'), and the last step in the trace will be the lookup for @('foo'). In other words, the first step in the trace corresponds to the ``final'' declaration that @('x') refers to. Many applications won't care about the rest of the trace beyond its first step. However, the rest of the trace may be useful if you are trying to deal with, e.g., all of the interfaces along the hierarchical identifier.</p> <h5>Tail</h5> <p>The trace we return stops at variable declarations. This may be confusing because, in Verilog, the same @('.') syntax is used to index through the module hierarchy and to index through structures. To make this concrete, suppose we have something like:</p> @({ typedef struct { logic fastMode; ...; } opcode_t; typedef struct { opcode_t opcode; ... } instruction_t; module bar (...) ; instruction_t instruction1; ... endmodule module foo (...) ; bar mybar(...) ; ... endmodule module main (...) ; foo myfoo(...) ; ... $display(\"fastMode is %b\", myfoo.mybar.instruction1.opcode.fastMode); endmodule }) <p>When we follow @('myfoo.mybar.instruction1.opcode.fastMode'), our trace will <b>only go to @('instruction1')</b>, because the @('.opcode.fastMode') part is structure indexing, not scope indexing.</p> <p>To account for this, we return not only the @('trace') but also the @('tail') of the hierarchical identifier that remains where we stop. For instance, in this case the @('tail') would be @('instruction1.opcode.fastMode').</p>" (b* ((x (vl-hidexpr-fix x)) ((mv name1 indices rest kind) (vl-hidexpr-case x :end (mv x.name nil nil :end) :dot (b* (((vl-hidindex x.first))) (mv x.first.name x.first.indices x.rest :dot)))) (trace nil) ((when (eq name1 :vl-$root)) (mv (vl-follow-hidexpr-error "$root isn't supported yet" ss) trace nil x)) ((mv item ctx-ss pkg-name) (vl-scopestack-find-item/context name1 ss)) ((when item) (b* (((mv err trace tail) (vl-follow-hidexpr-aux x nil ss :strictp strictp)) ((when err) (mv err trace nil tail)) ((mv err context) (cond (pkg-name (b* ((pkg (vl-scopestack-find-package pkg-name ss)) ((unless pkg) (mv (vmsg "Programming error: found item in ~ package ~s0 but couldn't find package" pkg-name) nil))) (mv nil (make-vl-scopecontext-package :pkg pkg)))) ((vl-scopestack-case ctx-ss :global) (mv nil (make-vl-scopecontext-root))) (t (mv nil (make-vl-scopecontext-local :levels (- (vl-scopestack-nesting-level ss) (vl-scopestack-nesting-level ctx-ss)))))))) (mv err trace context tail))) ((when (eq kind :end)) ;; Item was not found AND it is not of the form foo.bar, so we do NOT ;; want to interpret it as any sort of reference to a top-level module. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Otherwise, might be a valid reference into a top-level module? (design (vl-scopestack->design ss)) ((unless design) ;; We must be using a phony scopestack. We have no way of knowing what ;; the top-level modules are so we have no idea if this is valid. (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) (mods (vl-design->mods design)) (toplevel (vl-modulelist-toplevel mods)) ((unless (member-equal name1 toplevel)) (mv (vl-follow-hidexpr-error "item not found" ss) trace nil x)) ;; Successfully found a top-level module with the first index name. ((when (consp indices)) ;; Something like topmod[3].foo.bar, doesn't make any sense. (mv (vl-follow-hidexpr-error "array indices into top level module" ss) trace nil x)) (mod (vl-find-module name1 mods)) (mod-ss (vl-scopestack-init design)) ;; BOZO how should the fact that we have followed a top-level hierarchical ;; identifier present itself in the trace? We would like to perhaps add a ;; trace step along the lines of: ;; ;; (cons (make-vl-hidstep :item mod :ss mod-ss) trace) ;; ;; But that is not possible because the ITEM for a trace needs to be a ;; scopeitem, and a module is not a scopeitem. ;; ;; We might eventually want to extend the notion of traces to be able to ;; record this sort of thing. For now, out of sheer pragmatism, I think ;; it seems pretty reasonable to just not bother to record the first ;; step. (next-ss (vl-scopestack-push mod mod-ss)) ((mv err trace tail) (vl-follow-hidexpr-aux rest trace next-ss :strictp strictp)) (context (make-vl-scopecontext-module :mod mod))) (mv err trace context tail)) /// (defret consp-of-vl-follow-hidexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-hidexpr.tail (<= (vl-hidexpr-count tail) (vl-hidexpr-count x)) :rule-classes :linear) (local (defthm vl-hidname-stringp-when-not-$root (implies (vl-hidname-p x) (equal (equal x :vl-$root) (not (stringp x)))) :hints(("Goal" :in-theory (enable vl-hidname-p))))) (defret vl-subhid-p-of-vl-follow-hidexpr (implies (not err) (vl-subhid-p tail x)) :hints(("Goal" :in-theory (enable vl-subhid-p))))) (define vl-follow-scopeexpr :short "Follow a scope expression to find the associated declaration." ((x vl-scopeexpr-p "Scope expression to follow.") (ss vl-scopestack-p "Scopestack where the lookup originates.") &key (strictp booleanp "Require all array indices and bounds to be resolved?")) :returns (mv (err (iff (vl-msg-p err) err) "A message for any error.") (trace vl-hidtrace-p "On success: a non-empty trace that records all the items we went through to resolve this HID. The @(see car) of the trace is the final declaration for this HID.") (context (implies (not err) (vl-scopecontext-p context)) "On success, a scopecontext showing where the hid is found.") (tail vl-hidexpr-p "On success: the remainder of @('x') after arriving at the declaration. This may include array indexing or structure indexing.")) (vl-scopeexpr-case x :end (vl-follow-hidexpr x.hid ss :strictp strictp :origx x) :colon (b* ((x (vl-scopeexpr-fix x)) ((unless (stringp x.first)) (mv (vmsg "~a0: The scope modifier '~x1' is not yet supported." x (case x.first (:vl-local "local") (:vl-$unit "$unit") (otherwise "??UNKNOWN??"))) nil nil (vl-scopeexpr->hid x))) ((mv package pkg-ss) (vl-scopestack-find-package/ss x.first ss)) ((unless package) (mv (vmsg "~a0: Package ~s1 not found.." x x.first) nil nil (vl-scopeexpr->hid x))) (pkg-ss (vl-scopestack-push package pkg-ss)) ((unless (vl-scopeexpr-case x.rest :end)) (mv (vmsg "~a0: Multiple levels of :: operators are ~ not yet supported." x) nil nil (vl-scopeexpr->hid x))) ((mv err trace context tail) (vl-follow-hidexpr (vl-scopeexpr-end->hid x.rest) pkg-ss :strictp strictp :origx x)) ((when err) (mv err trace context tail)) ((unless (vl-scopecontext-case context :local)) (mv nil trace context tail))) (mv nil trace (make-vl-scopecontext-package :pkg package) tail))) /// (defret consp-of-vl-follow-scopeexpr.trace (implies (not err) (consp trace))) (defret count-of-vl-follow-scopeexpr.tail (< (vl-hidexpr-count tail) (vl-scopeexpr-count x)) :rule-classes :linear) (defret vl-subhid-p-of-vl-follow-scopeexpr (implies (not err) (vl-subhid-p tail (vl-scopeexpr->hid x))) :hints(("Goal" :in-theory (enable vl-scopeexpr->hid))))) ;; ------ (defxdoc datatype-tools :parents (mlib) :short "Functions for working with datatypes.") (local (xdoc::set-default-parents datatype-tools)) (defines vl-datatype-resolved-p (define vl-datatype-resolved-p ((x vl-datatype-p)) :measure (vl-datatype-count x) (vl-datatype-case x :vl-coretype t :vl-struct (vl-structmemberlist-resolved-p x.members) :vl-union (vl-structmemberlist-resolved-p x.members) :vl-enum (vl-datatype-resolved-p x.basetype) :vl-usertype (and x.res (vl-datatype-resolved-p x.res)))) (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p)) :measure (vl-structmemberlist-count x) (if (atom x) t (and (vl-datatype-resolved-p (vl-structmember->type (car x))) (vl-structmemberlist-resolved-p (cdr x))))) /// (deffixequiv-mutual vl-datatype-resolved-p) (defthm vl-datatype-resolved-p-of-make-coretype (vl-datatype-resolved-p (vl-coretype name signedp pdims udims))) (defthm vl-datatype-resolved-p-of-make-struct (equal (vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("goal" :expand ((vl-datatype-resolved-p (vl-struct packedp signedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-union (equal (vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)) (vl-structmemberlist-resolved-p members)) :hints (("Goal" :expand ((vl-datatype-resolved-p (vl-union packedp signedp taggedp members pdims udims)))))) (defthm vl-datatype-resolved-p-of-make-enum (equal (vl-datatype-resolved-p (vl-enum basetype items pdims udims)) (vl-datatype-resolved-p basetype)) :hints (("goal" :expand (vl-datatype-resolved-p (vl-enum basetype items pdims udims))))) (defthm vl-datatype-resolved-p-of-make-usertype (equal (vl-datatype-resolved-p (vl-usertype name res pdims udims)) (and res (vl-datatype-resolved-p res))) :hints (("Goal" :expand (vl-datatype-resolved-p (vl-usertype name res pdims udims))))) (defthm vl-structmemberlist-resolved-p-of-struct-members (implies (and (vl-datatype-case x :vl-struct) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-struct->members x)))) (defthm vl-structmemberlist-resolved-p-of-union-members (implies (and (vl-datatype-case x :vl-union) (vl-datatype-resolved-p x)) (vl-structmemberlist-resolved-p (vl-union->members x)))) (defthm vl-datatype-resolved-p-of-enum-basetype (implies (and (vl-datatype-case x :vl-enum) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p (vl-enum->basetype x)))) (defthm vl-datatype-resolved-p-of-usertype-basetype (implies (and (vl-datatype-case x :vl-usertype) (vl-datatype-resolved-p x)) (and (vl-datatype-resolved-p (vl-usertype->res x)) (vl-usertype->res x)))) (defthm vl-structmemberlist-resolved-p-of-cons (equal (vl-structmemberlist-resolved-p (cons a b)) (and (vl-datatype-resolved-p (vl-structmember->type a)) (vl-structmemberlist-resolved-p b)))) (defthm vl-datatype-resolved-p-of-car-structmember-type (implies (vl-structmemberlist-resolved-p x) (vl-datatype-resolved-p (vl-structmember->type (car x))))) (defthm vl-structmemberlist-resolved-p-of-cdr (implies (vl-structmemberlist-resolved-p x) (vl-structmemberlist-resolved-p (cdr x)))) (defthm vl-datatype-resolved-p-of-update-dims (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p (vl-datatype-update-dims pdims udims x))) :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) (fty::defalist vl-typeoverride :key-type vl-scopeexpr :val-type vl-datatype :short "Alist mapping names to datatypes, used to store resolutions of parameter types that have been computed but not yet put in the design." :long "<p>The names may be of various different kinds of objects, meaning slightly different things:</p> <ul> <li>A value parameter name maps to the type of the parameter value</li> <li>A type parameter name maps to the resolved type that is that parameter's value</li> <li>A typedef name maps to the resolved type</li> <li>A function name maps to the resolved return type of the function.</li> </ul>") (defines vl-datatype-usertype-resolve (define vl-datatype-usertype-resolve ((x vl-datatype-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :verify-guards nil :measure (two-nats-measure rec-limit (vl-datatype-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-datatype-p)) (b* ((x (vl-datatype-fix x))) (vl-datatype-case x :vl-coretype (mv nil x) :vl-struct (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-struct x :members members))) :vl-union (b* (((mv err members) (vl-structmemberlist-usertype-resolve x.members ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-union x :members members))) :vl-enum (b* (((mv err basetype) (vl-datatype-usertype-resolve x.basetype ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-enum x :basetype basetype))) :vl-usertype (b* (((when (and x.res (vl-datatype-resolved-p x.res))) (mv nil x)) ((mv err def) (vl-usertype-lookup x.name ss :typeov typeov :rec-limit rec-limit))) (mv err (change-vl-usertype x :res def)))))) (define vl-structmemberlist-usertype-resolve ((x vl-structmemberlist-p) (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) :returns (mv (err (iff (vl-msg-p err) err)) (new-x vl-structmemberlist-p)) (b* (((when (atom x)) (mv nil nil)) ((mv err1 type1) (vl-datatype-usertype-resolve (vl-structmember->type (car x)) ss :typeov typeov :rec-limit rec-limit)) ((mv err2 rest) (vl-structmemberlist-usertype-resolve (cdr x) ss :typeov typeov :rec-limit rec-limit))) (mv (or err1 err2) (cons (change-vl-structmember (car x) :type type1) rest)))) (define vl-usertype-lookup ((x vl-scopeexpr-p "The usertype name to look up") (ss vl-scopestack-p) &key ((typeov vl-typeoverride-p) 'nil) ((rec-limit natp) '1000)) :short "Looks up a usertype name and returns its definition if successful." :measure (two-nats-measure rec-limit 0) :returns (mv (err (iff (vl-msg-p err) err) "Error message if unsuccessful") (type (and (vl-maybe-datatype-p type) (implies (not err) (vl-datatype-p type))) "Fully resolved type, if successful")) (b* ((x (vl-scopeexpr-fix x)) (typeov (vl-typeoverride-fix typeov)) (hid (vl-scopeexpr->hid x)) ;; BOZO Maybe we should use a different type than scopeexpr for a usertype name ((unless (vl-hidexpr-case hid :end)) (mv (vmsg "Type names cannot be specified with dotted ~ paths, only package scopes: ~a1" nil x) nil)) (look (hons-get x typeov)) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: unresolved override type") nil))) ((mv err trace ?context ?tail) (vl-follow-scopeexpr x ss)) ((when err) (mv err nil)) ((vl-hidstep ref) (car trace)) ((when (eq (tag ref.item) :vl-typedef)) (b* (((vl-typedef item) ref.item) ((when (zp rec-limit)) (mv (vmsg "Recursion limit ran out looking up ~ usertype ~a0" x) nil))) (vl-datatype-usertype-resolve item.type ref.ss :typeov nil ;; different scope! :rec-limit (1- rec-limit)))) ((when (eq (tag ref.item) :vl-paramdecl)) (b* (((vl-paramdecl item) ref.item)) (vl-paramtype-case item.type :vl-typeparam (if (and item.type.default (vl-datatype-resolved-p item.type.default)) (mv nil item.type.default) (mv (vmsg "Reference to unresolved type parameter ~a0" item) nil)) :otherwise (mv (vmsg "Reference to data parameter ~a0 as type" item) nil))))) (mv (vmsg "Didn't find a typedef ~a1, instead found ~a2" nil x ref.item) nil))) /// (verify-guards vl-datatype-usertype-resolve-fn) (defthm vl-datatype-usertype-resolve-nonnil (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit)) :hints (("goal" :use ((:instance (:theorem (implies (not x) (not (vl-datatype-p x)))) (x (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) :in-theory (disable vl-datatype-usertype-resolve))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))))) (defthm vl-usertype-lookup-nonnil (b* (((mv err res) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) res)) :hints (("goal" :use ((:instance return-type-of-vl-usertype-lookup-fn.type)) :in-theory (disable return-type-of-vl-usertype-lookup-fn.type))) :rule-classes ((:type-prescription :typed-term (mv-nth 1 (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))))) (defthm-vl-datatype-usertype-resolve-flag (defthm vl-datatype-resolved-p-of-vl-datatype-usertype-resolve (b* (((mv err new-x) (vl-datatype-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p new-x))) :hints('(:expand ((vl-datatype-resolved-p x)))) :flag vl-datatype-usertype-resolve) (defthm vl-structmemberlist-resolved-p-of-vl-structmemberlist-usertype-resolve (b* (((mv err new-x) (vl-structmemberlist-usertype-resolve x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-structmemberlist-resolved-p new-x))) ;; :hints('(:in-theory (enable vl-structmemberlist-resolved-p))) :flag vl-structmemberlist-usertype-resolve) (defthm vl-datatype-resolved-p-of-vl-usertype-lookup (b* (((mv err type) (vl-usertype-lookup x ss :typeov typeov :rec-limit rec-limit))) (implies (not err) (vl-datatype-resolved-p type))) :flag vl-usertype-lookup)) (deffixequiv-mutual vl-datatype-usertype-resolve)) ;; (define vl-usertype-resolve ((x vl-scopeexpr-p "The usertype name to look up") ;; (ss vl-scopestack-p) ;; &key ((rec-limit natp) '1000)) ;; :short "Looks up a usertype name recursively, stopping and and returning its ;; definition when it is a non-usertype or has dimensions." ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Error message if unsuccessful") ;; (type (iff (vl-datatype-p type) (not err)) ;; "Resolved type, if successful") ;; (scope vl-scopestack-p ;; "Scopestack for the context in which the type was defined ;; (only sensible if successful)")) ;; :measure (nfix rec-limit) ;; (b* (((mv err def new-ss) ;; (vl-usertype-lookup x ss)) ;; ((when err) (mv err def new-ss)) ;; ((unless (vl-datatype-case def :vl-usertype)) ;; (mv nil def new-ss)) ;; ((vl-usertype def)) ;; ((when (or (consp def.pdims) (consp def.udims))) ;; (mv nil def new-ss)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out looking up usertype ~a0" def) nil new-ss))) ;; (vl-usertype-resolve def.name new-ss :rec-limit (1- rec-limit))) ;; /// ;; (defret vl-usertype-resolve-result-has-dims ;; (implies (and (not err) ;; (vl-datatype-case type :vl-usertype) ;; (not (consp (vl-datatype->udims type)))) ;; (consp (vl-datatype->pdims type))))) ;; (define vl-usertype-resolve ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; (rec-limit natp)) ;; :guard (vl-datatype-case x :vl-usertype) ;; :short "Resolves a datatype of usertype kind to a concrete ;; datatype, i.e. anything but a user typename." ;; :long "<p>The input is guarded to be a usertype. If it is defined as another ;; usertype (possibly with packed/unpacked dimensions), then we recur until it is ;; defined as something other than a usertype. However, the final type may still ;; have usertypes within it, i.e. as struct/union member types.</p> ;; <p>Also returns the scopestack representing the scope in which the ;; final type declaration was found.</p> ;; <p>This function is strict with respect to packed vs. unpacked dimensions; ;; i.e., if a usertype is defined as having unpacked dimensions, it will warn if ;; any packed dimensions are applied to that type. Arguably this check should be ;; done elsewhere, in which case this function could ignore the distinction ;; between packed and unpacked dimensions. However, it is important to preserve ;; the order of dimensions, and it's not clear how to handle cases that mix the ;; two: packed dimensions are always treated as \"inner\" or \"most rapidly ;; varying\" dimensions. So if we have (illegal) nested typedefs that place ;; unpacked dimensions inside of packed dimensions, we have no way to express that ;; as a single, usertype-free datatype, unless we change some packed dimensions ;; into unpacked ones or vice versa:</p> ;; @({ ;; typedef logic t1 [5:1]; // unpacked dimension ;; typedef t1 [3:0] t2; // packed dimension applied to unpacked datatype ;; typedef logic [3:0] t3 [5:1]; // not the same as t2 ;; typedef logic [5:1] [3:0] t4; // same dimensions as t2, but all dimensions packed ;; typedef logic t5 [5:1] [3:0]; // same dimensions as t2, but all dimensions unpacked ;; }) ;; <p>We don't have this problem for the (also illegal) case where packed ;; dimensions are applied to an unpacked structure or union, so we don't warn in ;; this case; this should be checked separately.</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p) ;; (scope vl-scopestack-p)) ;; :measure (nfix rec-limit) ;; :verify-guards nil ;; (b* ((ss (vl-scopestack-fix ss)) ;; (x (vl-datatype-fix x)) ;; ((vl-usertype x)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Rec-limit ran out: recursively defined ~ ;; datatype? ~a1" ;; nil x.name) ;; x ss)) ;; ((unless (vl-hidexpr-case (vl-scopeexpr->hid x.name) :end)) ;; (mv (vmsg "Type names cannot be specified with dotted ~ ;; paths, only package scopes: ~a1" ;; nil x.name) ;; x ss)) ;; ((mv err trace ?tail) ;; (vl-follow-scopeexpr x.name ss)) ;; ((when err) ;; (mv err x ss)) ;; ((vl-hidstep ref) (car trace)) ;; ((unless (eq (tag ref.item) :vl-typedef)) ;; (mv (vmsg "Didn't find a typedef ~a1, instead ~ ;; found ~a2" ;; nil x.name ref.item) ;; x ss)) ;; ((vl-typedef item) ref.item) ;; ((mv warning subtype final-ss) ;; (if (vl-datatype-case item.type :vl-usertype) ;; (vl-usertype-resolve item.type ref.ss (1- rec-limit)) ;; (mv nil item.type ref.ss))) ;; ((when warning) ;; (mv warning x ss)) ;; (sub-udims (vl-datatype->udims subtype)) ;; ((when (and (consp x.pdims) (consp (vl-datatype->udims item.type)))) ;; ;; Bad case: we have unpacked dimensions from the inner call but ;; ;; we're trying to add packed ones. Warn and return x. ;; (mv (vmsg "Usertype ~a1 was declared with packed ~ ;; dimensions, but its definition ~a2 already ~ ;; has unpacked dimensions." ;; x item.type) ;; x ss)) ;; (subtype (mbe :logic (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; :exec ;; (if (or x.udims x.pdims) ;; (vl-datatype-update-dims ;; (append-without-guard x.pdims (vl-datatype->pdims subtype)) ;; (append-without-guard x.udims sub-udims) ;; subtype) ;; subtype)))) ;; (mv nil subtype final-ss)) ;; /// ;; (verify-guards vl-usertype-resolve)) ;; (defines vl-datatype-usertype-elim ;; :verify-guards nil ;; (define vl-datatype-usertype-elim ((x vl-datatype-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) '1000)) ;; :measure (two-nats-measure rec-limit (vl-datatype-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type vl-datatype-p)) ;; :prepwork ((local (in-theory (disable nfix)))) ;; :short "Resolves all usertypes within a datatype, recursively." ;; :long "<p>A recursion limit is needed in case a usertype is defined in ;; terms of itself.</p> ;; <p>Always returns a datatype; however, when a warning is present, it may still ;; contain usertypes.</p> ;; <p>An example to work through: suppose we want to resolve the usertype memchunk ;; into a usertype-free datatype --</p> ;; @({ ;; typedef logic [3:0] mynibble; ;; typedef mynibble [7:0] my32; ;; typedef my32 [0:3] membank [63:0]; ;; // error: since membank now has unpacked dims, we can't give it more packed dims: ;; // typedef membank [3:0] memchunk; ;; // this works: ;; typedef membank memchunk [3:0]; ;; })" ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; :vl-coretype (mv nil x) ;; :vl-enum (mv nil x) ;; bozo ;; :vl-usertype ;; (b* (((mv warning newx newss) (vl-usertype-resolve x ss)) ;; ((when warning) (mv warning newx)) ;; ((when (zp rec-limit)) ;; (mv (vmsg "Recursion limit ran out: ~a1" ;; nil x.name) ;; newx))) ;; (vl-datatype-usertype-elim newx newss :rec-limit (1- rec-limit))) ;; :vl-struct ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-struct x :members members))) ;; (mv warning newx)) ;; :vl-union ;; (b* (((mv warning members) (vl-structmembers-usertype-elim x.members ss)) ;; (newx (change-vl-union x :members members))) ;; (mv warning newx))))) ;; (define vl-structmembers-usertype-elim ((x vl-structmemberlist-p) ;; (ss vl-scopestack-p) ;; &key ;; ((rec-limit natp) 'rec-limit)) ;; :measure (two-nats-measure rec-limit (vl-structmemberlist-count x)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (newx vl-structmemberlist-p)) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((mv warning type1) (vl-datatype-usertype-elim ;; (vl-structmember->type (car x)) ss ;; rec-limit)) ;; (first (change-vl-structmember (car x) :type type1)) ;; ((when warning) (mv warning (cons first (vl-structmemberlist-fix (cdr x))))) ;; ((mv warning membs2) (vl-structmembers-usertype-elim (cdr x) ss rec-limit))) ;; (mv warning (cons first membs2)))) ;; /// ;; (deffixequiv-mutual vl-datatype-usertype-elim) ;; (verify-guards vl-datatype-usertype-elim)) (define vl-datatype->structmembers ((x vl-datatype-p)) :short "Finds the struct members of x when it is a struct or union." :returns (mv ok (members vl-structmemberlist-p)) (vl-datatype-case x :vl-struct (mv t x.members) :vl-union (mv t x.members) :otherwise (mv nil nil)) /// (defthm vl-structmemberlist-resolved-p-of-vl-datatype->structmembers (implies (vl-datatype-resolved-p x) (vl-structmemberlist-resolved-p (mv-nth 1 (vl-datatype->structmembers x)))) :hints(("Goal" :in-theory (enable vl-datatype->structmembers))))) (define vl-find-structmember ((name stringp) (membs vl-structmemberlist-p)) :returns (memb (iff (vl-structmember-p memb) memb)) (if (atom membs) nil (if (equal (string-fix name) (vl-structmember->name (car membs))) (vl-structmember-fix (car membs)) (vl-find-structmember name (cdr membs)))) /// (defthm vl-datatype-resolved-p-of-find-structmember (implies (and (vl-structmemberlist-resolved-p members) (vl-find-structmember name members)) (vl-datatype-resolved-p (vl-structmember->type (vl-find-structmember name members)))) :hints(("Goal" :in-theory (enable vl-structmemberlist-resolved-p))))) (define vl-packeddimensionlist-resolved-p ((x vl-packeddimensionlist-p)) :short "Returns true if all sized packed dimensions are resolved." (b* (((when (atom x)) t) (x1 (car x))) (and (vl-packeddimension-case x1 :unsized t :range (vl-range-resolved-p x1.range)) (vl-packeddimensionlist-resolved-p (cdr x))))) (define vl-packeddimensionlist-total-size ((x vl-packeddimensionlist-p)) :short "Given a packeddimensionlist like [5:0][3:1][0:8], multiplies the dimensions together to get the total number of bits, or returns nil if there are unsized dimensions." :guard (vl-packeddimensionlist-resolved-p x) :verify-guards nil :returns (size maybe-posp :rule-classes :type-prescription) (b* (((when (atom x)) 1) (rest (vl-packeddimensionlist-total-size (cdr x))) ((unless rest) nil) (first (car x)) ((when (vl-packeddimension-case first :unsized)) nil) (range (vl-packeddimension->range first))) (* (vl-range-size range) rest)) /// (verify-guards vl-packeddimensionlist-total-size :hints (("goal" :in-theory (enable vl-packeddimensionlist-resolved-p))))) (define vl-packeddimension-size ((x vl-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if (vl-packeddimension-case x :unsized) (mv nil nil) (b* ((range (vl-packeddimension->range x))) (if (vl-range-resolved-p range) (mv nil (vl-range-size range)) (mv t nil))))) (define vl-maybe-packeddimension-size ((x vl-maybe-packeddimension-p)) :returns (mv (unresolved-flg) (size maybe-posp :rule-classes :type-prescription)) (if x (vl-packeddimension-size x) (mv nil nil))) (fty::deflist maybe-nat-list :elt-type maybe-natp) (defines vl-datatype-size :prepwork ((local (in-theory (disable all-equalp stringp-when-true-listp default-*-1 integerp-when-natp natp-when-posp rationalp-implies-acl2-numberp acl2::member-when-atom acl2::posp-redefinition rationalp-when-integerp double-containment member-equal-when-member-equal-of-cdr-under-iff equal-of-cons-rewrite))) (std::set-returnspec-mrec-default-hints ((acl2::just-expand-mrec-default-hint 'std::fnname id nil world)))) (define vl-datatype-size ((x vl-datatype-p "The datatype to size")) :short "Computes the number of bits in the datatype." :long "<p>This works for unpacked datatypes as well as packed ones; you should check separately that the datatype is packed if that is what you want. Returns nil without error if given a datatype that has no fixed bit size, e.g. if it contains a real number or has unsized dimensions. We produce an error message if a usertype is not found, if the recursion limit runs out, or if unresolved dimensions are present.</p>" :measure (vl-datatype-count x) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err)) (size maybe-natp :rule-classes :type-prescription)) :verify-guards nil (b* ((x (vl-datatype-fix x)) (udims (vl-datatype->udims x)) (pdims (vl-datatype->pdims x)) ((unless (vl-packeddimensionlist-resolved-p udims)) (mv (vmsg "Unresolved unpacked dimensions: ~a0" (vl-datatype-update-dims nil (append-without-guard udims pdims) x)) nil)) ((unless (vl-packeddimensionlist-resolved-p pdims)) (mv (vmsg "Unresolved packed dimensions: ~a0" x) nil)) (udim-size (vl-packeddimensionlist-total-size udims)) (pdim-size (vl-packeddimensionlist-total-size pdims)) (dim-size (and udim-size pdim-size (* udim-size pdim-size)))) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.size dim-size (* typinfo.size dim-size))))) (:vl-struct (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (sum-nats widths) dim-size))))) (:vl-union (b* (((mv err widths) (vl-structmemberlist-sizes x.members)) ((when err) (mv err nil)) ((when (member nil widths)) (mv nil nil))) (mv nil (and dim-size (* (max-nats widths) dim-size))))) (:vl-enum (b* (((mv err sub-size) (vl-datatype-size x.basetype)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size))))) (:vl-usertype (b* (((unless (mbt (and x.res t))) (mv (vmsg "Usertype unresolved: ~a0" x) nil)) ((mv err sub-size) (vl-datatype-size x.res)) ((when (or err (not sub-size))) (mv err nil))) (mv nil (and dim-size (* sub-size dim-size)))))))) (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) :returns (mv (err (iff (vl-msg-p err) err)) (sizes maybe-nat-list-p)) :guard (vl-structmemberlist-resolved-p x) :measure (vl-structmemberlist-count x) (b* (((when (atom x)) (mv nil nil)) ((mv err1 size1) (vl-datatype-size (vl-structmember->type (car x)))) ((mv err2 size2) (vl-structmemberlist-sizes (cdr x)))) (mv (or err1 err2) (cons size1 size2))) /// (defret len-of-vl-structmemberlist-sizes (equal (len sizes) (len x)) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x))))) (defret true-listp-of-vl-structmemberlist-sizes (true-listp sizes) :hints (("goal" :induct (len x) :expand ((vl-structmemberlist-sizes x)))) :rule-classes :type-prescription)) /// (local (defthm nat-listp-when-maybe-nat-list-p (implies (and (maybe-nat-list-p x) (not (member nil x))) (nat-listp x)) :hints(("Goal" :in-theory (enable maybe-nat-list-p))))) (verify-guards vl-datatype-size) (deffixequiv-mutual vl-datatype-size)) (define vl-maybe-usertype-resolve ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :returns (new-x vl-datatype-p) :measure (vl-datatype-count x) (b* ((x (vl-datatype-fix x)) ((when (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)))) x)) (vl-datatype-case x :vl-usertype (if x.res (vl-maybe-usertype-resolve x.res) x) :otherwise x)) /// (defret vl-datatype-count-of-vl-maybe-usertype-resolve (<= (vl-datatype-count new-x) (vl-datatype-count x)) :rule-classes :linear) (defret vl-datatype-resolved-p-of-vl-maybe-usertype-resolve (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x))) (local (defret vl-maybe-usertype-resolve-nonnil new-x :rule-classes :type-prescription)) (defret not-usertype-of-vl-maybe-usertype-resolve (implies (and (not (consp (vl-datatype->pdims new-x))) (not (consp (vl-datatype->udims new-x))) (vl-datatype-resolved-p x)) (not (equal (vl-datatype-kind new-x) :vl-usertype))) :rule-classes ((:forward-chaining :trigger-terms ((vl-datatype-kind (vl-maybe-usertype-resolve x))))))) (define vl-datatype-packedp ((x vl-datatype-p)) :guard (vl-datatype-resolved-p x) :short "Decide whether the datatype is packed or not." :long "<p>A shallow check; e.g. we don't check for invalid things such as a packed struct with a member that's an unpacked array.</p> <p>Note that the question of whether something is packed is subtly different from the question of whether you can select from it: namely, simple bit types such as @('logic') are packed but not selectable.</p>" :returns (packedp) (b* ((x (vl-maybe-usertype-resolve x)) ((when (consp (vl-datatype->udims x))) nil) ((when (consp (vl-datatype->pdims x))) t)) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) (and xinfo.size t)) :vl-struct x.packedp :vl-union x.packedp :vl-enum t :vl-usertype (impossible)))) (define vl-datatype-signedness ((x vl-datatype-p)) :short "Decide whether the datatype is signed or not." :long "<p>Returns NIL if there isn't an appropriate signedness, as in an unpacked or non-integer type. This function never fails, as such, but in some cases where implementations disagree on the correct signedness, we return a flag to signal that there is a caveat about that signedness.</p> <p>This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, NCV treats the array as unsigned, but VCS treats it as signed. The SV spec only touches on this to say (from Sec. 7.4.1, Packed Arrays):</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [20:0] btest; assign btest = b; }) <p>In NCVerilog, btest has the value @('0ffff'), indicating that @('b') (as a whole) is considered unsigned; in VCS, btest has the value @('fffff'), indicating that @('b') is considered signed.</p> " :guard (vl-datatype-resolved-p x) :measure (vl-datatype-count x) :returns (mv (caveat-flag) (signedness vl-maybe-exprtype-p)) (b* (((when (consp (vl-datatype->udims x))) (mv nil nil))) (vl-datatype-case x :vl-coretype (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) (mv nil (and typinfo.takes-signingp (if x.signedp :vl-signed :vl-unsigned)))) :vl-struct (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-union (mv nil (and x.packedp (if x.signedp :vl-signed :vl-unsigned))) :vl-enum (vl-datatype-signedness x.basetype) :vl-usertype (b* (((unless (mbt (and x.res t))) (mv nil nil)) ((mv caveat ans1) (vl-datatype-signedness x.res)) ((when (and (consp (vl-datatype->pdims x)) (eq ans1 :vl-signed))) (mv t :vl-unsigned))) (mv caveat ans1))))) ;; (defines vl-datatype-check-resolved ;; (define vl-datatype-check-resolved ((x vl-datatype-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-datatype-count x) ;; :short "Returns an explanatory message if the datatype has a problem that would ;; prevent its size from being measured." ;; :long "<p>Packedp indicates whether we require it to be a packed (i.e., ;; vector) datatype.</p>" ;; (b* ((x (vl-datatype-fix x)) ;; (udims (vl-datatype->udims x)) ;; ((when (and packedp (consp udims))) ;; (vmsg "~a0: unpacked dimensions in packed context" x)) ;; ((unless (vl-packeddimensionlist-resolved-p udims)) ;; (vmsg "~a0 has unresolved unpacked dimensions" x)) ;; (pdims (vl-datatype->pdims x)) ;; ((unless (vl-packeddimensionlist-resolved-p pdims)) ;; (vmsg "~a0 has unresolved packed dimensions" x)) ;; (packedp (or (consp pdims) packedp))) ;; (vl-datatype-case x ;; :vl-coretype ;; (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name)) ;; ((when (and packedp (not xinfo.size))) ;; (vmsg "~a0: non-packed coretype" x))) ;; nil) ;; :vl-struct ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty struct" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked struct in packed context" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-union ;; (b* (((unless (consp x.members)) ;; (vmsg "~a0: empty union" x)) ;; ((when (and packedp (not x.packedp))) ;; (vmsg "~a0: unpacked union" x)) ;; (packedp (or packedp x.packedp))) ;; (vl-structmemberlist-check-resolved x.members packedp)) ;; :vl-enum ;; (vmsg "~a0: enum types not yet supported" x) ;; :vl-usertype ;; (vmsg "~a0: datatype not resolved" x)))) ;; (define vl-structmemberlist-check-resolved ((x vl-structmemberlist-p) ;; (packedp)) ;; :returns (err (iff (vl-msg-p err) err)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (or (vl-datatype-check-resolved (vl-structmember->type (car x)) packedp) ;; (vl-structmemberlist-check-resolved (cdr x) packedp)))) ;; /// ;; (deffixequiv-mutual vl-datatype-check-resolved) ;; (deffixequiv-mutual vl-datatype-check-resolved ;; :args ((packedp booleanp))) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-datatype-check-resolved x t))) ;; (not (vl-datatype-check-resolved x packedp))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-packed-implies-any ;; (implies (and (syntaxp (not (equal packedp ''t))) ;; (not (vl-structmemberlist-check-resolved x t))) ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; :flag vl-structmemberlist-check-resolved)) ;; (defthm-vl-datatype-check-resolved-flag ;; (defthm vl-datatype-check-resolved-implies-unpacked ;; (implies (not (vl-datatype-check-resolved x packedp)) ;; (not (vl-datatype-check-resolved x nil))) ;; :flag vl-datatype-check-resolved) ;; (defthm vl-structmemberlist-check-resolved-implies-unpacked ;; (implies (not (vl-structmemberlist-check-resolved x packedp)) ;; (not (vl-structmemberlist-check-resolved x nil))) ;; :flag vl-structmemberlist-check-resolved))) ;; (define vl-datatype-resolved-p ((x vl-datatype-p) ;; (packedp)) ;; :enabled t ;; (not (vl-datatype-check-resolved x packedp))) ;; (define vl-structmemberlist-resolved-p ((x vl-structmemberlist-p) ;; (packedp)) ;; :enabled t ;; (not (vl-structmemberlist-check-resolved x packedp))) ;; (defines vl-packed-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-packed-datatype-size ;; :short "Get the size for any packed data type." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) and be ;; packed or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :guard (vl-datatype-resolved-p x t) ;; :returns ;; (size posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((totalsize (vl-packeddimensionlist-total-size x.pdims)) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name))) ;; (lposfix (* typinfo.size totalsize)))) ;; (:vl-struct ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (sum-nats widths))))) ;; (:vl-union ;; (b* ((widths (vl-packed-structmemberlist-sizes x.members)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims))) ;; (lposfix (* packedsize (max-nats widths))))) ;; (:otherwise (lposfix (impossible)))))) ;; (define vl-packed-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x t) ;; :returns (sizes (pos-listp sizes)) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-packed-datatype-size (vl-structmember->type (car x))) ;; (vl-packed-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-packed-datatype-size-flag ;; (defthm len-of-vl-packed-structmemberlist-sizes ;; (b* ((sizes (vl-packed-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-packed-structmemberlist-sizes x)))) ;; :flag vl-packed-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (verify-guards vl-packed-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x t) ;; (vl-structmemberlist-check-resolved x t))))) ;; (deffixequiv-mutual vl-packed-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite)))) ;; (define vl-datatype-size ;; ((x vl-datatype-p)) ;; :short "Get the size for any datatype, even unpacked, that is made up of packed ;; elements." ;; :long "<p>We return NIL if there are non-bit datatypes like @('real').</p>" ;; :guard (vl-datatype-resolved-p x nil) ;; :returns ;; (size maybe-posp :rule-classes :type-prescription) ;; :measure (vl-datatype-count x) ;; (b* ((x (vl-datatype-fix x)) ;; (x.pdims (vl-datatype->pdims x)) ;; (x.udims (vl-datatype->udims x)) ;; (pdimsize (vl-packeddimensionlist-total-size x.pdims)) ;; (udimsize (vl-packeddimensionlist-total-size x.udims))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) nil)) ;; (lposfix (* typinfo.size pdimsize udimsize)))) ;; (:vl-struct ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (sum-nats widths) pdimsize udimsize)))) ;; (:vl-union ;; (b* ((widths (vl-structmemberlist-sizes x.members)) ;; ((when (member nil widths)) nil)) ;; (lposfix (* (max-nats widths) pdimsize udimsize)))) ;; ;; BOZO enums ;; (:otherwise nil)))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :guard (vl-structmemberlist-resolved-p x nil) ;; :returns (sizes maybe-pos-list-p) ;; :measure (vl-structmemberlist-count x) ;; (if (atom x) ;; nil ;; (cons (vl-datatype-size (vl-structmember->type (car x))) ;; (vl-structmemberlist-sizes (cdr x))))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* ((sizes (vl-structmemberlist-sizes x))) ;; (equal (len sizes) (len x))) ;; :hints ('(:expand ((vl-structmemberlist-sizes x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (local (defthm posp-not-equal-0 ;; (implies (posp x) ;; (not (Equal x 0))))) ;; (local (defthm pos-listp-when-not-member-nil ;; (implies (and (maybe-pos-list-p x) ;; (not (member nil x))) ;; (pos-listp x)) ;; :hints(("Goal" :in-theory (enable member))))) ;; (verify-guards vl-datatype-size ;; :hints(("Goal" :in-theory (enable vl-datatype-resolved-p ;; vl-structmemberlist-resolved-p) ;; :expand ((vl-datatype-check-resolved x nil) ;; (vl-structmemberlist-check-resolved x nil))))) ;; (deffixequiv-mutual vl-datatype-size)) ;; (defines vl-datatype-size ;; :verify-guards nil ;; :prepwork ((local (defthm posp-sum-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (sum-nats x))) ;; :hints(("Goal" :in-theory (enable sum-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-max-nats-of-pos-listp ;; (implies (and (pos-listp x) (consp x)) ;; (posp (max-nats x))) ;; :hints(("Goal" :in-theory (enable max-nats))) ;; :rule-classes (:rewrite :type-prescription))) ;; (local (defthm posp-product ;; (implies (and (posp x) (posp y)) ;; (posp (* x y))))) ;; (local (in-theory (disable equal-of-cons-rewrite not)))) ;; (define vl-datatype-size ;; :short "Get the size for a data type, including unpacked dimensions." ;; :long "<p>The type should be fully resolved (i.e. no usertypes) or we'll fail.</p>" ;; ((x vl-datatype-p)) ;; :returns ;; (mv (err (iff (vl-msg-p err) err)) ;; (size (implies (not err) (posp size)) :rule-classes :type-prescription)) ;; :measure (vl-datatype-count x) ;; (b* (((fun (fail reason args)) ;; (mv (make-vl-msg :msg reason ;; :args args) ;; nil)) ;; ((fun (success width)) (mv nil width)) ;; (x (vl-datatype-fix x))) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* ((udim-size (vl-packeddimensionlist-total-size x.udims)) ;; (pdim-size (vl-packeddimensionlist-total-size x.pdims)) ;; ((unless (and udim-size pdim-size)) ;; (fail "Dimensions of vector type ~a0 not resolvd" ;; (list x))) ;; ((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((unless typinfo.size) ;; ;; Something like a real, shortreal, void, realtime, chandle, etc. ;; (fail "bad coretype ~a0" (list x)))) ;; (success (* typinfo.size pdim-size udim-size)))) ;; (:vl-struct ;; (b* (;; bozo is there a correct thing to do for a struct with no members? ;; ((unless (consp x.members)) (fail "empty struct: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of struct type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (sum-nats widths))))) ;; (:vl-union ;; (b* (;; bozo is there a correct thing to do for a union with no members? ;; ((unless (consp x.members)) (fail "empty union: ~a0" (list x))) ;; ((mv warning widths) (vl-structmemberlist-sizes x.members)) ;; ((when warning) (mv warning nil)) ;; (packedsize (vl-packeddimensionlist-total-size x.pdims)) ;; (unpackedsize (vl-packeddimensionlist-total-size x.udims)) ;; ((unless (and packedsize unpackedsize)) ;; (fail "Dimensions of union type ~a0 not resolvd" ;; (list x)))) ;; (success (* packedsize unpackedsize (max-nats widths))))) ;; (:vl-enum ;; need to compute size from the base type? ;; (fail "bozo: implement enum range" nil)) ;; (:vl-usertype ;; (fail "unresolved usertype: ~a0" (list x.name)))))) ;; (define vl-structmemberlist-sizes ((x vl-structmemberlist-p)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (sizes (and (pos-listp sizes) ;; (implies (not err) ;; (equal (consp sizes) (consp x)))))) ;; :measure (vl-structmemberlist-count x) ;; (b* (((when (atom x)) (mv nil nil)) ;; ((vl-structmember first) (vl-structmember-fix (car x))) ;; ((mv warning size) (vl-datatype-size first.type)) ;; ((when warning) (mv warning nil)) ;; ((mv warning rest) (vl-structmemberlist-sizes (cdr x))) ;; ((when warning) (mv warning nil))) ;; (mv nil (cons size rest)))) ;; /// ;; (defthm-vl-datatype-size-flag ;; (defthm len-of-vl-structmemberlist-sizes ;; (b* (((mv warning sizes) (vl-structmemberlist-sizes x))) ;; (implies (not warning) ;; (equal (len sizes) (len x)))) ;; :flag vl-structmemberlist-sizes) ;; :skip-others t) ;; (local (defthm nat-listp-when-pos-listp ;; (implies (pos-listp x) ;; (nat-listp x)) ;; :hints(("Goal" :in-theory (enable nat-listp))))) ;; (verify-guards vl-datatype-size) ;; (deffixequiv-mutual vl-datatype-size)) ;; (define vl-datatype-exprtype ;; :parents (datatype-tools vl-expr-typedecide) ;; :short "Get the self-determined signedness of a datatype." ;; ((x vl-datatype-p)) ;; :returns ;; (type vl-maybe-exprtype-p ;; "On success: the self-determined signedness (exprtype) of this expression. ;; Note that some expressions (e.g., real numbers, unpacked types) have ;; exprtype NIL.") ;; :long "<p>BOZO This is tricky with packed arrays etc.; I'm not sure we've ;; taken time yet to understand all the rules.</p>" ;; (b* (((when (consp (vl-datatype->udims x))) ;; nil)) ;; (vl-datatype-case x ;; (:vl-coretype ;; (b* (((vl-coredatatype-info typinfo) (vl-coretypename->info x.name)) ;; ((when typinfo.takes-signingp) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (success nil))) ;; (:vl-enum ;; just need to look at the base type, right? ;; (fail "bozo: implement enum typing")) ;; (:vl-struct ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed struct") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-union ;; just need to look at signedp and packed? ;; (b* (((unless x.packedp) ;; (fail "non-packed union") ;; ;; Can we just say unpacked stuff is always unsigned? ;; )) ;; (success (if x.signedp :vl-signed :vl-unsigned)))) ;; (:vl-usertype ;; ;; BOZO maybe some day extend this to be able to do lookups, but maybe ;; ;; just depend on usertype-elim ;; (fail "vl-datatype-exprtype can't handle unresolved usertypes"))))) (define vl-datatype-select-ok ((x vl-datatype-p)) :parents (datatype-tools) :short "Determines whether this datatype can be selected." :long "<p>The input datatype should not have packed or unpacked dimensions; if it does, then it's definitely OK to index into it (though it's only a select if it's the last packed dimension). The input datatype should have usertypes resolved.</p>" :guard (vl-datatype-resolved-p x) :returns (ok) :measure (vl-datatype-count x) (b* ((x (vl-maybe-usertype-resolve x))) (or (consp (vl-datatype->pdims x)) (consp (vl-datatype->udims x)) (vl-datatype-case x (:vl-coretype (b* (((vl-coredatatype-info xinfo) (vl-coretypename->info x.name))) ;; Checks whether this is an integer atom type. If it's an integer ;; vector type, it's only selectable if it has dims. (and xinfo.size (not (eql xinfo.size 1))))) (:vl-struct x.packedp) (:vl-union x.packedp) (:vl-enum ;; NOTE: This is a little nonsensical, but simulators seem to treat enums ;; as if they were always 1-dimensional vectors, even in the case of ;; typedef enum logic {a, b} foo ; ;; which you might think would be a 0-dimensional thing. t) (:vl-usertype (impossible)))))) (define vl-datatype-dims-count ((x vl-datatype-p)) :short "Gives the number of packed plus unpacked dimensions on a datatype." :returns (ndims natp :rule-classes :type-prescription) (+ (len (vl-datatype->udims x)) (len (vl-datatype->pdims x)))) (define vl-datatype-set-unsigned ((x vl-datatype-p)) :short "Removes any explicit signed indicator from a datatype." :long "<p>This is rather specific in purpose and generally shouldn't be used. The case where it is useful is when we are indexing into an (explicitly signed) packed array; this means that the whole array is signed, but not the selected parts. So we strip the signed qualifier off of the type when we index into packed dimensions. (This doesn't apply to usertypes that are defined as signed types! If we index down to such a type, it IS signed, but any packed array of such a type is not. So we don't need to descend into usertypes or somehow mark them as unsigned. We just have to know that a usertype with one or more packed dimensions counts as unsigned.)</p>" :returns (new-x vl-datatype-p) (vl-datatype-case x :vl-coretype (mbe :logic (change-vl-coretype x :signedp nil) :exec (if x.signedp (change-vl-coretype x :signedp nil) x)) :vl-struct (mbe :logic (change-vl-struct x :signedp nil) :exec (if x.signedp (change-vl-struct x :signedp nil) x)) :vl-union (mbe :logic (change-vl-union x :signedp nil) :exec (if x.signedp (change-vl-union x :signedp nil) x)) :otherwise (vl-datatype-fix x)) /// (defret vl-datatype-resolved-p-of-set-unsigned (implies (vl-datatype-resolved-p x) (vl-datatype-resolved-p new-x)))) ;; (define vl-datatype-indexing-dimension ((x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :returns (dim (iff (vl-packeddimension-p dim) dim)) ;; (b* ((udims (vl-datatype->udims x)) ;; ((when (consp udims)) (car udims)) ;; (pdims (vl-datatype->pdims x)) ;; ((when (consp pdims)) (car pdims)) (define vl-datatype-remove-dim ((x vl-datatype-p)) :short "Get the type of a variable of type @('x') after an indexing operation is applied to it." :long " <p>The caveat flag returned identifies a case where implementations disagree on the signedness of the resulting type. This caveat occurs when we have packed dimensions on a usertype that is declared as signed. In this case, if we index into an object down to the usertype, NCV treats the resulting object as signed, but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation is correct: from Sec. 7.4.1, Packed Arrays:</p> <blockquote> If a packed array is declared as signed, then the array viewed as a single vector shall be signed. The individual elements of the array are unsigned unless they are of a named type declared as signed. A partselect of a packed array shall be unsigned.</blockquote> <p>An example:</p> @({ typedef logic signed [3:0] squad; squad [3:0] b; assign b = 16'hffff; logic [7:0] btest; assign btest = b[1]; }) <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is considered signed; in VCS, btest has the value @('0f'), indicating that @('b[1]') is considered unsigned.</p>" :prepwork ((local (in-theory (disable not equal-of-cons-rewrite equal-of-vl-usertype acl2::len-when-atom acl2::true-listp-of-nthcdr acl2::true-listp-when-string-listp-rewrite acl2::true-listp-when-symbol-listp-rewrite acl2::nfix-when-not-natp acl2::zp-open acl2::consp-under-iff-when-true-listp acl2::list-fix-under-iff acl2::append-when-not-consp acl2::list-fix-when-len-zero acl2::take-of-len-free double-containment)))) :guard (vl-datatype-resolved-p x) :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") (caveat-flag "Indicates caveat about possible signedness ambiguities") (new-x (implies (not err) (vl-datatype-p new-x)) "Datatype after indexing") (dim (implies (not err) (vl-packeddimension-p dim)) "Dimension removed from the datatype")) (b* ((x (vl-maybe-usertype-resolve x)) (udims (vl-datatype->udims x)) ((when (consp udims)) (mv nil nil (vl-datatype-update-udims (cdr udims) x) (car udims))) (pdims (vl-datatype->pdims x)) ((when (consp pdims)) (b* ((x (vl-datatype-set-unsigned x)) ((when (or (vl-datatype-case x :vl-usertype) (consp (cdr pdims)))) ;; (unless (and (eql n np) ;; (not (vl-datatype-case x :vl-usertype)))) (mv nil nil (vl-datatype-update-dims (cdr pdims) nil ;; no udims x) (car pdims))) (new-x (vl-datatype-update-dims nil nil x)) ((mv & signedness) (vl-datatype-signedness new-x))) (mv nil (eq signedness :vl-signed) new-x (car pdims)))) ((unless (vl-datatype-packedp x)) (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) nil nil nil)) ((mv err size) (vl-datatype-size x)) ((when err) (mv err nil nil nil)) ((unless (posp size)) (mv (vmsg "Index applied to ~s0 packed type: ~a1" (if size "unsizeable" "zero-sized") x) nil nil nil)) ((when (and (vl-datatype-case x :vl-coretype) (eql size 1))) (mv (vmsg "Index applied to bit type ~a0" x) nil nil nil)) (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) :lsb (vl-make-index 0))))) (mv nil nil (make-vl-coretype :name :vl-logic) dim)) /// (defret vl-datatype-resolved-p-of-remove-dim (implies (and (not err) (vl-datatype-resolved-p x)) (vl-datatype-resolved-p new-x))) (defret no-error-when-pdims (implies (consp (vl-datatype->pdims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve)))) (defret no-error-when-udims (implies (consp (vl-datatype->udims x)) (not err)) :hints(("Goal" :in-theory (enable vl-maybe-usertype-resolve))))) (define vl-selstep-usertypes-ok ((x vl-selstep-p)) (b* (((vl-selstep x))) (vl-datatype-resolved-p x.type))) (define vl-seltrace-usertypes-ok ((x vl-seltrace-p)) (if (atom x) t (and (vl-selstep-usertypes-ok (car x)) (vl-seltrace-usertypes-ok (cdr x)))) /// (defthm vl-seltrace-usertypes-ok-of-append (implies (and (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok y)) (vl-seltrace-usertypes-ok (append x y)))) (defthm vl-seltrace-usertypes-ok-of-rev (implies (vl-seltrace-usertypes-ok x) (vl-seltrace-usertypes-ok (rev x)))) (defthm vl-datatype-resolved-p-of-first-seltrace (implies (and (vl-seltrace-usertypes-ok x) (consp x)) (vl-datatype-resolved-p (vl-selstep->type (car x)))) :hints(("Goal" :in-theory (enable vl-selstep-usertypes-ok))))) (define vl-follow-array-indices ((x vl-exprlist-p) (type vl-datatype-p)) :returns (mv (err (iff (vl-msg-p err) err)) (trace vl-seltrace-p)) :guard (vl-datatype-resolved-p type) (b* (((when (atom x)) (mv nil nil)) ((mv err caveat newtype &) (vl-datatype-remove-dim type)) ((when err) (mv err nil)) ((mv err rest) (vl-follow-array-indices (cdr x) newtype)) ((when err) (mv err nil))) (mv nil (cons (make-vl-selstep :select (make-vl-select-index :val (car x)) :type newtype :caveat caveat) rest))) /// (defret vl-seltrace-usertypes-ok-of-follow-array-indices (implies (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (defret true-listp-of-vl-follow-array-indices-trace (true-listp trace) :rule-classes :type-prescription) (defret vl-seltrace->indices-of-vl-follow-array-indices (implies (not err) (equal (vl-seltrace->indices trace) (vl-exprlist-fix x))) :hints(("Goal" :in-theory (enable vl-seltrace->indices)))) (defret consp-of-vl-follow-array-indices (implies (not err) (equal (consp trace) (consp x)))) (defret len-of-vl-follow-array-indices (implies (not err) (equal (len trace) (len x))))) ;; (define vl-datatype-remove-dims ((n natp) ;; (x vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :short "Get the type of a variable of type @('x') after @('n') indexing ;; operations are applied to it." ;; :long " ;; <p>The caveat flag returned identifies a case where implementations disagree on ;; the signedness of the resulting type. This caveat occurs when we have packed ;; dimensions on a usertype that is declared as signed. In this case, if we index ;; into an object down to the usertype, NCV treats the resulting object as signed, ;; but VCS treats it as unsigned. The SV spec seems to say NCV's interpretation ;; is correct: from Sec. 7.4.1, Packed Arrays:</p> ;; <blockquote> If a packed array is declared as signed, then the array viewed as ;; a single vector shall be signed. The individual elements of the array are ;; unsigned unless they are of a named type declared as signed. A partselect of a ;; packed array shall be unsigned.</blockquote> ;; <p>An example:</p> ;; @({ ;; typedef logic signed [3:0] squad; ;; squad [3:0] b; ;; assign b = 16'hffff; ;; logic [7:0] btest; ;; assign btest = b[1]; ;; }) ;; <p>In NCVerilog, btest has the value @('ff'), indicating that @('b[1]') is ;; considered signed; in VCS, btest has the value @('0f'), indicating that ;; @('b[1]') is considered unsigned.</p>" ;; :prepwork ;; ((local (in-theory (disable not equal-of-cons-rewrite ;; equal-of-vl-usertype ;; acl2::len-when-atom ;; acl2::true-listp-of-nthcdr ;; acl2::true-listp-when-string-listp-rewrite ;; acl2::true-listp-when-symbol-listp-rewrite ;; acl2::nfix-when-not-natp ;; acl2::zp-open ;; acl2::consp-under-iff-when-true-listp ;; acl2::list-fix-under-iff ;; acl2::append-when-not-consp ;; acl2::list-fix-when-len-zero ;; acl2::take-of-len-free ;; double-containment)))) ;; :guard (not (vl-datatype-check-usertypes x ss)) ;; :returns (mv (err (iff (vl-msg-p err) err) "Error message on failure") ;; (caveat-flag "Indicates caveat about possible signedness ambiguities") ;; (new-x (implies (not err) (vl-datatype-p new-x)) ;; "Datatype after indexing") ;; (dims vl-packeddimensionlist-p) ;; (new-ss vl-scopestack-p "Scopestack where the most recently looked-up ;; usertype was defined -- this is the scopestack ;; needed to look up the next usertype that ;; might remain in the new type.")) ;; :measure (two-nats-measure ;; n ;; (if (and (vl-datatype-case x :vl-usertype) ;; (not (consp (vl-datatype->udims x))) ;; (not (consp (vl-datatype->pdims x)))) ;; 1 0)) ;; (b* ((x (vl-datatype-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; (udims (redundant-list-fix (vl-datatype->udims x))) ;; (pdims (redundant-list-fix (vl-datatype->pdims x))) ;; (nu (len udims)) ;; (n (lnfix n)) ;; ((when (<= n nu)) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (nthcdr n udims) x) ;; (take n udims) ;; ss)) ;; (n (- n nu)) ;; (np (len pdims)) ;; ((when (<= n np)) ;; (b* ((x (vl-datatype-set-unsigned x)) ;; (dims (append udims (take n pdims))) ;; ((when (or (vl-datatype-case x :vl-usertype) ;; (< n np))) ;; ;; (unless (and (eql n np) ;; ;; (not (vl-datatype-case x :vl-usertype)))) ;; (mv nil nil ;; (vl-datatype-update-dims ;; (nthcdr n pdims) ;; nil ;; no udims ;; x) ;; dims ;; ss)) ;; (new-x (vl-datatype-update-dims nil nil x)) ;; ((mv & signedness) (vl-datatype-signedness new-x ss))) ;; (mv nil (eq signedness :vl-signed) new-x dims ss))) ;; (n (- n np))) ;; (vl-datatype-case x ;; :vl-usertype ;; (b* (((mv err def new-ss) (vl-usertype-resolve x.name ss)) ;; ((when err) (mv err nil nil (append udims pdims) new-ss)) ;; ((mv err caveat new-x rest-dims new-ss) ;; (vl-datatype-remove-dims n def new-ss))) ;; (mv err caveat new-x (append udims pdims rest-dims) new-ss)) ;; :otherwise ;; (b* ((x (vl-datatype-update-dims nil nil x)) ;; ((unless (vl-datatype-packedp x ss)) ;; (mv (vmsg "Index applied to non-packed, non-array type ~a0" x) ;; nil nil (append udims pdims) ss)) ;; ((unless (eql n 1)) ;; (mv (vmsg "Too many indices applied to packed non-array ~a0" x) nil nil (append udims pdims) ss)) ;; ((mv err size) (vl-datatype-size x ss)) ;; ((when err) ;; (mv err nil nil (append udims pdims) ss)) ;; ((unless (posp size)) ;; (mv (vmsg "Index applied to ~s0 packed type: ~a1" ;; (if size "unsizeable" "zero-sized") x) ;; nil nil (append udims pdims) ss)) ;; ((when (and (vl-datatype-case x :vl-coretype) ;; (eql size 1))) ;; (mv (vmsg "Index applied to bit type ~a0" x) nil nil (append udims pdims) ss)) ;; (dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))))) ;; (mv nil nil ;; (make-vl-coretype :name :vl-logic) ;; (append udims pdims (list dim)) ;; ss)))) ;; /// ;; (defret vl-datatype-check-usertypes-of-remove-dims ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes new-x new-ss :rec-limit rec-limit))) ;; :hints (("goal" :induct t :in-theory (enable vl-datatype-check-usertypes)))) ;; (defret vl-datatype-remove-dims-true-listp-dims ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret vl-datatype-remove-dims-dims-length ;; (implies (not err) ;; (equal (len dims) ;; (nfix n)))) ;; (verify-guards vl-datatype-remove-dims ;; :hints ((and stable-under-simplificationp ;; '(:expand ((:free (rec-limit) ;; (vl-datatype-check-usertypes x ss :rec-limit rec-limit))))))) ;; (local ;; (defthm vl-datatype-update-dims-compose ;; (equal (vl-datatype-update-dims ;; pdims udims ;; (vl-datatype-update-dims ;; pdims1 udims1 x)) ;; (vl-datatype-update-dims ;; pdims udims x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims))))) ;; (local (Defthm append-of-nil ;; (equal (append nil x) x) ;; :hints(("Goal" :in-theory (enable append))))) ;; (local (defthm list-fix-of-nthcdr ;; (equal (list-fix (nthcdr n x)) ;; (nthcdr n (list-fix x))))) ;; (local (in-theory (disable acl2::nthcdr-of-list-fix))) ;; (local (defthm append-take-take-nthcdr ;; (equal (append (take n a) ;; (take m (nthcdr n a))) ;; (take (+ (nfix n) (nfix m)) a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a)) ;; a)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (defthm append-take-take-nthcdr-1 ;; (equal (append (take n a) ;; (take m (nthcdr n a)) ;; x) ;; (append (take (+ (nfix n) (nfix m)) a) x)) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr))))) ;; (local (defthm append-take-nthcdr-1 ;; (implies (<= (nfix n) (len a)) ;; (equal (append (take n a) ;; (nthcdr n a) ;; x) ;; (append a x))) ;; :hints (("goal" :induct (nthcdr n a) ;; :in-theory (enable acl2::take-redefinition nthcdr len))))) ;; (local (in-theory (disable ACL2::INEQUALITY-WITH-NFIX-HYP-1))) ;; ;; (local (defthm nfix-linear ;; ;; (<= 0 (nfix n)) ;; ;; :rule-classes :linear)) ;; (local (defthm vl-datatype-kind-of-set-unsigned ;; (equal (vl-datatype-kind (vl-datatype-set-unsigned x)) ;; (vl-datatype-kind x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (defthm packedp-update-dims-of-set-unsigned ;; (equal (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss) ;; (vl-datatype-packedp ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss)) ;; :hints(("Goal" :in-theory (enable vl-datatype-packedp ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm size-update-dims-of-set-unsigned ;; (b* (((mv err1 size1) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims (vl-datatype-set-unsigned x)) ;; ss)) ;; ((mv err2 size2) ;; (vl-datatype-size ;; (vl-datatype-update-dims ;; pdims udims x) ;; ss))) ;; (and (iff err1 err2) ;; (equal size1 size2))) ;; :hints(("Goal" :in-theory (enable vl-datatype-size ;; vl-datatype-update-dims ;; vl-datatype-set-unsigned))))) ;; (local (defthm vl-usertype->name-of-update-dims ;; (equal (vl-usertype->name (vl-datatype-update-dims pdims udims x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-update-dims ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-usertype->name-of-set-unsigned ;; (equal (vl-usertype->name (vl-datatype-set-unsigned x)) ;; (vl-usertype->name x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-usertype->name-when-wrong-kind))))) ;; (local (defthm vl-datatype-set-unsigned-of-update-dims ;; (Equal (vl-datatype-set-unsigned ;; (vl-datatype-update-dims pdims udims x)) ;; (vl-datatype-update-dims pdims udims (vl-datatype-set-unsigned x))) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned ;; vl-datatype-update-dims))))) ;; (local (Defthm vl-datatype-set-unsigned-idempotent ;; (equal (vl-datatype-set-unsigned (vl-datatype-set-unsigned x)) ;; (vl-datatype-set-unsigned x)) ;; :hints(("Goal" :in-theory (enable vl-datatype-set-unsigned))))) ;; (local (in-theory (disable vl-datatype-fix-when-vl-coretype ;; vl-datatype-fix-when-vl-struct ;; vl-datatype-fix-when-vl-union ;; vl-datatype-fix-when-vl-enum ;; vl-datatype-fix-when-vl-usertype))) ;; (local (defthm <=-when-equal ;; (implies (equal a b) ;; (<= a b)))) ;; (defthm vl-datatype-remove-dims-compose ;; (b* (((mv err ?caveat new-x dims new-ss) ;; (vl-datatype-remove-dims (+ (nfix n) (nfix m)) x ss)) ;; ((mv err1 ?caveat1 new-x1 dims1 new-ss1) ;; (vl-datatype-remove-dims n x ss)) ;; ((mv err2 ?caveat2 new-x2 dims2 new-ss2) ;; (vl-datatype-remove-dims m new-x1 new-ss1))) ;; (implies (not err) ;; (and (not err1) ;; (not err2) ;; ;; (equal caveat2 caveat) ;; (equal new-x2 new-x) ;; (equal new-ss2 new-ss) ;; (list-equiv (append dims1 dims2) dims)))) ;; :hints (("goal" :induct (vl-datatype-remove-dims n x ss) ;; :in-theory (disable (:d vl-datatype-remove-dims)) ;; :expand ((:free (n) (vl-datatype-remove-dims n x ss)) ;; (:free (x ss) ;; (vl-datatype-remove-dims 1 x ss)) ;; ;; (:free (x) (vl-datatype-size (vl-datatype-update-dims nil nil x) ss)) ;; )) ;; ;; (and stable-under-simplificationp ;; ;; '(:in-theory (enable ;; ;; vl-datatype-update-dims ;; ;; vl-datatype-set-unsigned ;; ;; vl-datatype-packedp))) ;; (and stable-under-simplificationp ;; '(:expand ((:free (x ss) ;; (vl-datatype-remove-dims m x ss))))) ;; ))) ;; (define vl-hidindex-datatype-resolve-dims ((x vl-hidindex-p) ;; (type vl-datatype-p)) ;; :short "Given the indices of some expression, e.g. foo[5][3], and the ;; datatype of foo, return the datatype of the whole expression." ;; :long "<p>Note: we don't check whether indices are in bounds or anything, ;; just whether the number of indices is less than or equal the number of ;; total (unpacked plus packed) dimensions.</p> ;; <p>We produce a non-fatal warning because we're not sure in what contexts this ;; will be used.</p> ;; <p>Example: Suppose our datatype is from a typedef</p> ;; @({ ;; typedef bit [3:0] [4:2] foo [0:6] [0:8]; ;; }) ;; <p>that is, it has one unpacked dimension @('[0:6]') and two packed dimensions. ;; Suppose our expression is @('bar[5][7][2]'), where bar is of type foo. Then we ;; should return @('bit[4:2]') as our resolved datatype, with no unpacked ;; dimensions, because the first two indices correspond to the unpacked dimension ;; and the second to the first packed dimension. On the other hand if we had ;; @('bar[5]'), we should return @('bit') with packed dimensions @('[3:0][4:2]') ;; and unpacked dimension @('[0:8]').</p>" ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type1 (iff (vl-datatype-p type1) (not warning)))) ;; (b* ((idxcount (len (vl-hidindex->indices x))) ;; (type (vl-datatype-fix type)) ;; (x (vl-hidindex-fix x)) ;; (unpacked-dims (vl-datatype->udims type)) ;; (packed-dims (vl-datatype->pdims type)) ;; (nunpacked (len unpacked-dims)) ;; ((when (<= idxcount nunpacked)) ;; (mv nil (vl-datatype-update-udims ;; (nthcdr idxcount (redundant-list-fix unpacked-dims)) type))) ;; (remaining-idxcount (- idxcount nunpacked)) ;; ((unless (<= remaining-idxcount (len packed-dims))) ;; (mv (make-vl-warning :type :vl-too-many-indices ;; :msg "Too many indices on expression ~a0 ~ ;; relative to dimensions of type ~a1." ;; :args (list x type) ;; :fn __function__) ;; nil)) ;; (type (vl-datatype-update-dims ;; (nthcdr remaining-idxcount (redundant-list-fix packed-dims)) ;; nil ;; udims ;; type))) ;; (mv nil type))) ;; Have a HID, and know (for the base name) the type (unresolved) and unpacked ;; dims. ;; Resolve the type. ;; If the hid is an ID, return the type and dims. ;; Resolve the indices of the base part against the unpacked/packed dims. If we ;; end up still having dims remaining, fail. ;; If the type is not a struct or union type, fail. ;; Find the next name in the HID among the structmembers. If not found, fail. ;; Recur with the rest of the HID and the type/unpacked dims of the member. ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (final-type (implies (not err) (vl-datatype-p final-type)))) ;; (b* (((mv type ss) ;; (if (vl-datatype-case type :vl-usertype) ;; (b* (((mv & type ss) (vl-usertype-resolve type ss))) ;; (mv type ss)) ;; (mv type ss))) ;; ((mv name1 indices rest) ;; (vl-hidexpr-case x ;; :end (mv x.name nil nil) ;; :dot (b* (((vl-hidindex x.first))) ;; (mv x.first.name x.first.indices x.rest)))) ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and (atom (vl-datatype->udims type)) ;; (atom (vl-datatype->pdims type)) ;; ok)) ;; (mv (vmsg "Can't get field ~s0 from non-struct/union type ~a1" ;; name1 type) ;; nil)) ;; (member (vl-find-structmember name1 members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil)) ;; (membtype (vl-structmember->type member)) (define vl-hidexpr-index-count ((x vl-hidexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end 0 :dot (+ (len (vl-hidindex->indices x.first)) (vl-hidexpr-index-count x.rest)))) (define vl-scopeexpr-index-count ((x vl-scopeexpr-p)) :returns (nunres natp :rule-classes :type-prescription) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-index-count x.hid) :colon (vl-scopeexpr-index-count x.rest))) (define vl-follow-data-selects ((x vl-hidexpr-p) (type vl-datatype-p) (trace vl-seltrace-p "Accumulator")) :short "Given a HID expression denoting a variable of the input type, create a trace showing the type of each field select/indexing operation." :long "<p>Implementation notes: This function only </p>" :returns (mv (err (iff (vl-msg-p err) err)) (seltrace vl-seltrace-p)) :measure (vl-hidexpr-count x) :guard (vl-datatype-resolved-p type) :verify-guards nil ;; Resolve the type and dims. (b* ((type (vl-datatype-fix type)) ;; (name1 (vl-hidexpr-case x ;; :end x.name ;; :dot (vl-hidindex->name x.first))) ;; (frame (make-vl-selstep ;; :select (make-vl-select-field :name name1) ;; :type type ;; :ss ss)) ;; (trace (cons frame (vl-seltrace-fix trace))) (trace (vl-seltrace-fix trace)) ((when (vl-hidexpr-case x :end)) ;; We just have an ID. It has already been added to the trace (or else ;; it is just a plain variable and the outer hidtrace has its type info). (mv nil trace)) ;; Cancel the indices of the first element of the HID with the unpacked ;; and packed dims of the type. ;; Note: We have at least one more dot in this HID, so if we don't have ;; a struct or union at the end of this, we have a problem. ((vl-hidexpr-dot x)) ((mv err rev-idxtrace) (vl-follow-array-indices (vl-hidindex->indices x.first) type)) ((when err) (mv err nil)) (trace (revappend rev-idxtrace trace)) (type (if (consp rev-idxtrace) (vl-selstep->type (car trace)) type)) (type (vl-maybe-usertype-resolve type)) ;; Next we're going to dot-index into the datatype, so get its ;; structmembers, making sure it's a struct. ((mv ok members) (vl-datatype->structmembers type)) (nextname (vl-hidexpr-case x.rest :end x.rest.name :dot (vl-hidindex->name x.rest.first))) ;; Look up the member corresponding to the next name in the hid. ((unless (and ok (atom (vl-datatype->udims type)) (atom (vl-datatype->pdims type)))) (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" nextname (vl-datatype-update-dims (append-without-guard (vl-datatype->udims type) (vl-datatype->pdims type)) nil type)) nil)) ((when (eq nextname :vl-$root)) (mv (vmsg "Can't use $root to index into a data structure: ~a0" (vl-hidexpr-fix x)) nil)) (member (vl-find-structmember nextname members)) ((unless member) (mv (vmsg "Dot-indexing failed: struct/union member ~ ~s0 not found in type ~a1" nextname (vl-datatype-fix type)) nil)) (membtype (vl-structmember->type member)) (next-frame (make-vl-selstep :select (make-vl-select-field :name nextname) :type membtype)) (trace (cons next-frame trace))) (vl-follow-data-selects x.rest membtype trace)) /// (verify-guards vl-follow-data-selects) (defret vl-seltrace-usertypes-ok-of-vl-follow-data-selects (implies (and (vl-datatype-resolved-p type) (vl-seltrace-usertypes-ok trace)) (vl-seltrace-usertypes-ok seltrace)) :hints(("Goal" :in-theory (enable vl-seltrace-usertypes-ok vl-selstep-usertypes-ok)))) (local (in-theory (disable acl2::car-of-append acl2::consp-under-iff-when-true-listp))) (defret vl-seltrace-indices-of-vl-follow-data-selects (implies (not err) (equal (vl-seltrace->indices seltrace) (revappend (vl-hidexpr->subexprs x) (vl-seltrace->indices trace)))) :hints(("Goal" :in-theory (enable vl-seltrace->indices vl-hidexpr->subexprs))))) ;; (define vl-hidexpr-traverse-datatype ((x vl-hidexpr-p) ;; (type vl-datatype-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Given a HID expression that indexes into a datatype, find the type ;; of the expression." ;; :long " <p>A helpful invariant to remember when thinking about this function: ;; The type input of a given call of this function belong to the base (leftmost) ;; variable in the HID.</p> ;; <p>Example: Suppose we have the following type declarations</p> ;; @({ ;; typedef struct packed { logic [3:0] foo; } [4:0] foostruct; ;; typedef union { foostruct [5:0] bar; logic [2:0] baz; } bunion [0:6]; ;; typedef struct { bunion fa [0:8], logic [1:0] ba; } bstruct; ;; bstruct myvar [8:0]; ;; }) ;; <p>For this example, we'll write a type with both packed an unpacked dimensions ;; with an underscore between the packed and unpacked dims.</p> ;; <p>A bunion is a type consisting of an unpacked array of 7 elements ;; each of which may either be a packed array of 6 foostructs (a packed structure ;; containing one 4-bit logic field) or a 3-bit logic; a bstruct is a struct ;; containing an unpacked array of 9 bunions and an additional 2-bit logic field; ;; and myvar is an unpacked array of 9 bstructs.</p> ;; <p>Suppose our expression is @('myvar[1].fa[8][4].bar[3][4].foo').</p> ;; <ul> ;; <li>First, before calling this function we look up the type of myvar. We get a ;; vardecl, which has a type @('bstruct _ [8:0]'). Then we're ready to run.</li> ;; <li>Outermost call: We resolve the type bstruct to its struct definition. We ;; cancel our index with the single array dimension, leaving just the struct. We ;; find the element fa inside the struct, and ;; recur on the remainder of our expression, @('fa[8][4].bar[3][4].foo'), with the ;; structmember's type, @('bunion _ [0:8]').</li> ;; <li> We resolve the bunion type to the union, and append the unpacked ;; dimensions of the type and the element to get @('[0:8][0:6]'). We then check ;; the indices from the expression against this type and unpacked dimensions, ;; which results in just the bare union type (the definition of bunion, but ;; without its unpacked dimension @('[0:6]')). We find the element bar inside the ;; union and recur: @('bar[3][4].foo'), type @('foostruct[5:0]').</li> ;; <li> We resolve the type foostruct to its struct type, and append the packed ;; dimensions to get @('[5:0][4:0]'). We then check the indices from the ;; expression, which results in cancelling out the dimension to obtain just the ;; bare struct. We find the element foo of the struct and recur on that.</li> ;; <li>Finally, we have just the atom @('foo') as our expression, so we return the ;; type @('logic[3:0]').</li> </ul>" ;; :measure (vl-hidexpr-count x) ;; :guard (not (vl-datatype-check-usertypes type ss)) ;; :verify-guards nil ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (restype (iff (vl-datatype-p restype) (not err))) ;; (dims vl-packeddimensionlist-p ;; "Dimensions of indices along the way") ;; (final-ss vl-scopestack-p "Scopestack in which the last usertype was found")) ;; ;; Resolve the type and dims. ;; (b* ((type (vl-datatype-fix type)) ;; (ss (vl-scopestack-fix ss)) ;; ((when (vl-hidexpr-case x :end)) ;; ;; We just have an ID. Return the resolved type. ;; (mv nil type nil ss)) ;; ;; Cancel the indices of the first element of the HID with the unpacked ;; ;; and packed dims of the type. ;; ;; Note: We have at least one more dot in this HID, so if we don't have ;; ;; a struct or union at the end of this, we have a problem. ;; ((vl-hidexpr-dot x)) ;; (nindices (len (vl-hidindex->indices x.first))) ;; ((mv err ?caveat idxtype dims ss) ;; ;; Ignore the caveat because we're going dot-index into the new type at ;; ;; least once more. ;; (vl-datatype-remove-dims nindices type ss)) ;; ((when err) (mv err nil nil ss)) ;; ((mv baretype ss) (vl-maybe-usertype-resolve idxtype ss)) ;; ;; Next we're going to dot-index into the datatype, so get its ;; ;; structmembers, making sure it's a struct. ;; ((mv ok members) (vl-datatype->structmembers baretype)) ;; ((unless (and ok ;; (atom (vl-datatype->udims baretype)) ;; (atom (vl-datatype->pdims baretype)))) ;; (mv (vmsg "Dot-indexing (field ~s0) into a non-struct/union datatype: ~a1" ;; (vl-datatype-update-dims (append-without-guard ;; (vl-datatype->udims baretype) ;; (vl-datatype->pdims baretype)) ;; nil baretype)) ;; nil nil ss)) ;; ;; Look up the member corresponding to the next name in the hid. ;; (nextname (vl-hidexpr-case x.rest ;; :end x.rest.name ;; :dot (vl-hidindex->name x.rest.first))) ;; (member (vl-find-structmember nextname members)) ;; ((unless member) ;; (mv (vmsg "Dot-indexing failed: struct/union member ~ ;; ~s0 not found in type ~a1" ;; nextname (vl-datatype-fix baretype)) ;; nil nil ss)) ;; (membtype (vl-structmember->type member)) ;; ((mv err type rest-dims ss) ;; (vl-hidexpr-traverse-datatype x.rest membtype ss))) ;; (mv err type (append dims rest-dims) ss)) ;; /// ;; (defret true-listp-dims-of-vl-hidexpr-traverse-datatype ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-hidexpr-traverse-datatype ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count x))) ;; :hints(("Goal" :in-theory (enable vl-hidexpr-index-count)))) ;; ;; bozo move these two theorems ;; (defthm vl-structmemberlist-check-usertypes-of-vl-datatype->structmembers ;; (b* (((mv ok members) (vl-datatype->structmembers x))) ;; (implies (and (not (vl-datatype-check-usertypes x ss :rec-limit rec-limit)) ;; ok) ;; (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)))) ;; :hints(("Goal" :in-theory (enable vl-datatype->structmembers ;; vl-datatype-check-usertypes)))) ;; (defthm vl-datatype-check-usertypes-of-find-structmember ;; (implies (and (not (vl-structmemberlist-check-usertypes members ss :rec-limit rec-limit)) ;; (vl-find-structmember name members)) ;; (not (vl-datatype-check-usertypes ;; (vl-structmember->type (vl-find-structmember name members)) ;; ss :rec-limit rec-limit))) ;; :hints(("Goal" :in-theory (enable vl-structmemberlist-check-usertypes ;; vl-find-structmember)))) ;; (verify-guards vl-hidexpr-traverse-datatype) ;; (defret vl-datatype-check-usertypes-of-vl-hidexpr-traverse-datatype ;; (implies (and (not (vl-datatype-check-usertypes type ss :rec-limit rec-limit)) ;; (not err)) ;; (not (vl-datatype-check-usertypes restype final-ss :rec-limit rec-limit))))) ;; (define vl-scopeexpr-find-type ((x vl-scopeexpr-p) ;; (ss vl-scopestack-p)) ;; :parents (hid-tools) ;; :short "Looks up a HID in a scopestack and looks for a declaration, returning ;; the type if found, and the scopestack relative to that type." ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (iff (vl-datatype-p type) (not err))) ;; (dims vl-packeddimensionlist-p) ;; (type-ss vl-scopestack-p)) ;; (b* ((x (vl-scopeexpr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv err trace tail) (vl-follow-scopeexpr x ss)) ;; ((when err) (mv err nil nil ss)) ;; ((vl-hidstep step1) (car trace)) ;; ((when (eq (tag step1.item) :vl-vardecl)) ;; ;; check its datatype ;; (b* (((vl-vardecl step1.item)) ;; (err (vl-datatype-check-usertypes step1.item.type step1.ss)) ;; ((when err) (mv err nil nil step1.ss))) ;; (vl-hidexpr-traverse-datatype tail step1.item.type step1.ss)))) ;; (mv (vmsg "Failed to find a type for ~s1 because we ~ ;; didn't find a vardecl but rather a ~x2" ;; nil x (tag step1.item)) ;; nil nil ss)) ;; /// ;; (defret true-listp-dims-of-vl-scopeexpr-find-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (equal (len dims) ;; (vl-hidexpr-index-count (mv-nth 2 (vl-follow-scopeexpr x ss))))) ;; :hints(("Goal" :in-theory (enable vl-scopeexpr-index-count)))) ;; (defret vl-datatype-check-usertypes-of-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret follow-scopeexpr-when-vl-scopeexpr-find-type ;; (implies (not err) ;; (not (mv-nth 0 (vl-follow-scopeexpr x ss)))))) (define vl-partselect-width ((x vl-partselect-p)) :guard (not (vl-partselect-case x :none)) :returns (mv (err (iff (vl-msg-p err) err)) (width (implies (not err) (posp width)) :rule-classes :type-prescription)) (b* ((x (vl-partselect-fix x))) (vl-partselect-case x :range (b* (((unless (and (vl-expr-resolved-p x.msb) (vl-expr-resolved-p x.lsb))) (mv (vmsg "Unresolved partselect: ~a0" x) nil)) (msb (vl-resolved->val x.msb)) (lsb (vl-resolved->val x.lsb))) ;; BOZO We might want to check here whether the msb/lsb are ;; correctly ascending/descending. Not the core mission, though. (mv nil (+ 1 (abs (- msb lsb))))) :plusminus (b* (((unless (vl-expr-resolved-p x.width)) (mv (vmsg "Unresolved partselect width: ~a0" x) nil)) (width (vl-resolved->val x.width)) ((when (eql width 0)) (mv (vmsg "Zero-width partselect not allowed: ~a0" x) nil))) (mv nil width)) :otherwise (mv (vmsg "Impossible") (impossible))))) (define vl-operandinfo-usertypes-ok ((x vl-operandinfo-p)) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace))) /// (defthm vl-operandinfo-usertypes-ok-implies (implies (vl-operandinfo-usertypes-ok x) (b* (((vl-operandinfo x))) (and (vl-datatype-resolved-p x.type) (vl-seltrace-usertypes-ok x.seltrace) (vl-datatype-resolved-p x.hidtype) (consp x.hidtrace)))))) (define vl-operandinfo-index-count ((x vl-operandinfo-p)) :returns (count natp :rule-classes :type-prescription) ;; Gives the number of indices (b* (((vl-operandinfo x))) (+ (vl-seltrace-index-count x.seltrace) (vl-partselect-case x.part :none 0 :otherwise 2)))) (define vl-operandinfo->indices ((x vl-operandinfo-p)) :returns (indices vl-exprlist-p) (b* (((vl-operandinfo x))) (append (vl-partselect-case x.part :none nil :range (list x.part.msb x.part.lsb) :plusminus (list x.part.base x.part.width)) (vl-seltrace->indices x.seltrace))) /// (defret len-of-vl-operandinfo->indices (equal (len indices) (vl-operandinfo-index-count x)) :hints(("Goal" :in-theory (enable vl-operandinfo-index-count))))) (defthm vl-exprlist-count-of-append (equal (vl-exprlist-count (append a b)) (+ -1 (vl-exprlist-count a) (vl-exprlist-count b))) :hints(("Goal" :in-theory (enable vl-exprlist-count append)))) (defthm vl-exprlist-count-of-rev (equal (vl-exprlist-count (rev x)) (vl-exprlist-count x)) :hints(("Goal" :in-theory (enable vl-exprlist-count rev)))) (define vl-datatype-resolve-selects ((type vl-datatype-p) (tail vl-hidexpr-p) (indices vl-exprlist-p) (part vl-partselect-p)) :returns (mv (err (iff (vl-msg-p err) err)) (seltrace (implies (not err) (vl-seltrace-p seltrace))) (finaltype (implies (not err) (vl-datatype-p finaltype)))) :guard (vl-datatype-resolved-p type) (b* (((mv err seltrace) (vl-follow-data-selects tail type nil)) ((when err) (mv err nil nil)) (type (vl-datatype-fix type)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((mv err rev-idxtrace) (vl-follow-array-indices indices seltype)) ((when err) (mv err nil nil)) (seltrace (revappend rev-idxtrace seltrace)) (seltype (if (consp seltrace) (b* (((vl-selstep selstep) (car seltrace))) selstep.type) type)) ((when (vl-partselect-case part :none)) (mv nil seltrace seltype)) ((mv err ?caveat single-type &) (vl-datatype-remove-dim seltype)) ((when err) (mv err nil nil)) ((mv err width) (vl-partselect-width part)) ((when err) (mv err nil nil)) (new-dim (vl-range->packeddimension (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) (packedp (vl-datatype-packedp seltype)) (psel-type (if packedp (vl-datatype-update-pdims (cons new-dim (vl-datatype->pdims single-type)) single-type) (vl-datatype-update-udims (cons new-dim (vl-datatype->udims single-type)) single-type)))) (mv nil seltrace psel-type)) /// (defret vl-seltrace-usertypes-ok-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-seltrace-usertypes-ok seltrace))) (defret vl-datatype-resolved-p-of-vl-datatype-resolve-selects (implies (and (not err) (vl-datatype-resolved-p type)) (vl-datatype-resolved-p finaltype))) (defret vl-seltrace-count-of-vl-datatype-resolve-selects (implies (not err) (< (vl-exprlist-count (vl-seltrace->indices seltrace)) (+ (vl-exprlist-count indices) (vl-hidexpr-count tail)))) :rule-classes :linear)) (define vl-index-expr-typetrace ((x vl-expr-p "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical identifier with 0 or more array selects and a possible partselect.") (ss vl-scopestack-p "Scopestack where @('x') is referenced.") (typeov vl-typeoverride-p)) :guard (vl-expr-case x :vl-index) :returns (mv (err (iff (vl-msg-p err) err) "Success indicator, we fail if we can't follow the HID or this isn't an appropriate expression.") (opinfo (implies (not err) (vl-operandinfo-p opinfo)))) :prepwork ((local (defthm natp-abs (implies (integerp x) (natp (abs x))) :rule-classes :type-prescription)) (local (in-theory (disable abs)))) (b* (((vl-index x) (vl-expr-fix x)) (ss (vl-scopestack-fix ss)) ((mv err hidtrace context tail) (vl-follow-scopeexpr x.scope ss)) ((when err) (mv err nil)) ((vl-hidstep hidstep) (car hidtrace)) ;; Suppose x is foo.bar.baz.fum[0][1][3:2]. ;; Suppose foo.bar is the actual vardecl, and .baz.fum are selects into it. ;; We want to see if foo.bar has a cached resolved type. ;; Compute foo.bar. (prefix-name (vl-scopeexpr-replace-hid x.scope (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ((mv err type) (b* ((look (hons-get prefix-name (vl-typeoverride-fix typeov))) ((when look) (if (vl-datatype-resolved-p (cdr look)) (mv nil (cdr look)) (mv (vmsg "Programming error: Type override was unresolved") nil)))) (case (tag hidstep.item) (:vl-vardecl (b* ((type1 (vl-vardecl->type hidstep.item))) (vl-datatype-usertype-resolve type1 hidstep.ss :typeov typeov))) (:vl-paramdecl (b* (((vl-paramdecl decl) hidstep.item)) (vl-paramtype-case decl.type :vl-explicitvalueparam (if (vl-datatype-resolved-p decl.type.type) (mv nil decl.type.type) (mv (vmsg "Reference to parameter with unresolved type: ~a0" x) nil)) :otherwise (mv (vmsg "Bad parameter reference: ~a0" x) nil)))) (otherwise (mv (vmsg "~a0: instead of a vardecl, found ~a1" x hidstep.item) nil))))) ((when err) (mv err nil)) ((mv err seltrace final-type) (vl-datatype-resolve-selects type tail x.indices x.part)) ((when err) (mv err nil))) (mv nil (make-vl-operandinfo :context context :prefixname prefix-name :hidtrace hidtrace :hidtype type :seltrace seltrace :part x.part :type final-type))) ;; ((mv err seltrace) (vl-follow-data-selects tail type nil)) ;; ((when err) (mv err nil)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; ((mv err rev-idxtrace) ;; (vl-follow-array-indices x.indices seltype)) ;; ((when err) (mv err nil)) ;; (seltrace (revappend rev-idxtrace seltrace)) ;; (seltype (if (consp seltrace) ;; (b* (((vl-selstep selstep) (car seltrace))) ;; selstep.type) ;; type)) ;; (prefix-name (vl-scopeexpr-replace-hid ;; x.scope ;; (vl-hid-prefix-for-subhid (vl-scopeexpr->hid x.scope) tail))) ;; ((when (vl-partselect-case x.part :none)) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type seltype))) ;; ((mv err ?caveat single-type &) ;; (vl-datatype-remove-dim seltype)) ;; ((when err) (mv err nil)) ;; ((mv err width) (vl-partselect-width x.part)) ;; ((when err) (mv err nil)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (packedp (vl-datatype-packedp seltype)) ;; (psel-type (if packedp ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type)))) ;; (mv nil (make-vl-operandinfo ;; :context context ;; :prefixname prefix-name ;; :hidtrace hidtrace ;; :hidtype type ;; :seltrace seltrace ;; :part x.part ;; :type psel-type))) /// (defret vl-seltrace-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-seltrace-usertypes-ok (vl-operandinfo->seltrace opinfo)))) (defret consp-hidtrace-of-vl-index-expr-typetrace (implies (not err) (consp (vl-operandinfo->hidtrace opinfo)))) ;; (defret vl-hidtrace-top-is-vardecl-or-paramdecl-of-vl-index-expr-typetrace ;; (implies (and (not err) ;; (not (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-paramdecl))) ;; (equal (tag (vl-hidstep->item (car (vl-operandinfo->hidtrace opinfo)))) ;; :vl-vardecl))) (defret vl-datatype-usertypes-ok-of-vl-index-expr-typetrace-type (implies (not err) (vl-datatype-resolved-p (vl-operandinfo->type opinfo)))) (defret vl-operandinfo-usertypes-ok-of-vl-index-expr-typetrace (implies (not err) (vl-operandinfo-usertypes-ok opinfo)) :hints(("Goal" :in-theory (enable vl-operandinfo-usertypes-ok)))) (defret follow-scopeexpr-when-vl-index-expr-type (implies (not err) (b* (((vl-index x))) (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss)))))) (defret index-count-of-vl-index-expr-typetrace (implies (and (not err) (equal (vl-expr-kind x) :vl-index)) (< (vl-exprlist-count (vl-operandinfo->indices opinfo)) (vl-expr-count x))) :hints(("Goal" :in-theory (enable vl-operandinfo->indices vl-exprlist-count vl-partselect-count vl-plusminus-count vl-range-count) :expand ((vl-expr-count x)))) :rule-classes :linear)) ;; (define vl-index-expr-typetrace ;; ((x vl-expr-p ;; "An index expression, i.e. a possibly-package-scoped, possibly-hierarchical ;; identifier with 0 or more array selects and a possible partselect.") ;; (ss vl-scopestack-p ;; "Scopestack where @('x') is referenced.")) ;; :guard (vl-expr-case x :vl-index) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (caveat-flg) ;; (type (implies (not err) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.") ;; (dims vl-packeddimensionlist-p ;; "Dimensions corresponding to the array indices in the expression") ;; (type-ss vl-scopestack-p ;; "Scopestack relative to the type returned.")) ;; :prepwork ((local (defthm natp-abs ;; (implies (integerp x) ;; (natp (abs x))) ;; :rule-classes :type-prescription)) ;; (local (in-theory (disable abs)))) ;; (b* (((vl-index x) (vl-expr-fix x)) ;; (ss (vl-scopestack-fix ss)) ;; ((mv warning type sdims type-ss) (vl-scopeexpr-find-type x.scope ss)) ;; ((when warning) (mv warning nil nil nil ss)) ;; (has-partselect (vl-partselect-case x.part ;; :none nil ;; :otherwise t)) ;; ((mv err caveat-flg reduced-type idims reduced-ss) ;; (vl-datatype-remove-dims (len x.indices) type type-ss)) ;; ((when err) (mv err nil nil nil reduced-ss)) ;; ((unless has-partselect) ;; (mv nil ;; caveat-flg ;; reduced-type ;; (append sdims idims) ;; reduced-ss)) ;; ;; Take off one more dimension, and then add a dimension the width of ;; ;; the partselect. ;; ;; Caveat-flag doesn't apply because implementations seem to agree that ;; ;; partselects are always unsigned. ;; ((mv err ?caveat-flg single-type psdims single-ss) ;; (vl-datatype-remove-dims 1 reduced-type reduced-ss)) ;; ((when err) ;; (mv err nil nil nil single-ss)) ;; ((mv err width) ;; (vl-partselect-width x.part)) ;; ((when err) (mv err nil nil nil single-ss)) ;; (new-dim (vl-range->packeddimension ;; (make-vl-range ;; :msb (vl-make-index (1- width)) ;; :lsb (vl-make-index 0)))) ;; (dims (append sdims idims psdims)) ;; ;; The result is now width many elements of ;; ;; type single-type. So we add a dimension [width-1:0] back onto ;; ;; reduced-type. However, we need to know whether it should be an ;; ;; unpacked or packed dimension: the way to determine this is whether ;; ;; the last dimension selected was packed or unpacked. ;; (packedp (vl-datatype-packedp reduced-type reduced-ss)) ;; ((when packedp) ;; (mv nil nil ;; (vl-datatype-update-pdims ;; (cons new-dim (vl-datatype->pdims single-type)) ;; single-type) ;; dims ;; single-ss))) ;; (mv nil nil ;; (vl-datatype-update-udims ;; (cons new-dim (vl-datatype->udims single-type)) ;; single-type) ;; dims ;; single-ss)) ;; /// ;; (defret vl-datatype-check-usertypes-of-vl-index-expr-type ;; (implies (not err) ;; (not (vl-datatype-check-usertypes type type-ss)))) ;; (defret true-listp-dims-of-vl-index-expr-type ;; (true-listp dims) ;; :rule-classes :type-prescription) ;; (defret len-dims-of-vl-index-expr-type ;; (implies (not err) ;; (equal (len dims) ;; (b* (((vl-index x))) ;; (+ (len x.indices) ;; (vl-partselect-case x.part :none 0 :otherwise 1) ;; (vl-hidexpr-index-count ;; (mv-nth 2 (vl-follow-scopeexpr x.scope ss)))))))) ;; (defret follow-scopeexpr-when-vl-index-expr-type ;; (implies (not err) ;; (b* (((vl-index x))) ;; (not (mv-nth 0 (vl-follow-scopeexpr x.scope ss))))))) #|| (trace$ #!vl (vl-index-find-type :entry (list 'vl-index-find-type (with-local-ps (vl-pp-expr x)) ;; (if (equal (vl-pps-expr x) "popcounts[30]") ;; (break$) ;; nil) ) :exit (cons 'vl-index-find-type (b* (((list warning type) values)) (list type (with-local-ps (if warning (vl-print-warnings (list warning)) (vl-ps-seq (vl-pp-datatype type) (vl-print " udims: ") (vl-pp-packeddimensionlist (vl-datatype->udims type)))))))))) ||# ;; (define vl-index-find-type ;; ((x vl-expr-p "Should be a hid (perhaps just an ID), perhaps with some indexing ;; operators applied to it, i.e., bitselect or index operators but ;; not part-select operators. So for instance: @('foo, foo.bar, ;; foo.bar[3], foo.bar[3][4][5]')") ;; (ss vl-scopestack-p "Scopestack where @('x') occurs.") ;; (ctx acl2::any-p)) ;; :returns (mv (err (iff (vl-msg-p err) err) ;; "Success indicator, we fail if we can't follow the HID or ;; this isn't an appropriate expression.") ;; (type (implies (not warning) (vl-datatype-p type)) ;; "The type of the resulting expression after all indexing ;; is done.")) ;; :prepwork ((local (in-theory (disable default-car ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :verify-guards nil ;; :measure (vl-expr-count x) ;; (b* ((x (vl-expr-fix x)) ;; ((when (or (vl-atom-p x) ;; (not (member (vl-nonatom->op x) ;; '(:vl-index :vl-bitselect))))) ;; (b* (((unless (vl-hidexpr-p x)) ;; (mv (make-vl-warning ;; :type :vl-bad-index-expr ;; :msg "~a0: An index operator was applied to a bad subexpression, ~a1." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning type) (vl-hidexpr-find-type x ss ctx)) ;; ((when warning) (mv warning nil))) ;; (mv nil type))) ;; ((vl-nonatom x)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; ((when (consp udims)) ;; ;; We could check here that the index is in bounds, but maybe that ;; ;; should more appropriately be done elsewhere. ;; (mv nil (vl-datatype-update-udims (cdr udims) sub-type))) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((when (consp pdims)) ;; ;; An index operator applied to packed dimensions makes the datatype unsigned. ;; (mv nil (vl-datatype-update-pdims (cdr pdims) (vl-datatype-set-unsigned sub-type)))) ;; ;; If there are no dimensions, the index has to be a bitselect; check ;; ;; whether this is ok. ;; ((when (vl-datatype-bitselect-ok sub-type)) ;; ;; We have a bitselect of some packed non-array type. The result is ;; ;; therefore an unsigned single bit. ;; (mv nil ;; (make-vl-coretype :name :vl-logic)))) ;; (mv (make-vl-warning :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because ~ ;; it has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; /// ;; (verify-guards vl-index-find-type ;; :hints(("Goal" :in-theory (e/d (acl2::member-of-cons) ;; (vl-index-find-type))))) ;; (defthm context-irrelevance-of-vl-index-find-type ;; (implies (syntaxp (not (equal ctx ''nil))) ;; (b* (((mv err1 type1) (vl-index-find-type x ss ctx)) ;; ((mv err2 type2) (vl-index-find-type x ss nil))) ;; (and (iff err1 err2) ;; (equal type1 type2)))))) ;; (define vl-partselect-type-top-dimension-replacement ((dim vl-packeddimension-p) ;; (x vl-expr-p) ;; (ctx vl-context-p)) ;; :guard-hints ((and stable-under-simplificationp ;; '(:in-theory (enable acl2::member-of-cons)))) ;; :guard (and (not (vl-atom-p x)) ;; (member (vl-nonatom->op x) ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (range (implies (not warning) (vl-range-p range)))) ;; (b* (((vl-nonatom x)) ;; (x (vl-expr-fix x)) ;; (dim (vl-packeddimension-fix dim)) ;; (ctx (vl-context-fix ctx)) ;; ((when (or (eq dim :vl-unsized-dimension) ;; (not (vl-range-resolved-p dim)))) ;; (mv (make-vl-warning :type :vl-partselect-type-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; most significant dimension of the type of ~ ;; ~a2 was unsized or non-constant." ;; :args (list ctx x (first x.args)) ;; :fn __function__) ;; nil)) ;; ((unless (and (vl-expr-resolved-p (third x.args)) ;; (or (not (member x.op '(:vl-partselect-colon ;; :vl-select-colon))) ;; (vl-expr-resolved-p (second x.args))))) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Couldn't find type of ~a1 because the ~ ;; partselect has non-constant indices." ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((when (member x.op '(:vl-select-colon :vl-partselect-colon))) ;; (mv nil (make-vl-range :msb (second x.args) :lsb (third x.args)))) ;; (width (vl-resolved->val (third x.args))) ;; ((unless (posp width)) ;; (mv (make-vl-warning :type :vl-partselect-indices-unresolved ;; :msg "~a0: Zero width in partselect operator?" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((unless (vl-expr-resolved-p (second x.args))) ;; (mv nil (make-vl-range :msb (vl-make-index (1- width)) :lsb (vl-make-index 0)))) ;; ;; The second argument is resolved, so set the range as specified. ;; (m-or-lsb (vl-resolved->val (second x.args))) ;; (backward-range-p (< (vl-resolved->val (vl-range->msb dim)) ;; (vl-resolved->val (vl-range->lsb dim)))) ;; (greater-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; (+ m-or-lsb width -1) ;; m-or-lsb)) ;; (lesser-idx (if (member x.op '(:vl-select-pluscolon :vl-partselect-pluscolon)) ;; m-or-lsb ;; (+ m-or-lsb (- width) 1))) ;; ((when (< lesser-idx 0)) ;; (mv (make-vl-warning :type :vl-partselect-index-error ;; :msg "~a0: Partselect ~s1 operator yields negative index: ~a2" ;; :args (list ctx (if (eq x.op :vl-partselect-pluscolon) ;; "+:" "-:") ;; x) ;; :fn __function__) ;; nil)) ;; (range (make-vl-range :msb (vl-make-index (if backward-range-p lesser-idx greater-idx)) ;; :lsb (vl-make-index (if backward-range-p greater-idx lesser-idx))))) ;; (mv nil range)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-type-top-dimension-replacement ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 1 (vl-partselect-type-top-dimension-replacement dim x nil))) ;; (iff (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x ctx)) ;; (mv-nth 0 (vl-partselect-type-top-dimension-replacement dim x nil))))))) ;; (define vl-partselect-expr-type ((x vl-expr-p) ;; (ss vl-scopestack-p) ;; (ctx vl-context-p "context")) ;; :guard (not (eq (vl-expr-kind x) :atom)) ;; :guard-hints (("goal" :in-theory (enable acl2::member-of-cons))) ;; :returns (mv (err (iff (vl-msg-p err) err)) ;; (type (implies (not warning) (vl-datatype-p type)))) ;; :prepwork ((local (in-theory (disable default-car default-cdr ;; vl-expr-resolved-p-of-car-when-vl-exprlist-resolved-p ;; vl-hidexpr-p-when-id-atom ;; vl-nonatom->op-when-vl-hidindex-p)))) ;; :measure (vl-expr-count x) ;; (b* ((ctx (vl-context-fix ctx)) ;; ((vl-nonatom x) (vl-expr-fix x)) ;; ((unless (member x.op ;; '(:vl-select-colon ;; :vl-select-pluscolon ;; :vl-select-minuscolon ;; :vl-partselect-colon ;; :vl-partselect-pluscolon ;; :vl-partselect-minuscolon))) ;; (mv (make-vl-warning :type :vl-programming-error ;; :msg "~a0: called vl-partselect-selfsize on non-partselect expr ~a1" ;; :args (list ctx x) ;; :fn __function__) ;; nil)) ;; ((mv warning sub-type) (vl-index-find-type (first x.args) ss ctx)) ;; ((when warning) (mv warning nil)) ;; (udims (vl-datatype->udims sub-type)) ;; (pdims (vl-datatype->pdims sub-type)) ;; ((unless (or (consp udims) (consp pdims))) ;; (b* (((unless (vl-datatype-bitselect-ok sub-type)) ;; (mv (make-vl-warning ;; :type :vl-bad-indexing-operator ;; :msg "~a0: Can't apply an index operator to ~a1 because it ~ ;; has no dimensions; its type is ~a2." ;; :args (list ctx (first x.args) sub-type) ;; :fn __function__) ;; nil)) ;; ((mv warning size) (vl-datatype-size sub-type)) ;; ((when warning) (mv warning nil)) ;; ;; The type is some packed thing, and we have its size. As long ;; ;; as the partselect is in range, we'll just return a new logic ;; ;; with the correct dimension on it. ;; (range (make-vl-range :msb (vl-make-index (1- size)) ;; :lsb (vl-make-index 0))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement range x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (make-vl-coretype :name :vl-logic ;; :pdims (list new-dim1)))) ;; (mv nil new-type))) ;; (dim1 (if (consp udims) (car udims) (car pdims))) ;; ((mv warning new-dim1) ;; (vl-partselect-type-top-dimension-replacement dim1 x ctx)) ;; ((when warning) (mv warning nil)) ;; (new-type (vl-datatype-update-dims ;; (if (consp udims) pdims (cons new-dim1 (cdr pdims))) ;; (and (consp udims) (cons new-dim1 (cdr udims))) ;; sub-type)) ;; ;; packed types become unsigned ;; (new-type (if (consp udims) new-type (vl-datatype-set-unsigned new-type)))) ;; (mv nil new-type)) ;; /// ;; (defthm context-irrelevance-of-vl-partselect-expr-type ;; (implies (syntaxp (not (equal ctx (list 'quote (with-guard-checking :none (vl-context-fix nil)))))) ;; (and (equal (mv-nth 1 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 1 (vl-partselect-expr-type x ss nil))) ;; (iff (mv-nth 0 (vl-partselect-expr-type x ss ctx)) ;; (mv-nth 0 (vl-partselect-expr-type x ss nil))))))) ;; 99% sure this is deprecated ;; (define vl-hid-range ;; :short "Try to look up a range for a HID, which may have been installed by ;; @(see vl-expr-follow-hids)." ;; ((x vl-expr-p "This should generally be the top-level HID expression.")) ;; :guard (not (vl-atom-p x)) ;; :returns (mv (successp booleanp :rule-classes :type-prescription) ;; (range vl-maybe-range-p ;; :hints(("Goal" :in-theory (disable (force)))))) ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; (mv nil nil)) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((when (and (not left) (not right))) ;; ;; It's resolved, there's just no range. ;; (mv t nil)) ;; ((unless (and left right)) ;; ;; Maybe this should be a programming error? ;; (mv nil nil)) ;; ;; Dumb hackery for unconditional return theorem ;; (left (mbe :logic (if (vl-expr-p left) ;; left ;; (vl-make-index 0)) ;; :exec left)) ;; (right (mbe :logic (if (vl-expr-p right) ;; right ;; (vl-make-index 0)) ;; :exec right)) ;; (range (make-vl-range :msb left :lsb right))) ;; (mv t range)) ;; /// ;; (defthm vl-hid-range-of-copy-atts ;; (equal (vl-hid-range (vl-nonatom op (vl-nonatom->atts x) args fw ft)) ;; (vl-hid-range x)))) ;; (define vl-hid-rangeatts ;; :short "Extend the attributes for a HID with range information." ;; ;; BOZO we should probably be using this in vl-expr-follow-hids. ;; ((range vl-maybe-range-p) ;; (atts vl-atts-p "the rest of the atts")) ;; :guard (vl-maybe-range-resolved-p range) ;; :returns (new-atts vl-atts-p) ;; (b* ((atts (vl-atts-fix atts)) ;; (atts (if range ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" (vl-range->msb range)) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" (vl-range->lsb range)) ;; atts) ;; (list* (cons "VL_HID_RESOLVED_RANGE_LEFT" nil) ;; (cons "VL_HID_RESOLVED_RANGE_RIGHT" nil) ;; atts)))) ;; (cons (list "VL_HID_RESOLVED_RANGE_P") atts)) ;; /// ;; (defthm vl-hid-range-of-vl-hid-rangeatts ;; (implies range ;; (equal (vl-hid-range (vl-nonatom op (vl-hid-rangeatts range atts) args fw ft)) ;; (mv t (vl-range-fix range)))) ;; :hints(("Goal" :in-theory (e/d (vl-hid-range)))))) ;; (define vl-hid-width ;; :short "Try to return the width of a HID, using range attribute information ;; that may have been installed by @(see vl-expr-follow-hids)." ;; ((x vl-expr-p)) ;; :guard (not (vl-atom-p x)) ;; :enabled t ;; :guard-hints (("goal" :in-theory (enable vl-hid-range ;; vl-maybe-range-resolved-p ;; vl-maybe-range-size ;; vl-range-resolved-p ;; vl-range-size ;; vl-width-from-difference ;; ))) ;; :returns (width maybe-posp :rule-classes :type-prescription) ;; (mbe :logic (b* (((mv ok range) (vl-hid-range x))) ;; (and ok ;; (vl-maybe-range-resolved-p range) ;; (vl-maybe-range-size range))) ;; :exec ;; (b* ((atts (vl-nonatom->atts x)) ;; ((unless (assoc-equal "VL_HID_RESOLVED_RANGE_P" atts)) ;; nil) ;; (left (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_LEFT" atts))) ;; (right (cdr (assoc-equal "VL_HID_RESOLVED_RANGE_RIGHT" atts))) ;; ((unless (or (and (not left) (not right)) ;; (and left (vl-expr-resolved-p left) ;; right (vl-expr-resolved-p right)))) ;; nil)) ;; (if left ;; (vl-width-from-difference ;; (- (vl-resolved->val left) (vl-resolved->val right))) ;; 1)))) (define vl-hidindex-resolved-p ((x vl-hidindex-p)) :returns (bool) :short "Determines if every index in a @(see vl-hidindex-p) is resolved." :measure (vl-expr-count x) (vl-exprlist-resolved-p (vl-hidindex->indices x)) ;; (b* (((when (vl-atom-p x)) ;; t) ;; ((vl-nonatom x) x)) ;; (and (mbt (eq x.op :vl-index)) ;; (vl-hidindex-resolved-p (first x.args)) ;; (vl-expr-resolved-p (second x.args)))) /// ;; (defthm vl-hidindex-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidindex-resolved-p x))) (deffixequiv vl-hidindex-resolved-p) ;; (defthm vl-hidindex-resolved-p-of-make-vl-nonatom ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-expr-resolved-p (second args)))) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :in-theory (e/d (vl-arity-fix) ((force))) ;; :expand ((:free (atts args finalwidth finaltype) ;; (vl-hidindex-resolved-p (make-vl-nonatom :op :vl-index ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))))))) ;; (defthmd vl-nonatom->op-when-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (equal (vl-nonatom->op x) :vl-index))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-expr-resolved-p-of-arg2-when-vl-hidindex-resolved-p ;; (implies (and (vl-hidindex-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-expr-resolved-p (second (vl-nonatom->args x))))) ) (define vl-hidexpr-resolved-p ((x vl-hidexpr-p)) ;; :prepwork ((local (in-theory (enable vl-nonatom->op-when-hidindex-resolved-p)))) :returns (bool) :short "Determines if every index throughout a @(see vl-hidexpr-p) is resolved." :guard-debug t :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end t :dot (and (vl-hidindex-resolved-p x.first) (vl-hidexpr-resolved-p x.rest))) /// (defthm vl-hidexpr-resolved-p-when-endp (implies (vl-hidexpr-case x :end) (vl-hidexpr-resolved-p x))) (defthm vl-hidexpr-resolved-p-of-vl-hidexpr-dot ;; Really I should be using something like a of-cons rule here, but without ;; a constructor... (equal (vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)) (and (vl-hidindex-resolved-p first) (vl-hidexpr-resolved-p rest))) :hints (("goal" :Expand ((vl-hidexpr-resolved-p (make-vl-hidexpr-dot :first first :rest rest)))))) (defthm vl-hidexpr-resolved-p-implies-dot (implies (and (vl-hidexpr-resolved-p x) (vl-hidexpr-case x :dot)) (and (vl-hidindex-resolved-p (vl-hidexpr-dot->first x)) (vl-hidexpr-resolved-p (vl-hidexpr-dot->rest x))))) ;; (defthm vl-hidexpr-resolved-p-when-atom ;; (implies (vl-atom-p x) ;; (vl-hidexpr-resolved-p x))) ;; (defthm vl-hidindex-resolved-p-of-arg1-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidindex-resolved-p (first (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-arg2-when-vl-hidexpr-resolved-p ;; (implies (and (vl-hidexpr-resolved-p x) ;; (force (not (vl-atom-p x)))) ;; (vl-hidexpr-resolved-p (second (vl-nonatom->args x))))) ;; (defthm vl-hidexpr-resolved-p-of-make-vl-nonatom-for-dot ;; (implies (and (force (vl-hidindex-resolved-p (first args))) ;; (force (vl-hidexpr-resolved-p (second args)))) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :hints(("Goal" ;; :expand (:free (atts args finalwidth finaltype) ;; (vl-hidexpr-resolved-p (make-vl-nonatom :op :vl-hid-dot ;; :args args ;; :atts atts ;; :finalwidth finalwidth ;; :finaltype finaltype))) ;; :in-theory (e/d (vl-arity-fix) ((force)))))) ) (define vl-scopeexpr-resolved-p ((x vl-scopeexpr-p)) :measure (vl-scopeexpr-count x) (vl-scopeexpr-case x :end (vl-hidexpr-resolved-p x.hid) :colon (vl-scopeexpr-resolved-p x.rest))) (define vl-flatten-hidindex-aux ((indices vl-exprlist-p) acc) :guard (vl-exprlist-resolved-p indices) :parents (vl-flatten-hidindex) :returns (new-acc character-listp :hyp (character-listp acc)) (b* (((when (atom indices)) acc) (acc (cons #\[ acc)) (acc (revappend (str::natchars (vl-resolved->val (car indices))) acc)) (acc (cons #\] acc))) (vl-flatten-hidindex-aux (cdr indices) acc))) (define vl-flatten-hidindex ((x vl-hidindex-p)) :guard (vl-hidindex-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a @(see vl-hidindex-p) into a string like @('\"bar[3][4][5]\"')." :measure (vl-expr-count x) :guard-hints(("Goal" :in-theory (enable vl-hidindex-resolved-p))) (b* ((name (vl-hidindex->name x)) (name (if (eq name :vl-$root) "$root" name)) (indices (vl-hidindex->indices x)) ((when (atom indices)) name) (acc nil) (acc (str::revappend-chars name acc)) (acc (vl-flatten-hidindex-aux indices acc))) (str::rchars-to-string acc))) (define vl-flatten-hidexpr ((x vl-hidexpr-p)) :guard (vl-hidexpr-resolved-p x) :returns (flat-string stringp :rule-classes :type-prescription) :short "Converts a hierarchical identifier expression into a string like @('foo.bar[3][4][5].baz')." :measure (vl-hidexpr-count x) (vl-hidexpr-case x :end x.name :dot (cat (vl-flatten-hidindex x.first) "." (vl-flatten-hidexpr x.rest)))) ;; (define vl-explode-hidindex ;; :short "Explode a (resolved) @(see vl-hidindex-p) into a flat list of ;; its components." ;; ((x vl-expr-p "The hidindex to explode, e.g., @('foo[3][4][5]')")) ;; :guard (and (vl-hidindex-p x) ;; (vl-hidindex-resolved-p x)) ;; :returns (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" 3 4 5)').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x) ;; (from (vl-explode-hidindex (first x.args))) ;; (idx (vl-resolved->val (second x.args)))) ;; (append from (list idx)))) ;; (define vl-explode-hid ;; :short "Explode a (resolved) @(see vl-hidexpr-p) into a flat list of its ;; components." ;; ((x vl-expr-p "The hidexpr to explode, e.g., foo.bar[2][3].baz.")) ;; :guard (and (vl-hidexpr-p x) ;; (vl-hidexpr-resolved-p x)) ;; :returns ;; (pieces true-listp :rule-classes :type-prescription ;; "A flat, mixed list of strings and numbers, e.g., ;; @('(\"foo\" \"bar\" 2 3 \"baz\")').") ;; :measure (vl-expr-count x) ;; (b* (((when (vl-atom-p x)) ;; (list (vl-hidname->name x))) ;; ((vl-nonatom x) x)) ;; (append (vl-explode-hidindex (first x.args)) ;; (vl-explode-hid (second x.args)))))
[ { "context": ";; Common Lisp Script\n;; Manoel Vilela\n\n(defun compose (&rest funs)\n (let ((funs (rever", "end": 38, "score": 0.999878466129303, "start": 25, "tag": "NAME", "value": "Manoel Vilela" } ]
random/compose.lisp
ryukinix/lisp-insights
11
;; Common Lisp Script ;; Manoel Vilela (defun compose (&rest funs) (let ((funs (reverse funs))) (lambda (&rest args) (loop with result = args for fun in funs do (setf result (list (apply fun result))) finally (return (car result)))))) (funcall (compose #'abs #'-) 1 2) #| ==> 1 |#
37215
;; Common Lisp Script ;; <NAME> (defun compose (&rest funs) (let ((funs (reverse funs))) (lambda (&rest args) (loop with result = args for fun in funs do (setf result (list (apply fun result))) finally (return (car result)))))) (funcall (compose #'abs #'-) 1 2) #| ==> 1 |#
true
;; Common Lisp Script ;; PI:NAME:<NAME>END_PI (defun compose (&rest funs) (let ((funs (reverse funs))) (lambda (&rest args) (loop with result = args for fun in funs do (setf result (list (apply fun result))) finally (return (car result)))))) (funcall (compose #'abs #'-) 1 2) #| ==> 1 |#
[ { "context": ":32:56 edi Exp $\n\n;;; Copyright (c) 2005-2008, Dr. Edmund Weitz. All rights reserved.\n\n;;; Redistribution and us", "end": 218, "score": 0.9998286366462708, "start": 206, "tag": "NAME", "value": "Edmund Weitz" } ]
books/quicklisp/bundle/software/flexi-streams-20200715-git/stream.lisp
mayankmanj/acl2
305
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- ;;; $Header: /usr/local/cvsrep/flexi-streams/stream.lisp,v 1.61 2008/05/19 22:32:56 edi Exp $ ;;; Copyright (c) 2005-2008, Dr. Edmund Weitz. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :flexi-streams) (defclass flexi-stream (trivial-gray-stream-mixin) ((stream :initarg :stream :reader flexi-stream-stream :documentation "The actual stream that's used for input and/or output. It must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE.") (external-format :initform (make-external-format :iso-8859-1) :initarg :flexi-stream-external-format :accessor flexi-stream-external-format :documentation "The encoding currently used by this stream. Can be changed on the fly.") (element-type :initform 'char* :initarg :element-type :accessor flexi-stream-element-type :documentation "The element type of this stream.")) (:documentation "A FLEXI-STREAM object is a stream that's `layered' atop an existing binary/bivalent stream in order to allow for multi-octet external formats. FLEXI-STREAM itself is a mixin and should not be instantiated.")) (defmethod initialize-instance :after ((flexi-stream flexi-stream) &rest initargs) "Makes sure the EXTERNAL-FORMAT and ELEMENT-TYPE slots contain reasonable values." (declare #.*standard-optimize-settings*) (declare (ignore initargs)) (with-accessors ((external-format flexi-stream-external-format) (element-type flexi-stream-element-type)) flexi-stream (unless (or (subtypep element-type 'character) (subtypep element-type 'octet)) (error 'flexi-stream-element-type-error :element-type element-type :stream flexi-stream)) (setq external-format (maybe-convert-external-format external-format)))) (defmethod (setf flexi-stream-external-format) :around (new-value (flexi-stream flexi-stream)) "Converts the new value to an EXTERNAL-FORMAT object if necessary." (declare #.*standard-optimize-settings*) (call-next-method (maybe-convert-external-format new-value) flexi-stream)) (defmethod (setf flexi-stream-element-type) :before (new-value (flexi-stream flexi-stream)) "Checks whether the new value makes sense before it is set." (declare #.*standard-optimize-settings*) (unless (or (subtypep new-value 'character) (type-equal new-value 'octet)) (error 'flexi-stream-element-type-error :element-type new-value :stream flexi-stream))) (defmethod stream-element-type ((stream flexi-stream)) "Returns the element type that was provided by the creator of the stream." (declare #.*standard-optimize-settings*) (with-accessors ((element-type flexi-stream-element-type)) stream element-type)) (defmethod close ((stream flexi-stream) &key abort) "Closes the flexi stream by closing the underlying `real' stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (cond ((open-stream-p stream) (close stream :abort abort)) (t nil)))) (defmethod open-stream-p ((stream flexi-stream)) "A flexi stream is open if its underlying stream is open." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (open-stream-p stream))) (defmethod stream-file-position ((stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (file-position stream))) (defmethod (setf stream-file-position) (position-spec (stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((underlying-stream flexi-stream-stream)) stream (if (file-position underlying-stream position-spec) (setf (flexi-stream-position stream) (file-position underlying-stream)) nil))) (defclass flexi-output-stream (flexi-stream fundamental-binary-output-stream fundamental-character-output-stream) ((column :initform 0 :accessor flexi-stream-column :documentation "The current output column. A non-negative integer or NIL.")) (:documentation "A FLEXI-OUTPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for output. Don't use MAKE-INSTANCE to create a new FLEXI-OUTPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-output-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-input-stream (flexi-stream fundamental-binary-input-stream fundamental-character-input-stream) ((last-char-code :initform nil :accessor flexi-stream-last-char-code :documentation "This slot either holds NIL or the last character \(code) read successfully. This is mainly used for UNREAD-CHAR sanity checks.") (last-octet :initform nil :accessor flexi-stream-last-octet :documentation "This slot either holds NIL or the last octet read successfully from the stream using a `binary' operation such as READ-BYTE. This is mainly used for UNREAD-BYTE sanity checks.") (octet-stack :initform nil :accessor flexi-stream-octet-stack :documentation "A small buffer which holds octets that were already read from the underlying stream but not yet used to produce characters. This is mainly used if we have to look ahead for a CR/LF line ending.") (position :initform 0 :initarg :position :type integer :accessor flexi-stream-position :documentation "The position within the stream where each octet read counts as one.") (bound :initform nil :initarg :bound :type (or null integer) :accessor flexi-stream-bound :documentation "When this is not NIL, it must be an integer and the stream will behave as if no more data is available as soon as POSITION is greater or equal than this value.")) (:documentation "A FLEXI-INPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input. Don't use MAKE-INSTANCE to create a new FLEXI-INPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod output-stream-p ((stream flexi-input-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-io-stream (flexi-input-stream flexi-output-stream) () (:documentation "A FLEXI-IO-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input and output. Don't use MAKE-INSTANCE to create a new FLEXI-IO-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) t) #+:cmu (defmethod output-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) t) (defun make-flexi-stream (stream &rest args &key (external-format (make-external-format :iso-8859-1)) element-type column position bound) "Creates and returns a new flexi stream. STREAM must be an open binary or `bivalent' stream, i.e. it must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE. The resulting flexi stream is an input stream if and only if STREAM is an input stream. Likewise, it's an output stream if and only if STREAM is an output stream. The default for ELEMENT-TYPE is LW:SIMPLE-CHAR on LispWorks and CHARACTER on other Lisps. EXTERNAL-FORMAT must be an EXTERNAL-FORMAT object or a symbol or a list denoting such an object. COLUMN is the initial column of the stream which is either a non-negative integer or NIL. The COLUMN argument must only be used for output streams. POSITION \(only used for input streams) should be an integer and it denotes the position the stream is in - it will be increased by one for each octet read. BOUND \(only used for input streams) should be NIL or an integer. If BOUND is not NIL and POSITION has gone beyond BOUND, then the stream will behave as if no more input is available." (declare #.*standard-optimize-settings*) ;; these arguments are ignored - they are only there to provide a ;; meaningful parameter list for IDEs (declare (ignore element-type column position bound)) (unless (and (streamp stream) (open-stream-p stream)) (error "~S should have been an open stream." stream)) (apply #'make-instance ;; actual type depends on STREAM (cond ((and (input-stream-p stream) (output-stream-p stream)) 'flexi-io-stream) ((input-stream-p stream) 'flexi-input-stream) ((output-stream-p stream) 'flexi-output-stream) (t (error "~S is neither an input nor an output stream." stream))) :stream stream :flexi-stream-external-format external-format (sans args :external-format)))
18910
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- ;;; $Header: /usr/local/cvsrep/flexi-streams/stream.lisp,v 1.61 2008/05/19 22:32:56 edi Exp $ ;;; Copyright (c) 2005-2008, Dr. <NAME>. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :flexi-streams) (defclass flexi-stream (trivial-gray-stream-mixin) ((stream :initarg :stream :reader flexi-stream-stream :documentation "The actual stream that's used for input and/or output. It must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE.") (external-format :initform (make-external-format :iso-8859-1) :initarg :flexi-stream-external-format :accessor flexi-stream-external-format :documentation "The encoding currently used by this stream. Can be changed on the fly.") (element-type :initform 'char* :initarg :element-type :accessor flexi-stream-element-type :documentation "The element type of this stream.")) (:documentation "A FLEXI-STREAM object is a stream that's `layered' atop an existing binary/bivalent stream in order to allow for multi-octet external formats. FLEXI-STREAM itself is a mixin and should not be instantiated.")) (defmethod initialize-instance :after ((flexi-stream flexi-stream) &rest initargs) "Makes sure the EXTERNAL-FORMAT and ELEMENT-TYPE slots contain reasonable values." (declare #.*standard-optimize-settings*) (declare (ignore initargs)) (with-accessors ((external-format flexi-stream-external-format) (element-type flexi-stream-element-type)) flexi-stream (unless (or (subtypep element-type 'character) (subtypep element-type 'octet)) (error 'flexi-stream-element-type-error :element-type element-type :stream flexi-stream)) (setq external-format (maybe-convert-external-format external-format)))) (defmethod (setf flexi-stream-external-format) :around (new-value (flexi-stream flexi-stream)) "Converts the new value to an EXTERNAL-FORMAT object if necessary." (declare #.*standard-optimize-settings*) (call-next-method (maybe-convert-external-format new-value) flexi-stream)) (defmethod (setf flexi-stream-element-type) :before (new-value (flexi-stream flexi-stream)) "Checks whether the new value makes sense before it is set." (declare #.*standard-optimize-settings*) (unless (or (subtypep new-value 'character) (type-equal new-value 'octet)) (error 'flexi-stream-element-type-error :element-type new-value :stream flexi-stream))) (defmethod stream-element-type ((stream flexi-stream)) "Returns the element type that was provided by the creator of the stream." (declare #.*standard-optimize-settings*) (with-accessors ((element-type flexi-stream-element-type)) stream element-type)) (defmethod close ((stream flexi-stream) &key abort) "Closes the flexi stream by closing the underlying `real' stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (cond ((open-stream-p stream) (close stream :abort abort)) (t nil)))) (defmethod open-stream-p ((stream flexi-stream)) "A flexi stream is open if its underlying stream is open." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (open-stream-p stream))) (defmethod stream-file-position ((stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (file-position stream))) (defmethod (setf stream-file-position) (position-spec (stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((underlying-stream flexi-stream-stream)) stream (if (file-position underlying-stream position-spec) (setf (flexi-stream-position stream) (file-position underlying-stream)) nil))) (defclass flexi-output-stream (flexi-stream fundamental-binary-output-stream fundamental-character-output-stream) ((column :initform 0 :accessor flexi-stream-column :documentation "The current output column. A non-negative integer or NIL.")) (:documentation "A FLEXI-OUTPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for output. Don't use MAKE-INSTANCE to create a new FLEXI-OUTPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-output-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-input-stream (flexi-stream fundamental-binary-input-stream fundamental-character-input-stream) ((last-char-code :initform nil :accessor flexi-stream-last-char-code :documentation "This slot either holds NIL or the last character \(code) read successfully. This is mainly used for UNREAD-CHAR sanity checks.") (last-octet :initform nil :accessor flexi-stream-last-octet :documentation "This slot either holds NIL or the last octet read successfully from the stream using a `binary' operation such as READ-BYTE. This is mainly used for UNREAD-BYTE sanity checks.") (octet-stack :initform nil :accessor flexi-stream-octet-stack :documentation "A small buffer which holds octets that were already read from the underlying stream but not yet used to produce characters. This is mainly used if we have to look ahead for a CR/LF line ending.") (position :initform 0 :initarg :position :type integer :accessor flexi-stream-position :documentation "The position within the stream where each octet read counts as one.") (bound :initform nil :initarg :bound :type (or null integer) :accessor flexi-stream-bound :documentation "When this is not NIL, it must be an integer and the stream will behave as if no more data is available as soon as POSITION is greater or equal than this value.")) (:documentation "A FLEXI-INPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input. Don't use MAKE-INSTANCE to create a new FLEXI-INPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod output-stream-p ((stream flexi-input-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-io-stream (flexi-input-stream flexi-output-stream) () (:documentation "A FLEXI-IO-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input and output. Don't use MAKE-INSTANCE to create a new FLEXI-IO-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) t) #+:cmu (defmethod output-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) t) (defun make-flexi-stream (stream &rest args &key (external-format (make-external-format :iso-8859-1)) element-type column position bound) "Creates and returns a new flexi stream. STREAM must be an open binary or `bivalent' stream, i.e. it must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE. The resulting flexi stream is an input stream if and only if STREAM is an input stream. Likewise, it's an output stream if and only if STREAM is an output stream. The default for ELEMENT-TYPE is LW:SIMPLE-CHAR on LispWorks and CHARACTER on other Lisps. EXTERNAL-FORMAT must be an EXTERNAL-FORMAT object or a symbol or a list denoting such an object. COLUMN is the initial column of the stream which is either a non-negative integer or NIL. The COLUMN argument must only be used for output streams. POSITION \(only used for input streams) should be an integer and it denotes the position the stream is in - it will be increased by one for each octet read. BOUND \(only used for input streams) should be NIL or an integer. If BOUND is not NIL and POSITION has gone beyond BOUND, then the stream will behave as if no more input is available." (declare #.*standard-optimize-settings*) ;; these arguments are ignored - they are only there to provide a ;; meaningful parameter list for IDEs (declare (ignore element-type column position bound)) (unless (and (streamp stream) (open-stream-p stream)) (error "~S should have been an open stream." stream)) (apply #'make-instance ;; actual type depends on STREAM (cond ((and (input-stream-p stream) (output-stream-p stream)) 'flexi-io-stream) ((input-stream-p stream) 'flexi-input-stream) ((output-stream-p stream) 'flexi-output-stream) (t (error "~S is neither an input nor an output stream." stream))) :stream stream :flexi-stream-external-format external-format (sans args :external-format)))
true
;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*- ;;; $Header: /usr/local/cvsrep/flexi-streams/stream.lisp,v 1.61 2008/05/19 22:32:56 edi Exp $ ;;; Copyright (c) 2005-2008, Dr. PI:NAME:<NAME>END_PI. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :flexi-streams) (defclass flexi-stream (trivial-gray-stream-mixin) ((stream :initarg :stream :reader flexi-stream-stream :documentation "The actual stream that's used for input and/or output. It must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE.") (external-format :initform (make-external-format :iso-8859-1) :initarg :flexi-stream-external-format :accessor flexi-stream-external-format :documentation "The encoding currently used by this stream. Can be changed on the fly.") (element-type :initform 'char* :initarg :element-type :accessor flexi-stream-element-type :documentation "The element type of this stream.")) (:documentation "A FLEXI-STREAM object is a stream that's `layered' atop an existing binary/bivalent stream in order to allow for multi-octet external formats. FLEXI-STREAM itself is a mixin and should not be instantiated.")) (defmethod initialize-instance :after ((flexi-stream flexi-stream) &rest initargs) "Makes sure the EXTERNAL-FORMAT and ELEMENT-TYPE slots contain reasonable values." (declare #.*standard-optimize-settings*) (declare (ignore initargs)) (with-accessors ((external-format flexi-stream-external-format) (element-type flexi-stream-element-type)) flexi-stream (unless (or (subtypep element-type 'character) (subtypep element-type 'octet)) (error 'flexi-stream-element-type-error :element-type element-type :stream flexi-stream)) (setq external-format (maybe-convert-external-format external-format)))) (defmethod (setf flexi-stream-external-format) :around (new-value (flexi-stream flexi-stream)) "Converts the new value to an EXTERNAL-FORMAT object if necessary." (declare #.*standard-optimize-settings*) (call-next-method (maybe-convert-external-format new-value) flexi-stream)) (defmethod (setf flexi-stream-element-type) :before (new-value (flexi-stream flexi-stream)) "Checks whether the new value makes sense before it is set." (declare #.*standard-optimize-settings*) (unless (or (subtypep new-value 'character) (type-equal new-value 'octet)) (error 'flexi-stream-element-type-error :element-type new-value :stream flexi-stream))) (defmethod stream-element-type ((stream flexi-stream)) "Returns the element type that was provided by the creator of the stream." (declare #.*standard-optimize-settings*) (with-accessors ((element-type flexi-stream-element-type)) stream element-type)) (defmethod close ((stream flexi-stream) &key abort) "Closes the flexi stream by closing the underlying `real' stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (cond ((open-stream-p stream) (close stream :abort abort)) (t nil)))) (defmethod open-stream-p ((stream flexi-stream)) "A flexi stream is open if its underlying stream is open." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (open-stream-p stream))) (defmethod stream-file-position ((stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((stream flexi-stream-stream)) stream (file-position stream))) (defmethod (setf stream-file-position) (position-spec (stream flexi-stream)) "Dispatch to method for underlying stream." (declare #.*standard-optimize-settings*) (with-accessors ((underlying-stream flexi-stream-stream)) stream (if (file-position underlying-stream position-spec) (setf (flexi-stream-position stream) (file-position underlying-stream)) nil))) (defclass flexi-output-stream (flexi-stream fundamental-binary-output-stream fundamental-character-output-stream) ((column :initform 0 :accessor flexi-stream-column :documentation "The current output column. A non-negative integer or NIL.")) (:documentation "A FLEXI-OUTPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for output. Don't use MAKE-INSTANCE to create a new FLEXI-OUTPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-output-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-input-stream (flexi-stream fundamental-binary-input-stream fundamental-character-input-stream) ((last-char-code :initform nil :accessor flexi-stream-last-char-code :documentation "This slot either holds NIL or the last character \(code) read successfully. This is mainly used for UNREAD-CHAR sanity checks.") (last-octet :initform nil :accessor flexi-stream-last-octet :documentation "This slot either holds NIL or the last octet read successfully from the stream using a `binary' operation such as READ-BYTE. This is mainly used for UNREAD-BYTE sanity checks.") (octet-stack :initform nil :accessor flexi-stream-octet-stack :documentation "A small buffer which holds octets that were already read from the underlying stream but not yet used to produce characters. This is mainly used if we have to look ahead for a CR/LF line ending.") (position :initform 0 :initarg :position :type integer :accessor flexi-stream-position :documentation "The position within the stream where each octet read counts as one.") (bound :initform nil :initarg :bound :type (or null integer) :accessor flexi-stream-bound :documentation "When this is not NIL, it must be an integer and the stream will behave as if no more data is available as soon as POSITION is greater or equal than this value.")) (:documentation "A FLEXI-INPUT-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input. Don't use MAKE-INSTANCE to create a new FLEXI-INPUT-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod output-stream-p ((stream flexi-input-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) nil) (defclass flexi-io-stream (flexi-input-stream flexi-output-stream) () (:documentation "A FLEXI-IO-STREAM is a FLEXI-STREAM that can actually be instatiated and used for input and output. Don't use MAKE-INSTANCE to create a new FLEXI-IO-STREAM but use MAKE-FLEXI-STREAM instead.")) #+:cmu (defmethod input-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an input stream." (declare #.*standard-optimize-settings*) t) #+:cmu (defmethod output-stream-p ((stream flexi-io-stream)) "Explicitly states whether this is an output stream." (declare #.*standard-optimize-settings*) t) (defun make-flexi-stream (stream &rest args &key (external-format (make-external-format :iso-8859-1)) element-type column position bound) "Creates and returns a new flexi stream. STREAM must be an open binary or `bivalent' stream, i.e. it must be capable of reading/writing octets with READ-SEQUENCE and/or WRITE-SEQUENCE. The resulting flexi stream is an input stream if and only if STREAM is an input stream. Likewise, it's an output stream if and only if STREAM is an output stream. The default for ELEMENT-TYPE is LW:SIMPLE-CHAR on LispWorks and CHARACTER on other Lisps. EXTERNAL-FORMAT must be an EXTERNAL-FORMAT object or a symbol or a list denoting such an object. COLUMN is the initial column of the stream which is either a non-negative integer or NIL. The COLUMN argument must only be used for output streams. POSITION \(only used for input streams) should be an integer and it denotes the position the stream is in - it will be increased by one for each octet read. BOUND \(only used for input streams) should be NIL or an integer. If BOUND is not NIL and POSITION has gone beyond BOUND, then the stream will behave as if no more input is available." (declare #.*standard-optimize-settings*) ;; these arguments are ignored - they are only there to provide a ;; meaningful parameter list for IDEs (declare (ignore element-type column position bound)) (unless (and (streamp stream) (open-stream-p stream)) (error "~S should have been an open stream." stream)) (apply #'make-instance ;; actual type depends on STREAM (cond ((and (input-stream-p stream) (output-stream-p stream)) 'flexi-io-stream) ((input-stream-p stream) 'flexi-input-stream) ((output-stream-p stream) 'flexi-output-stream) (t (error "~S is neither an input nor an output stream." stream))) :stream stream :flexi-stream-external-format external-format (sans args :external-format)))
[ { "context": "s a part of cl-gists project.\n Copyright (c) 2015 Rudolph Miller ([email protected])\n|#\n\n(defsystem \"cl", "end": 81, "score": 0.9998971819877625, "start": 67, "tag": "NAME", "value": "Rudolph Miller" }, { "context": "sts project.\n Copyright (c) 2015 Rudolph Miller ([email protected])\n|#\n\n(defsystem \"cl-gists-test\"\n :author \"Rudolp", "end": 111, "score": 0.9999331831932068, "start": 83, "tag": "EMAIL", "value": "[email protected]" }, { "context": "il.com)\n|#\n\n(defsystem \"cl-gists-test\"\n :author \"Rudolph Miller\"\n :license \"MIT\"\n :homepage \"https://github.com", "end": 169, "score": 0.9999003410339355, "start": 155, "tag": "NAME", "value": "Rudolph Miller" } ]
cl-gists-test.asd
Rudolph-Miller/cl-gists
13
#| This file is a part of cl-gists project. Copyright (c) 2015 Rudolph Miller ([email protected]) |# (defsystem "cl-gists-test" :author "Rudolph Miller" :license "MIT" :homepage "https://github.com/Rudolph-Miller/cl-gists" :depends-on ("cl-gists" "prove" "closer-mop") :components ((:module "t" :components ((:file "init") (:test-file "util") (:test-file "user") (:test-file "file") (:test-file "fork") (:test-file "history") (:test-file "gist") (:test-file "api") (:test-file "cl-gists")))) :description "Test system for cl-gists." :defsystem-depends-on ("prove-asdf") :perform (test-op (o c) (symbol-call :prove-asdf :run-test-system c)))
83946
#| This file is a part of cl-gists project. Copyright (c) 2015 <NAME> (<EMAIL>) |# (defsystem "cl-gists-test" :author "<NAME>" :license "MIT" :homepage "https://github.com/Rudolph-Miller/cl-gists" :depends-on ("cl-gists" "prove" "closer-mop") :components ((:module "t" :components ((:file "init") (:test-file "util") (:test-file "user") (:test-file "file") (:test-file "fork") (:test-file "history") (:test-file "gist") (:test-file "api") (:test-file "cl-gists")))) :description "Test system for cl-gists." :defsystem-depends-on ("prove-asdf") :perform (test-op (o c) (symbol-call :prove-asdf :run-test-system c)))
true
#| This file is a part of cl-gists project. Copyright (c) 2015 PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) |# (defsystem "cl-gists-test" :author "PI:NAME:<NAME>END_PI" :license "MIT" :homepage "https://github.com/Rudolph-Miller/cl-gists" :depends-on ("cl-gists" "prove" "closer-mop") :components ((:module "t" :components ((:file "init") (:test-file "util") (:test-file "user") (:test-file "file") (:test-file "fork") (:test-file "history") (:test-file "gist") (:test-file "api") (:test-file "cl-gists")))) :description "Test system for cl-gists." :defsystem-depends-on ("prove-asdf") :perform (test-op (o c) (symbol-call :prove-asdf :run-test-system c)))
[ { "context": "ail-recursive function\n;\n; Copyright (C) 2008-2011 Eric Smith and Stanford University\n; Copyright (C) 2013-2021", "end": 109, "score": 0.9994184970855713, "start": 99, "tag": "NAME", "value": "Eric Smith" }, { "context": "ense. See the file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;", "end": 320, "score": 0.9989984631538391, "start": 310, "tag": "NAME", "value": "Eric Smith" }, { "context": " file books/3BSD-mod.txt.\n;\n; Author: Eric Smith ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 344, "score": 0.9999306201934814, "start": 322, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/algorithm-theories/generic-tail-rec.lisp
mayankmanj/acl2
305
; A generic pattern for proving things about a tail-recursive function ; ; Copyright (C) 2008-2011 Eric Smith and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: Eric Smith ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; Postulate the existence of functions to: ;; - test whether we should exit the recursion ;; - update the params one step ;; - measure the params, for termination (encapsulate (((generic-tail-exitp *) => *) ((generic-tail-update *) => *) ((generic-tail-measure *) => *)) (local (defun generic-tail-exitp (params) (zp params))) (local (defun generic-tail-update (params) (+ -1 params))) (local (defun generic-tail-measure (params) (nfix params))) ;; The measure must always be an ordinal: (defthm o-p-of-generic-tail-measure (o-p (generic-tail-measure x))) ;; The measure must decrease when we update the params, assuming we do not ;; exit: (defthm generic-tail-rec-termination (implies (not (generic-tail-exitp params)) (o< (generic-tail-measure (generic-tail-update params)) (generic-tail-measure params))))) ;; Postulate the existence of a function that computes a return value from the ;; params, in the base case. (defstub generic-tail-base (params) t) ;; A generic tail recursive function: (defun generic-tail (params) (declare (xargs :measure (generic-tail-measure params))) (if (generic-tail-exitp params) (generic-tail-base params) (generic-tail (generic-tail-update params)))) ;; TODO: Make post take the params too. also the inv? ;; Postulate the existence of some postcondition and invariant: (encapsulate (((generic-tail-inv *)=> *) ((generic-tail-post *)=> *)) (local (defun generic-tail-inv (params) (declare (ignore params)) t)) (local (defun generic-tail-post (params) (declare (ignore params)) t)) ;;the update function must preserve the invariant, assuming we don't exit: (defthm generic-tail-inv-of-generic-tail-update (implies (and (generic-tail-inv params) (not (generic-tail-exitp params)) ;we get to assume we are not exiting ) (generic-tail-inv (generic-tail-update params)))) ;;the invariant must impliy the postcondition after we do the base case work, ;;assuming we exit: (defthm generic-tail-post-of-generic-tail-base (implies (and (generic-tail-inv params) (generic-tail-exitp params) ;we get to assume we are exiting ) (generic-tail-post (generic-tail-base params))))) ;; If the invariant is true of the initial params, then the postcondition is ;; true of the final value returned. Proved by induction. (defthm main (implies (generic-tail-inv params) (generic-tail-post (generic-tail params))))
14701
; A generic pattern for proving things about a tail-recursive function ; ; Copyright (C) 2008-2011 <NAME> and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; Postulate the existence of functions to: ;; - test whether we should exit the recursion ;; - update the params one step ;; - measure the params, for termination (encapsulate (((generic-tail-exitp *) => *) ((generic-tail-update *) => *) ((generic-tail-measure *) => *)) (local (defun generic-tail-exitp (params) (zp params))) (local (defun generic-tail-update (params) (+ -1 params))) (local (defun generic-tail-measure (params) (nfix params))) ;; The measure must always be an ordinal: (defthm o-p-of-generic-tail-measure (o-p (generic-tail-measure x))) ;; The measure must decrease when we update the params, assuming we do not ;; exit: (defthm generic-tail-rec-termination (implies (not (generic-tail-exitp params)) (o< (generic-tail-measure (generic-tail-update params)) (generic-tail-measure params))))) ;; Postulate the existence of a function that computes a return value from the ;; params, in the base case. (defstub generic-tail-base (params) t) ;; A generic tail recursive function: (defun generic-tail (params) (declare (xargs :measure (generic-tail-measure params))) (if (generic-tail-exitp params) (generic-tail-base params) (generic-tail (generic-tail-update params)))) ;; TODO: Make post take the params too. also the inv? ;; Postulate the existence of some postcondition and invariant: (encapsulate (((generic-tail-inv *)=> *) ((generic-tail-post *)=> *)) (local (defun generic-tail-inv (params) (declare (ignore params)) t)) (local (defun generic-tail-post (params) (declare (ignore params)) t)) ;;the update function must preserve the invariant, assuming we don't exit: (defthm generic-tail-inv-of-generic-tail-update (implies (and (generic-tail-inv params) (not (generic-tail-exitp params)) ;we get to assume we are not exiting ) (generic-tail-inv (generic-tail-update params)))) ;;the invariant must impliy the postcondition after we do the base case work, ;;assuming we exit: (defthm generic-tail-post-of-generic-tail-base (implies (and (generic-tail-inv params) (generic-tail-exitp params) ;we get to assume we are exiting ) (generic-tail-post (generic-tail-base params))))) ;; If the invariant is true of the initial params, then the postcondition is ;; true of the final value returned. Proved by induction. (defthm main (implies (generic-tail-inv params) (generic-tail-post (generic-tail params))))
true
; A generic pattern for proving things about a tail-recursive function ; ; Copyright (C) 2008-2011 PI:NAME:<NAME>END_PI and Stanford University ; Copyright (C) 2013-2021 Kestrel Institute ; Copyright (C) 2016-2020 Kestrel Technology, LLC ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; Postulate the existence of functions to: ;; - test whether we should exit the recursion ;; - update the params one step ;; - measure the params, for termination (encapsulate (((generic-tail-exitp *) => *) ((generic-tail-update *) => *) ((generic-tail-measure *) => *)) (local (defun generic-tail-exitp (params) (zp params))) (local (defun generic-tail-update (params) (+ -1 params))) (local (defun generic-tail-measure (params) (nfix params))) ;; The measure must always be an ordinal: (defthm o-p-of-generic-tail-measure (o-p (generic-tail-measure x))) ;; The measure must decrease when we update the params, assuming we do not ;; exit: (defthm generic-tail-rec-termination (implies (not (generic-tail-exitp params)) (o< (generic-tail-measure (generic-tail-update params)) (generic-tail-measure params))))) ;; Postulate the existence of a function that computes a return value from the ;; params, in the base case. (defstub generic-tail-base (params) t) ;; A generic tail recursive function: (defun generic-tail (params) (declare (xargs :measure (generic-tail-measure params))) (if (generic-tail-exitp params) (generic-tail-base params) (generic-tail (generic-tail-update params)))) ;; TODO: Make post take the params too. also the inv? ;; Postulate the existence of some postcondition and invariant: (encapsulate (((generic-tail-inv *)=> *) ((generic-tail-post *)=> *)) (local (defun generic-tail-inv (params) (declare (ignore params)) t)) (local (defun generic-tail-post (params) (declare (ignore params)) t)) ;;the update function must preserve the invariant, assuming we don't exit: (defthm generic-tail-inv-of-generic-tail-update (implies (and (generic-tail-inv params) (not (generic-tail-exitp params)) ;we get to assume we are not exiting ) (generic-tail-inv (generic-tail-update params)))) ;;the invariant must impliy the postcondition after we do the base case work, ;;assuming we exit: (defthm generic-tail-post-of-generic-tail-base (implies (and (generic-tail-inv params) (generic-tail-exitp params) ;we get to assume we are exiting ) (generic-tail-post (generic-tail-base params))))) ;; If the invariant is true of the initial params, then the postcondition is ;; true of the final value returned. Proved by induction. (defthm main (implies (generic-tail-inv params) (generic-tail-post (generic-tail params))))
[ { "context": ";; latex.lsp -- write latex file\n;;\n;; Roger B. Dannenberg\n;; March 2015\n\n(setf *lt-preamble* '(\n\"\\\\document", "end": 58, "score": 0.9998581409454346, "start": 39, "tag": "NAME", "value": "Roger B. Dannenberg" } ]
docsrc/s2h/latex.lsp
lxlxlo/nyquist-devel
0
;; latex.lsp -- write latex file ;; ;; Roger B. Dannenberg ;; March 2015 (setf *lt-preamble* '( "\\documentclass[11pt,]{report}" "\\setcounter{secnumdepth}{3}" "\\usepackage[T1]{fontenc}" "% \\usepackage{lmodern} -- results in texttt{AR} being too small!" "\\usepackage{amssymb,amsmath}" "\\usepackage{makeidx}" "\\makeindex" "\\usepackage{ifxetex,ifluatex}" "\\usepackage{fixltx2e} % provides \\textsubscript" "\\usepackage{mathptmx}% Times Roman font" "\\usepackage[scaled=.90]{helvet}% Helvetica, served as a model for arial" "\\usepackage[dvipsnames*,svgnames]{xcolor}" "\\usepackage{titlesec}" "\\usepackage{fancyvrb}" "\\DefineVerbatimEnvironment{verbatim}{Verbatim}{xleftmargin=.3in}" "\\usepackage{etoolbox}" "\\usepackage{graphicx}" "% patch for fancyvrb " "\\makeatletter " "\\patchcmd{\\FV@ListVSpace}{\\@topsepadd\\topsep}{}{}" "\\makeatother " "" "% patch for verbatim " "% \\makeatletter" "% \\preto{\\@verbatim}{\\topsep=0pt \\partopsep=0pt }" "% \\makeatother" "" "\\usepackage{alltt}" "\\usepackage{changepage}" "\\newenvironment{expl}{\\begin{adjustwidth}{0.4cm}{0cm}\\begin{minipage}{\\textwidth}\\begin{alltt}}" ; \\begin{adjustwidth}{0.4cm}{} ; \\end{adjustwidth}\\end{alltt}}" " {\\end{alltt}\\end{minipage}\\end{adjustwidth}}" "% \\newcommand{\\sectionbreak}{\\clearpage}" "\\usepackage{placeins}" "\\usepackage{needspace}" "\\usepackage[tocindentauto]{tocstyle}" "\\usepackage{enumitem}" "\\newenvironment{description2}" "{\\begin{description}[style=nextline,font=\\normalfont]}{\\end{description}}" "\\newenvironment{description3}" "{\\begin{description}[font=\\normalfont,noitemsep,nolistsep]}{\\end{description}}" "\\makeatletter " "%\\renewcommand{\\l@section}{\\@dottedtocline{1}{1.5em}{2.6em}}" "%\\renewcommand{\\l@subsection}{\\@dottedtocline{2}{4.0em}{3.6em}}" "%\\renewcommand{\\l@subsubsection}{\\@dottedtocline{3}{7.4em}{4.5em}}" "\\makeatother " "" "% use microtype if available" "\\IfFileExists{microtype.sty}{\\usepackage{microtype}}{}" "% use upquote if available, for straight quotes in verbatim environments" "\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}" "\\ifnum 0\\ifxetex 1\\fi\\ifluatex 1\\fi=0 % if pdftex" " \\usepackage[utf8]{inputenc}" "\\else % if luatex or xelatex" " \\usepackage{fontspec}" " \\ifxetex" " \\usepackage{xltxtra,xunicode}" " \\fi" " \\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}" " \\newcommand{\\euro}{€}" " \\setmainfont{Georgia}" " \\setsansfont{Arial}" " \\setmonofont{Lucida Console}" "\\fi" "" "\\usepackage[includeheadfoot,top=1in, bottom=1in, left=1in, right=1in]{geometry}" "" "\\usepackage{fancyhdr}" "\\pagestyle{fancy}" "\\pagenumbering{arabic}" )) (setf *lt-preamble2* '( "\\cfoot{}" "\\rfoot{\\thepage}" "" "\\ifxetex" " \\usepackage[setpagesize=false, % page size defined by xetex" " unicode=false, % unicode breaks when used with xetex" " xetex]{hyperref}" "\\else" " \\usepackage[unicode=true]{hyperref}" "\\fi" "\\hypersetup{breaklinks=true," " bookmarks=true," " pdfauthor={}," " pdftitle={}," " colorlinks=true," " urlcolor=blue," " linkcolor=magenta," " pdfborder={0 0 0}}" "\\setlength{\\parindent}{0pt}" "\\setlength{\\parskip}{6pt plus 2pt minus 1pt}" "\\setlength{\\emergencystretch}{3em} % prevent overfull lines" "" )) (setf *lt-preamble3* '( "" "%\\definecolor{sec-color}{gray}{0.4}" "%\\definecolor{subsec-color}{gray}{0.3}" "%\\definecolor{subsubsec-color}{gray}{0.25}" "" "" "\\titleformat{\\chapter}" " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}" "}" " {\\thechapter}{24pt}{}" "" "\\titleformat{\\section}" " {\\normalfont\\sffamily\\LARGE\\bfseries%\\color{MidnightBlue}" "}" " {\\thesection}{20pt}{}" "\\titleformat{\\subsection}" " {\\normalfont\\sffamily\\Large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsection}{16pt}{}" "\\titleformat{\\subsubsection}" " {\\normalfont\\sffamily\\large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsubsection}{14pt}{}" "" "\\begin{document}" "\\maketitle" "" "\\newpage" "" "{" "\\hypersetup{linkcolor=black}" "\\setcounter{tocdepth}{3}" "\\tableofcontents" "}" )) (defun write-lines (lines) (dolist (line lines) (princ line *ltoutf*) (terpri *ltoutf*))) ;; tells when preamble has been written, no other output until then (setf *lt-started* nil) (defun lt-title-info(title version author) (write-lines *lt-preamble*) (format *ltoutf* "\\lhead{\\itshape ~A}~%" title) (format *ltoutf* "\\chead{}~%\\rhead{\\itshape{\\nouppercase{\\leftmark}}}") (format *ltoutf* "\\lfoot{v ~A}~%" version) ; e.g. "3.10" (write-lines *lt-preamble2*) (format *ltoutf* "\\title{\\Huge{\\textbf{~A}}}~%" title) (format *ltoutf* "\\author{\\textbf{\\normalsize{Version ~A}}}~%" version) (format *ltoutf* "\\date{\\textbf{\\large{~A}}\\\\~ \\vspace{1 in}\\today\\\\~ \\vspace{2 in}Carnegie Mellon University\\\\~ \\vspace{10 pt}School of Computer Science\\\\~ \\vspace{10 pt}Pittsburgh, PA 15213, U.S.A.}~%" author) (write-lines *lt-preamble3*) (setf *lt-started* t)) (defun lt-end () (format *ltoutf* "}")) (defun lt-begin-code () (setf *font-is-tt* t) (if (or *html* *omit*) nil (format *ltoutf* "\\texttt{"))) (defun lt-end-code () (setf *font-is-tt nil) (if (or *html* *omit*) nil (format *ltoutf* "}"))) (defun lt-begin-quotation () (format *ltoutf* "\\quotation{")) (setfn lt-end-quotation lt-end) (defun lt-begin-example () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{expl}"))) (defun lt-end-example () (if (or *html* *omit*) nil (format *ltoutf* "\\end{expl}"))) (defun lt-begin-enumerate () (format *ltoutf* "\\begin{enumerate}\\item ~%")) (defun lt-end-enumerate () (format *ltoutf* "\\end{enumerate}")) (defun lt-begin-itemize () (format *ltoutf* "\\begin{itemize}~%\\item ")) (defun lt-list-paragraph () (format *ltoutf* "~%\\item~%")) (defun lt-end-itemize () (format *ltoutf* "\\end{itemize}")) (defun lt-begin-normal () (format *ltoutf* "{\\fontfamily{cmr}\\selectfont ")) (setfn lt-end-normal lt-end) (defun latex-escape (str) (let (s cs) ;; s will accumulate escaped chars of str (dotimes (i (length str)) ;; map each char of str into an escaped version (setf cs (assoc (char str i) '((#\% "\\%") (#\& "\\&") (#\\ "\\textbackslash{}") (#\$ "\\$") (#\# "\\#") (#\_ "\\_") (#\{ "\\{") (#\} "\\}") (#\[ "{[}") (#\] "{]}") (#\^ "\\textasciicircum{}") (#\~ "\\textasciitilde{}")))) ;; if no substitute found, use original converted to a string (setf cs (if cs (second cs) (string (char str i)))) (setf s (cons cs s))) (apply #'strcat (reverse s)))) (defun lt-write-index (str) (format *ltoutf* "\\index{~A}" (latex-escape str))) (defun lt-write-indexsecondary (str n) (format *ltoutf* "\\index{~A!~A}" (latex-escape (get-primary str)) (latex-escape (get-secondary str)))) (defun lt-linebreak (source) (if *s2h-dbg* (display "lt-linebreak" *line-empty* *fdescription* *pdescription*)) (cond ((and *fdescription* (not *pdescription*) (not (eq source 'write-blankspace))) (display "lt-linebreak in fdesc" source) (break "lt-linebreak in fdescription")) (*pdescription* nil) ((not *line-empty*) (setf *line-empty* t) (format *ltoutf* "\\\\")) (t (display "lt-linebreak when" *line-empty*) (format *ltoutf* "\\hspace*{1em} \\\\")))) (defun lt-write-cite (link) (format *ltoutf* "\\cite{~A}" (car link))) (defun lt-write-label (sym) (format *ltoutf* "\\label{~A}" sym)) (defun lt-write-ref (ref tok) (cond ((eq tok 'ref) (format *ltoutf* "\\ref{~A}" (car ref))) ((eq tok 'pageref) (format *ltoutf* "\\pageref{~A}" (car ref))) (t (break "lt-write-ref got bad tok argument")))) (defun style-to-latex (style) (cond ((equal style "b") "textbf") ((equal style "i") "textit") (t style))) (defun lt-begin-style (style) (format *ltoutf* "\\~A{" (style-to-latex style))) (defun lt-end-style (style) (lt-end)) (defun lt-begin-bold-italic () (format *ltoutf* "\\textbf{\\textit{")) (defun lt-end-bold-italic () (format *ltoutf* "}}")) (defun lt-begin-underline () (format *ltoutf* "\\underline{")) (setfn lt-end-underline lt-end) (defun lt-begin-write-dd () (format *ltoutf* "<begin dd>")) (defun lt-end-write-dd () (format *ltoutf* "<end dd>")) (defun lt-write-dd () ; (format *ltoutf* "<lt-write-dd>") (cond (*description-item-is-open* (if *token-trace* (format t "LT-WRITE-DD:CLOSE")) (setf *skip-white-space* nil) (setf *description-item-is-open* nil)) (t (break "lt-write-dd: *description-item-is-open* is false - were closing a description term, but there was no term to begin with. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "]")) (defun lt-break-dt () (if (not *description-item-is-open*) (break "lt-break-dt: *description-item-is-open* is false")) (setf *description-item-is-open* nil) (setf *skip-white-space* nil) (format *ltoutf* "]")) (defun write-fdescription-item () ; (let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *fdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) (defun write-pdescription-item () ;(let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *pdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) ;; write "-" unless this is an @itemsep, which gets "--" (defun lt-dash (tok) ; (cond ((and *pdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-pdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM CALLED ~A ~A " ;; *fdescription-item-capture* tok) ;(cond ((and *fdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-fdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM RETURNED ~A ~A " ;; *fdescription-item-capture* tok) (format *ltoutf* "~A" (if (eq tok 'itemsep) "--" "-"))) (defun lt-blankspace-in-fdescription () (setf *line-empty* t) (if *html* (break)) (format *ltoutf* "~%")) (defun lt-begin-detail () (format *ltoutf* "\\small{")) (setfn lt-end-detail lt-end) (defun lt-begin-write-description () (setf *description-item-is-open* t) (setf *skip-white-space* t) (if *token-trace* (format t "LT-BEGIN-WRITE-DESCRIPTION:OPEN")) (format *ltoutf* "\\begin{description2}~%") (needspace 3) (format *ltoutf* "\\item[")) (defun lt-end-write-description () (cond (*description-item-is-open* (break "lt-end-write-description: *description-item-is-open* indicates we are expecting a description term and description. Probably there is a blank line before @end(description) in the source file, or maybe there is a missing @\\ to mark the description. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "\\end{description2}")) (defun lt-description-paragraph () (cond (*description-item-is-open* (format *ltoutf* "]"))) (setf *description-item-is-open* t) (setf *skip-white-space* t) (format *ltoutf* "~%") (needspace 3) (format *ltoutf* "\\item[")) ;; string-stream captures items in fdescription or pdescription: (setf *save-ltoutf* nil) (defun take-to (str marker) (let ((loc (string-search marker str))) (cond ((not loc) (setf *rslt* nil) str) (t (setf *rslt* (subseq str 0 loc)) (subseq str (+ loc (length marker))))))) (defun trim (s) (string-trim " \t\n" s)) ;; remove all \\ latex line breaks from end of string: (defun remove-breaks (s) (if (and (>= (length s) 2) (equal "\\\\" (subseq s (- (length s) 2)))) (remove-breaks (subseq s 0 (- (length s) 2))) s)) (defun newlines-to-break (s) (let ((loc (string-search "\n\n" s))) (if loc (strcat (trim (subseq s 0 loc)) "\\\\" (trim (subseq s (+ 2 loc)))) s))) ;; anything not inside <!BEGIN-PDESC> <!END-PDESC> goes into item ;; first get the strings separated by <!BEGIN-*> <!END-*> <!BREAK-*> ;; mark them as FDESC or PDESC, finally generate output ;; (setf showcount 0) (defun lt-fdescription (body) (prog (lines line (pdlevel 0)) ;; pdlevel = nesting level for pdescription ; (cond ((string-search "let*" body) ; (setf showcount 1) ; (print "------------------------------------------------------------") ; (print body) ; (print "------------------------------------------------------------"))) (format *ltoutf* "\\begin{description2}~%") loop1 (setf body (take-to body "<!")) (cond (*rslt* (setf line (remove-breaks (trim *rslt*))) (if (> showcount 0) (display "lt-fdesc before ntb" line)) (if (= pdlevel 0) (setf line (newlines-to-break line))) (if (> showcount 0) (display "lt-fdesc after ntb" line)) (cond ((> (length line) 0) (push (list pdlevel line) lines) ; (if (> pdlevel 1) (print (list pdlevel line))) )) (setf body (take-to body ">")) (if (equal *rslt* "BEGIN-PDESC") (setf pdlevel (1+ pdlevel))) (if (equal *rslt* "END-PDESC") (setf pdlevel (1- pdlevel))) (go loop1) )) (setf lines (reverse lines)) ;; now we have ((pdlevel "line1") (pdlevel "line2") (pdlevel "line3") ...) (if (<= 0 (decf showcount)) (dolist (x lines) (format t "~A~%" x))) ;; collect FDESC (pdlevel == 0) lines as an item (while lines (format *ltoutf* "\\item[~A" (cadar lines)) (setf lines (rest lines)) (while (and lines (eql 0 (caar lines))) (format *ltoutf* "\\\\~%~A" (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "]~%") (cond ((and lines (/= 0 (caar lines))) (format *ltoutf* "~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines)) (while (and lines (/= 0 (caar lines))) (format *ltoutf* "\\\\~%~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "~%")))) (format *ltoutf* "\\end{description2}~%"))) (defun lt-begin-write-fdescription () (cond ((not *save-ltoutf*) (setf *save-ltoutf* *ltoutf*) (setf *ltoutf* (make-string-output-stream))))) (defun lt-end-write-fdescription () (let ((body (get-output-stream-string *ltoutf*))) (cond ((not *fdescription*) (setf *ltoutf* *save-ltoutf*) (setf *save-ltoutf* nil) (lt-fdescription body))))) (defun lt-begin-write-pdescription () (format *ltoutf* "<!BEGIN-PDESC>") nil) (defun lt-end-write-pdescription () (format *ltoutf* "<!END-PDESC>") nil) (defun lt-fdescription-break () (format *ltoutf* "<!BREAK-FDESC>") nil) (defun lt-pdescription-break () (format *ltoutf* "<!BREAK-PDESC>") nil) (defun lt-begin-write-format () (format *ltoutf* "<begin format>")) (defun lt-end-write-format () (format *ltoutf* "<end format>")) (defun lt-begin-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{quote}"))) (defun lt-end-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\end{quote}"))) (defun lt-begin-center () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{center}"))) (defun lt-end-center () (if (or *html* *omit*) nil (format *ltoutf* "\\end{center}"))) (defun lt-begin-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{figure}~%"))) (defun lt-end-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\end{figure}~%"))) (defun lt-label (name) (if (or *html* *omit*) nil (format *ltoutf* "\\label{~A}~%" name))) (defun lt-write-footnote (name number) (format *ltoutf* "\\footnote{")) (defun lt-footnote-end () (format *ltoutf* "}")) (defun lt-write-fillcaption (n) (if (or *html* *omit*) nil (format *ltoutf* "\\caption{"))) (defun lt-end-fillcaption () (if (or *html* *omit*) nil (format *ltoutf* "}"))) ;; this is what starts generating output, including the ;; Latex preamble ;; (defun lt-majorheading (title) (lt-title-info title *doc-version* *doc-author*)) (defun lt-write-chapter (body numbered) (setf *line-empty* t) (format *ltoutf* "\\chapter~A{~A}~%" (if numbered "" "*") (latex-escape body))) (defun lt-finish-chapter () (setf *line-empty* t) ; (format *ltoutf* "~%<chapter finish>~%") ) (defun lt-begin-h2 () (format *ltoutf* "\\section{")) (setfn lt-end-h2 lt-end) (defun lt-begin-h3 () (format *ltoutf* "\\subsection{")) (setfn lt-end-h3 lt-end) (defun lt-begin-h4 () (format *ltoutf* "\\subsubsection{")) (setfn lt-end-h4 lt-end) (defun lt-begin-superscript () (format *ltoutf* "\\textsuperscript{")) (defun lt-end-superscript () (format *ltoutf* "}")) (defun lt-begin-subscript () (format *ltoutf* "\\textsubscript{")) (defun lt-end-subscript () (format *ltoutf* "}")) (defun lt-paragraph () (if *html* (break)) (terpri *ltoutf*) (terpri *ltoutf*)) (defun needspace (n) (cond ((<= skip-count 0) (format *ltoutf* "\\needspace{~A\\baselineskip}~%" n) (setf skip-count n)))) (defun lt-write-paragraph (name-number body) (needspace 3) (format *ltoutf* "\\subsubsection{~A}" (latex-escape body))) (defun lt-write-subsection (name-number body) (needspace 3) (format *ltoutf* "\\subsection{~A}" (latex-escape body))) (defun lt-write-section (name-number body) (needspace 4) (format *ltoutf* "\\section{~A}" (latex-escape body))) (setf *lt-started-appendices* nil) (defun lt-appendix (name-number body) (cond ((not *lt-started-appendices*) (setf *lt-started-appendices* t) (format *ltoutf* "\\appendix~%") (format *ltoutf* "\\renewcommand{\\thechapter}{\\Alph{chapter}}~%") (format *ltoutf* "\\titleformat{\\chapter}~%") (format *ltoutf* " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}~%") (format *ltoutf* "}~%") (format *ltoutf* " {Appendix \\thechapter}{24pt}{}~%"))) (format *ltoutf* "\\chapter{~A}" (latex-escape body))) (defun lt-end-document () (setf *line-empty* t) (format *ltoutf* "\\clearpage~%\\addcontentsline{toc}{chapter}{Index}~%") (format *ltoutf* "\\printindex~%\\end{document}~%"))
59683
;; latex.lsp -- write latex file ;; ;; <NAME> ;; March 2015 (setf *lt-preamble* '( "\\documentclass[11pt,]{report}" "\\setcounter{secnumdepth}{3}" "\\usepackage[T1]{fontenc}" "% \\usepackage{lmodern} -- results in texttt{AR} being too small!" "\\usepackage{amssymb,amsmath}" "\\usepackage{makeidx}" "\\makeindex" "\\usepackage{ifxetex,ifluatex}" "\\usepackage{fixltx2e} % provides \\textsubscript" "\\usepackage{mathptmx}% Times Roman font" "\\usepackage[scaled=.90]{helvet}% Helvetica, served as a model for arial" "\\usepackage[dvipsnames*,svgnames]{xcolor}" "\\usepackage{titlesec}" "\\usepackage{fancyvrb}" "\\DefineVerbatimEnvironment{verbatim}{Verbatim}{xleftmargin=.3in}" "\\usepackage{etoolbox}" "\\usepackage{graphicx}" "% patch for fancyvrb " "\\makeatletter " "\\patchcmd{\\FV@ListVSpace}{\\@topsepadd\\topsep}{}{}" "\\makeatother " "" "% patch for verbatim " "% \\makeatletter" "% \\preto{\\@verbatim}{\\topsep=0pt \\partopsep=0pt }" "% \\makeatother" "" "\\usepackage{alltt}" "\\usepackage{changepage}" "\\newenvironment{expl}{\\begin{adjustwidth}{0.4cm}{0cm}\\begin{minipage}{\\textwidth}\\begin{alltt}}" ; \\begin{adjustwidth}{0.4cm}{} ; \\end{adjustwidth}\\end{alltt}}" " {\\end{alltt}\\end{minipage}\\end{adjustwidth}}" "% \\newcommand{\\sectionbreak}{\\clearpage}" "\\usepackage{placeins}" "\\usepackage{needspace}" "\\usepackage[tocindentauto]{tocstyle}" "\\usepackage{enumitem}" "\\newenvironment{description2}" "{\\begin{description}[style=nextline,font=\\normalfont]}{\\end{description}}" "\\newenvironment{description3}" "{\\begin{description}[font=\\normalfont,noitemsep,nolistsep]}{\\end{description}}" "\\makeatletter " "%\\renewcommand{\\l@section}{\\@dottedtocline{1}{1.5em}{2.6em}}" "%\\renewcommand{\\l@subsection}{\\@dottedtocline{2}{4.0em}{3.6em}}" "%\\renewcommand{\\l@subsubsection}{\\@dottedtocline{3}{7.4em}{4.5em}}" "\\makeatother " "" "% use microtype if available" "\\IfFileExists{microtype.sty}{\\usepackage{microtype}}{}" "% use upquote if available, for straight quotes in verbatim environments" "\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}" "\\ifnum 0\\ifxetex 1\\fi\\ifluatex 1\\fi=0 % if pdftex" " \\usepackage[utf8]{inputenc}" "\\else % if luatex or xelatex" " \\usepackage{fontspec}" " \\ifxetex" " \\usepackage{xltxtra,xunicode}" " \\fi" " \\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}" " \\newcommand{\\euro}{€}" " \\setmainfont{Georgia}" " \\setsansfont{Arial}" " \\setmonofont{Lucida Console}" "\\fi" "" "\\usepackage[includeheadfoot,top=1in, bottom=1in, left=1in, right=1in]{geometry}" "" "\\usepackage{fancyhdr}" "\\pagestyle{fancy}" "\\pagenumbering{arabic}" )) (setf *lt-preamble2* '( "\\cfoot{}" "\\rfoot{\\thepage}" "" "\\ifxetex" " \\usepackage[setpagesize=false, % page size defined by xetex" " unicode=false, % unicode breaks when used with xetex" " xetex]{hyperref}" "\\else" " \\usepackage[unicode=true]{hyperref}" "\\fi" "\\hypersetup{breaklinks=true," " bookmarks=true," " pdfauthor={}," " pdftitle={}," " colorlinks=true," " urlcolor=blue," " linkcolor=magenta," " pdfborder={0 0 0}}" "\\setlength{\\parindent}{0pt}" "\\setlength{\\parskip}{6pt plus 2pt minus 1pt}" "\\setlength{\\emergencystretch}{3em} % prevent overfull lines" "" )) (setf *lt-preamble3* '( "" "%\\definecolor{sec-color}{gray}{0.4}" "%\\definecolor{subsec-color}{gray}{0.3}" "%\\definecolor{subsubsec-color}{gray}{0.25}" "" "" "\\titleformat{\\chapter}" " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}" "}" " {\\thechapter}{24pt}{}" "" "\\titleformat{\\section}" " {\\normalfont\\sffamily\\LARGE\\bfseries%\\color{MidnightBlue}" "}" " {\\thesection}{20pt}{}" "\\titleformat{\\subsection}" " {\\normalfont\\sffamily\\Large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsection}{16pt}{}" "\\titleformat{\\subsubsection}" " {\\normalfont\\sffamily\\large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsubsection}{14pt}{}" "" "\\begin{document}" "\\maketitle" "" "\\newpage" "" "{" "\\hypersetup{linkcolor=black}" "\\setcounter{tocdepth}{3}" "\\tableofcontents" "}" )) (defun write-lines (lines) (dolist (line lines) (princ line *ltoutf*) (terpri *ltoutf*))) ;; tells when preamble has been written, no other output until then (setf *lt-started* nil) (defun lt-title-info(title version author) (write-lines *lt-preamble*) (format *ltoutf* "\\lhead{\\itshape ~A}~%" title) (format *ltoutf* "\\chead{}~%\\rhead{\\itshape{\\nouppercase{\\leftmark}}}") (format *ltoutf* "\\lfoot{v ~A}~%" version) ; e.g. "3.10" (write-lines *lt-preamble2*) (format *ltoutf* "\\title{\\Huge{\\textbf{~A}}}~%" title) (format *ltoutf* "\\author{\\textbf{\\normalsize{Version ~A}}}~%" version) (format *ltoutf* "\\date{\\textbf{\\large{~A}}\\\\~ \\vspace{1 in}\\today\\\\~ \\vspace{2 in}Carnegie Mellon University\\\\~ \\vspace{10 pt}School of Computer Science\\\\~ \\vspace{10 pt}Pittsburgh, PA 15213, U.S.A.}~%" author) (write-lines *lt-preamble3*) (setf *lt-started* t)) (defun lt-end () (format *ltoutf* "}")) (defun lt-begin-code () (setf *font-is-tt* t) (if (or *html* *omit*) nil (format *ltoutf* "\\texttt{"))) (defun lt-end-code () (setf *font-is-tt nil) (if (or *html* *omit*) nil (format *ltoutf* "}"))) (defun lt-begin-quotation () (format *ltoutf* "\\quotation{")) (setfn lt-end-quotation lt-end) (defun lt-begin-example () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{expl}"))) (defun lt-end-example () (if (or *html* *omit*) nil (format *ltoutf* "\\end{expl}"))) (defun lt-begin-enumerate () (format *ltoutf* "\\begin{enumerate}\\item ~%")) (defun lt-end-enumerate () (format *ltoutf* "\\end{enumerate}")) (defun lt-begin-itemize () (format *ltoutf* "\\begin{itemize}~%\\item ")) (defun lt-list-paragraph () (format *ltoutf* "~%\\item~%")) (defun lt-end-itemize () (format *ltoutf* "\\end{itemize}")) (defun lt-begin-normal () (format *ltoutf* "{\\fontfamily{cmr}\\selectfont ")) (setfn lt-end-normal lt-end) (defun latex-escape (str) (let (s cs) ;; s will accumulate escaped chars of str (dotimes (i (length str)) ;; map each char of str into an escaped version (setf cs (assoc (char str i) '((#\% "\\%") (#\& "\\&") (#\\ "\\textbackslash{}") (#\$ "\\$") (#\# "\\#") (#\_ "\\_") (#\{ "\\{") (#\} "\\}") (#\[ "{[}") (#\] "{]}") (#\^ "\\textasciicircum{}") (#\~ "\\textasciitilde{}")))) ;; if no substitute found, use original converted to a string (setf cs (if cs (second cs) (string (char str i)))) (setf s (cons cs s))) (apply #'strcat (reverse s)))) (defun lt-write-index (str) (format *ltoutf* "\\index{~A}" (latex-escape str))) (defun lt-write-indexsecondary (str n) (format *ltoutf* "\\index{~A!~A}" (latex-escape (get-primary str)) (latex-escape (get-secondary str)))) (defun lt-linebreak (source) (if *s2h-dbg* (display "lt-linebreak" *line-empty* *fdescription* *pdescription*)) (cond ((and *fdescription* (not *pdescription*) (not (eq source 'write-blankspace))) (display "lt-linebreak in fdesc" source) (break "lt-linebreak in fdescription")) (*pdescription* nil) ((not *line-empty*) (setf *line-empty* t) (format *ltoutf* "\\\\")) (t (display "lt-linebreak when" *line-empty*) (format *ltoutf* "\\hspace*{1em} \\\\")))) (defun lt-write-cite (link) (format *ltoutf* "\\cite{~A}" (car link))) (defun lt-write-label (sym) (format *ltoutf* "\\label{~A}" sym)) (defun lt-write-ref (ref tok) (cond ((eq tok 'ref) (format *ltoutf* "\\ref{~A}" (car ref))) ((eq tok 'pageref) (format *ltoutf* "\\pageref{~A}" (car ref))) (t (break "lt-write-ref got bad tok argument")))) (defun style-to-latex (style) (cond ((equal style "b") "textbf") ((equal style "i") "textit") (t style))) (defun lt-begin-style (style) (format *ltoutf* "\\~A{" (style-to-latex style))) (defun lt-end-style (style) (lt-end)) (defun lt-begin-bold-italic () (format *ltoutf* "\\textbf{\\textit{")) (defun lt-end-bold-italic () (format *ltoutf* "}}")) (defun lt-begin-underline () (format *ltoutf* "\\underline{")) (setfn lt-end-underline lt-end) (defun lt-begin-write-dd () (format *ltoutf* "<begin dd>")) (defun lt-end-write-dd () (format *ltoutf* "<end dd>")) (defun lt-write-dd () ; (format *ltoutf* "<lt-write-dd>") (cond (*description-item-is-open* (if *token-trace* (format t "LT-WRITE-DD:CLOSE")) (setf *skip-white-space* nil) (setf *description-item-is-open* nil)) (t (break "lt-write-dd: *description-item-is-open* is false - were closing a description term, but there was no term to begin with. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "]")) (defun lt-break-dt () (if (not *description-item-is-open*) (break "lt-break-dt: *description-item-is-open* is false")) (setf *description-item-is-open* nil) (setf *skip-white-space* nil) (format *ltoutf* "]")) (defun write-fdescription-item () ; (let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *fdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) (defun write-pdescription-item () ;(let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *pdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) ;; write "-" unless this is an @itemsep, which gets "--" (defun lt-dash (tok) ; (cond ((and *pdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-pdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM CALLED ~A ~A " ;; *fdescription-item-capture* tok) ;(cond ((and *fdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-fdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM RETURNED ~A ~A " ;; *fdescription-item-capture* tok) (format *ltoutf* "~A" (if (eq tok 'itemsep) "--" "-"))) (defun lt-blankspace-in-fdescription () (setf *line-empty* t) (if *html* (break)) (format *ltoutf* "~%")) (defun lt-begin-detail () (format *ltoutf* "\\small{")) (setfn lt-end-detail lt-end) (defun lt-begin-write-description () (setf *description-item-is-open* t) (setf *skip-white-space* t) (if *token-trace* (format t "LT-BEGIN-WRITE-DESCRIPTION:OPEN")) (format *ltoutf* "\\begin{description2}~%") (needspace 3) (format *ltoutf* "\\item[")) (defun lt-end-write-description () (cond (*description-item-is-open* (break "lt-end-write-description: *description-item-is-open* indicates we are expecting a description term and description. Probably there is a blank line before @end(description) in the source file, or maybe there is a missing @\\ to mark the description. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "\\end{description2}")) (defun lt-description-paragraph () (cond (*description-item-is-open* (format *ltoutf* "]"))) (setf *description-item-is-open* t) (setf *skip-white-space* t) (format *ltoutf* "~%") (needspace 3) (format *ltoutf* "\\item[")) ;; string-stream captures items in fdescription or pdescription: (setf *save-ltoutf* nil) (defun take-to (str marker) (let ((loc (string-search marker str))) (cond ((not loc) (setf *rslt* nil) str) (t (setf *rslt* (subseq str 0 loc)) (subseq str (+ loc (length marker))))))) (defun trim (s) (string-trim " \t\n" s)) ;; remove all \\ latex line breaks from end of string: (defun remove-breaks (s) (if (and (>= (length s) 2) (equal "\\\\" (subseq s (- (length s) 2)))) (remove-breaks (subseq s 0 (- (length s) 2))) s)) (defun newlines-to-break (s) (let ((loc (string-search "\n\n" s))) (if loc (strcat (trim (subseq s 0 loc)) "\\\\" (trim (subseq s (+ 2 loc)))) s))) ;; anything not inside <!BEGIN-PDESC> <!END-PDESC> goes into item ;; first get the strings separated by <!BEGIN-*> <!END-*> <!BREAK-*> ;; mark them as FDESC or PDESC, finally generate output ;; (setf showcount 0) (defun lt-fdescription (body) (prog (lines line (pdlevel 0)) ;; pdlevel = nesting level for pdescription ; (cond ((string-search "let*" body) ; (setf showcount 1) ; (print "------------------------------------------------------------") ; (print body) ; (print "------------------------------------------------------------"))) (format *ltoutf* "\\begin{description2}~%") loop1 (setf body (take-to body "<!")) (cond (*rslt* (setf line (remove-breaks (trim *rslt*))) (if (> showcount 0) (display "lt-fdesc before ntb" line)) (if (= pdlevel 0) (setf line (newlines-to-break line))) (if (> showcount 0) (display "lt-fdesc after ntb" line)) (cond ((> (length line) 0) (push (list pdlevel line) lines) ; (if (> pdlevel 1) (print (list pdlevel line))) )) (setf body (take-to body ">")) (if (equal *rslt* "BEGIN-PDESC") (setf pdlevel (1+ pdlevel))) (if (equal *rslt* "END-PDESC") (setf pdlevel (1- pdlevel))) (go loop1) )) (setf lines (reverse lines)) ;; now we have ((pdlevel "line1") (pdlevel "line2") (pdlevel "line3") ...) (if (<= 0 (decf showcount)) (dolist (x lines) (format t "~A~%" x))) ;; collect FDESC (pdlevel == 0) lines as an item (while lines (format *ltoutf* "\\item[~A" (cadar lines)) (setf lines (rest lines)) (while (and lines (eql 0 (caar lines))) (format *ltoutf* "\\\\~%~A" (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "]~%") (cond ((and lines (/= 0 (caar lines))) (format *ltoutf* "~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines)) (while (and lines (/= 0 (caar lines))) (format *ltoutf* "\\\\~%~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "~%")))) (format *ltoutf* "\\end{description2}~%"))) (defun lt-begin-write-fdescription () (cond ((not *save-ltoutf*) (setf *save-ltoutf* *ltoutf*) (setf *ltoutf* (make-string-output-stream))))) (defun lt-end-write-fdescription () (let ((body (get-output-stream-string *ltoutf*))) (cond ((not *fdescription*) (setf *ltoutf* *save-ltoutf*) (setf *save-ltoutf* nil) (lt-fdescription body))))) (defun lt-begin-write-pdescription () (format *ltoutf* "<!BEGIN-PDESC>") nil) (defun lt-end-write-pdescription () (format *ltoutf* "<!END-PDESC>") nil) (defun lt-fdescription-break () (format *ltoutf* "<!BREAK-FDESC>") nil) (defun lt-pdescription-break () (format *ltoutf* "<!BREAK-PDESC>") nil) (defun lt-begin-write-format () (format *ltoutf* "<begin format>")) (defun lt-end-write-format () (format *ltoutf* "<end format>")) (defun lt-begin-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{quote}"))) (defun lt-end-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\end{quote}"))) (defun lt-begin-center () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{center}"))) (defun lt-end-center () (if (or *html* *omit*) nil (format *ltoutf* "\\end{center}"))) (defun lt-begin-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{figure}~%"))) (defun lt-end-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\end{figure}~%"))) (defun lt-label (name) (if (or *html* *omit*) nil (format *ltoutf* "\\label{~A}~%" name))) (defun lt-write-footnote (name number) (format *ltoutf* "\\footnote{")) (defun lt-footnote-end () (format *ltoutf* "}")) (defun lt-write-fillcaption (n) (if (or *html* *omit*) nil (format *ltoutf* "\\caption{"))) (defun lt-end-fillcaption () (if (or *html* *omit*) nil (format *ltoutf* "}"))) ;; this is what starts generating output, including the ;; Latex preamble ;; (defun lt-majorheading (title) (lt-title-info title *doc-version* *doc-author*)) (defun lt-write-chapter (body numbered) (setf *line-empty* t) (format *ltoutf* "\\chapter~A{~A}~%" (if numbered "" "*") (latex-escape body))) (defun lt-finish-chapter () (setf *line-empty* t) ; (format *ltoutf* "~%<chapter finish>~%") ) (defun lt-begin-h2 () (format *ltoutf* "\\section{")) (setfn lt-end-h2 lt-end) (defun lt-begin-h3 () (format *ltoutf* "\\subsection{")) (setfn lt-end-h3 lt-end) (defun lt-begin-h4 () (format *ltoutf* "\\subsubsection{")) (setfn lt-end-h4 lt-end) (defun lt-begin-superscript () (format *ltoutf* "\\textsuperscript{")) (defun lt-end-superscript () (format *ltoutf* "}")) (defun lt-begin-subscript () (format *ltoutf* "\\textsubscript{")) (defun lt-end-subscript () (format *ltoutf* "}")) (defun lt-paragraph () (if *html* (break)) (terpri *ltoutf*) (terpri *ltoutf*)) (defun needspace (n) (cond ((<= skip-count 0) (format *ltoutf* "\\needspace{~A\\baselineskip}~%" n) (setf skip-count n)))) (defun lt-write-paragraph (name-number body) (needspace 3) (format *ltoutf* "\\subsubsection{~A}" (latex-escape body))) (defun lt-write-subsection (name-number body) (needspace 3) (format *ltoutf* "\\subsection{~A}" (latex-escape body))) (defun lt-write-section (name-number body) (needspace 4) (format *ltoutf* "\\section{~A}" (latex-escape body))) (setf *lt-started-appendices* nil) (defun lt-appendix (name-number body) (cond ((not *lt-started-appendices*) (setf *lt-started-appendices* t) (format *ltoutf* "\\appendix~%") (format *ltoutf* "\\renewcommand{\\thechapter}{\\Alph{chapter}}~%") (format *ltoutf* "\\titleformat{\\chapter}~%") (format *ltoutf* " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}~%") (format *ltoutf* "}~%") (format *ltoutf* " {Appendix \\thechapter}{24pt}{}~%"))) (format *ltoutf* "\\chapter{~A}" (latex-escape body))) (defun lt-end-document () (setf *line-empty* t) (format *ltoutf* "\\clearpage~%\\addcontentsline{toc}{chapter}{Index}~%") (format *ltoutf* "\\printindex~%\\end{document}~%"))
true
;; latex.lsp -- write latex file ;; ;; PI:NAME:<NAME>END_PI ;; March 2015 (setf *lt-preamble* '( "\\documentclass[11pt,]{report}" "\\setcounter{secnumdepth}{3}" "\\usepackage[T1]{fontenc}" "% \\usepackage{lmodern} -- results in texttt{AR} being too small!" "\\usepackage{amssymb,amsmath}" "\\usepackage{makeidx}" "\\makeindex" "\\usepackage{ifxetex,ifluatex}" "\\usepackage{fixltx2e} % provides \\textsubscript" "\\usepackage{mathptmx}% Times Roman font" "\\usepackage[scaled=.90]{helvet}% Helvetica, served as a model for arial" "\\usepackage[dvipsnames*,svgnames]{xcolor}" "\\usepackage{titlesec}" "\\usepackage{fancyvrb}" "\\DefineVerbatimEnvironment{verbatim}{Verbatim}{xleftmargin=.3in}" "\\usepackage{etoolbox}" "\\usepackage{graphicx}" "% patch for fancyvrb " "\\makeatletter " "\\patchcmd{\\FV@ListVSpace}{\\@topsepadd\\topsep}{}{}" "\\makeatother " "" "% patch for verbatim " "% \\makeatletter" "% \\preto{\\@verbatim}{\\topsep=0pt \\partopsep=0pt }" "% \\makeatother" "" "\\usepackage{alltt}" "\\usepackage{changepage}" "\\newenvironment{expl}{\\begin{adjustwidth}{0.4cm}{0cm}\\begin{minipage}{\\textwidth}\\begin{alltt}}" ; \\begin{adjustwidth}{0.4cm}{} ; \\end{adjustwidth}\\end{alltt}}" " {\\end{alltt}\\end{minipage}\\end{adjustwidth}}" "% \\newcommand{\\sectionbreak}{\\clearpage}" "\\usepackage{placeins}" "\\usepackage{needspace}" "\\usepackage[tocindentauto]{tocstyle}" "\\usepackage{enumitem}" "\\newenvironment{description2}" "{\\begin{description}[style=nextline,font=\\normalfont]}{\\end{description}}" "\\newenvironment{description3}" "{\\begin{description}[font=\\normalfont,noitemsep,nolistsep]}{\\end{description}}" "\\makeatletter " "%\\renewcommand{\\l@section}{\\@dottedtocline{1}{1.5em}{2.6em}}" "%\\renewcommand{\\l@subsection}{\\@dottedtocline{2}{4.0em}{3.6em}}" "%\\renewcommand{\\l@subsubsection}{\\@dottedtocline{3}{7.4em}{4.5em}}" "\\makeatother " "" "% use microtype if available" "\\IfFileExists{microtype.sty}{\\usepackage{microtype}}{}" "% use upquote if available, for straight quotes in verbatim environments" "\\IfFileExists{upquote.sty}{\\usepackage{upquote}}{}" "\\ifnum 0\\ifxetex 1\\fi\\ifluatex 1\\fi=0 % if pdftex" " \\usepackage[utf8]{inputenc}" "\\else % if luatex or xelatex" " \\usepackage{fontspec}" " \\ifxetex" " \\usepackage{xltxtra,xunicode}" " \\fi" " \\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}" " \\newcommand{\\euro}{€}" " \\setmainfont{Georgia}" " \\setsansfont{Arial}" " \\setmonofont{Lucida Console}" "\\fi" "" "\\usepackage[includeheadfoot,top=1in, bottom=1in, left=1in, right=1in]{geometry}" "" "\\usepackage{fancyhdr}" "\\pagestyle{fancy}" "\\pagenumbering{arabic}" )) (setf *lt-preamble2* '( "\\cfoot{}" "\\rfoot{\\thepage}" "" "\\ifxetex" " \\usepackage[setpagesize=false, % page size defined by xetex" " unicode=false, % unicode breaks when used with xetex" " xetex]{hyperref}" "\\else" " \\usepackage[unicode=true]{hyperref}" "\\fi" "\\hypersetup{breaklinks=true," " bookmarks=true," " pdfauthor={}," " pdftitle={}," " colorlinks=true," " urlcolor=blue," " linkcolor=magenta," " pdfborder={0 0 0}}" "\\setlength{\\parindent}{0pt}" "\\setlength{\\parskip}{6pt plus 2pt minus 1pt}" "\\setlength{\\emergencystretch}{3em} % prevent overfull lines" "" )) (setf *lt-preamble3* '( "" "%\\definecolor{sec-color}{gray}{0.4}" "%\\definecolor{subsec-color}{gray}{0.3}" "%\\definecolor{subsubsec-color}{gray}{0.25}" "" "" "\\titleformat{\\chapter}" " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}" "}" " {\\thechapter}{24pt}{}" "" "\\titleformat{\\section}" " {\\normalfont\\sffamily\\LARGE\\bfseries%\\color{MidnightBlue}" "}" " {\\thesection}{20pt}{}" "\\titleformat{\\subsection}" " {\\normalfont\\sffamily\\Large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsection}{16pt}{}" "\\titleformat{\\subsubsection}" " {\\normalfont\\sffamily\\large\\bfseries%\\color{MidnightBlue}" "}" " {\\thesubsubsection}{14pt}{}" "" "\\begin{document}" "\\maketitle" "" "\\newpage" "" "{" "\\hypersetup{linkcolor=black}" "\\setcounter{tocdepth}{3}" "\\tableofcontents" "}" )) (defun write-lines (lines) (dolist (line lines) (princ line *ltoutf*) (terpri *ltoutf*))) ;; tells when preamble has been written, no other output until then (setf *lt-started* nil) (defun lt-title-info(title version author) (write-lines *lt-preamble*) (format *ltoutf* "\\lhead{\\itshape ~A}~%" title) (format *ltoutf* "\\chead{}~%\\rhead{\\itshape{\\nouppercase{\\leftmark}}}") (format *ltoutf* "\\lfoot{v ~A}~%" version) ; e.g. "3.10" (write-lines *lt-preamble2*) (format *ltoutf* "\\title{\\Huge{\\textbf{~A}}}~%" title) (format *ltoutf* "\\author{\\textbf{\\normalsize{Version ~A}}}~%" version) (format *ltoutf* "\\date{\\textbf{\\large{~A}}\\\\~ \\vspace{1 in}\\today\\\\~ \\vspace{2 in}Carnegie Mellon University\\\\~ \\vspace{10 pt}School of Computer Science\\\\~ \\vspace{10 pt}Pittsburgh, PA 15213, U.S.A.}~%" author) (write-lines *lt-preamble3*) (setf *lt-started* t)) (defun lt-end () (format *ltoutf* "}")) (defun lt-begin-code () (setf *font-is-tt* t) (if (or *html* *omit*) nil (format *ltoutf* "\\texttt{"))) (defun lt-end-code () (setf *font-is-tt nil) (if (or *html* *omit*) nil (format *ltoutf* "}"))) (defun lt-begin-quotation () (format *ltoutf* "\\quotation{")) (setfn lt-end-quotation lt-end) (defun lt-begin-example () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{expl}"))) (defun lt-end-example () (if (or *html* *omit*) nil (format *ltoutf* "\\end{expl}"))) (defun lt-begin-enumerate () (format *ltoutf* "\\begin{enumerate}\\item ~%")) (defun lt-end-enumerate () (format *ltoutf* "\\end{enumerate}")) (defun lt-begin-itemize () (format *ltoutf* "\\begin{itemize}~%\\item ")) (defun lt-list-paragraph () (format *ltoutf* "~%\\item~%")) (defun lt-end-itemize () (format *ltoutf* "\\end{itemize}")) (defun lt-begin-normal () (format *ltoutf* "{\\fontfamily{cmr}\\selectfont ")) (setfn lt-end-normal lt-end) (defun latex-escape (str) (let (s cs) ;; s will accumulate escaped chars of str (dotimes (i (length str)) ;; map each char of str into an escaped version (setf cs (assoc (char str i) '((#\% "\\%") (#\& "\\&") (#\\ "\\textbackslash{}") (#\$ "\\$") (#\# "\\#") (#\_ "\\_") (#\{ "\\{") (#\} "\\}") (#\[ "{[}") (#\] "{]}") (#\^ "\\textasciicircum{}") (#\~ "\\textasciitilde{}")))) ;; if no substitute found, use original converted to a string (setf cs (if cs (second cs) (string (char str i)))) (setf s (cons cs s))) (apply #'strcat (reverse s)))) (defun lt-write-index (str) (format *ltoutf* "\\index{~A}" (latex-escape str))) (defun lt-write-indexsecondary (str n) (format *ltoutf* "\\index{~A!~A}" (latex-escape (get-primary str)) (latex-escape (get-secondary str)))) (defun lt-linebreak (source) (if *s2h-dbg* (display "lt-linebreak" *line-empty* *fdescription* *pdescription*)) (cond ((and *fdescription* (not *pdescription*) (not (eq source 'write-blankspace))) (display "lt-linebreak in fdesc" source) (break "lt-linebreak in fdescription")) (*pdescription* nil) ((not *line-empty*) (setf *line-empty* t) (format *ltoutf* "\\\\")) (t (display "lt-linebreak when" *line-empty*) (format *ltoutf* "\\hspace*{1em} \\\\")))) (defun lt-write-cite (link) (format *ltoutf* "\\cite{~A}" (car link))) (defun lt-write-label (sym) (format *ltoutf* "\\label{~A}" sym)) (defun lt-write-ref (ref tok) (cond ((eq tok 'ref) (format *ltoutf* "\\ref{~A}" (car ref))) ((eq tok 'pageref) (format *ltoutf* "\\pageref{~A}" (car ref))) (t (break "lt-write-ref got bad tok argument")))) (defun style-to-latex (style) (cond ((equal style "b") "textbf") ((equal style "i") "textit") (t style))) (defun lt-begin-style (style) (format *ltoutf* "\\~A{" (style-to-latex style))) (defun lt-end-style (style) (lt-end)) (defun lt-begin-bold-italic () (format *ltoutf* "\\textbf{\\textit{")) (defun lt-end-bold-italic () (format *ltoutf* "}}")) (defun lt-begin-underline () (format *ltoutf* "\\underline{")) (setfn lt-end-underline lt-end) (defun lt-begin-write-dd () (format *ltoutf* "<begin dd>")) (defun lt-end-write-dd () (format *ltoutf* "<end dd>")) (defun lt-write-dd () ; (format *ltoutf* "<lt-write-dd>") (cond (*description-item-is-open* (if *token-trace* (format t "LT-WRITE-DD:CLOSE")) (setf *skip-white-space* nil) (setf *description-item-is-open* nil)) (t (break "lt-write-dd: *description-item-is-open* is false - were closing a description term, but there was no term to begin with. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "]")) (defun lt-break-dt () (if (not *description-item-is-open*) (break "lt-break-dt: *description-item-is-open* is false")) (setf *description-item-is-open* nil) (setf *skip-white-space* nil) (format *ltoutf* "]")) (defun write-fdescription-item () ; (let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *fdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) (defun write-pdescription-item () ;(let ((item (get-output-stream-string *ltoutf*))) ; (setf *ltoutf* *save-ltoutf*) ; (setf *save-ltoutf* nil) ; mark as invalid ; (setf *pdescription-item-capture* nil) ; (format *ltoutf* "\\item[~A] " (string-trim "\n\t " item)))) nil) ;; write "-" unless this is an @itemsep, which gets "--" (defun lt-dash (tok) ; (cond ((and *pdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-pdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM CALLED ~A ~A " ;; *fdescription-item-capture* tok) ;(cond ((and *fdescription-item-capture* (eq tok 'itemsep)) ; ;; we've capture the item, now write it: ; (write-fdescription-item))) ;;(format *ltoutf* "WRITE-FDESCRIPTION-ITEM RETURNED ~A ~A " ;; *fdescription-item-capture* tok) (format *ltoutf* "~A" (if (eq tok 'itemsep) "--" "-"))) (defun lt-blankspace-in-fdescription () (setf *line-empty* t) (if *html* (break)) (format *ltoutf* "~%")) (defun lt-begin-detail () (format *ltoutf* "\\small{")) (setfn lt-end-detail lt-end) (defun lt-begin-write-description () (setf *description-item-is-open* t) (setf *skip-white-space* t) (if *token-trace* (format t "LT-BEGIN-WRITE-DESCRIPTION:OPEN")) (format *ltoutf* "\\begin{description2}~%") (needspace 3) (format *ltoutf* "\\item[")) (defun lt-end-write-description () (cond (*description-item-is-open* (break "lt-end-write-description: *description-item-is-open* indicates we are expecting a description term and description. Probably there is a blank line before @end(description) in the source file, or maybe there is a missing @\\ to mark the description. Turn on *token-trace* and continue to see where you are."))) (format *ltoutf* "\\end{description2}")) (defun lt-description-paragraph () (cond (*description-item-is-open* (format *ltoutf* "]"))) (setf *description-item-is-open* t) (setf *skip-white-space* t) (format *ltoutf* "~%") (needspace 3) (format *ltoutf* "\\item[")) ;; string-stream captures items in fdescription or pdescription: (setf *save-ltoutf* nil) (defun take-to (str marker) (let ((loc (string-search marker str))) (cond ((not loc) (setf *rslt* nil) str) (t (setf *rslt* (subseq str 0 loc)) (subseq str (+ loc (length marker))))))) (defun trim (s) (string-trim " \t\n" s)) ;; remove all \\ latex line breaks from end of string: (defun remove-breaks (s) (if (and (>= (length s) 2) (equal "\\\\" (subseq s (- (length s) 2)))) (remove-breaks (subseq s 0 (- (length s) 2))) s)) (defun newlines-to-break (s) (let ((loc (string-search "\n\n" s))) (if loc (strcat (trim (subseq s 0 loc)) "\\\\" (trim (subseq s (+ 2 loc)))) s))) ;; anything not inside <!BEGIN-PDESC> <!END-PDESC> goes into item ;; first get the strings separated by <!BEGIN-*> <!END-*> <!BREAK-*> ;; mark them as FDESC or PDESC, finally generate output ;; (setf showcount 0) (defun lt-fdescription (body) (prog (lines line (pdlevel 0)) ;; pdlevel = nesting level for pdescription ; (cond ((string-search "let*" body) ; (setf showcount 1) ; (print "------------------------------------------------------------") ; (print body) ; (print "------------------------------------------------------------"))) (format *ltoutf* "\\begin{description2}~%") loop1 (setf body (take-to body "<!")) (cond (*rslt* (setf line (remove-breaks (trim *rslt*))) (if (> showcount 0) (display "lt-fdesc before ntb" line)) (if (= pdlevel 0) (setf line (newlines-to-break line))) (if (> showcount 0) (display "lt-fdesc after ntb" line)) (cond ((> (length line) 0) (push (list pdlevel line) lines) ; (if (> pdlevel 1) (print (list pdlevel line))) )) (setf body (take-to body ">")) (if (equal *rslt* "BEGIN-PDESC") (setf pdlevel (1+ pdlevel))) (if (equal *rslt* "END-PDESC") (setf pdlevel (1- pdlevel))) (go loop1) )) (setf lines (reverse lines)) ;; now we have ((pdlevel "line1") (pdlevel "line2") (pdlevel "line3") ...) (if (<= 0 (decf showcount)) (dolist (x lines) (format t "~A~%" x))) ;; collect FDESC (pdlevel == 0) lines as an item (while lines (format *ltoutf* "\\item[~A" (cadar lines)) (setf lines (rest lines)) (while (and lines (eql 0 (caar lines))) (format *ltoutf* "\\\\~%~A" (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "]~%") (cond ((and lines (/= 0 (caar lines))) (format *ltoutf* "~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines)) (while (and lines (/= 0 (caar lines))) (format *ltoutf* "\\\\~%~A~A" (if (< 1 (caar lines)) "\\hspace*{3em}" "") (cadar lines)) (setf lines (rest lines))) (format *ltoutf* "~%")))) (format *ltoutf* "\\end{description2}~%"))) (defun lt-begin-write-fdescription () (cond ((not *save-ltoutf*) (setf *save-ltoutf* *ltoutf*) (setf *ltoutf* (make-string-output-stream))))) (defun lt-end-write-fdescription () (let ((body (get-output-stream-string *ltoutf*))) (cond ((not *fdescription*) (setf *ltoutf* *save-ltoutf*) (setf *save-ltoutf* nil) (lt-fdescription body))))) (defun lt-begin-write-pdescription () (format *ltoutf* "<!BEGIN-PDESC>") nil) (defun lt-end-write-pdescription () (format *ltoutf* "<!END-PDESC>") nil) (defun lt-fdescription-break () (format *ltoutf* "<!BREAK-FDESC>") nil) (defun lt-pdescription-break () (format *ltoutf* "<!BREAK-PDESC>") nil) (defun lt-begin-write-format () (format *ltoutf* "<begin format>")) (defun lt-end-write-format () (format *ltoutf* "<end format>")) (defun lt-begin-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{quote}"))) (defun lt-end-blockquote () (if (or *html* *omit*) nil (format *ltoutf* "\\end{quote}"))) (defun lt-begin-center () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{center}"))) (defun lt-end-center () (if (or *html* *omit*) nil (format *ltoutf* "\\end{center}"))) (defun lt-begin-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\begin{figure}~%"))) (defun lt-end-figure () (if (or *html* *omit*) nil (format *ltoutf* "\\end{figure}~%"))) (defun lt-label (name) (if (or *html* *omit*) nil (format *ltoutf* "\\label{~A}~%" name))) (defun lt-write-footnote (name number) (format *ltoutf* "\\footnote{")) (defun lt-footnote-end () (format *ltoutf* "}")) (defun lt-write-fillcaption (n) (if (or *html* *omit*) nil (format *ltoutf* "\\caption{"))) (defun lt-end-fillcaption () (if (or *html* *omit*) nil (format *ltoutf* "}"))) ;; this is what starts generating output, including the ;; Latex preamble ;; (defun lt-majorheading (title) (lt-title-info title *doc-version* *doc-author*)) (defun lt-write-chapter (body numbered) (setf *line-empty* t) (format *ltoutf* "\\chapter~A{~A}~%" (if numbered "" "*") (latex-escape body))) (defun lt-finish-chapter () (setf *line-empty* t) ; (format *ltoutf* "~%<chapter finish>~%") ) (defun lt-begin-h2 () (format *ltoutf* "\\section{")) (setfn lt-end-h2 lt-end) (defun lt-begin-h3 () (format *ltoutf* "\\subsection{")) (setfn lt-end-h3 lt-end) (defun lt-begin-h4 () (format *ltoutf* "\\subsubsection{")) (setfn lt-end-h4 lt-end) (defun lt-begin-superscript () (format *ltoutf* "\\textsuperscript{")) (defun lt-end-superscript () (format *ltoutf* "}")) (defun lt-begin-subscript () (format *ltoutf* "\\textsubscript{")) (defun lt-end-subscript () (format *ltoutf* "}")) (defun lt-paragraph () (if *html* (break)) (terpri *ltoutf*) (terpri *ltoutf*)) (defun needspace (n) (cond ((<= skip-count 0) (format *ltoutf* "\\needspace{~A\\baselineskip}~%" n) (setf skip-count n)))) (defun lt-write-paragraph (name-number body) (needspace 3) (format *ltoutf* "\\subsubsection{~A}" (latex-escape body))) (defun lt-write-subsection (name-number body) (needspace 3) (format *ltoutf* "\\subsection{~A}" (latex-escape body))) (defun lt-write-section (name-number body) (needspace 4) (format *ltoutf* "\\section{~A}" (latex-escape body))) (setf *lt-started-appendices* nil) (defun lt-appendix (name-number body) (cond ((not *lt-started-appendices*) (setf *lt-started-appendices* t) (format *ltoutf* "\\appendix~%") (format *ltoutf* "\\renewcommand{\\thechapter}{\\Alph{chapter}}~%") (format *ltoutf* "\\titleformat{\\chapter}~%") (format *ltoutf* " {\\normalfont\\sffamily\\huge\\bfseries%\\color{MidnightBlue}~%") (format *ltoutf* "}~%") (format *ltoutf* " {Appendix \\thechapter}{24pt}{}~%"))) (format *ltoutf* "\\chapter{~A}" (latex-escape body))) (defun lt-end-document () (setf *line-empty* t) (format *ltoutf* "\\clearpage~%\\addcontentsline{toc}{chapter}{Index}~%") (format *ltoutf* "\\printindex~%\\end{document}~%"))
[ { "context": "le for more details.\n;;;\n;;; Copyright (c) 2011 by Dương \"Yang\" ヤン Hà Nguyễn <[email protected]>\n;;;\n\n;;; Thi", "end": 170, "score": 0.9988791346549988, "start": 165, "tag": "NAME", "value": "Dương" }, { "context": "ore details.\n;;;\n;;; Copyright (c) 2011 by Dương \"Yang\" ヤン Hà Nguyễn <[email protected]>\n;;;\n\n;;; This fi", "end": 176, "score": 0.8927537202835083, "start": 172, "tag": "NAME", "value": "Yang" }, { "context": "etails.\n;;;\n;;; Copyright (c) 2011 by Dương \"Yang\" ヤン Hà Nguyễn <[email protected]>\n;;;\n\n;;; This file is not desi", "end": 190, "score": 0.9766035676002502, "start": 178, "tag": "NAME", "value": "ヤン Hà Nguyễn" }, { "context": " Copyright (c) 2011 by Dương \"Yang\" ヤン Hà Nguyễn <[email protected]>\n;;;\n\n;;; This file is not designed to use as a s", "end": 208, "score": 0.9999309778213501, "start": 192, "tag": "EMAIL", "value": "[email protected]" } ]
tests/nl-unittest.lsp
IngoHohmann/newlisp-matrix-client
8
;;; ;;; This file is a part of the nl-unittest project, released under ;;; MIT license. ;;; ;;; See the COPYING file for more details. ;;; ;;; Copyright (c) 2011 by Dương "Yang" ヤン Hà Nguyễn <[email protected]> ;;; ;;; This file is not designed to use as a standalone program but in ;;; conjuction with other programs. ;;; need cleaning up!!!!!!!!!!!! (context 'TermColor) ;;; define some terminal color (constant '+fg-light-red+ "\027[1;31m") (constant '+fg-light-green+ "\027[1;32m") (constant '+fg-light-yellow+ "\027[1;33m") (constant '+fg-red+ "\027[31m") (constant '+fg-green+ "\027[32m") (constant '+fg-yellow+ "\027[33m") (constant '+bg-cyan+ "\027[46m") (constant '+bg-dark-gray+ "\027[1;40m") (constant '+reset+ "\027[0m") ;;; colorize a string (define (colorize color str) (letn ((color-name (term color)) (const-str (append "+" color-name "+")) (color-sym (sym const-str))) (append (eval color-sym) str +reset+))) (context 'UnitTest) (setq *enable-term-color* true) ; use colors in console? (setq *report-failed* true) ; report failed assertions? (setq *report-passed* nil) ; report passed assertions? (setq *continue-after-failure* true) (setq *verbose* nil) ;;; current test in a test-case, *cur-test* help tracking a test which ;;; contains other test cases (setq *cur-test* '()) ;;; convert and concat all the arguments into a string and colorize it ;;; if necessary (define (colorize color) (letn (s (apply append (args))) (if *enable-term-color* (TermColor:colorize color s) s))) (define (report-failure expression) (let (report (if (true? *verbose*) (colorize 'fg-red "--> " (string expression) " FAILED!") (colorize 'fg-red ;; "--> Expression: " (string (expression 2)) "--> " (string expression) " => Expected: " (string (eval (expression 1))) " -> Received: " (string (eval (expression 2))) "."))) (if *report-failed* (println report))) nil) (define (report-error expression msg) (let (report (colorize 'fg-light-yellow "--> " (string expression) " got error(s):\n" (join (map (lambda (s) (append " " s)) (parse msg "\n")) "\n"))) (println report)) nil) ;;; requert result of a passed test (define (report-pass expression) (let (report (colorize 'fg-green "--> " (string expression) " passed")) (if *report-passed* (println report))) true) (define (assertion? form) ;; a symbol is an assertion only if it contains "assert=" (local (res) (catch (term (first form)) 'res) (ends-with res "assert="))) (define (report-result expr res) ;; (println "-- debug; report-result => " expr " -> " res) (if (= true res) (report-pass expr) (= nil res) (report-failure expr) (report-error expr res))) ;;; run all the test cases and return the list of results (define (run-and-report cases , res) (setq res '()) (dolist (single-case cases) (let (*cur-results* '() *cur-expressions* '()) (catch (eval single-case) 'some-error) ;; now, we have the list current results as well as their ;; corresponding expressions: ``*cur-results*`` and ;; ``*cur-expressions*`` (dotimes (idx (length *cur-results*)) (report-result (*cur-expressions* idx) (*cur-results* idx))) (setq res (append res *cur-results*))))) (define-macro (check test-cases cur-test) ;; (println) (println "=== Testing " (eval cur-test)) (letn (time-running 0 result-list '()) ;; calculate result and time at the same time (setq time-running (time (setq result-list (run-and-report test-cases)))) ;; because result-list may contain non-assertion expression, we ;; need to filter them out (letn ((passed-ass (length (filter (lambda (x) (= true x)) result-list))) (failed-ass (length (filter (lambda (x) (!= true x)) result-list))) (total-ass (+ passed-ass failed-ass)) (msg-passed (append (string passed-ass) " pass(es)")) (msg-failed (append (string failed-ass) " fail(s)"))) ;; colorize if necessary (if (< 0 passed-ass) (setq msg-passed (colorize 'fg-light-green msg-passed))) (if (< 0 failed-ass) (setq msg-failed (colorize 'fg-light-red msg-failed))) (println ">>> Total assertions: " total-ass) (println " - " msg-passed) (println " - " msg-failed) (println " - Total time: " time-running "ms") (println) ;; the test case is considered passed only if there's no failure (= 0 failed-ass)))) ;;; run all test cases, aka functions of the form ``test_`` (define (run-all cont) (println) (println "======================================================================") (letn (counter 0 failed 0 passed 0 time-running 0) (dotree (symbol cont) (if (starts-with (term symbol) "test_") (begin (inc time-running (time (if (apply symbol) (inc passed) (inc failed)))) (println "----------------------------------------------------------------------")))) ;; make report and colorize if necessary (setq counter (+ failed passed)) (println "STATUS:") (println "==> RAN " counter " test(s) IN " time-running "ms") (println "==> " (if (zero? failed) (colorize 'bg-dark-gray (colorize 'fg-green "ALL PASSED!!!")) (colorize 'bg-dark-gray (colorize 'fg-red "FAILED (failures = " (string failed) ")")))) (println "======================================================================") (println) (zero? failed))) ;;; ;;; convenient methods in context 'MAIN ;;; (context 'MAIN) ;;; ;;; alias for ``=`` for testing clarification ;;; (define-macro (assert= expected expression , _ass-result) (catch (eval '(apply = (list (eval expected) (eval expression)))) '_ass-result) ;; eval the expression and save the result (push _ass-result UnitTest:*cur-results* -1) ;; save the expression as symbol (push (list 'assert= expected expression) UnitTest:*cur-expressions* -1) ;; (println "-- debug => " (list 'assert= expected expression) " -> " ;; _ass-result) _ass-result) ;;; ;;; what this functions does are ;;; * setting the current test, tracking if the current test contains other tests ;;; * evaluating every expression in the current test and return the result (define-macro (define-test params) ;; ;; `params` the function signature ;; `test_name` is the name of the test, equals `(first params)` ;; `exps` is the body of the ;; (eval (expand '(define signature (let ((UnitTest:*cur-test* (append UnitTest:*cur-test* '(test-name)))) (UnitTest:check exps UnitTest:*cur-test*))) (list (list 'signature params) (list 'exps (args)) (list 'test-name (params 0)))))) ;;; make all symbol used for testing available (global 'assert=) (global 'define-test)
30773
;;; ;;; This file is a part of the nl-unittest project, released under ;;; MIT license. ;;; ;;; See the COPYING file for more details. ;;; ;;; Copyright (c) 2011 by <NAME> "<NAME>" <NAME> <<EMAIL>> ;;; ;;; This file is not designed to use as a standalone program but in ;;; conjuction with other programs. ;;; need cleaning up!!!!!!!!!!!! (context 'TermColor) ;;; define some terminal color (constant '+fg-light-red+ "\027[1;31m") (constant '+fg-light-green+ "\027[1;32m") (constant '+fg-light-yellow+ "\027[1;33m") (constant '+fg-red+ "\027[31m") (constant '+fg-green+ "\027[32m") (constant '+fg-yellow+ "\027[33m") (constant '+bg-cyan+ "\027[46m") (constant '+bg-dark-gray+ "\027[1;40m") (constant '+reset+ "\027[0m") ;;; colorize a string (define (colorize color str) (letn ((color-name (term color)) (const-str (append "+" color-name "+")) (color-sym (sym const-str))) (append (eval color-sym) str +reset+))) (context 'UnitTest) (setq *enable-term-color* true) ; use colors in console? (setq *report-failed* true) ; report failed assertions? (setq *report-passed* nil) ; report passed assertions? (setq *continue-after-failure* true) (setq *verbose* nil) ;;; current test in a test-case, *cur-test* help tracking a test which ;;; contains other test cases (setq *cur-test* '()) ;;; convert and concat all the arguments into a string and colorize it ;;; if necessary (define (colorize color) (letn (s (apply append (args))) (if *enable-term-color* (TermColor:colorize color s) s))) (define (report-failure expression) (let (report (if (true? *verbose*) (colorize 'fg-red "--> " (string expression) " FAILED!") (colorize 'fg-red ;; "--> Expression: " (string (expression 2)) "--> " (string expression) " => Expected: " (string (eval (expression 1))) " -> Received: " (string (eval (expression 2))) "."))) (if *report-failed* (println report))) nil) (define (report-error expression msg) (let (report (colorize 'fg-light-yellow "--> " (string expression) " got error(s):\n" (join (map (lambda (s) (append " " s)) (parse msg "\n")) "\n"))) (println report)) nil) ;;; requert result of a passed test (define (report-pass expression) (let (report (colorize 'fg-green "--> " (string expression) " passed")) (if *report-passed* (println report))) true) (define (assertion? form) ;; a symbol is an assertion only if it contains "assert=" (local (res) (catch (term (first form)) 'res) (ends-with res "assert="))) (define (report-result expr res) ;; (println "-- debug; report-result => " expr " -> " res) (if (= true res) (report-pass expr) (= nil res) (report-failure expr) (report-error expr res))) ;;; run all the test cases and return the list of results (define (run-and-report cases , res) (setq res '()) (dolist (single-case cases) (let (*cur-results* '() *cur-expressions* '()) (catch (eval single-case) 'some-error) ;; now, we have the list current results as well as their ;; corresponding expressions: ``*cur-results*`` and ;; ``*cur-expressions*`` (dotimes (idx (length *cur-results*)) (report-result (*cur-expressions* idx) (*cur-results* idx))) (setq res (append res *cur-results*))))) (define-macro (check test-cases cur-test) ;; (println) (println "=== Testing " (eval cur-test)) (letn (time-running 0 result-list '()) ;; calculate result and time at the same time (setq time-running (time (setq result-list (run-and-report test-cases)))) ;; because result-list may contain non-assertion expression, we ;; need to filter them out (letn ((passed-ass (length (filter (lambda (x) (= true x)) result-list))) (failed-ass (length (filter (lambda (x) (!= true x)) result-list))) (total-ass (+ passed-ass failed-ass)) (msg-passed (append (string passed-ass) " pass(es)")) (msg-failed (append (string failed-ass) " fail(s)"))) ;; colorize if necessary (if (< 0 passed-ass) (setq msg-passed (colorize 'fg-light-green msg-passed))) (if (< 0 failed-ass) (setq msg-failed (colorize 'fg-light-red msg-failed))) (println ">>> Total assertions: " total-ass) (println " - " msg-passed) (println " - " msg-failed) (println " - Total time: " time-running "ms") (println) ;; the test case is considered passed only if there's no failure (= 0 failed-ass)))) ;;; run all test cases, aka functions of the form ``test_`` (define (run-all cont) (println) (println "======================================================================") (letn (counter 0 failed 0 passed 0 time-running 0) (dotree (symbol cont) (if (starts-with (term symbol) "test_") (begin (inc time-running (time (if (apply symbol) (inc passed) (inc failed)))) (println "----------------------------------------------------------------------")))) ;; make report and colorize if necessary (setq counter (+ failed passed)) (println "STATUS:") (println "==> RAN " counter " test(s) IN " time-running "ms") (println "==> " (if (zero? failed) (colorize 'bg-dark-gray (colorize 'fg-green "ALL PASSED!!!")) (colorize 'bg-dark-gray (colorize 'fg-red "FAILED (failures = " (string failed) ")")))) (println "======================================================================") (println) (zero? failed))) ;;; ;;; convenient methods in context 'MAIN ;;; (context 'MAIN) ;;; ;;; alias for ``=`` for testing clarification ;;; (define-macro (assert= expected expression , _ass-result) (catch (eval '(apply = (list (eval expected) (eval expression)))) '_ass-result) ;; eval the expression and save the result (push _ass-result UnitTest:*cur-results* -1) ;; save the expression as symbol (push (list 'assert= expected expression) UnitTest:*cur-expressions* -1) ;; (println "-- debug => " (list 'assert= expected expression) " -> " ;; _ass-result) _ass-result) ;;; ;;; what this functions does are ;;; * setting the current test, tracking if the current test contains other tests ;;; * evaluating every expression in the current test and return the result (define-macro (define-test params) ;; ;; `params` the function signature ;; `test_name` is the name of the test, equals `(first params)` ;; `exps` is the body of the ;; (eval (expand '(define signature (let ((UnitTest:*cur-test* (append UnitTest:*cur-test* '(test-name)))) (UnitTest:check exps UnitTest:*cur-test*))) (list (list 'signature params) (list 'exps (args)) (list 'test-name (params 0)))))) ;;; make all symbol used for testing available (global 'assert=) (global 'define-test)
true
;;; ;;; This file is a part of the nl-unittest project, released under ;;; MIT license. ;;; ;;; See the COPYING file for more details. ;;; ;;; Copyright (c) 2011 by PI:NAME:<NAME>END_PI "PI:NAME:<NAME>END_PI" PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; ;;; This file is not designed to use as a standalone program but in ;;; conjuction with other programs. ;;; need cleaning up!!!!!!!!!!!! (context 'TermColor) ;;; define some terminal color (constant '+fg-light-red+ "\027[1;31m") (constant '+fg-light-green+ "\027[1;32m") (constant '+fg-light-yellow+ "\027[1;33m") (constant '+fg-red+ "\027[31m") (constant '+fg-green+ "\027[32m") (constant '+fg-yellow+ "\027[33m") (constant '+bg-cyan+ "\027[46m") (constant '+bg-dark-gray+ "\027[1;40m") (constant '+reset+ "\027[0m") ;;; colorize a string (define (colorize color str) (letn ((color-name (term color)) (const-str (append "+" color-name "+")) (color-sym (sym const-str))) (append (eval color-sym) str +reset+))) (context 'UnitTest) (setq *enable-term-color* true) ; use colors in console? (setq *report-failed* true) ; report failed assertions? (setq *report-passed* nil) ; report passed assertions? (setq *continue-after-failure* true) (setq *verbose* nil) ;;; current test in a test-case, *cur-test* help tracking a test which ;;; contains other test cases (setq *cur-test* '()) ;;; convert and concat all the arguments into a string and colorize it ;;; if necessary (define (colorize color) (letn (s (apply append (args))) (if *enable-term-color* (TermColor:colorize color s) s))) (define (report-failure expression) (let (report (if (true? *verbose*) (colorize 'fg-red "--> " (string expression) " FAILED!") (colorize 'fg-red ;; "--> Expression: " (string (expression 2)) "--> " (string expression) " => Expected: " (string (eval (expression 1))) " -> Received: " (string (eval (expression 2))) "."))) (if *report-failed* (println report))) nil) (define (report-error expression msg) (let (report (colorize 'fg-light-yellow "--> " (string expression) " got error(s):\n" (join (map (lambda (s) (append " " s)) (parse msg "\n")) "\n"))) (println report)) nil) ;;; requert result of a passed test (define (report-pass expression) (let (report (colorize 'fg-green "--> " (string expression) " passed")) (if *report-passed* (println report))) true) (define (assertion? form) ;; a symbol is an assertion only if it contains "assert=" (local (res) (catch (term (first form)) 'res) (ends-with res "assert="))) (define (report-result expr res) ;; (println "-- debug; report-result => " expr " -> " res) (if (= true res) (report-pass expr) (= nil res) (report-failure expr) (report-error expr res))) ;;; run all the test cases and return the list of results (define (run-and-report cases , res) (setq res '()) (dolist (single-case cases) (let (*cur-results* '() *cur-expressions* '()) (catch (eval single-case) 'some-error) ;; now, we have the list current results as well as their ;; corresponding expressions: ``*cur-results*`` and ;; ``*cur-expressions*`` (dotimes (idx (length *cur-results*)) (report-result (*cur-expressions* idx) (*cur-results* idx))) (setq res (append res *cur-results*))))) (define-macro (check test-cases cur-test) ;; (println) (println "=== Testing " (eval cur-test)) (letn (time-running 0 result-list '()) ;; calculate result and time at the same time (setq time-running (time (setq result-list (run-and-report test-cases)))) ;; because result-list may contain non-assertion expression, we ;; need to filter them out (letn ((passed-ass (length (filter (lambda (x) (= true x)) result-list))) (failed-ass (length (filter (lambda (x) (!= true x)) result-list))) (total-ass (+ passed-ass failed-ass)) (msg-passed (append (string passed-ass) " pass(es)")) (msg-failed (append (string failed-ass) " fail(s)"))) ;; colorize if necessary (if (< 0 passed-ass) (setq msg-passed (colorize 'fg-light-green msg-passed))) (if (< 0 failed-ass) (setq msg-failed (colorize 'fg-light-red msg-failed))) (println ">>> Total assertions: " total-ass) (println " - " msg-passed) (println " - " msg-failed) (println " - Total time: " time-running "ms") (println) ;; the test case is considered passed only if there's no failure (= 0 failed-ass)))) ;;; run all test cases, aka functions of the form ``test_`` (define (run-all cont) (println) (println "======================================================================") (letn (counter 0 failed 0 passed 0 time-running 0) (dotree (symbol cont) (if (starts-with (term symbol) "test_") (begin (inc time-running (time (if (apply symbol) (inc passed) (inc failed)))) (println "----------------------------------------------------------------------")))) ;; make report and colorize if necessary (setq counter (+ failed passed)) (println "STATUS:") (println "==> RAN " counter " test(s) IN " time-running "ms") (println "==> " (if (zero? failed) (colorize 'bg-dark-gray (colorize 'fg-green "ALL PASSED!!!")) (colorize 'bg-dark-gray (colorize 'fg-red "FAILED (failures = " (string failed) ")")))) (println "======================================================================") (println) (zero? failed))) ;;; ;;; convenient methods in context 'MAIN ;;; (context 'MAIN) ;;; ;;; alias for ``=`` for testing clarification ;;; (define-macro (assert= expected expression , _ass-result) (catch (eval '(apply = (list (eval expected) (eval expression)))) '_ass-result) ;; eval the expression and save the result (push _ass-result UnitTest:*cur-results* -1) ;; save the expression as symbol (push (list 'assert= expected expression) UnitTest:*cur-expressions* -1) ;; (println "-- debug => " (list 'assert= expected expression) " -> " ;; _ass-result) _ass-result) ;;; ;;; what this functions does are ;;; * setting the current test, tracking if the current test contains other tests ;;; * evaluating every expression in the current test and return the result (define-macro (define-test params) ;; ;; `params` the function signature ;; `test_name` is the name of the test, equals `(first params)` ;; `exps` is the body of the ;; (eval (expand '(define signature (let ((UnitTest:*cur-test* (append UnitTest:*cur-test* '(test-name)))) (UnitTest:check exps UnitTest:*cur-test*))) (list (list 'signature params) (list 'exps (args)) (list 'test-name (params 0)))))) ;;; make all symbol used for testing available (global 'assert=) (global 'define-test)
[ { "context": ";;; Copyright (c) 2019,2020 Nicolas Martyanoff <[email protected]>\n;;;\n;;; Permission to use, co", "end": 46, "score": 0.9998844265937805, "start": 28, "tag": "NAME", "value": "Nicolas Martyanoff" }, { "context": ";;; Copyright (c) 2019,2020 Nicolas Martyanoff <[email protected]>\n;;;\n;;; Permission to use, copy, modify, and dis", "end": 65, "score": 0.9999261498451233, "start": 48, "tag": "EMAIL", "value": "[email protected]" }, { "context": "description \"A simple test framework.\"\n :author \"Nicolas Martyanoff <[email protected]>\"\n :licence \"ISC\"\n :serial t", "end": 908, "score": 0.9998882412910461, "start": 890, "tag": "NAME", "value": "Nicolas Martyanoff" }, { "context": "e test framework.\"\n :author \"Nicolas Martyanoff <[email protected]>\"\n :licence \"ISC\"\n :serial t\n :pathname \"src\"\n", "end": 927, "score": 0.9999296069145203, "start": 910, "tag": "EMAIL", "value": "[email protected]" }, { "context": "\"Tests for the tungsten.check system.\"\n :author \"Nicolas Martyanoff <[email protected]>\"\n :licence \"ISC\"\n :depends-", "end": 1426, "score": 0.9998885989189148, "start": 1408, "tag": "NAME", "value": "Nicolas Martyanoff" }, { "context": "ten.check system.\"\n :author \"Nicolas Martyanoff <[email protected]>\"\n :licence \"ISC\"\n :depends-on (\"tungsten.check", "end": 1445, "score": 0.9999250173568726, "start": 1428, "tag": "EMAIL", "value": "[email protected]" } ]
systems/check/tungsten.check.asd
galdor/tungsten
0
;;; Copyright (c) 2019,2020 Nicolas Martyanoff <[email protected]> ;;; ;;; Permission to use, copy, modify, and distribute this software for any ;;; purpose with or without fee is hereby granted, provided that the above ;;; copyright notice and this permission notice appear in all copies. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (defsystem "tungsten.check" :description "A simple test framework." :author "Nicolas Martyanoff <[email protected]>" :licence "ISC" :serial t :pathname "src" :components ((:file "package") (:file "test") (:file "tests") (:file "reporter") (:file "text-reporter") (:file "execution") (:file "assertions") (:file "systems")) :in-order-to ((test-op (test-op "tungsten.check/test")))) (defsystem "tungsten.check/test" :description "Tests for the tungsten.check system." :author "Nicolas Martyanoff <[email protected]>" :licence "ISC" :depends-on ("tungsten.check") :serial t :pathname "t" :components ((:file "package") (:file "assertions")) :perform (test-op (op system) (symbol-call :tungsten.check :run :package :tungsten.check-test)))
96305
;;; Copyright (c) 2019,2020 <NAME> <<EMAIL>> ;;; ;;; Permission to use, copy, modify, and distribute this software for any ;;; purpose with or without fee is hereby granted, provided that the above ;;; copyright notice and this permission notice appear in all copies. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (defsystem "tungsten.check" :description "A simple test framework." :author "<NAME> <<EMAIL>>" :licence "ISC" :serial t :pathname "src" :components ((:file "package") (:file "test") (:file "tests") (:file "reporter") (:file "text-reporter") (:file "execution") (:file "assertions") (:file "systems")) :in-order-to ((test-op (test-op "tungsten.check/test")))) (defsystem "tungsten.check/test" :description "Tests for the tungsten.check system." :author "<NAME> <<EMAIL>>" :licence "ISC" :depends-on ("tungsten.check") :serial t :pathname "t" :components ((:file "package") (:file "assertions")) :perform (test-op (op system) (symbol-call :tungsten.check :run :package :tungsten.check-test)))
true
;;; Copyright (c) 2019,2020 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; ;;; Permission to use, copy, modify, and distribute this software for any ;;; purpose with or without fee is hereby granted, provided that the above ;;; copyright notice and this permission notice appear in all copies. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. (defsystem "tungsten.check" :description "A simple test framework." :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :licence "ISC" :serial t :pathname "src" :components ((:file "package") (:file "test") (:file "tests") (:file "reporter") (:file "text-reporter") (:file "execution") (:file "assertions") (:file "systems")) :in-order-to ((test-op (test-op "tungsten.check/test")))) (defsystem "tungsten.check/test" :description "Tests for the tungsten.check system." :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :licence "ISC" :depends-on ("tungsten.check") :serial t :pathname "t" :components ((:file "package") (:file "assertions")) :perform (test-op (op system) (symbol-call :tungsten.check :run :package :tungsten.check-test)))
[ { "context": ";; AUTHOR:\n;; Shilpi Goel <[email protected]>\n\n(in-package \"X86ISA\")\n\n;", "end": 25, "score": 0.9998828768730164, "start": 14, "tag": "NAME", "value": "Shilpi Goel" }, { "context": ";; AUTHOR:\n;; Shilpi Goel <[email protected]>\n\n(in-package \"X86ISA\")\n\n;; To ensure both of the", "end": 48, "score": 0.9999292492866516, "start": 27, "tag": "EMAIL", "value": "[email protected]" } ]
books/projects/x86isa/proofs/utilities/system-level-mode/top.lisp
solswords/acl2
0
;; AUTHOR: ;; Shilpi Goel <[email protected]> (in-package "X86ISA") ;; To ensure both of these certify... (local (encapsulate () (local (include-book "non-marking-mode-top" :ttags :all)))) (local (encapsulate () (local (include-book "marking-mode-top" :ttags :all))))
43780
;; AUTHOR: ;; <NAME> <<EMAIL>> (in-package "X86ISA") ;; To ensure both of these certify... (local (encapsulate () (local (include-book "non-marking-mode-top" :ttags :all)))) (local (encapsulate () (local (include-book "marking-mode-top" :ttags :all))))
true
;; AUTHOR: ;; PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "X86ISA") ;; To ensure both of these certify... (local (encapsulate () (local (include-book "non-marking-mode-top" :ttags :all)))) (local (encapsulate () (local (include-book "marking-mode-top" :ttags :all))))
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"VL\")\n(includ", "end": 1389, "score": 0.9998705387115479, "start": 1379, "tag": "NAME", "value": "Sol Swords" }, { "context": "IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"VL\")\n(include-book \"utils\")\n(inclu", "end": 1411, "score": 0.9999309778213501, "start": 1391, "tag": "EMAIL", "value": "[email protected]" } ]
books/centaur/vl/loader/parser/classes.lisp
solswords/acl2
0
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Sol Swords <[email protected]> (in-package "VL") (include-book "utils") (include-book "../../parsetree") (local (include-book "../../util/arithmetic")) (defparser vl-maybe-parse-lifetime () :parents (parser) :short "Match an optional @('lifetime') for SystemVerilog-2012." :long "<p>Grammar:</p> @({ lifetime ::= 'static' | 'automatic' })" :result (vl-lifetime-p val) :resultp-of-nil t :fails gracefully :count strong-on-value (seq tokstream (when (vl-is-token? :vl-kwd-static) (:= (vl-match)) (return :vl-static)) (when (vl-is-token? :vl-kwd-automatic) (:= (vl-match)) (return :vl-automatic)) (return nil))) (defparser vl-parse-class-declaration-aux () :result (vl-endinfo-p val) :resultp-of-nil nil :fails gracefully :count strong ;; Similar to UDPs, but we don't have to check for Verilog-2005 because ;; classes only exist in SystemVerilog-2012. (seq tokstream (unless (vl-is-token? :vl-kwd-endclass) (:s= (vl-match-any)) (info := (vl-parse-class-declaration-aux)) (return info)) (end := (vl-match)) (unless (vl-is-token? :vl-colon) (return (make-vl-endinfo :name nil :loc (vl-token->loc end)))) (:= (vl-match)) (id := (vl-match-token :vl-idtoken)) (return (make-vl-endinfo :name (vl-idtoken->name id) :loc (vl-token->loc id))))) (defparser vl-parse-class-declaration (atts) :guard (vl-atts-p atts) :result (vl-class-p val) :resultp-of-nil nil :fails gracefully :count strong (seq tokstream (virtual := (vl-maybe-match-token :vl-kwd-virtual)) (:= (vl-match-token :vl-kwd-class)) (lifetime := (vl-maybe-parse-lifetime)) (name := (vl-match-token :vl-idtoken)) (endinfo := (vl-parse-class-declaration-aux)) (when (and (vl-endinfo->name endinfo) (not (equal (vl-idtoken->name name) (vl-endinfo->name endinfo)))) (return-raw (vl-parse-error (cat "Mismatched class/endclass pair: expected " (vl-idtoken->name name) " but found " (vl-endinfo->name endinfo))))) (return (make-vl-class :name (vl-idtoken->name name) :atts atts :virtualp (and virtual t) :lifetime lifetime :warnings (fatal :type :vl-warn-class :msg "Classes are not supported." :args nil :acc nil) :minloc (vl-token->loc name) :maxloc (vl-endinfo->loc endinfo)))))
19605
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> (in-package "VL") (include-book "utils") (include-book "../../parsetree") (local (include-book "../../util/arithmetic")) (defparser vl-maybe-parse-lifetime () :parents (parser) :short "Match an optional @('lifetime') for SystemVerilog-2012." :long "<p>Grammar:</p> @({ lifetime ::= 'static' | 'automatic' })" :result (vl-lifetime-p val) :resultp-of-nil t :fails gracefully :count strong-on-value (seq tokstream (when (vl-is-token? :vl-kwd-static) (:= (vl-match)) (return :vl-static)) (when (vl-is-token? :vl-kwd-automatic) (:= (vl-match)) (return :vl-automatic)) (return nil))) (defparser vl-parse-class-declaration-aux () :result (vl-endinfo-p val) :resultp-of-nil nil :fails gracefully :count strong ;; Similar to UDPs, but we don't have to check for Verilog-2005 because ;; classes only exist in SystemVerilog-2012. (seq tokstream (unless (vl-is-token? :vl-kwd-endclass) (:s= (vl-match-any)) (info := (vl-parse-class-declaration-aux)) (return info)) (end := (vl-match)) (unless (vl-is-token? :vl-colon) (return (make-vl-endinfo :name nil :loc (vl-token->loc end)))) (:= (vl-match)) (id := (vl-match-token :vl-idtoken)) (return (make-vl-endinfo :name (vl-idtoken->name id) :loc (vl-token->loc id))))) (defparser vl-parse-class-declaration (atts) :guard (vl-atts-p atts) :result (vl-class-p val) :resultp-of-nil nil :fails gracefully :count strong (seq tokstream (virtual := (vl-maybe-match-token :vl-kwd-virtual)) (:= (vl-match-token :vl-kwd-class)) (lifetime := (vl-maybe-parse-lifetime)) (name := (vl-match-token :vl-idtoken)) (endinfo := (vl-parse-class-declaration-aux)) (when (and (vl-endinfo->name endinfo) (not (equal (vl-idtoken->name name) (vl-endinfo->name endinfo)))) (return-raw (vl-parse-error (cat "Mismatched class/endclass pair: expected " (vl-idtoken->name name) " but found " (vl-endinfo->name endinfo))))) (return (make-vl-class :name (vl-idtoken->name name) :atts atts :virtualp (and virtual t) :lifetime lifetime :warnings (fatal :type :vl-warn-class :msg "Classes are not supported." :args nil :acc nil) :minloc (vl-token->loc name) :maxloc (vl-endinfo->loc endinfo)))))
true
; VL Verilog Toolkit ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "VL") (include-book "utils") (include-book "../../parsetree") (local (include-book "../../util/arithmetic")) (defparser vl-maybe-parse-lifetime () :parents (parser) :short "Match an optional @('lifetime') for SystemVerilog-2012." :long "<p>Grammar:</p> @({ lifetime ::= 'static' | 'automatic' })" :result (vl-lifetime-p val) :resultp-of-nil t :fails gracefully :count strong-on-value (seq tokstream (when (vl-is-token? :vl-kwd-static) (:= (vl-match)) (return :vl-static)) (when (vl-is-token? :vl-kwd-automatic) (:= (vl-match)) (return :vl-automatic)) (return nil))) (defparser vl-parse-class-declaration-aux () :result (vl-endinfo-p val) :resultp-of-nil nil :fails gracefully :count strong ;; Similar to UDPs, but we don't have to check for Verilog-2005 because ;; classes only exist in SystemVerilog-2012. (seq tokstream (unless (vl-is-token? :vl-kwd-endclass) (:s= (vl-match-any)) (info := (vl-parse-class-declaration-aux)) (return info)) (end := (vl-match)) (unless (vl-is-token? :vl-colon) (return (make-vl-endinfo :name nil :loc (vl-token->loc end)))) (:= (vl-match)) (id := (vl-match-token :vl-idtoken)) (return (make-vl-endinfo :name (vl-idtoken->name id) :loc (vl-token->loc id))))) (defparser vl-parse-class-declaration (atts) :guard (vl-atts-p atts) :result (vl-class-p val) :resultp-of-nil nil :fails gracefully :count strong (seq tokstream (virtual := (vl-maybe-match-token :vl-kwd-virtual)) (:= (vl-match-token :vl-kwd-class)) (lifetime := (vl-maybe-parse-lifetime)) (name := (vl-match-token :vl-idtoken)) (endinfo := (vl-parse-class-declaration-aux)) (when (and (vl-endinfo->name endinfo) (not (equal (vl-idtoken->name name) (vl-endinfo->name endinfo)))) (return-raw (vl-parse-error (cat "Mismatched class/endclass pair: expected " (vl-idtoken->name name) " but found " (vl-endinfo->name endinfo))))) (return (make-vl-class :name (vl-idtoken->name name) :atts atts :virtualp (and virtual t) :lifetime lifetime :warnings (fatal :type :vl-warn-class :msg "Classes are not supported." :args nil :acc nil) :minloc (vl-token->loc name) :maxloc (vl-endinfo->loc endinfo)))))
[ { "context": " ;;;;;\n;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;\n;;; All rights re", "end": 356, "score": 0.9998838901519775, "start": 340, "tag": "NAME", "value": "William Schelter" } ]
maxima/src/maxima/src/trprop.lisp
nilqed/spadlib
1
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; (c) Copyright 1981 Massachusetts Institute of Technology ;;; ;;; GJC 10:11pm Tuesday, 14 July 1981 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :maxima) (macsyma-module trprop) ;; Many macsyma extension commands, e.g. $INFIX, $TELLSIMP, ;; $DEFTAYLOR work by doing explicit PUTPROPS. ;; These META-PROP functions allow selected commands to ;; also output DEFPROP's when processed in the Macsyma->lisp translation. (defmvar meta-prop-p nil) (defmvar meta-prop-l nil) (defun meta-output (form) (if *in-translate-file* (push form meta-prop-l)) ;; unfortunately, MATCOM needs to see properties in order ;; to compose tellsimps. so eval it always. (eval form)) (defun meta-add2lnc (item ssymbol) (if meta-prop-p (meta-output `(add2lnc ',item ,ssymbol)) (add2lnc item (symbol-value ssymbol)))) (defun meta-putprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(defprop ,ssymbol ,item ,key))) (putprop ssymbol item key))) (defun meta-mputprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(mdefprop ,ssymbol ,item ,key))) (mputprop ssymbol item key))) (defun meta-fset (ssymbol definition) (if meta-prop-p (prog1 definition (meta-output `(fset ',ssymbol (coerce ',definition 'function)))) (fset ssymbol (coerce definition 'function))))
50468
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by <NAME>,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; (c) Copyright 1981 Massachusetts Institute of Technology ;;; ;;; GJC 10:11pm Tuesday, 14 July 1981 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :maxima) (macsyma-module trprop) ;; Many macsyma extension commands, e.g. $INFIX, $TELLSIMP, ;; $DEFTAYLOR work by doing explicit PUTPROPS. ;; These META-PROP functions allow selected commands to ;; also output DEFPROP's when processed in the Macsyma->lisp translation. (defmvar meta-prop-p nil) (defmvar meta-prop-l nil) (defun meta-output (form) (if *in-translate-file* (push form meta-prop-l)) ;; unfortunately, MATCOM needs to see properties in order ;; to compose tellsimps. so eval it always. (eval form)) (defun meta-add2lnc (item ssymbol) (if meta-prop-p (meta-output `(add2lnc ',item ,ssymbol)) (add2lnc item (symbol-value ssymbol)))) (defun meta-putprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(defprop ,ssymbol ,item ,key))) (putprop ssymbol item key))) (defun meta-mputprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(mdefprop ,ssymbol ,item ,key))) (mputprop ssymbol item key))) (defun meta-fset (ssymbol definition) (if meta-prop-p (prog1 definition (meta-output `(fset ',ssymbol (coerce ',definition 'function)))) (fset ssymbol (coerce definition 'function))))
true
;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The data in this file contains enhancments. ;;;;; ;;; ;;;;; ;;; Copyright (c) 1984,1987 by PI:NAME:<NAME>END_PI,University of Texas ;;;;; ;;; All rights reserved ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; (c) Copyright 1981 Massachusetts Institute of Technology ;;; ;;; GJC 10:11pm Tuesday, 14 July 1981 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :maxima) (macsyma-module trprop) ;; Many macsyma extension commands, e.g. $INFIX, $TELLSIMP, ;; $DEFTAYLOR work by doing explicit PUTPROPS. ;; These META-PROP functions allow selected commands to ;; also output DEFPROP's when processed in the Macsyma->lisp translation. (defmvar meta-prop-p nil) (defmvar meta-prop-l nil) (defun meta-output (form) (if *in-translate-file* (push form meta-prop-l)) ;; unfortunately, MATCOM needs to see properties in order ;; to compose tellsimps. so eval it always. (eval form)) (defun meta-add2lnc (item ssymbol) (if meta-prop-p (meta-output `(add2lnc ',item ,ssymbol)) (add2lnc item (symbol-value ssymbol)))) (defun meta-putprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(defprop ,ssymbol ,item ,key))) (putprop ssymbol item key))) (defun meta-mputprop (ssymbol item key) (if meta-prop-p (prog1 item (meta-output `(mdefprop ,ssymbol ,item ,key))) (mputprop ssymbol item key))) (defun meta-fset (ssymbol definition) (if meta-prop-p (prog1 definition (meta-output `(fset ',ssymbol (coerce ',definition 'function)))) (fset ssymbol (coerce definition 'function))))
[ { "context": "icate certificate\n :key key\n :password certificate-password))))\n\n#+lispworks\n(defun open-connection (uri)\n (", "end": 3860, "score": 0.9963574409484863, "start": 3840, "tag": "PASSWORD", "value": "certificate-password" } ]
http/connection-manager.lisp
xh4/web-toolk
81
(in-package :http) (defclass connection-manager () ((connections :initarg :connections :initform nil :accessor connection-manager-connections))) (defgeneric request-connection (connection-manager request) (:method (connection-manager request) (let ((uri (request-uri request))) (let ((connection (open-connection uri))) (with-slots (connections) connection-manager (push connection connections)) (set-header-field request (header-field "Connection" "close")) connection)))) (defgeneric release-connection (connection-manager connection) (:method (connection-manager connection) (with-slots (connections) connection-manager (setf connections (remove connection connections))))) (defgeneric shutdown-connection-manager (connection-manager) (:method (connection-manager) (with-slots (connections) connection-manager (loop for connection in connections do (close-connection connection)) (setf connections nil)))) #-lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (usocket:socket-connect host port :element-type '(unsigned-byte 8) #+sbcl :timeout #+sbcl 10 :nodelay :if-supported))) (let ((connection (make-connection socket))) (with-slots (input-stream output-stream) connection (when https-p (setf output-stream (make-ssl-stream output-stream :hostname host :certificate nil :key nil :certificate-password nil :verify nil ;; :max-depth 10 :ca-file nil :ca-directory nil) input-stream output-stream))) connection))))) #-lispworks (defun make-ssl-stream (stream &key hostname certificate key certificate-password verify (max-depth 10) ca-file ca-directory) "Attaches SSL to the stream STREAM and returns the SSL stream \(which will not be equal to STREAM)." (declare (ignorable stream certificate-password max-depth ca-directory hostname)) (check-type verify (member nil :optional :required)) (when (and certificate (not (probe-file certificate))) (error "certificate file ~A not found" certificate)) (when (and key (not (probe-file key))) (error "key file ~A not found" key)) (when (and ca-file (not (probe-file ca-file))) (error "ca file ~A not found" ca-file)) (let ((ctx (cl+ssl:make-context :verify-depth max-depth :verify-mode cl+ssl:+ssl-verify-none+ :verify-callback nil :verify-location (or (and ca-file ca-directory (list ca-file ca-directory)) ca-file ca-directory :default)))) (cl+ssl:with-global-context (ctx) (cl+ssl:make-ssl-client-stream (cl+ssl:stream-fd stream) :verify verify :hostname hostname :close-callback (lambda () (close stream) (cl+ssl:ssl-ctx-free ctx)) :certificate certificate :key key :password certificate-password)))) #+lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (comm:connect-to-tcp-server host port :timeout 10 :errorp t))) (let ((connection (make-connection socket))) (let ((stream (connection-output-stream connection))) (setf (stream:stream-read-timeout stream) 10 (stream:stream-write-timeout stream) 10) (when https-p (comm:attach-ssl (connection-output-stream connection) :ssl-ctx t :ssl-side :client :tlsext-host-name host))) connection))))) (defclass persistent-connection-manager (connection-mamanger) ()) (defmethod request-connection ((connection-mamanger persistent-connection-manager) request) ) (defmethod release-connection ((connection-mamanger persistent-connection-manager) connection) ) (defmethod shutdown-connection-manager ((connection-mamanger persistent-connection-manager)) )
97015
(in-package :http) (defclass connection-manager () ((connections :initarg :connections :initform nil :accessor connection-manager-connections))) (defgeneric request-connection (connection-manager request) (:method (connection-manager request) (let ((uri (request-uri request))) (let ((connection (open-connection uri))) (with-slots (connections) connection-manager (push connection connections)) (set-header-field request (header-field "Connection" "close")) connection)))) (defgeneric release-connection (connection-manager connection) (:method (connection-manager connection) (with-slots (connections) connection-manager (setf connections (remove connection connections))))) (defgeneric shutdown-connection-manager (connection-manager) (:method (connection-manager) (with-slots (connections) connection-manager (loop for connection in connections do (close-connection connection)) (setf connections nil)))) #-lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (usocket:socket-connect host port :element-type '(unsigned-byte 8) #+sbcl :timeout #+sbcl 10 :nodelay :if-supported))) (let ((connection (make-connection socket))) (with-slots (input-stream output-stream) connection (when https-p (setf output-stream (make-ssl-stream output-stream :hostname host :certificate nil :key nil :certificate-password nil :verify nil ;; :max-depth 10 :ca-file nil :ca-directory nil) input-stream output-stream))) connection))))) #-lispworks (defun make-ssl-stream (stream &key hostname certificate key certificate-password verify (max-depth 10) ca-file ca-directory) "Attaches SSL to the stream STREAM and returns the SSL stream \(which will not be equal to STREAM)." (declare (ignorable stream certificate-password max-depth ca-directory hostname)) (check-type verify (member nil :optional :required)) (when (and certificate (not (probe-file certificate))) (error "certificate file ~A not found" certificate)) (when (and key (not (probe-file key))) (error "key file ~A not found" key)) (when (and ca-file (not (probe-file ca-file))) (error "ca file ~A not found" ca-file)) (let ((ctx (cl+ssl:make-context :verify-depth max-depth :verify-mode cl+ssl:+ssl-verify-none+ :verify-callback nil :verify-location (or (and ca-file ca-directory (list ca-file ca-directory)) ca-file ca-directory :default)))) (cl+ssl:with-global-context (ctx) (cl+ssl:make-ssl-client-stream (cl+ssl:stream-fd stream) :verify verify :hostname hostname :close-callback (lambda () (close stream) (cl+ssl:ssl-ctx-free ctx)) :certificate certificate :key key :password <PASSWORD>)))) #+lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (comm:connect-to-tcp-server host port :timeout 10 :errorp t))) (let ((connection (make-connection socket))) (let ((stream (connection-output-stream connection))) (setf (stream:stream-read-timeout stream) 10 (stream:stream-write-timeout stream) 10) (when https-p (comm:attach-ssl (connection-output-stream connection) :ssl-ctx t :ssl-side :client :tlsext-host-name host))) connection))))) (defclass persistent-connection-manager (connection-mamanger) ()) (defmethod request-connection ((connection-mamanger persistent-connection-manager) request) ) (defmethod release-connection ((connection-mamanger persistent-connection-manager) connection) ) (defmethod shutdown-connection-manager ((connection-mamanger persistent-connection-manager)) )
true
(in-package :http) (defclass connection-manager () ((connections :initarg :connections :initform nil :accessor connection-manager-connections))) (defgeneric request-connection (connection-manager request) (:method (connection-manager request) (let ((uri (request-uri request))) (let ((connection (open-connection uri))) (with-slots (connections) connection-manager (push connection connections)) (set-header-field request (header-field "Connection" "close")) connection)))) (defgeneric release-connection (connection-manager connection) (:method (connection-manager connection) (with-slots (connections) connection-manager (setf connections (remove connection connections))))) (defgeneric shutdown-connection-manager (connection-manager) (:method (connection-manager) (with-slots (connections) connection-manager (loop for connection in connections do (close-connection connection)) (setf connections nil)))) #-lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (usocket:socket-connect host port :element-type '(unsigned-byte 8) #+sbcl :timeout #+sbcl 10 :nodelay :if-supported))) (let ((connection (make-connection socket))) (with-slots (input-stream output-stream) connection (when https-p (setf output-stream (make-ssl-stream output-stream :hostname host :certificate nil :key nil :certificate-password nil :verify nil ;; :max-depth 10 :ca-file nil :ca-directory nil) input-stream output-stream))) connection))))) #-lispworks (defun make-ssl-stream (stream &key hostname certificate key certificate-password verify (max-depth 10) ca-file ca-directory) "Attaches SSL to the stream STREAM and returns the SSL stream \(which will not be equal to STREAM)." (declare (ignorable stream certificate-password max-depth ca-directory hostname)) (check-type verify (member nil :optional :required)) (when (and certificate (not (probe-file certificate))) (error "certificate file ~A not found" certificate)) (when (and key (not (probe-file key))) (error "key file ~A not found" key)) (when (and ca-file (not (probe-file ca-file))) (error "ca file ~A not found" ca-file)) (let ((ctx (cl+ssl:make-context :verify-depth max-depth :verify-mode cl+ssl:+ssl-verify-none+ :verify-callback nil :verify-location (or (and ca-file ca-directory (list ca-file ca-directory)) ca-file ca-directory :default)))) (cl+ssl:with-global-context (ctx) (cl+ssl:make-ssl-client-stream (cl+ssl:stream-fd stream) :verify verify :hostname hostname :close-callback (lambda () (close stream) (cl+ssl:ssl-ctx-free ctx)) :certificate certificate :key key :password PI:PASSWORD:<PASSWORD>END_PI)))) #+lispworks (defun open-connection (uri) (let ((https-p (equal "https" (uri-scheme uri)))) (let ((host (uri-host uri)) (port (or (uri-port uri) (if https-p 443 80)))) (let ((socket (comm:connect-to-tcp-server host port :timeout 10 :errorp t))) (let ((connection (make-connection socket))) (let ((stream (connection-output-stream connection))) (setf (stream:stream-read-timeout stream) 10 (stream:stream-write-timeout stream) 10) (when https-p (comm:attach-ssl (connection-output-stream connection) :ssl-ctx t :ssl-side :client :tlsext-host-name host))) connection))))) (defclass persistent-connection-manager (connection-mamanger) ()) (defmethod request-connection ((connection-mamanger persistent-connection-manager) request) ) (defmethod release-connection ((connection-mamanger persistent-connection-manager) connection) ) (defmethod shutdown-connection-manager ((connection-mamanger persistent-connection-manager)) )
[ { "context": "ption \"Small weather fetching utility\"\n :author \"Theodor Thornhill <[email protected]>\"\n :license \"MIT\"\n :version ", "end": 102, "score": 0.9998998641967773, "start": 85, "tag": "NAME", "value": "Theodor Thornhill" }, { "context": "r fetching utility\"\n :author \"Theodor Thornhill <[email protected]>\"\n :license \"MIT\"\n :version \"0.0.1\"\n :depends-", "end": 121, "score": 0.999932587146759, "start": 104, "tag": "EMAIL", "value": "[email protected]" } ]
weather.asd
theothornhill/weather
0
(asdf:defsystem :weather :description "Small weather fetching utility" :author "Theodor Thornhill <[email protected]>" :license "MIT" :version "0.0.1" :depends-on (:flexi-streams :cl-json :drakma :cl-ppcre :unix-opts) :components ((:module "src" :components ((:file "package") (:file "weather")))))
41913
(asdf:defsystem :weather :description "Small weather fetching utility" :author "<NAME> <<EMAIL>>" :license "MIT" :version "0.0.1" :depends-on (:flexi-streams :cl-json :drakma :cl-ppcre :unix-opts) :components ((:module "src" :components ((:file "package") (:file "weather")))))
true
(asdf:defsystem :weather :description "Small weather fetching utility" :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "MIT" :version "0.0.1" :depends-on (:flexi-streams :cl-json :drakma :cl-ppcre :unix-opts) :components ((:module "src" :components ((:file "package") (:file "weather")))))
[ { "context": "defsystem #:zpb-ttf\n :version \"1.0.3\"\n :author \"Zach Beane <[email protected]>\"\n :description \"Access TrueType ", "end": 202, "score": 0.9998677968978882, "start": 192, "tag": "NAME", "value": "Zach Beane" }, { "context": "zpb-ttf\n :version \"1.0.3\"\n :author \"Zach Beane <[email protected]>\"\n :description \"Access TrueType font metrics an", "end": 217, "score": 0.9999274015426636, "start": 204, "tag": "EMAIL", "value": "[email protected]" } ]
zpb-ttf.asd
3b/zpb-ttf
13
;; $Id: zpb-ttf.asd,v 1.5 2006/03/24 20:47:27 xach Exp $ (defpackage #:zpb-ttf-system (:use #:cl #:asdf)) (in-package #:zpb-ttf-system) (defsystem #:zpb-ttf :version "1.0.3" :author "Zach Beane <[email protected]>" :description "Access TrueType font metrics and outlines from Common Lisp" :license "BSD" :components ((:file "package") (:file "util" :depends-on ("package")) (:file "conditions" :depends-on ("package")) (:file "bounding-box" :depends-on ("package")) (:file "font-loader" :depends-on ("package" "util" "bounding-box")) (:file "maxp" :depends-on ("package" "util" "font-loader")) (:file "head" :depends-on ("package" "util" "conditions" "font-loader")) (:file "kern" :depends-on ("package" "util" "conditions" "font-loader")) (:file "loca" :depends-on ("package" "util" "font-loader")) (:file "name" :depends-on ("package" "util" "conditions" "font-loader")) (:file "cmap" :depends-on ("package" "util" "name" "font-loader")) (:file "post" :depends-on ("package" "util" "conditions" "font-loader")) (:file "hhea" :depends-on ("package" "util" "font-loader")) (:file "hmtx" :depends-on ("package" "util" "font-loader" "hhea")) (:file "glyf" :depends-on ("package" "util" "loca" "font-loader")) (:file "glyph" :depends-on ("package" "util" "font-loader" "bounding-box" "glyf" "kern" "loca")) (:file "font-loader-interface" :depends-on ("package" "util" "conditions" "font-loader" "maxp" "head" "kern" "loca" "name" "cmap" "post" "hhea" "hmtx"))))
78691
;; $Id: zpb-ttf.asd,v 1.5 2006/03/24 20:47:27 xach Exp $ (defpackage #:zpb-ttf-system (:use #:cl #:asdf)) (in-package #:zpb-ttf-system) (defsystem #:zpb-ttf :version "1.0.3" :author "<NAME> <<EMAIL>>" :description "Access TrueType font metrics and outlines from Common Lisp" :license "BSD" :components ((:file "package") (:file "util" :depends-on ("package")) (:file "conditions" :depends-on ("package")) (:file "bounding-box" :depends-on ("package")) (:file "font-loader" :depends-on ("package" "util" "bounding-box")) (:file "maxp" :depends-on ("package" "util" "font-loader")) (:file "head" :depends-on ("package" "util" "conditions" "font-loader")) (:file "kern" :depends-on ("package" "util" "conditions" "font-loader")) (:file "loca" :depends-on ("package" "util" "font-loader")) (:file "name" :depends-on ("package" "util" "conditions" "font-loader")) (:file "cmap" :depends-on ("package" "util" "name" "font-loader")) (:file "post" :depends-on ("package" "util" "conditions" "font-loader")) (:file "hhea" :depends-on ("package" "util" "font-loader")) (:file "hmtx" :depends-on ("package" "util" "font-loader" "hhea")) (:file "glyf" :depends-on ("package" "util" "loca" "font-loader")) (:file "glyph" :depends-on ("package" "util" "font-loader" "bounding-box" "glyf" "kern" "loca")) (:file "font-loader-interface" :depends-on ("package" "util" "conditions" "font-loader" "maxp" "head" "kern" "loca" "name" "cmap" "post" "hhea" "hmtx"))))
true
;; $Id: zpb-ttf.asd,v 1.5 2006/03/24 20:47:27 xach Exp $ (defpackage #:zpb-ttf-system (:use #:cl #:asdf)) (in-package #:zpb-ttf-system) (defsystem #:zpb-ttf :version "1.0.3" :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :description "Access TrueType font metrics and outlines from Common Lisp" :license "BSD" :components ((:file "package") (:file "util" :depends-on ("package")) (:file "conditions" :depends-on ("package")) (:file "bounding-box" :depends-on ("package")) (:file "font-loader" :depends-on ("package" "util" "bounding-box")) (:file "maxp" :depends-on ("package" "util" "font-loader")) (:file "head" :depends-on ("package" "util" "conditions" "font-loader")) (:file "kern" :depends-on ("package" "util" "conditions" "font-loader")) (:file "loca" :depends-on ("package" "util" "font-loader")) (:file "name" :depends-on ("package" "util" "conditions" "font-loader")) (:file "cmap" :depends-on ("package" "util" "name" "font-loader")) (:file "post" :depends-on ("package" "util" "conditions" "font-loader")) (:file "hhea" :depends-on ("package" "util" "font-loader")) (:file "hmtx" :depends-on ("package" "util" "font-loader" "hhea")) (:file "glyf" :depends-on ("package" "util" "loca" "font-loader")) (:file "glyph" :depends-on ("package" "util" "font-loader" "bounding-box" "glyf" "kern" "loca")) (:file "font-loader-interface" :depends-on ("package" "util" "conditions" "font-loader" "maxp" "head" "kern" "loca" "name" "cmap" "post" "hhea" "hmtx"))))
[ { "context": " Reserved.\n;;;\n;;; Additional developments made by Robert P. Goldman, John Maraist.\n;;; Portions created by Drs. Goldm", "end": 835, "score": 0.9998661875724792, "start": 818, "tag": "NAME", "value": "Robert P. Goldman" }, { "context": "Additional developments made by Robert P. Goldman, John Maraist.\n;;; Portions created by Drs. Goldman and Maraist", "end": 849, "score": 0.9998776912689209, "start": 837, "tag": "NAME", "value": "John Maraist" }, { "context": " P. Goldman, John Maraist.\n;;; Portions created by Drs. Goldman and Maraist are Copyright (C)\n;;; 2004-2007 SIFT,", "end": 887, "score": 0.9998067617416382, "start": 875, "tag": "NAME", "value": "Drs. Goldman" }, { "context": " Maraist.\n;;; Portions created by Drs. Goldman and Maraist are Copyright (C)\n;;; 2004-2007 SIFT, LLC. These", "end": 899, "score": 0.9931816458702087, "start": 892, "tag": "NAME", "value": "Maraist" } ]
platform/site-lisp/shop3/shop3/io/debugging.lisp
TeamSPoon/CYC_JRTL_with_CommonLisp_OLD
10
;;; ;;; Version: MPL 1.1/GPL 2.0/LGPL 2.1 ;;; ;;; The contents of this file are subject to the Mozilla Public License ;;; Version 1.1 (the "License"); you may not use this file except in ;;; compliance with the License. You may obtain a copy of the License at ;;; http://www.mozilla.org/MPL/ ;;; ;;; Software distributed under the License is distributed on an "AS IS" ;;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ;;; License for the specific language governing rights and limitations under ;;; the License. ;;; ;;; The Original Code is SHOP2. ;;; ;;; The Initial Developer of the Original Code is the University of ;;; Maryland. Portions created by the Initial Developer are Copyright (C) ;;; 2002,2003 the Initial Developer. All Rights Reserved. ;;; ;;; Additional developments made by Robert P. Goldman, John Maraist. ;;; Portions created by Drs. Goldman and Maraist are Copyright (C) ;;; 2004-2007 SIFT, LLC. These additions and modifications are also ;;; available under the MPL/GPL/LGPL licensing terms. ;;; ;;; ;;; Alternatively, the contents of this file may be used under the terms of ;;; either of the GNU General Public License Version 2 or later (the "GPL"), ;;; or the GNU Lesser General Public License Version 2.1 or later (the ;;; "LGPL"), in which case the provisions of the GPL or the LGPL are ;;; applicable instead of those above. If you wish to allow use of your ;;; version of this file only under the terms of either the GPL or the LGPL, ;;; and not to allow others to use your version of this file under the terms ;;; of the MPL, indicate your decision by deleting the provisions above and ;;; replace them with the notice and other provisions required by the GPL or ;;; the LGPL. If you do not delete the provisions above, a recipient may use ;;; your version of this file under the terms of any one of the MPL, the GPL ;;; or the LGPL. ;;; ---------------------------------------------------------------------- ;;; Smart Information Flow Technologies Copyright 2006-2007 Unpublished work ;;; ;;; GOVERNMENT PURPOSE RIGHTS ;;; ;;; Contract No. FA8650-06-C-7606, ;;; Contractor Name Smart Information Flow Technologies, LLC ;;; d/b/a SIFT, LLC ;;; Contractor Address 211 N 1st Street, Suite 300 ;;; Minneapolis, MN 55401 ;;; Expiration Date 5/2/2011 ;;; ;;; The Government's rights to use, modify, reproduce, release, ;;; perform, display, or disclose this software are restricted by ;;; paragraph (b)(2) of the Rights in Noncommercial Computer Software ;;; and Noncommercial Computer Software Documentation clause contained ;;; in the above identified contract. No restrictions apply after the ;;; expiration date shown above. Any reproduction of the software or ;;; portions thereof marked with this legend must also reproduce the ;;; markings. (in-package :shop2) (defvar *start-run-time*) (defvar *start-real-time*) ;; (defvar *traced-operators* nil) ; break when attempting to ; apply one of these. (defvar *traced-methods* nil) ; break when attempting to ; apply one of these. (defvar *traced-tasks* nil) ; break when attempting to ; expand one of these. (defvar *traced-axioms* nil) (defvar *traced-goals* nil) (defconstant SHOP-TRACE-ITEMS (list :methods :axioms :operators :tasks :goals :effects :protections :states :plans :item) "Acceptable arguments for SHOP-TRACE (and SHOP-UNTRACE).") (defmacro shop-trace (&rest items) "- (SHOP-TRACE) with no arguments will return a list of what's currently being traced. - (SHOP-TRACE ITEM) will turn on tracing for ITEM. ITEM may be any of the following: - the name of a method, axiom, operator, task, or predicate; - one of the keywords :METHODS, :AXIOMS, :OPERATORS, :TASKS, :GOALS, :EFFECTS, or :PROTECTIONS, in which case SHOP will trace all items of that type (:GOALS, :EFFECTS, and :PROTECTIONS refer to three different ways predicates can occur: as goals to be satisfied, and as effects or protections in operators); - a pair of the form (:TASK <taskname>), (:METHOD <methodname>). SHOP will break when attempting to expand the task, or apply the method, respectively. - the keyword :STATES, in which case SHOP will include the current state whenever it prints out a tracing message - the keyword :ALL in which case SHOP will print out all the tracing information it knows how to. - (SHOP-TRACE ITEM1 ITEM2 ...) will do the same for a list of items" (let* ((items `,items) (new-items (if (null items) nil items) )) (when (member :all new-items) (setf new-items (delete :all new-items)) (setf new-items (union SHOP-TRACE-ITEMS new-items))) `(shop-trace-1 ',new-items))) (defun shop-trace-1 (items) ;; make sure the argument is coerced to a list (unless (null items) (dolist (item items) (cond ((member item SHOP-TRACE-ITEMS) (pushnew item *shop-trace*)) ((listp item) (macrolet ((trace-item (variable) `(progn (pushnew (second item) ,variable) (pushnew :item *shop-trace*)))) (case (car item) (:task (trace-item *traced-tasks*)) (:method (trace-item *traced-methods*)) (:goal (trace-item *traced-goals*)) (:axiom (trace-item *traced-axioms*)) (otherwise (warn "Ignoring invalid shop-trace argument ~S" item))))) (t (warn "Ignoring invalid shop-trace argument ~S" item))))) (shop-trace-info)) (defmethod trigger-trace ((keyword (eql :methods)) (item symbol)) (member item *traced-methods* :test 'eq)) (defmethod trigger-trace ((keyword (eql :axioms)) (item symbol)) (member item *traced-axioms* :test 'eq)) (defmethod trigger-trace ((keyword (eql :goals)) (item symbol)) (member item *traced-goals* :test 'eq)) (defmethod trigger-trace ((keyword (eql :tasks)) (item symbol)) (member item *traced-tasks* :test 'eq)) (defun shop-trace-info () "Information about the traced aspects of shop2." (append *shop-trace* (mapcar #'(lambda (taskname) `(:task ,taskname)) *traced-tasks*) (mapcar #'(lambda (methname) `(:method ,methname)) *traced-methods*) (mapcar #'(lambda (goalname) `(:goal ,goalname)) *traced-goals*) (mapcar #'(lambda (axiomname) `(:axiom ,axiomname)) *traced-axioms*))) (defmacro shop-untrace (&rest items) "(SHOP-UNTRACE ...) is the inverse of (SHOP-TRACE ...)" (if (or (member :all items) (null items)) '(shop-untrace-all) `(shop-untrace-1 ',items))) (defun shop-untrace-all () (setf *shop-trace* nil *traced-tasks* nil ;;*traced-operators* nil *traced-methods* nil *traced-goals* nil *traced-axioms* nil)) (defun shop-untrace-1 (items) ;; it's OK to use destructive deletion here (dolist (item items) (cond ((symbolp item) (setq *shop-trace* (delete item *shop-trace*))) ((eq (car item) :task) (setf *traced-tasks* (delete (second item) *traced-tasks*))) ((eq (car item) :method) (setf *traced-methods* (delete (second item) *traced-methods*))) ((eq (car item) :all) (shop-untrace-all)) (t (warn "don't know how to delete ~S from shop-trace items: ignoring." item))))) (defun print-methods (&optional name (domain *domain*)) (if name (progn (format t "Methods for name ~S are:" name) (mapcar #'(lambda (x) (format t "~2% ~s" x)) (methods domain name))) (maphash #'(lambda (k defs) (format t "~2%Methods for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-methods domain)))) ;;; this I don't understand: AFAICT from the rest of the code there ;;; can be only ONE operator defined with a particular ;;; name... [2006/07/05:rpg] (defun print-operators (&optional name (domain *domain*)) (if name (progn (format t "Operator for name ~S is:" name) (format t "~2% ~s" (operator domain name))) (maphash #'(lambda (k defs) (format t "~2%Operators for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-operators domain)))) (defun print-operator (operator &optional (stream t)) (format stream "~THead: ~S~%~@[~TPreconditions: ~S~%~]~@[~TDelete-list: ~S~%~] ~@[~TAdd-list: ~S~%~]~@[~TCost-fun: ~S~%~]" (operator-head operator) (operator-preconditions operator) (operator-deletions operator) (operator-additions operator) (operator-cost-fun operator)))
73019
;;; ;;; Version: MPL 1.1/GPL 2.0/LGPL 2.1 ;;; ;;; The contents of this file are subject to the Mozilla Public License ;;; Version 1.1 (the "License"); you may not use this file except in ;;; compliance with the License. You may obtain a copy of the License at ;;; http://www.mozilla.org/MPL/ ;;; ;;; Software distributed under the License is distributed on an "AS IS" ;;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ;;; License for the specific language governing rights and limitations under ;;; the License. ;;; ;;; The Original Code is SHOP2. ;;; ;;; The Initial Developer of the Original Code is the University of ;;; Maryland. Portions created by the Initial Developer are Copyright (C) ;;; 2002,2003 the Initial Developer. All Rights Reserved. ;;; ;;; Additional developments made by <NAME>, <NAME>. ;;; Portions created by <NAME> and <NAME> are Copyright (C) ;;; 2004-2007 SIFT, LLC. These additions and modifications are also ;;; available under the MPL/GPL/LGPL licensing terms. ;;; ;;; ;;; Alternatively, the contents of this file may be used under the terms of ;;; either of the GNU General Public License Version 2 or later (the "GPL"), ;;; or the GNU Lesser General Public License Version 2.1 or later (the ;;; "LGPL"), in which case the provisions of the GPL or the LGPL are ;;; applicable instead of those above. If you wish to allow use of your ;;; version of this file only under the terms of either the GPL or the LGPL, ;;; and not to allow others to use your version of this file under the terms ;;; of the MPL, indicate your decision by deleting the provisions above and ;;; replace them with the notice and other provisions required by the GPL or ;;; the LGPL. If you do not delete the provisions above, a recipient may use ;;; your version of this file under the terms of any one of the MPL, the GPL ;;; or the LGPL. ;;; ---------------------------------------------------------------------- ;;; Smart Information Flow Technologies Copyright 2006-2007 Unpublished work ;;; ;;; GOVERNMENT PURPOSE RIGHTS ;;; ;;; Contract No. FA8650-06-C-7606, ;;; Contractor Name Smart Information Flow Technologies, LLC ;;; d/b/a SIFT, LLC ;;; Contractor Address 211 N 1st Street, Suite 300 ;;; Minneapolis, MN 55401 ;;; Expiration Date 5/2/2011 ;;; ;;; The Government's rights to use, modify, reproduce, release, ;;; perform, display, or disclose this software are restricted by ;;; paragraph (b)(2) of the Rights in Noncommercial Computer Software ;;; and Noncommercial Computer Software Documentation clause contained ;;; in the above identified contract. No restrictions apply after the ;;; expiration date shown above. Any reproduction of the software or ;;; portions thereof marked with this legend must also reproduce the ;;; markings. (in-package :shop2) (defvar *start-run-time*) (defvar *start-real-time*) ;; (defvar *traced-operators* nil) ; break when attempting to ; apply one of these. (defvar *traced-methods* nil) ; break when attempting to ; apply one of these. (defvar *traced-tasks* nil) ; break when attempting to ; expand one of these. (defvar *traced-axioms* nil) (defvar *traced-goals* nil) (defconstant SHOP-TRACE-ITEMS (list :methods :axioms :operators :tasks :goals :effects :protections :states :plans :item) "Acceptable arguments for SHOP-TRACE (and SHOP-UNTRACE).") (defmacro shop-trace (&rest items) "- (SHOP-TRACE) with no arguments will return a list of what's currently being traced. - (SHOP-TRACE ITEM) will turn on tracing for ITEM. ITEM may be any of the following: - the name of a method, axiom, operator, task, or predicate; - one of the keywords :METHODS, :AXIOMS, :OPERATORS, :TASKS, :GOALS, :EFFECTS, or :PROTECTIONS, in which case SHOP will trace all items of that type (:GOALS, :EFFECTS, and :PROTECTIONS refer to three different ways predicates can occur: as goals to be satisfied, and as effects or protections in operators); - a pair of the form (:TASK <taskname>), (:METHOD <methodname>). SHOP will break when attempting to expand the task, or apply the method, respectively. - the keyword :STATES, in which case SHOP will include the current state whenever it prints out a tracing message - the keyword :ALL in which case SHOP will print out all the tracing information it knows how to. - (SHOP-TRACE ITEM1 ITEM2 ...) will do the same for a list of items" (let* ((items `,items) (new-items (if (null items) nil items) )) (when (member :all new-items) (setf new-items (delete :all new-items)) (setf new-items (union SHOP-TRACE-ITEMS new-items))) `(shop-trace-1 ',new-items))) (defun shop-trace-1 (items) ;; make sure the argument is coerced to a list (unless (null items) (dolist (item items) (cond ((member item SHOP-TRACE-ITEMS) (pushnew item *shop-trace*)) ((listp item) (macrolet ((trace-item (variable) `(progn (pushnew (second item) ,variable) (pushnew :item *shop-trace*)))) (case (car item) (:task (trace-item *traced-tasks*)) (:method (trace-item *traced-methods*)) (:goal (trace-item *traced-goals*)) (:axiom (trace-item *traced-axioms*)) (otherwise (warn "Ignoring invalid shop-trace argument ~S" item))))) (t (warn "Ignoring invalid shop-trace argument ~S" item))))) (shop-trace-info)) (defmethod trigger-trace ((keyword (eql :methods)) (item symbol)) (member item *traced-methods* :test 'eq)) (defmethod trigger-trace ((keyword (eql :axioms)) (item symbol)) (member item *traced-axioms* :test 'eq)) (defmethod trigger-trace ((keyword (eql :goals)) (item symbol)) (member item *traced-goals* :test 'eq)) (defmethod trigger-trace ((keyword (eql :tasks)) (item symbol)) (member item *traced-tasks* :test 'eq)) (defun shop-trace-info () "Information about the traced aspects of shop2." (append *shop-trace* (mapcar #'(lambda (taskname) `(:task ,taskname)) *traced-tasks*) (mapcar #'(lambda (methname) `(:method ,methname)) *traced-methods*) (mapcar #'(lambda (goalname) `(:goal ,goalname)) *traced-goals*) (mapcar #'(lambda (axiomname) `(:axiom ,axiomname)) *traced-axioms*))) (defmacro shop-untrace (&rest items) "(SHOP-UNTRACE ...) is the inverse of (SHOP-TRACE ...)" (if (or (member :all items) (null items)) '(shop-untrace-all) `(shop-untrace-1 ',items))) (defun shop-untrace-all () (setf *shop-trace* nil *traced-tasks* nil ;;*traced-operators* nil *traced-methods* nil *traced-goals* nil *traced-axioms* nil)) (defun shop-untrace-1 (items) ;; it's OK to use destructive deletion here (dolist (item items) (cond ((symbolp item) (setq *shop-trace* (delete item *shop-trace*))) ((eq (car item) :task) (setf *traced-tasks* (delete (second item) *traced-tasks*))) ((eq (car item) :method) (setf *traced-methods* (delete (second item) *traced-methods*))) ((eq (car item) :all) (shop-untrace-all)) (t (warn "don't know how to delete ~S from shop-trace items: ignoring." item))))) (defun print-methods (&optional name (domain *domain*)) (if name (progn (format t "Methods for name ~S are:" name) (mapcar #'(lambda (x) (format t "~2% ~s" x)) (methods domain name))) (maphash #'(lambda (k defs) (format t "~2%Methods for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-methods domain)))) ;;; this I don't understand: AFAICT from the rest of the code there ;;; can be only ONE operator defined with a particular ;;; name... [2006/07/05:rpg] (defun print-operators (&optional name (domain *domain*)) (if name (progn (format t "Operator for name ~S is:" name) (format t "~2% ~s" (operator domain name))) (maphash #'(lambda (k defs) (format t "~2%Operators for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-operators domain)))) (defun print-operator (operator &optional (stream t)) (format stream "~THead: ~S~%~@[~TPreconditions: ~S~%~]~@[~TDelete-list: ~S~%~] ~@[~TAdd-list: ~S~%~]~@[~TCost-fun: ~S~%~]" (operator-head operator) (operator-preconditions operator) (operator-deletions operator) (operator-additions operator) (operator-cost-fun operator)))
true
;;; ;;; Version: MPL 1.1/GPL 2.0/LGPL 2.1 ;;; ;;; The contents of this file are subject to the Mozilla Public License ;;; Version 1.1 (the "License"); you may not use this file except in ;;; compliance with the License. You may obtain a copy of the License at ;;; http://www.mozilla.org/MPL/ ;;; ;;; Software distributed under the License is distributed on an "AS IS" ;;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ;;; License for the specific language governing rights and limitations under ;;; the License. ;;; ;;; The Original Code is SHOP2. ;;; ;;; The Initial Developer of the Original Code is the University of ;;; Maryland. Portions created by the Initial Developer are Copyright (C) ;;; 2002,2003 the Initial Developer. All Rights Reserved. ;;; ;;; Additional developments made by PI:NAME:<NAME>END_PI, PI:NAME:<NAME>END_PI. ;;; Portions created by PI:NAME:<NAME>END_PI and PI:NAME:<NAME>END_PI are Copyright (C) ;;; 2004-2007 SIFT, LLC. These additions and modifications are also ;;; available under the MPL/GPL/LGPL licensing terms. ;;; ;;; ;;; Alternatively, the contents of this file may be used under the terms of ;;; either of the GNU General Public License Version 2 or later (the "GPL"), ;;; or the GNU Lesser General Public License Version 2.1 or later (the ;;; "LGPL"), in which case the provisions of the GPL or the LGPL are ;;; applicable instead of those above. If you wish to allow use of your ;;; version of this file only under the terms of either the GPL or the LGPL, ;;; and not to allow others to use your version of this file under the terms ;;; of the MPL, indicate your decision by deleting the provisions above and ;;; replace them with the notice and other provisions required by the GPL or ;;; the LGPL. If you do not delete the provisions above, a recipient may use ;;; your version of this file under the terms of any one of the MPL, the GPL ;;; or the LGPL. ;;; ---------------------------------------------------------------------- ;;; Smart Information Flow Technologies Copyright 2006-2007 Unpublished work ;;; ;;; GOVERNMENT PURPOSE RIGHTS ;;; ;;; Contract No. FA8650-06-C-7606, ;;; Contractor Name Smart Information Flow Technologies, LLC ;;; d/b/a SIFT, LLC ;;; Contractor Address 211 N 1st Street, Suite 300 ;;; Minneapolis, MN 55401 ;;; Expiration Date 5/2/2011 ;;; ;;; The Government's rights to use, modify, reproduce, release, ;;; perform, display, or disclose this software are restricted by ;;; paragraph (b)(2) of the Rights in Noncommercial Computer Software ;;; and Noncommercial Computer Software Documentation clause contained ;;; in the above identified contract. No restrictions apply after the ;;; expiration date shown above. Any reproduction of the software or ;;; portions thereof marked with this legend must also reproduce the ;;; markings. (in-package :shop2) (defvar *start-run-time*) (defvar *start-real-time*) ;; (defvar *traced-operators* nil) ; break when attempting to ; apply one of these. (defvar *traced-methods* nil) ; break when attempting to ; apply one of these. (defvar *traced-tasks* nil) ; break when attempting to ; expand one of these. (defvar *traced-axioms* nil) (defvar *traced-goals* nil) (defconstant SHOP-TRACE-ITEMS (list :methods :axioms :operators :tasks :goals :effects :protections :states :plans :item) "Acceptable arguments for SHOP-TRACE (and SHOP-UNTRACE).") (defmacro shop-trace (&rest items) "- (SHOP-TRACE) with no arguments will return a list of what's currently being traced. - (SHOP-TRACE ITEM) will turn on tracing for ITEM. ITEM may be any of the following: - the name of a method, axiom, operator, task, or predicate; - one of the keywords :METHODS, :AXIOMS, :OPERATORS, :TASKS, :GOALS, :EFFECTS, or :PROTECTIONS, in which case SHOP will trace all items of that type (:GOALS, :EFFECTS, and :PROTECTIONS refer to three different ways predicates can occur: as goals to be satisfied, and as effects or protections in operators); - a pair of the form (:TASK <taskname>), (:METHOD <methodname>). SHOP will break when attempting to expand the task, or apply the method, respectively. - the keyword :STATES, in which case SHOP will include the current state whenever it prints out a tracing message - the keyword :ALL in which case SHOP will print out all the tracing information it knows how to. - (SHOP-TRACE ITEM1 ITEM2 ...) will do the same for a list of items" (let* ((items `,items) (new-items (if (null items) nil items) )) (when (member :all new-items) (setf new-items (delete :all new-items)) (setf new-items (union SHOP-TRACE-ITEMS new-items))) `(shop-trace-1 ',new-items))) (defun shop-trace-1 (items) ;; make sure the argument is coerced to a list (unless (null items) (dolist (item items) (cond ((member item SHOP-TRACE-ITEMS) (pushnew item *shop-trace*)) ((listp item) (macrolet ((trace-item (variable) `(progn (pushnew (second item) ,variable) (pushnew :item *shop-trace*)))) (case (car item) (:task (trace-item *traced-tasks*)) (:method (trace-item *traced-methods*)) (:goal (trace-item *traced-goals*)) (:axiom (trace-item *traced-axioms*)) (otherwise (warn "Ignoring invalid shop-trace argument ~S" item))))) (t (warn "Ignoring invalid shop-trace argument ~S" item))))) (shop-trace-info)) (defmethod trigger-trace ((keyword (eql :methods)) (item symbol)) (member item *traced-methods* :test 'eq)) (defmethod trigger-trace ((keyword (eql :axioms)) (item symbol)) (member item *traced-axioms* :test 'eq)) (defmethod trigger-trace ((keyword (eql :goals)) (item symbol)) (member item *traced-goals* :test 'eq)) (defmethod trigger-trace ((keyword (eql :tasks)) (item symbol)) (member item *traced-tasks* :test 'eq)) (defun shop-trace-info () "Information about the traced aspects of shop2." (append *shop-trace* (mapcar #'(lambda (taskname) `(:task ,taskname)) *traced-tasks*) (mapcar #'(lambda (methname) `(:method ,methname)) *traced-methods*) (mapcar #'(lambda (goalname) `(:goal ,goalname)) *traced-goals*) (mapcar #'(lambda (axiomname) `(:axiom ,axiomname)) *traced-axioms*))) (defmacro shop-untrace (&rest items) "(SHOP-UNTRACE ...) is the inverse of (SHOP-TRACE ...)" (if (or (member :all items) (null items)) '(shop-untrace-all) `(shop-untrace-1 ',items))) (defun shop-untrace-all () (setf *shop-trace* nil *traced-tasks* nil ;;*traced-operators* nil *traced-methods* nil *traced-goals* nil *traced-axioms* nil)) (defun shop-untrace-1 (items) ;; it's OK to use destructive deletion here (dolist (item items) (cond ((symbolp item) (setq *shop-trace* (delete item *shop-trace*))) ((eq (car item) :task) (setf *traced-tasks* (delete (second item) *traced-tasks*))) ((eq (car item) :method) (setf *traced-methods* (delete (second item) *traced-methods*))) ((eq (car item) :all) (shop-untrace-all)) (t (warn "don't know how to delete ~S from shop-trace items: ignoring." item))))) (defun print-methods (&optional name (domain *domain*)) (if name (progn (format t "Methods for name ~S are:" name) (mapcar #'(lambda (x) (format t "~2% ~s" x)) (methods domain name))) (maphash #'(lambda (k defs) (format t "~2%Methods for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-methods domain)))) ;;; this I don't understand: AFAICT from the rest of the code there ;;; can be only ONE operator defined with a particular ;;; name... [2006/07/05:rpg] (defun print-operators (&optional name (domain *domain*)) (if name (progn (format t "Operator for name ~S is:" name) (format t "~2% ~s" (operator domain name))) (maphash #'(lambda (k defs) (format t "~2%Operators for task ~S are:" k) (dolist (ad defs) (format t "~2% ~S" ad))) (domain-operators domain)))) (defun print-operator (operator &optional (stream t)) (format stream "~THead: ~S~%~@[~TPreconditions: ~S~%~]~@[~TDelete-list: ~S~%~] ~@[~TAdd-list: ~S~%~]~@[~TCost-fun: ~S~%~]" (operator-head operator) (operator-preconditions operator) (operator-deletions operator) (operator-additions operator) (operator-cost-fun operator)))
[ { "context": " of Colleen\n (c) 2014 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 91, "score": 0.9998995661735535, "start": 73, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 116, "score": 0.9998857975006104, "start": 102, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.colleen)\n(defpac", "end": 136, "score": 0.9999130964279175, "start": 118, "tag": "EMAIL", "value": "[email protected]" } ]
modules/chatlog-pg.lisp
Shinoa-Fores/colleen
29
#| This file is a part of Colleen (c) 2014 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.colleen) (defpackage #:org.shirakumo.colleen.mod.chatlog-pg (:nicknames #:co-chatlog-pg) (:use #:cl #:colleen #:events) (:export #:active-p #:external-address)) (in-package #:org.shirakumo.colleen.mod.chatlog-pg) (defconstant +UNIX-EPOCH-DIFFERENCE+ (encode-universal-time 0 0 0 1 1 1970 0)) (defvar *connection-active* NIL) (defun get-unix-time () (- (get-universal-time) +UNIX-EPOCH-DIFFERENCE+)) (define-module chatlog-pg () () (:documentation "Logs messages in channels to a database.")) (defun ident (server channel) (format NIL "~a/~a" server channel)) (defun active-p (server channel) (with-module-storage ((module :chatlog-pg)) (find (ident server channel) (uc:config-tree :active-in) :test #'string-equal))) (defun (setf active-p) (val server channel) (with-module-storage ((module :chatlog-pg)) (if val (pushnew (ident server channel) (uc:config-tree :active-in) :test #'string-equal) (setf (uc:config-tree :active-in) (delete (ident server channel) (uc:config-tree :active-in) :test #'string-equal))))) (defun connection () (with-module-storage ((module :chatlog-pg)) (list (uc:config-tree :user) (uc:config-tree :pass) (uc:config-tree :db) (uc:config-tree :host) (uc:config-tree :port)))) (defun (setf connection) (list) (destructuring-bind (user pass &optional (db "irc") (host "localhost") (port "5432")) list (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :user) user (uc:config-tree :pass) pass (uc:config-tree :db) db (uc:config-tree :host) host (uc:config-tree :port) port))) list) (defun external-address (&optional server channel time) (with-module-storage ((module :chatlog-pg)) (when (uc:config-tree :external-address) (format NIL "~a~@[~(~a~)/~]~@[~(~a~)~]~@[?around=~d#~:*~d~]" (uc:config-tree :external-address) server (string-trim "# " channel) time)))) (defun (setf external-address) (address) (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :external-address) address))) (defmethod start ((chatlog chatlog-pg)) (when (apply #'test-connection (connection)) (setf *connection-active* (connection)))) (defun test-connection (user pass &optional (db "irc") (host "localhost") (port 5432)) (v:info :chatlog-pg "Testing ~a/~v@{*~}@~a:~a/~a" user (length pass) host port db) (handler-case (postmodern:with-connection (list db user pass host :port port) (unless (postmodern:table-exists-p "chatlog") (postmodern:execute "CREATE TABLE \"chatlog\" (\"server\" character varying(36) NOT NULL, \"channel\" character varying(36) NOT NULL, \"nick\" character varying(36) NOT NULL, \"time\" bigint NOT NULL, \"type\" character(1) NOT NULL, \"message\" text NOT NULL)")) (list user pass db host port)) (error (err) (v:error :chatlog-pg "Failed to test connection! ~a" err) NIL))) (defun prepared-statement (statement &rest variables) (cl-postgres:prepare-query postmodern:*database* "" statement) (cl-postgres:exec-prepared postmodern:*database* "" variables (cl-postgres:row-reader (fields) (loop while (cl-postgres:next-row) collect (loop for field across fields collect (cl-postgres:next-field field)))))) (defmacro with-handled-connection ((&optional (spec '(connection))) &body body) (let ((info (gensym "CONNECTION-INFO")) (user (gensym "USER")) (pass (gensym "PASS")) (db (gensym "DB")) (host (gensym "HOST")) (port (gensym "PORT"))) `(let ((,info ,spec)) (when (and *connection-active* ,info) (destructuring-bind (,user ,pass ,db ,host ,port) ,info (handler-case (postmodern:with-connection (list ,db ,user ,pass ,host :port ,port) ,@body) (error (err) (v:error :chatlog-pg "Error in safe-connection block: ~a" err) NIL))))))) (defun insert-record (server channel user type message) (let ((server (string-downcase server)) (channel (string-downcase channel))) (when (active-p server channel) (v:debug :chatlog-pg "Logging event from ~a/~a <~a> (~a) ~s" server channel user type message) (with-handled-connection () (prepared-statement "INSERT INTO \"chatlog\" (\"server\", \"channel\", \"nick\", \"time\", \"type\", \"message\") VALUES ($1,$2,$3,$4,$5,$6)" server channel user (get-unix-time) type message))))) (define-group chatlog-pg :documentation "Change chatlog-pg settings.") (define-command (chatlog-pg server) (&optional user pass (db "irc") (host "localhost") (port "5432")) (:authorization T :documentation "View or switch the logging server.") (cond ((and user pass) (setf port (parse-integer port)) (let ((con (test-connection user pass db host port))) (cond (con (setf (connection) user pass db host port *connection-active* T))))) (T (destructuring-bind (user pass db host port) (connection) (declare (ignore pass)) (respond event "Currently connected to ~a@~a:~a/~a" user db host port))))) (defmacro with-chan/serv ((&optional (channel 'channel) (server 'server) (event 'event)) &body body) `(let ((,channel (string-downcase (or ,channel (channel ,event)))) (,server (string-downcase (or ,server (name (server ,event)))))) ,@body)) (define-command (chatlog-pg activate) (&optional channel server) (:authorization T :documentation "Activate logging for a channel.") (with-chan/serv () (setf (active-p channel server) T) (respond event "Activated logging for ~a/~a" server channel))) (define-command (chatlog-pg deactivate) (&optional channel server) (:authorization T :documentation "Deactivate logging for a channel.") (with-chan/serv () (setf (active-p channel server) NIL) (respond event "Deactivated logging for ~a/~a" server channel))) (define-handler (privmsg-event event) () (if (and (> (length (message event)) (length " ACTION ")) (string= (message event) "ACTION" :start1 1 :end1 7)) (insert-record (name (server event)) (channel event) (nick event) "a" (format NIL " * ~a" (subseq (message event) 7))) (insert-record (name (server event)) (channel event) (nick event) "m" (message event)))) (define-handler (send-event event) () (insert-record (name (server event)) (channel event) (nick event) "m" (message event))) (define-handler (nick-event event) () (dolist (channel (channels (server event))) (insert-record (name (server event)) channel (nick event) "n" (format NIL " ** NICK ~a" (new-nick event))))) (define-handler (quit-event event) () (dolist (channel (channels (server event))) (when (find (nick event) (users channel (server event)) :test #'string-equal) (insert-record (name (server event)) channel (nick event) "q" (format NIL " ** QUIT ~a" (reason event)))))) (define-handler (part-event event) () (insert-record (name (server event)) (channel event) (nick event) "p" " ** PART")) (define-handler (join-event event) () (insert-record (name (server event)) (channel event) (nick event) "j" " ** JOIN")) (define-handler (kick-event event) () (insert-record (name (server event)) (channel event) (nick event) "k" (format NIL " ** KICK ~a (~a)" (target event) (reason event)))) (define-handler (mode-event event) () (insert-record (name (server event)) (target event) (nick event) "o" (format NIL " ** MODE ~a ~a" (mode event) (parameter event)))) (define-handler (topic-event event) () (insert-record (name (server event)) (channel event) (channel event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (define-handler (topic-set-event event) () (insert-record (name (server event)) (channel event) (nick event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (defun %single-where (stream arg &rest rest) (declare (ignore rest)) (format stream "\"~(~a~)\"=~a" (first arg) (etypecase (second arg) (string (format NIL "'~a'" (second arg))) (fixnum (format NIL "$~a" (second arg)))))) (defun format-unix-time (time) (if time (local-time:format-timestring NIL (local-time:unix-to-timestamp time) :format '((:year 4) #\. (:month 2) #\. (:day 2) #\Space (:hour 2) #\: (:min 2) #\: (:sec 2))) "never")) (define-command (chatlog-pg stats) (&optional channel server) (:documentation "View logging statistics about a channel.") (with-chan/serv () (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) channel server vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (users (first (first (prepared-statement "SELECT COUNT(*) FROM (SELECT DISTINCT \"nick\" FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2 AND \"type\"='m') AS temp;" channel server)))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1"))) (topuser (single "\"nick\", COUNT(*) AS c" '(("type" "m")) "GROUP BY \"nick\" ORDER BY c DESC LIMIT 1"))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages from ~,,'':d users. The user with the most messages (~,,'':d) is ~a." (ident server channel) (format-unix-time since) (or events 0) (or messages 0) (or users 0) (or (second topuser) 0) (or (first topuser) "nobody")))) T) (respond event "Failed to retrieve statistics!")))) (define-command (chatlog-pg about) (nick) (:documentation "View logging statistics about a nick.") (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"nick\"=$1~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) nick vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1")))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages." nick (format-unix-time since) (or events 0) (or messages 0))))) (respond event "Failed to retrieve statistics!")))
46189
#| This file is a part of Colleen (c) 2014 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.colleen) (defpackage #:org.shirakumo.colleen.mod.chatlog-pg (:nicknames #:co-chatlog-pg) (:use #:cl #:colleen #:events) (:export #:active-p #:external-address)) (in-package #:org.shirakumo.colleen.mod.chatlog-pg) (defconstant +UNIX-EPOCH-DIFFERENCE+ (encode-universal-time 0 0 0 1 1 1970 0)) (defvar *connection-active* NIL) (defun get-unix-time () (- (get-universal-time) +UNIX-EPOCH-DIFFERENCE+)) (define-module chatlog-pg () () (:documentation "Logs messages in channels to a database.")) (defun ident (server channel) (format NIL "~a/~a" server channel)) (defun active-p (server channel) (with-module-storage ((module :chatlog-pg)) (find (ident server channel) (uc:config-tree :active-in) :test #'string-equal))) (defun (setf active-p) (val server channel) (with-module-storage ((module :chatlog-pg)) (if val (pushnew (ident server channel) (uc:config-tree :active-in) :test #'string-equal) (setf (uc:config-tree :active-in) (delete (ident server channel) (uc:config-tree :active-in) :test #'string-equal))))) (defun connection () (with-module-storage ((module :chatlog-pg)) (list (uc:config-tree :user) (uc:config-tree :pass) (uc:config-tree :db) (uc:config-tree :host) (uc:config-tree :port)))) (defun (setf connection) (list) (destructuring-bind (user pass &optional (db "irc") (host "localhost") (port "5432")) list (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :user) user (uc:config-tree :pass) pass (uc:config-tree :db) db (uc:config-tree :host) host (uc:config-tree :port) port))) list) (defun external-address (&optional server channel time) (with-module-storage ((module :chatlog-pg)) (when (uc:config-tree :external-address) (format NIL "~a~@[~(~a~)/~]~@[~(~a~)~]~@[?around=~d#~:*~d~]" (uc:config-tree :external-address) server (string-trim "# " channel) time)))) (defun (setf external-address) (address) (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :external-address) address))) (defmethod start ((chatlog chatlog-pg)) (when (apply #'test-connection (connection)) (setf *connection-active* (connection)))) (defun test-connection (user pass &optional (db "irc") (host "localhost") (port 5432)) (v:info :chatlog-pg "Testing ~a/~v@{*~}@~a:~a/~a" user (length pass) host port db) (handler-case (postmodern:with-connection (list db user pass host :port port) (unless (postmodern:table-exists-p "chatlog") (postmodern:execute "CREATE TABLE \"chatlog\" (\"server\" character varying(36) NOT NULL, \"channel\" character varying(36) NOT NULL, \"nick\" character varying(36) NOT NULL, \"time\" bigint NOT NULL, \"type\" character(1) NOT NULL, \"message\" text NOT NULL)")) (list user pass db host port)) (error (err) (v:error :chatlog-pg "Failed to test connection! ~a" err) NIL))) (defun prepared-statement (statement &rest variables) (cl-postgres:prepare-query postmodern:*database* "" statement) (cl-postgres:exec-prepared postmodern:*database* "" variables (cl-postgres:row-reader (fields) (loop while (cl-postgres:next-row) collect (loop for field across fields collect (cl-postgres:next-field field)))))) (defmacro with-handled-connection ((&optional (spec '(connection))) &body body) (let ((info (gensym "CONNECTION-INFO")) (user (gensym "USER")) (pass (gensym "PASS")) (db (gensym "DB")) (host (gensym "HOST")) (port (gensym "PORT"))) `(let ((,info ,spec)) (when (and *connection-active* ,info) (destructuring-bind (,user ,pass ,db ,host ,port) ,info (handler-case (postmodern:with-connection (list ,db ,user ,pass ,host :port ,port) ,@body) (error (err) (v:error :chatlog-pg "Error in safe-connection block: ~a" err) NIL))))))) (defun insert-record (server channel user type message) (let ((server (string-downcase server)) (channel (string-downcase channel))) (when (active-p server channel) (v:debug :chatlog-pg "Logging event from ~a/~a <~a> (~a) ~s" server channel user type message) (with-handled-connection () (prepared-statement "INSERT INTO \"chatlog\" (\"server\", \"channel\", \"nick\", \"time\", \"type\", \"message\") VALUES ($1,$2,$3,$4,$5,$6)" server channel user (get-unix-time) type message))))) (define-group chatlog-pg :documentation "Change chatlog-pg settings.") (define-command (chatlog-pg server) (&optional user pass (db "irc") (host "localhost") (port "5432")) (:authorization T :documentation "View or switch the logging server.") (cond ((and user pass) (setf port (parse-integer port)) (let ((con (test-connection user pass db host port))) (cond (con (setf (connection) user pass db host port *connection-active* T))))) (T (destructuring-bind (user pass db host port) (connection) (declare (ignore pass)) (respond event "Currently connected to ~a@~a:~a/~a" user db host port))))) (defmacro with-chan/serv ((&optional (channel 'channel) (server 'server) (event 'event)) &body body) `(let ((,channel (string-downcase (or ,channel (channel ,event)))) (,server (string-downcase (or ,server (name (server ,event)))))) ,@body)) (define-command (chatlog-pg activate) (&optional channel server) (:authorization T :documentation "Activate logging for a channel.") (with-chan/serv () (setf (active-p channel server) T) (respond event "Activated logging for ~a/~a" server channel))) (define-command (chatlog-pg deactivate) (&optional channel server) (:authorization T :documentation "Deactivate logging for a channel.") (with-chan/serv () (setf (active-p channel server) NIL) (respond event "Deactivated logging for ~a/~a" server channel))) (define-handler (privmsg-event event) () (if (and (> (length (message event)) (length " ACTION ")) (string= (message event) "ACTION" :start1 1 :end1 7)) (insert-record (name (server event)) (channel event) (nick event) "a" (format NIL " * ~a" (subseq (message event) 7))) (insert-record (name (server event)) (channel event) (nick event) "m" (message event)))) (define-handler (send-event event) () (insert-record (name (server event)) (channel event) (nick event) "m" (message event))) (define-handler (nick-event event) () (dolist (channel (channels (server event))) (insert-record (name (server event)) channel (nick event) "n" (format NIL " ** NICK ~a" (new-nick event))))) (define-handler (quit-event event) () (dolist (channel (channels (server event))) (when (find (nick event) (users channel (server event)) :test #'string-equal) (insert-record (name (server event)) channel (nick event) "q" (format NIL " ** QUIT ~a" (reason event)))))) (define-handler (part-event event) () (insert-record (name (server event)) (channel event) (nick event) "p" " ** PART")) (define-handler (join-event event) () (insert-record (name (server event)) (channel event) (nick event) "j" " ** JOIN")) (define-handler (kick-event event) () (insert-record (name (server event)) (channel event) (nick event) "k" (format NIL " ** KICK ~a (~a)" (target event) (reason event)))) (define-handler (mode-event event) () (insert-record (name (server event)) (target event) (nick event) "o" (format NIL " ** MODE ~a ~a" (mode event) (parameter event)))) (define-handler (topic-event event) () (insert-record (name (server event)) (channel event) (channel event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (define-handler (topic-set-event event) () (insert-record (name (server event)) (channel event) (nick event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (defun %single-where (stream arg &rest rest) (declare (ignore rest)) (format stream "\"~(~a~)\"=~a" (first arg) (etypecase (second arg) (string (format NIL "'~a'" (second arg))) (fixnum (format NIL "$~a" (second arg)))))) (defun format-unix-time (time) (if time (local-time:format-timestring NIL (local-time:unix-to-timestamp time) :format '((:year 4) #\. (:month 2) #\. (:day 2) #\Space (:hour 2) #\: (:min 2) #\: (:sec 2))) "never")) (define-command (chatlog-pg stats) (&optional channel server) (:documentation "View logging statistics about a channel.") (with-chan/serv () (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) channel server vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (users (first (first (prepared-statement "SELECT COUNT(*) FROM (SELECT DISTINCT \"nick\" FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2 AND \"type\"='m') AS temp;" channel server)))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1"))) (topuser (single "\"nick\", COUNT(*) AS c" '(("type" "m")) "GROUP BY \"nick\" ORDER BY c DESC LIMIT 1"))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages from ~,,'':d users. The user with the most messages (~,,'':d) is ~a." (ident server channel) (format-unix-time since) (or events 0) (or messages 0) (or users 0) (or (second topuser) 0) (or (first topuser) "nobody")))) T) (respond event "Failed to retrieve statistics!")))) (define-command (chatlog-pg about) (nick) (:documentation "View logging statistics about a nick.") (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"nick\"=$1~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) nick vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1")))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages." nick (format-unix-time since) (or events 0) (or messages 0))))) (respond event "Failed to retrieve statistics!")))
true
#| This file is a part of Colleen (c) 2014 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.colleen) (defpackage #:org.shirakumo.colleen.mod.chatlog-pg (:nicknames #:co-chatlog-pg) (:use #:cl #:colleen #:events) (:export #:active-p #:external-address)) (in-package #:org.shirakumo.colleen.mod.chatlog-pg) (defconstant +UNIX-EPOCH-DIFFERENCE+ (encode-universal-time 0 0 0 1 1 1970 0)) (defvar *connection-active* NIL) (defun get-unix-time () (- (get-universal-time) +UNIX-EPOCH-DIFFERENCE+)) (define-module chatlog-pg () () (:documentation "Logs messages in channels to a database.")) (defun ident (server channel) (format NIL "~a/~a" server channel)) (defun active-p (server channel) (with-module-storage ((module :chatlog-pg)) (find (ident server channel) (uc:config-tree :active-in) :test #'string-equal))) (defun (setf active-p) (val server channel) (with-module-storage ((module :chatlog-pg)) (if val (pushnew (ident server channel) (uc:config-tree :active-in) :test #'string-equal) (setf (uc:config-tree :active-in) (delete (ident server channel) (uc:config-tree :active-in) :test #'string-equal))))) (defun connection () (with-module-storage ((module :chatlog-pg)) (list (uc:config-tree :user) (uc:config-tree :pass) (uc:config-tree :db) (uc:config-tree :host) (uc:config-tree :port)))) (defun (setf connection) (list) (destructuring-bind (user pass &optional (db "irc") (host "localhost") (port "5432")) list (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :user) user (uc:config-tree :pass) pass (uc:config-tree :db) db (uc:config-tree :host) host (uc:config-tree :port) port))) list) (defun external-address (&optional server channel time) (with-module-storage ((module :chatlog-pg)) (when (uc:config-tree :external-address) (format NIL "~a~@[~(~a~)/~]~@[~(~a~)~]~@[?around=~d#~:*~d~]" (uc:config-tree :external-address) server (string-trim "# " channel) time)))) (defun (setf external-address) (address) (with-module-storage ((module :chatlog-pg)) (setf (uc:config-tree :external-address) address))) (defmethod start ((chatlog chatlog-pg)) (when (apply #'test-connection (connection)) (setf *connection-active* (connection)))) (defun test-connection (user pass &optional (db "irc") (host "localhost") (port 5432)) (v:info :chatlog-pg "Testing ~a/~v@{*~}@~a:~a/~a" user (length pass) host port db) (handler-case (postmodern:with-connection (list db user pass host :port port) (unless (postmodern:table-exists-p "chatlog") (postmodern:execute "CREATE TABLE \"chatlog\" (\"server\" character varying(36) NOT NULL, \"channel\" character varying(36) NOT NULL, \"nick\" character varying(36) NOT NULL, \"time\" bigint NOT NULL, \"type\" character(1) NOT NULL, \"message\" text NOT NULL)")) (list user pass db host port)) (error (err) (v:error :chatlog-pg "Failed to test connection! ~a" err) NIL))) (defun prepared-statement (statement &rest variables) (cl-postgres:prepare-query postmodern:*database* "" statement) (cl-postgres:exec-prepared postmodern:*database* "" variables (cl-postgres:row-reader (fields) (loop while (cl-postgres:next-row) collect (loop for field across fields collect (cl-postgres:next-field field)))))) (defmacro with-handled-connection ((&optional (spec '(connection))) &body body) (let ((info (gensym "CONNECTION-INFO")) (user (gensym "USER")) (pass (gensym "PASS")) (db (gensym "DB")) (host (gensym "HOST")) (port (gensym "PORT"))) `(let ((,info ,spec)) (when (and *connection-active* ,info) (destructuring-bind (,user ,pass ,db ,host ,port) ,info (handler-case (postmodern:with-connection (list ,db ,user ,pass ,host :port ,port) ,@body) (error (err) (v:error :chatlog-pg "Error in safe-connection block: ~a" err) NIL))))))) (defun insert-record (server channel user type message) (let ((server (string-downcase server)) (channel (string-downcase channel))) (when (active-p server channel) (v:debug :chatlog-pg "Logging event from ~a/~a <~a> (~a) ~s" server channel user type message) (with-handled-connection () (prepared-statement "INSERT INTO \"chatlog\" (\"server\", \"channel\", \"nick\", \"time\", \"type\", \"message\") VALUES ($1,$2,$3,$4,$5,$6)" server channel user (get-unix-time) type message))))) (define-group chatlog-pg :documentation "Change chatlog-pg settings.") (define-command (chatlog-pg server) (&optional user pass (db "irc") (host "localhost") (port "5432")) (:authorization T :documentation "View or switch the logging server.") (cond ((and user pass) (setf port (parse-integer port)) (let ((con (test-connection user pass db host port))) (cond (con (setf (connection) user pass db host port *connection-active* T))))) (T (destructuring-bind (user pass db host port) (connection) (declare (ignore pass)) (respond event "Currently connected to ~a@~a:~a/~a" user db host port))))) (defmacro with-chan/serv ((&optional (channel 'channel) (server 'server) (event 'event)) &body body) `(let ((,channel (string-downcase (or ,channel (channel ,event)))) (,server (string-downcase (or ,server (name (server ,event)))))) ,@body)) (define-command (chatlog-pg activate) (&optional channel server) (:authorization T :documentation "Activate logging for a channel.") (with-chan/serv () (setf (active-p channel server) T) (respond event "Activated logging for ~a/~a" server channel))) (define-command (chatlog-pg deactivate) (&optional channel server) (:authorization T :documentation "Deactivate logging for a channel.") (with-chan/serv () (setf (active-p channel server) NIL) (respond event "Deactivated logging for ~a/~a" server channel))) (define-handler (privmsg-event event) () (if (and (> (length (message event)) (length " ACTION ")) (string= (message event) "ACTION" :start1 1 :end1 7)) (insert-record (name (server event)) (channel event) (nick event) "a" (format NIL " * ~a" (subseq (message event) 7))) (insert-record (name (server event)) (channel event) (nick event) "m" (message event)))) (define-handler (send-event event) () (insert-record (name (server event)) (channel event) (nick event) "m" (message event))) (define-handler (nick-event event) () (dolist (channel (channels (server event))) (insert-record (name (server event)) channel (nick event) "n" (format NIL " ** NICK ~a" (new-nick event))))) (define-handler (quit-event event) () (dolist (channel (channels (server event))) (when (find (nick event) (users channel (server event)) :test #'string-equal) (insert-record (name (server event)) channel (nick event) "q" (format NIL " ** QUIT ~a" (reason event)))))) (define-handler (part-event event) () (insert-record (name (server event)) (channel event) (nick event) "p" " ** PART")) (define-handler (join-event event) () (insert-record (name (server event)) (channel event) (nick event) "j" " ** JOIN")) (define-handler (kick-event event) () (insert-record (name (server event)) (channel event) (nick event) "k" (format NIL " ** KICK ~a (~a)" (target event) (reason event)))) (define-handler (mode-event event) () (insert-record (name (server event)) (target event) (nick event) "o" (format NIL " ** MODE ~a ~a" (mode event) (parameter event)))) (define-handler (topic-event event) () (insert-record (name (server event)) (channel event) (channel event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (define-handler (topic-set-event event) () (insert-record (name (server event)) (channel event) (nick event) "t" (format NIL " ** TOPIC ~a" (topic event)))) (defun %single-where (stream arg &rest rest) (declare (ignore rest)) (format stream "\"~(~a~)\"=~a" (first arg) (etypecase (second arg) (string (format NIL "'~a'" (second arg))) (fixnum (format NIL "$~a" (second arg)))))) (defun format-unix-time (time) (if time (local-time:format-timestring NIL (local-time:unix-to-timestamp time) :format '((:year 4) #\. (:month 2) #\. (:day 2) #\Space (:hour 2) #\: (:min 2) #\: (:sec 2))) "never")) (define-command (chatlog-pg stats) (&optional channel server) (:documentation "View logging statistics about a channel.") (with-chan/serv () (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) channel server vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (users (first (first (prepared-statement "SELECT COUNT(*) FROM (SELECT DISTINCT \"nick\" FROM \"chatlog\" WHERE \"channel\"=$1 AND \"server\"=$2 AND \"type\"='m') AS temp;" channel server)))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1"))) (topuser (single "\"nick\", COUNT(*) AS c" '(("type" "m")) "GROUP BY \"nick\" ORDER BY c DESC LIMIT 1"))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages from ~,,'':d users. The user with the most messages (~,,'':d) is ~a." (ident server channel) (format-unix-time since) (or events 0) (or messages 0) (or users 0) (or (second topuser) 0) (or (first topuser) "nobody")))) T) (respond event "Failed to retrieve statistics!")))) (define-command (chatlog-pg about) (nick) (:documentation "View logging statistics about a nick.") (unless (with-handled-connection () (flet ((single (field &optional where clauses &rest vals) (first (apply #'prepared-statement (format NIL "SELECT ~a FROM \"chatlog\" WHERE \"nick\"=$1~@[ AND ~{~/co-chatlog-pg::%single-where/~^ AND ~}~]~@[ ~a~];" field where clauses) nick vals)))) (let ((events (first (single "COUNT(*)"))) (messages (first (single "COUNT(*)" '(("type" "m"))))) (since (first (single "\"time\"" () "ORDER BY \"time\" ASC LIMIT 1")))) (respond event "Logging ~a since ~a with a total of ~,,'':d events, of which ~,,'':d were messages." nick (format-unix-time since) (or events 0) (or messages 0))))) (respond event "Failed to retrieve statistics!")))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 190, "score": 0.9998712539672852, "start": 173, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 210, "score": 0.9999265074729919, "start": 192, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/fty/defbyte-standard-instances.lisp
mayankmanj/acl2
305
; FTY Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "FTY") (include-book "ubyte1") (include-book "ubyte2") (include-book "ubyte3") (include-book "ubyte4") (include-book "ubyte5") (include-book "ubyte6") (include-book "ubyte7") (include-book "ubyte8") (include-book "ubyte11") (include-book "ubyte12") (include-book "ubyte16") (include-book "ubyte20") (include-book "ubyte32") (include-book "ubyte64") (include-book "ubyte128") (include-book "ubyte256") (include-book "sbyte1") (include-book "sbyte2") (include-book "sbyte3") (include-book "sbyte4") (include-book "sbyte8") (include-book "sbyte16") (include-book "sbyte32") (include-book "sbyte64") (include-book "sbyte128") (include-book "sbyte256") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc defbyte-standard-instances :parents (fty-extensions specific-types defbyte) :short "Standard fixtypes of unsigned and signed bytes of various sizes, with some accompanying theorems." :long (xdoc::topstring (xdoc::p "Here `standard' means that these all have uniform structure and naming. They are unary counterparts of @('(unsigned-byte-p n ...)') and @('(signed-byte-p n ...)'), for various values of @('n').") (xdoc::p "These are all generated via @(tsee defbyte).") (xdoc::p "If standard (in the sense above) fixtypes of unsigned or signed bytes of a certain size are needed but are not among the ones defined here, they can be added here.")))
69084
; FTY Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "FTY") (include-book "ubyte1") (include-book "ubyte2") (include-book "ubyte3") (include-book "ubyte4") (include-book "ubyte5") (include-book "ubyte6") (include-book "ubyte7") (include-book "ubyte8") (include-book "ubyte11") (include-book "ubyte12") (include-book "ubyte16") (include-book "ubyte20") (include-book "ubyte32") (include-book "ubyte64") (include-book "ubyte128") (include-book "ubyte256") (include-book "sbyte1") (include-book "sbyte2") (include-book "sbyte3") (include-book "sbyte4") (include-book "sbyte8") (include-book "sbyte16") (include-book "sbyte32") (include-book "sbyte64") (include-book "sbyte128") (include-book "sbyte256") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc defbyte-standard-instances :parents (fty-extensions specific-types defbyte) :short "Standard fixtypes of unsigned and signed bytes of various sizes, with some accompanying theorems." :long (xdoc::topstring (xdoc::p "Here `standard' means that these all have uniform structure and naming. They are unary counterparts of @('(unsigned-byte-p n ...)') and @('(signed-byte-p n ...)'), for various values of @('n').") (xdoc::p "These are all generated via @(tsee defbyte).") (xdoc::p "If standard (in the sense above) fixtypes of unsigned or signed bytes of a certain size are needed but are not among the ones defined here, they can be added here.")))
true
; FTY Library ; ; Copyright (C) 2020 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "FTY") (include-book "ubyte1") (include-book "ubyte2") (include-book "ubyte3") (include-book "ubyte4") (include-book "ubyte5") (include-book "ubyte6") (include-book "ubyte7") (include-book "ubyte8") (include-book "ubyte11") (include-book "ubyte12") (include-book "ubyte16") (include-book "ubyte20") (include-book "ubyte32") (include-book "ubyte64") (include-book "ubyte128") (include-book "ubyte256") (include-book "sbyte1") (include-book "sbyte2") (include-book "sbyte3") (include-book "sbyte4") (include-book "sbyte8") (include-book "sbyte16") (include-book "sbyte32") (include-book "sbyte64") (include-book "sbyte128") (include-book "sbyte256") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc defbyte-standard-instances :parents (fty-extensions specific-types defbyte) :short "Standard fixtypes of unsigned and signed bytes of various sizes, with some accompanying theorems." :long (xdoc::topstring (xdoc::p "Here `standard' means that these all have uniform structure and naming. They are unary counterparts of @('(unsigned-byte-p n ...)') and @('(signed-byte-p n ...)'), for various values of @('n').") (xdoc::p "These are all generated via @(tsee defbyte).") (xdoc::p "If standard (in the sense above) fixtypes of unsigned or signed bytes of a certain size are needed but are not among the ones defined here, they can be added here.")))
[ { "context": ";; Cuong Chau <[email protected]>\n;; June 2017\n\n(in-package", "end": 13, "score": 0.9998259544372559, "start": 3, "tag": "NAME", "value": "Cuong Chau" }, { "context": ";; Cuong Chau <[email protected]>\n;; June 2017\n\n(in-package \"ADE\")\n\n(include-book ", "end": 36, "score": 0.9999319314956665, "start": 15, "tag": "EMAIL", "value": "[email protected]" } ]
books/projects/async/serial-adder/link-joint.lisp
solswords/acl2
0
;; Cuong Chau <[email protected]> ;; June 2017 (in-package "ADE") (include-book "de") (include-book "macros") ;; ====================================================================== ;; Some utility functions that help print out a readable format of link states. (defun 4v->link-st (x) (declare (xargs :guard t)) (cond ((equal x T) 'full) ((equal x NIL) 'empty) ((consp x) (4v->link-st (car x))) (t nil))) (defun 4v->data (x) (declare (xargs :guard t)) (cond ((equal x T) 1) ((equal x NIL) 0) ((equal x *X*) x) ((equal x *Z*) x) ((consp x) (cons (4v->data (car x)) (4v->data (cdr x)))) (t nil))) (defun map-to-links (x idx) (declare (xargs :guard (and (true-listp x) (natp idx)))) (if (endp x) nil (cons (list (string-append "L" (str::natstr idx)) (4v->link-st (car x)) (reverse (list-fix (4v->data (cadr x))))) (map-to-links (cddr x) (1+ idx))))) (defun map-to-links-list (x count) (declare (xargs :guard (and (true-list-listp x) (natp count)))) (if (endp x) nil (cons (map-to-links (car x) 0) (cons (string-append (str::natstr count) "-----") (map-to-links-list (cdr x) (1+ count)))))) ;; ====================================================================== ;; Non-RTZ two-phase handshake. (defun n-rtz-fullp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (not (equal req ack)))) (defun n-rtz-emptyp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (equal req ack))) (defthm n-rtz-fullp-of-b-not (implies (n-rtz-fullp req ack) (n-rtz-fullp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm n-rtz-emptyp-of-b-not (implies (n-rtz-emptyp req ack) (n-rtz-emptyp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm drain-n-rtz-full (implies (n-rtz-fullp req ack) (n-rtz-emptyp req (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm fill-n-rtz-empty (implies (n-rtz-emptyp req ack) (n-rtz-fullp (b-not req) ack)) :rule-classes (:rewrite :type-prescription)) (in-theory (disable n-rtz-fullp n-rtz-emptyp)) ;; RTZ two-phase handshake. (defun rtz-fullp (sw) (declare (xargs :guard t)) (equal sw t)) (defun rtz-emptyp (sw) (declare (xargs :guard t)) (equal sw nil)) (defun fullp (link-st) (declare (xargs :guard t)) (equal link-st '((t)))) (defun emptyp (link-st) (declare (xargs :guard t)) (equal link-st '((nil)))) (defun validp (link-st) (declare (xargs :guard t)) (or (fullp link-st) (emptyp link-st))) ;; ====================================================================== ;; Joint control circuit (defconst *joint-cntl* '((joint-cntl (fin fout go) (act) () ((not-fout (fout~) b-not (fout)) (g0 (ready) b-and (fin fout~)) (g1 (b-go) b-bool (go)) (jact (act) b-and (ready b-go)))))) (defthmd joint-cntl-okp (and (net-syntax-okp *joint-cntl*) (net-arity-okp *joint-cntl*))) (defund joint-cntl& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist joint-cntl)) (defun joint-act (fin fout go) (declare (xargs :guard t)) (f-and (f-and fin (f-not fout)) (f-bool go))) (defthm joint-act-rewrite (and (not (joint-act nil fout go)) (not (joint-act fin t go)) (not (joint-act fin fout nil)) (equal (joint-act t nil go) (f-bool go)))) (defthm joint-act-removes-f-buf (and (equal (joint-act (f-buf fin) fout go) (joint-act fin fout go)) (equal (joint-act fin (f-buf fout) go) (joint-act fin fout go)) (equal (joint-act fin fout (f-buf go)) (joint-act fin fout go))) :hints (("Goal" :in-theory (enable f-buf-delete-lemmas-2)))) (defthmd joint-cntl$value (implies (joint-cntl& netlist) (equal (se 'joint-cntl (list fin fout go) sts netlist) (list (joint-act fin fout go)))) :hints (("Goal" :in-theory (enable* se-rules joint-cntl&)))) (in-theory (disable joint-act)) ;; ====================================================================== ;; Click link-state control circuit (defconst *click-link-st* '((click-link-st (fi dr) (ls) (ff0 ff1) ((ff0 (req req~) fd1 (fi r)) (ff1 (ack ack~) fd1 (dr a)) (g0 (ls) b-xor (req ack)) (g1 (r) b-not (req)) (g2 (a) b-not (ack)))))) (defthmd click-link-st-okp (and (net-syntax-okp *click-link-st*) (net-arity-okp *click-link-st*))) (defund click-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist click-link-st)) (defthmd click-link-st$value (implies (click-link-st& netlist) (equal (se 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (f-xor (car ff0) (car ff1))))) :hints (("Goal" :in-theory (enable* se-rules click-link-st& f-gates)))) (defthmd click-link-st$state (implies (click-link-st& netlist) (equal (de 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (list (f-if fi (f-not (car ff0)) (car ff0))) (list (f-if dr (f-not (car ff1)) (car ff1)))))) :hints (("Goal" :in-theory (enable* de-rules click-link-st& f-gates)))) ;; ====================================================================== ;; SR link-state circuit (defconst *sr-link-st* '((sr-link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd sr-link-st-okp (and (net-syntax-okp *sr-link-st*) (net-arity-okp *sr-link-st*))) (defund sr-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist sr-link-st)) (defthmd sr-link-st$value (implies (sr-link-st& netlist) (equal (se 'sr-link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules sr-link-st&)))) (defthmd sr-link-st$state (implies (sr-link-st& netlist) (equal (de 'sr-link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules sr-link-st&)))) ;; ====================================================================== (defun or-list (x) (declare (xargs :guard t)) (if (atom x) nil (or (car x) (or-list (cdr x))))) (defconst *link-st* '((link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd link-st-okp (and (net-syntax-okp *link-st*) (net-arity-okp *link-st*))) (defund link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist link-st)) (defthmd link-st$value (implies (link-st& netlist) (equal (se 'link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules link-st&)))) (defthmd link-st$state (implies (link-st& netlist) (equal (de 'link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules link-st&))))
44887
;; <NAME> <<EMAIL>> ;; June 2017 (in-package "ADE") (include-book "de") (include-book "macros") ;; ====================================================================== ;; Some utility functions that help print out a readable format of link states. (defun 4v->link-st (x) (declare (xargs :guard t)) (cond ((equal x T) 'full) ((equal x NIL) 'empty) ((consp x) (4v->link-st (car x))) (t nil))) (defun 4v->data (x) (declare (xargs :guard t)) (cond ((equal x T) 1) ((equal x NIL) 0) ((equal x *X*) x) ((equal x *Z*) x) ((consp x) (cons (4v->data (car x)) (4v->data (cdr x)))) (t nil))) (defun map-to-links (x idx) (declare (xargs :guard (and (true-listp x) (natp idx)))) (if (endp x) nil (cons (list (string-append "L" (str::natstr idx)) (4v->link-st (car x)) (reverse (list-fix (4v->data (cadr x))))) (map-to-links (cddr x) (1+ idx))))) (defun map-to-links-list (x count) (declare (xargs :guard (and (true-list-listp x) (natp count)))) (if (endp x) nil (cons (map-to-links (car x) 0) (cons (string-append (str::natstr count) "-----") (map-to-links-list (cdr x) (1+ count)))))) ;; ====================================================================== ;; Non-RTZ two-phase handshake. (defun n-rtz-fullp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (not (equal req ack)))) (defun n-rtz-emptyp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (equal req ack))) (defthm n-rtz-fullp-of-b-not (implies (n-rtz-fullp req ack) (n-rtz-fullp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm n-rtz-emptyp-of-b-not (implies (n-rtz-emptyp req ack) (n-rtz-emptyp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm drain-n-rtz-full (implies (n-rtz-fullp req ack) (n-rtz-emptyp req (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm fill-n-rtz-empty (implies (n-rtz-emptyp req ack) (n-rtz-fullp (b-not req) ack)) :rule-classes (:rewrite :type-prescription)) (in-theory (disable n-rtz-fullp n-rtz-emptyp)) ;; RTZ two-phase handshake. (defun rtz-fullp (sw) (declare (xargs :guard t)) (equal sw t)) (defun rtz-emptyp (sw) (declare (xargs :guard t)) (equal sw nil)) (defun fullp (link-st) (declare (xargs :guard t)) (equal link-st '((t)))) (defun emptyp (link-st) (declare (xargs :guard t)) (equal link-st '((nil)))) (defun validp (link-st) (declare (xargs :guard t)) (or (fullp link-st) (emptyp link-st))) ;; ====================================================================== ;; Joint control circuit (defconst *joint-cntl* '((joint-cntl (fin fout go) (act) () ((not-fout (fout~) b-not (fout)) (g0 (ready) b-and (fin fout~)) (g1 (b-go) b-bool (go)) (jact (act) b-and (ready b-go)))))) (defthmd joint-cntl-okp (and (net-syntax-okp *joint-cntl*) (net-arity-okp *joint-cntl*))) (defund joint-cntl& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist joint-cntl)) (defun joint-act (fin fout go) (declare (xargs :guard t)) (f-and (f-and fin (f-not fout)) (f-bool go))) (defthm joint-act-rewrite (and (not (joint-act nil fout go)) (not (joint-act fin t go)) (not (joint-act fin fout nil)) (equal (joint-act t nil go) (f-bool go)))) (defthm joint-act-removes-f-buf (and (equal (joint-act (f-buf fin) fout go) (joint-act fin fout go)) (equal (joint-act fin (f-buf fout) go) (joint-act fin fout go)) (equal (joint-act fin fout (f-buf go)) (joint-act fin fout go))) :hints (("Goal" :in-theory (enable f-buf-delete-lemmas-2)))) (defthmd joint-cntl$value (implies (joint-cntl& netlist) (equal (se 'joint-cntl (list fin fout go) sts netlist) (list (joint-act fin fout go)))) :hints (("Goal" :in-theory (enable* se-rules joint-cntl&)))) (in-theory (disable joint-act)) ;; ====================================================================== ;; Click link-state control circuit (defconst *click-link-st* '((click-link-st (fi dr) (ls) (ff0 ff1) ((ff0 (req req~) fd1 (fi r)) (ff1 (ack ack~) fd1 (dr a)) (g0 (ls) b-xor (req ack)) (g1 (r) b-not (req)) (g2 (a) b-not (ack)))))) (defthmd click-link-st-okp (and (net-syntax-okp *click-link-st*) (net-arity-okp *click-link-st*))) (defund click-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist click-link-st)) (defthmd click-link-st$value (implies (click-link-st& netlist) (equal (se 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (f-xor (car ff0) (car ff1))))) :hints (("Goal" :in-theory (enable* se-rules click-link-st& f-gates)))) (defthmd click-link-st$state (implies (click-link-st& netlist) (equal (de 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (list (f-if fi (f-not (car ff0)) (car ff0))) (list (f-if dr (f-not (car ff1)) (car ff1)))))) :hints (("Goal" :in-theory (enable* de-rules click-link-st& f-gates)))) ;; ====================================================================== ;; SR link-state circuit (defconst *sr-link-st* '((sr-link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd sr-link-st-okp (and (net-syntax-okp *sr-link-st*) (net-arity-okp *sr-link-st*))) (defund sr-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist sr-link-st)) (defthmd sr-link-st$value (implies (sr-link-st& netlist) (equal (se 'sr-link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules sr-link-st&)))) (defthmd sr-link-st$state (implies (sr-link-st& netlist) (equal (de 'sr-link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules sr-link-st&)))) ;; ====================================================================== (defun or-list (x) (declare (xargs :guard t)) (if (atom x) nil (or (car x) (or-list (cdr x))))) (defconst *link-st* '((link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd link-st-okp (and (net-syntax-okp *link-st*) (net-arity-okp *link-st*))) (defund link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist link-st)) (defthmd link-st$value (implies (link-st& netlist) (equal (se 'link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules link-st&)))) (defthmd link-st$state (implies (link-st& netlist) (equal (de 'link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules link-st&))))
true
;; PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;; June 2017 (in-package "ADE") (include-book "de") (include-book "macros") ;; ====================================================================== ;; Some utility functions that help print out a readable format of link states. (defun 4v->link-st (x) (declare (xargs :guard t)) (cond ((equal x T) 'full) ((equal x NIL) 'empty) ((consp x) (4v->link-st (car x))) (t nil))) (defun 4v->data (x) (declare (xargs :guard t)) (cond ((equal x T) 1) ((equal x NIL) 0) ((equal x *X*) x) ((equal x *Z*) x) ((consp x) (cons (4v->data (car x)) (4v->data (cdr x)))) (t nil))) (defun map-to-links (x idx) (declare (xargs :guard (and (true-listp x) (natp idx)))) (if (endp x) nil (cons (list (string-append "L" (str::natstr idx)) (4v->link-st (car x)) (reverse (list-fix (4v->data (cadr x))))) (map-to-links (cddr x) (1+ idx))))) (defun map-to-links-list (x count) (declare (xargs :guard (and (true-list-listp x) (natp count)))) (if (endp x) nil (cons (map-to-links (car x) 0) (cons (string-append (str::natstr count) "-----") (map-to-links-list (cdr x) (1+ count)))))) ;; ====================================================================== ;; Non-RTZ two-phase handshake. (defun n-rtz-fullp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (not (equal req ack)))) (defun n-rtz-emptyp (req ack) (declare (xargs :guard t)) (and (booleanp req) (booleanp ack) (equal req ack))) (defthm n-rtz-fullp-of-b-not (implies (n-rtz-fullp req ack) (n-rtz-fullp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm n-rtz-emptyp-of-b-not (implies (n-rtz-emptyp req ack) (n-rtz-emptyp (b-not req) (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm drain-n-rtz-full (implies (n-rtz-fullp req ack) (n-rtz-emptyp req (b-not ack))) :rule-classes (:rewrite :type-prescription)) (defthm fill-n-rtz-empty (implies (n-rtz-emptyp req ack) (n-rtz-fullp (b-not req) ack)) :rule-classes (:rewrite :type-prescription)) (in-theory (disable n-rtz-fullp n-rtz-emptyp)) ;; RTZ two-phase handshake. (defun rtz-fullp (sw) (declare (xargs :guard t)) (equal sw t)) (defun rtz-emptyp (sw) (declare (xargs :guard t)) (equal sw nil)) (defun fullp (link-st) (declare (xargs :guard t)) (equal link-st '((t)))) (defun emptyp (link-st) (declare (xargs :guard t)) (equal link-st '((nil)))) (defun validp (link-st) (declare (xargs :guard t)) (or (fullp link-st) (emptyp link-st))) ;; ====================================================================== ;; Joint control circuit (defconst *joint-cntl* '((joint-cntl (fin fout go) (act) () ((not-fout (fout~) b-not (fout)) (g0 (ready) b-and (fin fout~)) (g1 (b-go) b-bool (go)) (jact (act) b-and (ready b-go)))))) (defthmd joint-cntl-okp (and (net-syntax-okp *joint-cntl*) (net-arity-okp *joint-cntl*))) (defund joint-cntl& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist joint-cntl)) (defun joint-act (fin fout go) (declare (xargs :guard t)) (f-and (f-and fin (f-not fout)) (f-bool go))) (defthm joint-act-rewrite (and (not (joint-act nil fout go)) (not (joint-act fin t go)) (not (joint-act fin fout nil)) (equal (joint-act t nil go) (f-bool go)))) (defthm joint-act-removes-f-buf (and (equal (joint-act (f-buf fin) fout go) (joint-act fin fout go)) (equal (joint-act fin (f-buf fout) go) (joint-act fin fout go)) (equal (joint-act fin fout (f-buf go)) (joint-act fin fout go))) :hints (("Goal" :in-theory (enable f-buf-delete-lemmas-2)))) (defthmd joint-cntl$value (implies (joint-cntl& netlist) (equal (se 'joint-cntl (list fin fout go) sts netlist) (list (joint-act fin fout go)))) :hints (("Goal" :in-theory (enable* se-rules joint-cntl&)))) (in-theory (disable joint-act)) ;; ====================================================================== ;; Click link-state control circuit (defconst *click-link-st* '((click-link-st (fi dr) (ls) (ff0 ff1) ((ff0 (req req~) fd1 (fi r)) (ff1 (ack ack~) fd1 (dr a)) (g0 (ls) b-xor (req ack)) (g1 (r) b-not (req)) (g2 (a) b-not (ack)))))) (defthmd click-link-st-okp (and (net-syntax-okp *click-link-st*) (net-arity-okp *click-link-st*))) (defund click-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist click-link-st)) (defthmd click-link-st$value (implies (click-link-st& netlist) (equal (se 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (f-xor (car ff0) (car ff1))))) :hints (("Goal" :in-theory (enable* se-rules click-link-st& f-gates)))) (defthmd click-link-st$state (implies (click-link-st& netlist) (equal (de 'click-link-st (list fi dr) (list ff0 ff1) netlist) (list (list (f-if fi (f-not (car ff0)) (car ff0))) (list (f-if dr (f-not (car ff1)) (car ff1)))))) :hints (("Goal" :in-theory (enable* de-rules click-link-st& f-gates)))) ;; ====================================================================== ;; SR link-state circuit (defconst *sr-link-st* '((sr-link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd sr-link-st-okp (and (net-syntax-okp *sr-link-st*) (net-arity-okp *sr-link-st*))) (defund sr-link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist sr-link-st)) (defthmd sr-link-st$value (implies (sr-link-st& netlist) (equal (se 'sr-link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules sr-link-st&)))) (defthmd sr-link-st$state (implies (sr-link-st& netlist) (equal (de 'sr-link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules sr-link-st&)))) ;; ====================================================================== (defun or-list (x) (declare (xargs :guard t)) (if (atom x) nil (or (car x) (or-list (cdr x))))) (defconst *link-st* '((link-st (fi dr) (ls) (sr-st) ((sr-st (ls ls~) sr (fi dr)))))) (defthmd link-st-okp (and (net-syntax-okp *link-st*) (net-arity-okp *link-st*))) (defund link-st& (netlist) (declare (xargs :guard (alistp netlist))) (netlist-hyps netlist link-st)) (defthmd link-st$value (implies (link-st& netlist) (equal (se 'link-st ins sts netlist) (list (f-buf (caar sts))))) :hints (("Goal" :in-theory (enable* se-rules link-st&)))) (defthmd link-st$state (implies (link-st& netlist) (equal (de 'link-st (list fi dr) sts netlist) (list (list (f-sr fi dr (caar sts)))))) :hints (("Goal" :in-theory (enable* de-rules link-st&))))
[ { "context": ";\n; Contact:\n;\n; Kookamara LLC\n; 11410 Windermere Meadows\n; Austin, TX 78759, USA\n; http://www.", "end": 126, "score": 0.7357149720191956, "start": 123, "tag": "NAME", "value": "ere" } ]
books/coi/lists/disjoint.lisp
mayankmanj/acl2
305
; Computational Object Inference ; Copyright (C) 2005-2014 Kookamara LLC ; ; Contact: ; ; Kookamara LLC ; 11410 Windermere Meadows ; Austin, TX 78759, USA ; http://www.kookamara.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. (in-package "LIST") (include-book "memberp") (local (include-book "../util/iff")) (local (include-book "remove")) (defun disjoint (x y) (declare (type t x y)) (if (consp x) (if (memberp (car x) y) nil (disjoint (cdr x) y)) t)) (defthm disjoint-remove-reduction-1 (implies (not (memberp a y)) (equal (disjoint (remove a x) y) (disjoint x y)))) (defthm open-disjoint-on-memberp (implies (memberp a x) (equal (disjoint x y) (and (not (memberp a y)) (disjoint (remove a x) y))))) (defthm not-consp-disjoint (implies (not (consp x)) (equal (disjoint x y) t))) ;; DAG: It's killing me that this is globally enabled .. (defthm disjoint-remove-definition (equal (disjoint x y) (if (consp x) (and (not (memberp (car x) y)) (disjoint (remove (car x) x) y)) t)) :rule-classes (:definition)) (defthm memberp-disjoint-non-memberp (implies (and (disjoint x y) (memberp a x)) (not (memberp a y))) :rule-classes (:rewrite :forward-chaining)) (defthm mutual-memberp-implies-not-disjoint (implies (and (memberp a x) (memberp a y)) (not (disjoint x y))) :rule-classes (:forward-chaining)) (in-theory (disable disjoint-remove-reduction-1)) (in-theory (disable open-disjoint-on-memberp)) (encapsulate () (defun mutual-non-membership (a x y) (implies (memberp a x) (not (memberp a y)))) (encapsulate (((disjoint-hyps) => *) ((disjoint-lhs) => *) ((disjoint-rhs) => *) ) (local (defun disjoint-hyps () nil)) (local (defun disjoint-lhs () nil)) (local (defun disjoint-rhs () nil)) (defthm disjoint-multiplicity-constraint (implies (disjoint-hyps) (mutual-non-membership arbitrary-element (disjoint-lhs) (disjoint-rhs))) :rule-classes nil) ) (local (defun badguy-rec (x y) (declare (xargs :measure (len x))) (cond ((or (atom x) (atom y)) nil) ((memberp (car x) y) (car x)) (t (badguy-rec (remove (car x) x) y))))) (local (defthm badguy-rec-membership-property (implies (and (not (disjoint x y)) (not (memberp a x))) (not (equal (badguy-rec x y) a))))) (local (defthm not-disjoint-membership-reduction (implies (not (disjoint x y)) (and (memberp (badguy-rec x y) x) (memberp (badguy-rec x y) y))))) (local (defun badguy (x y) (cond ((disjoint x y) (if (consp x) (car x) (if (consp y) (car y) nil))) (t (badguy-rec x y))))) (local (defthm badguy-witness (equal (disjoint x y) (mutual-non-membership (badguy x y) x y)))) (local (in-theory (disable mutual-non-membership badguy))) (defthm disjoint-by-multiplicity-driver (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes nil :hints(("Goal" :use ((:instance disjoint-multiplicity-constraint (arbitrary-element (badguy (disjoint-lhs) (disjoint-rhs)))))))) (ADVISER::defadvice disjoint-by-multiplicity (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes (:pick-a-point :driver disjoint-by-multiplicity-driver)) ) ;; How expensive is this? (defthm disjoint-commute-forward (implies (disjoint x y) (disjoint y x)) :rule-classes (:forward-chaining))
83681
; Computational Object Inference ; Copyright (C) 2005-2014 Kookamara LLC ; ; Contact: ; ; Kookamara LLC ; 11410 Winderm<NAME> Meadows ; Austin, TX 78759, USA ; http://www.kookamara.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. (in-package "LIST") (include-book "memberp") (local (include-book "../util/iff")) (local (include-book "remove")) (defun disjoint (x y) (declare (type t x y)) (if (consp x) (if (memberp (car x) y) nil (disjoint (cdr x) y)) t)) (defthm disjoint-remove-reduction-1 (implies (not (memberp a y)) (equal (disjoint (remove a x) y) (disjoint x y)))) (defthm open-disjoint-on-memberp (implies (memberp a x) (equal (disjoint x y) (and (not (memberp a y)) (disjoint (remove a x) y))))) (defthm not-consp-disjoint (implies (not (consp x)) (equal (disjoint x y) t))) ;; DAG: It's killing me that this is globally enabled .. (defthm disjoint-remove-definition (equal (disjoint x y) (if (consp x) (and (not (memberp (car x) y)) (disjoint (remove (car x) x) y)) t)) :rule-classes (:definition)) (defthm memberp-disjoint-non-memberp (implies (and (disjoint x y) (memberp a x)) (not (memberp a y))) :rule-classes (:rewrite :forward-chaining)) (defthm mutual-memberp-implies-not-disjoint (implies (and (memberp a x) (memberp a y)) (not (disjoint x y))) :rule-classes (:forward-chaining)) (in-theory (disable disjoint-remove-reduction-1)) (in-theory (disable open-disjoint-on-memberp)) (encapsulate () (defun mutual-non-membership (a x y) (implies (memberp a x) (not (memberp a y)))) (encapsulate (((disjoint-hyps) => *) ((disjoint-lhs) => *) ((disjoint-rhs) => *) ) (local (defun disjoint-hyps () nil)) (local (defun disjoint-lhs () nil)) (local (defun disjoint-rhs () nil)) (defthm disjoint-multiplicity-constraint (implies (disjoint-hyps) (mutual-non-membership arbitrary-element (disjoint-lhs) (disjoint-rhs))) :rule-classes nil) ) (local (defun badguy-rec (x y) (declare (xargs :measure (len x))) (cond ((or (atom x) (atom y)) nil) ((memberp (car x) y) (car x)) (t (badguy-rec (remove (car x) x) y))))) (local (defthm badguy-rec-membership-property (implies (and (not (disjoint x y)) (not (memberp a x))) (not (equal (badguy-rec x y) a))))) (local (defthm not-disjoint-membership-reduction (implies (not (disjoint x y)) (and (memberp (badguy-rec x y) x) (memberp (badguy-rec x y) y))))) (local (defun badguy (x y) (cond ((disjoint x y) (if (consp x) (car x) (if (consp y) (car y) nil))) (t (badguy-rec x y))))) (local (defthm badguy-witness (equal (disjoint x y) (mutual-non-membership (badguy x y) x y)))) (local (in-theory (disable mutual-non-membership badguy))) (defthm disjoint-by-multiplicity-driver (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes nil :hints(("Goal" :use ((:instance disjoint-multiplicity-constraint (arbitrary-element (badguy (disjoint-lhs) (disjoint-rhs)))))))) (ADVISER::defadvice disjoint-by-multiplicity (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes (:pick-a-point :driver disjoint-by-multiplicity-driver)) ) ;; How expensive is this? (defthm disjoint-commute-forward (implies (disjoint x y) (disjoint y x)) :rule-classes (:forward-chaining))
true
; Computational Object Inference ; Copyright (C) 2005-2014 Kookamara LLC ; ; Contact: ; ; Kookamara LLC ; 11410 WindermPI:NAME:<NAME>END_PI Meadows ; Austin, TX 78759, USA ; http://www.kookamara.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. (in-package "LIST") (include-book "memberp") (local (include-book "../util/iff")) (local (include-book "remove")) (defun disjoint (x y) (declare (type t x y)) (if (consp x) (if (memberp (car x) y) nil (disjoint (cdr x) y)) t)) (defthm disjoint-remove-reduction-1 (implies (not (memberp a y)) (equal (disjoint (remove a x) y) (disjoint x y)))) (defthm open-disjoint-on-memberp (implies (memberp a x) (equal (disjoint x y) (and (not (memberp a y)) (disjoint (remove a x) y))))) (defthm not-consp-disjoint (implies (not (consp x)) (equal (disjoint x y) t))) ;; DAG: It's killing me that this is globally enabled .. (defthm disjoint-remove-definition (equal (disjoint x y) (if (consp x) (and (not (memberp (car x) y)) (disjoint (remove (car x) x) y)) t)) :rule-classes (:definition)) (defthm memberp-disjoint-non-memberp (implies (and (disjoint x y) (memberp a x)) (not (memberp a y))) :rule-classes (:rewrite :forward-chaining)) (defthm mutual-memberp-implies-not-disjoint (implies (and (memberp a x) (memberp a y)) (not (disjoint x y))) :rule-classes (:forward-chaining)) (in-theory (disable disjoint-remove-reduction-1)) (in-theory (disable open-disjoint-on-memberp)) (encapsulate () (defun mutual-non-membership (a x y) (implies (memberp a x) (not (memberp a y)))) (encapsulate (((disjoint-hyps) => *) ((disjoint-lhs) => *) ((disjoint-rhs) => *) ) (local (defun disjoint-hyps () nil)) (local (defun disjoint-lhs () nil)) (local (defun disjoint-rhs () nil)) (defthm disjoint-multiplicity-constraint (implies (disjoint-hyps) (mutual-non-membership arbitrary-element (disjoint-lhs) (disjoint-rhs))) :rule-classes nil) ) (local (defun badguy-rec (x y) (declare (xargs :measure (len x))) (cond ((or (atom x) (atom y)) nil) ((memberp (car x) y) (car x)) (t (badguy-rec (remove (car x) x) y))))) (local (defthm badguy-rec-membership-property (implies (and (not (disjoint x y)) (not (memberp a x))) (not (equal (badguy-rec x y) a))))) (local (defthm not-disjoint-membership-reduction (implies (not (disjoint x y)) (and (memberp (badguy-rec x y) x) (memberp (badguy-rec x y) y))))) (local (defun badguy (x y) (cond ((disjoint x y) (if (consp x) (car x) (if (consp y) (car y) nil))) (t (badguy-rec x y))))) (local (defthm badguy-witness (equal (disjoint x y) (mutual-non-membership (badguy x y) x y)))) (local (in-theory (disable mutual-non-membership badguy))) (defthm disjoint-by-multiplicity-driver (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes nil :hints(("Goal" :use ((:instance disjoint-multiplicity-constraint (arbitrary-element (badguy (disjoint-lhs) (disjoint-rhs)))))))) (ADVISER::defadvice disjoint-by-multiplicity (implies (disjoint-hyps) (disjoint (disjoint-lhs) (disjoint-rhs))) :rule-classes (:pick-a-point :driver disjoint-by-multiplicity-driver)) ) ;; How expensive is this? (defthm disjoint-commute-forward (implies (disjoint x y) (disjoint y x)) :rule-classes (:forward-chaining))
[ { "context": "neo4j RESTful Client Interface ()\"\n :maintainer \"Mikhail Novikov <[email protected]>\"\n :author \"Kevin Raison <", "end": 240, "score": 0.9998829960823059, "start": 225, "tag": "NAME", "value": "Mikhail Novikov" }, { "context": "ent Interface ()\"\n :maintainer \"Mikhail Novikov <[email protected]>\"\n :author \"Kevin Raison <last name @ chatsubo d", "end": 262, "score": 0.9999322891235352, "start": 242, "tag": "EMAIL", "value": "[email protected]" }, { "context": "ikhail Novikov <[email protected]>\"\n :author \"Kevin Raison <last name @ chatsubo dot net>\"\n :version \"0.4\"\n", "end": 288, "score": 0.9998891353607178, "start": 276, "tag": "NAME", "value": "Kevin Raison" } ]
cl-neo4j.asd
kraison/cl-neo4j
12
;; ASDF package description for cl-neo4j -*- Lisp -*- (defpackage :cl-neo4j-system (:use :cl :asdf)) (in-package :cl-neo4j-system) (defsystem cl-neo4j :name "neo4j RESTful Client Interface ()" :maintainer "Mikhail Novikov <[email protected]>" :author "Kevin Raison <last name @ chatsubo dot net>" :version "0.4" :description "neo4j RESTful Client Interface" :long-description "neo4j RESTful Client Interface and higher order extensible CL wrapper for it." :depends-on (:alexandria :anaphora :split-sequence :drakma :babel :cl-json :cl-ppcre) :components ((:module "src" :serial t :components ((:file "package") (:file "globals" :depends-on ("package")) (:file "utilities" :depends-on ("globals")) (:file "conditions" :depends-on ("utilities")) (:file "query" :depends-on ("utilities")) (:file "requests" :depends-on ("conditions" "query")) (:file "restapi" :depends-on ("requests")) (:file "wrapper" :depends-on ("restapi")))))) (defsystem cl-neo4j.tests :depends-on (:cl-neo4j :fiveam) :components ((:module "test" :serial t :components ((:file "package") (:file "util") (:file "main") (:file "restapi") (:file "wrapper")))))
54813
;; ASDF package description for cl-neo4j -*- Lisp -*- (defpackage :cl-neo4j-system (:use :cl :asdf)) (in-package :cl-neo4j-system) (defsystem cl-neo4j :name "neo4j RESTful Client Interface ()" :maintainer "<NAME> <<EMAIL>>" :author "<NAME> <last name @ chatsubo dot net>" :version "0.4" :description "neo4j RESTful Client Interface" :long-description "neo4j RESTful Client Interface and higher order extensible CL wrapper for it." :depends-on (:alexandria :anaphora :split-sequence :drakma :babel :cl-json :cl-ppcre) :components ((:module "src" :serial t :components ((:file "package") (:file "globals" :depends-on ("package")) (:file "utilities" :depends-on ("globals")) (:file "conditions" :depends-on ("utilities")) (:file "query" :depends-on ("utilities")) (:file "requests" :depends-on ("conditions" "query")) (:file "restapi" :depends-on ("requests")) (:file "wrapper" :depends-on ("restapi")))))) (defsystem cl-neo4j.tests :depends-on (:cl-neo4j :fiveam) :components ((:module "test" :serial t :components ((:file "package") (:file "util") (:file "main") (:file "restapi") (:file "wrapper")))))
true
;; ASDF package description for cl-neo4j -*- Lisp -*- (defpackage :cl-neo4j-system (:use :cl :asdf)) (in-package :cl-neo4j-system) (defsystem cl-neo4j :name "neo4j RESTful Client Interface ()" :maintainer "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :author "PI:NAME:<NAME>END_PI <last name @ chatsubo dot net>" :version "0.4" :description "neo4j RESTful Client Interface" :long-description "neo4j RESTful Client Interface and higher order extensible CL wrapper for it." :depends-on (:alexandria :anaphora :split-sequence :drakma :babel :cl-json :cl-ppcre) :components ((:module "src" :serial t :components ((:file "package") (:file "globals" :depends-on ("package")) (:file "utilities" :depends-on ("globals")) (:file "conditions" :depends-on ("utilities")) (:file "query" :depends-on ("utilities")) (:file "requests" :depends-on ("conditions" "query")) (:file "restapi" :depends-on ("requests")) (:file "wrapper" :depends-on ("restapi")))))) (defsystem cl-neo4j.tests :depends-on (:cl-neo4j :fiveam) :components ((:module "test" :serial t :components ((:file "package") (:file "util") (:file "main") (:file "restapi") (:file "wrapper")))))
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(includ", "end": 1416, "score": 0.9998784065246582, "start": 1406, "tag": "NAME", "value": "Sol Swords" }, { "context": "IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(include-book \"bfr\")\n(include", "end": 1438, "score": 0.9999303221702576, "start": 1418, "tag": "EMAIL", "value": "[email protected]" }, { "context": " (consp x)\n (synp vars form term)\n; [Changed by Matt K. to handle changes to member, assoc, etc. after AC", "end": 2460, "score": 0.9995900392532349, "start": 2454, "tag": "NAME", "value": "Matt K" }, { "context": " n lst))\n lst))))\n\n; [Removed by Matt K. to handle changes to member, assoc, etc. after A", "end": 13168, "score": 0.9891449809074402, "start": 13162, "tag": "NAME", "value": "Matt K" }, { "context": "TRAINT-FOR RUN-GIFIED-EV SYMBOLP)\n;; ; [Changed by Matt K. to handle changes to member, assoc, etc. after AC", "end": 56211, "score": 0.9932973980903625, "start": 56205, "tag": "NAME", "value": "Matt K" } ]
books/centaur/gl/run-gified-cp.lisp
mayankmanj/acl2
305
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Sol Swords <[email protected]> (in-package "GL") (include-book "bfr") (include-book "gtypes") (include-book "tools/mv-nth" :dir :system) (include-book "std/util/bstar" :dir :system) (include-book "tools/defevaluator-fast" :dir :system) (include-book "clause-processors/unify-subst" :dir :system) (include-book "centaur/misc/evaluator-metatheorems" :dir :system) (include-book "centaur/misc/interp-function-lookup" :dir :system) (include-book "centaur/ubdds/witness" :dir :system) (include-book "hyp-fix") (local (include-book "std/lists/take" :dir :system)) (local (include-book "gtype-thms")) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (include-book "std/basic/arith-equivs" :dir :system)) (local (defun before-run-gified-ev-tag () nil)) (acl2::defevaluator-fast run-gified-ev run-gified-ev-lst ((eql a b) (equal a b) (implies a b) (if a b c) (not a) (use-by-hint a) (acl2::use-these-hints a) (car x) (cdr x) (nth n x) (cons a b) (consp x) (synp vars form term) ; [Changed by Matt K. to handle changes to member, assoc, etc. after ACL2 4.2 ; (replaced assoc-eq by assoc-equal).] (assoc-equal x a) (acl2::kwote-lst lst) (symbolp x) (pairlis$ a b) (cons a b) (atom a) (binary-+ a b) (hide a) (mv-nth n x) (mv-list n x) (acl2::return-last a b c) (force x) (bfr-eval x env) (bfr-hyp-eval x env) (acl2::typespec-check ts x) (iff a b) (binary-+ a b) (unary-- a) (len x) (return-last a b c))) (defchoose run-gified-ev-falsify (a) (x) (not (run-gified-ev x a))) (local (def-ruleset! run-gified-ev-constraints (set-difference-theories (current-theory :here) (current-theory 'before-run-gified-ev-tag)))) (acl2::def-meta-extract run-gified-ev run-gified-ev-lst) (local (progn (include-book "tools/def-functional-instance" :dir :system) (acl2::def-functional-instance check-ev-of-fncall-args-correct-for-run-gified-ev acl2::check-ev-of-fncall-args-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify) (:instance run-gified-ev-meta-extract-global-badguy)))))) (acl2::def-functional-instance check-ev-of-variable-correct-for-run-gified-ev acl2::check-ev-of-variable-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-quote-correct-for-run-gified-ev acl2::check-ev-of-quote-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-lambda-correct-for-run-gified-ev acl2::check-ev-of-lambda-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-nonsymbol-atom-correct-for-run-gified-ev acl2::check-ev-of-nonsymbol-atom-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-bad-fncall-correct-for-run-gified-ev acl2::check-ev-of-bad-fncall-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-call-correct-for-run-gified-ev acl2::check-ev-of-call-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance ev-of-arglist-is-ground-for-run-gified-ev acl2::ev-of-arglist-is-ground ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))))) (defun run-gified-lhs-and-okp-breakdown (lhs okp) (case-match okp (('mv-nth ''0 (fn . '(fn actuals hyp clk config bvar-db state))) (case-match lhs ((ev ('mv-nth ''1 (!fn . '(fn actuals hyp clk config bvar-db state))) 'env) (mv nil ev fn)) (& (mv "lhs mismatched" nil nil)))) (& (mv "okp mismatched" nil nil)))) (local (defthm run-gified-lhs-and-okp-breakdown-correct (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal lhs `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env)) (equal okp `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)))))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-lhs-and-okp-breakdown)) (defun run-gified-rhs-breakdown (rhs) (case-match rhs ((ev ('cons 'fn ('acl2::kwote-lst (geval-list . '(actuals env)))) . '('nil)) (mv nil ev geval-list)) (& (mv "rhs mismatched" nil nil)))) (local (defthm run-gified-rhs-breakdown-correct (mv-let (erp evfn geval-list) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal rhs `(,evfn (cons fn (acl2::kwote-lst (,geval-list actuals env))) 'nil)))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-rhs-breakdown)) (defun function-def-clause (rule fn formals body) `((not (use-by-hint ',rule)) (equal (,fn . ,formals) ,body))) (local (defthm function-def-clause-correct (implies (run-gified-ev (disjoin (function-def-clause rule fn formals body)) env) (equal (run-gified-ev (cons fn formals) env) (run-gified-ev body env))) :hints(("Goal" :in-theory (enable use-by-hint function-def-clause))))) (in-theory (disable function-def-clause)) (include-book "gl-util") (defun f-i-thmname (thm eval) (incat 'gl-thm::foo (symbol-name thm) "-FOR-" (symbol-name eval))) (defun geval-rule-alist (table geval world) (if (atom table) (mv nil nil) (let ((entry (car table))) (case-match entry ((& gfn (thm . thm-geval) . &) (b* (((mv erp alist) (geval-rule-alist (cdr table) geval world)) ((when erp) (mv erp alist)) (thmname (if (eq thm-geval geval) thm (f-i-thmname thm geval))) (theorem (fgetprop thmname 'theorem nil world)) ((unless theorem) (mv (acl2::msg "theorem not found: ~x0" thmname) nil))) (mv nil (hons-acons gfn (cons thmname theorem) alist)))) (& (mv (acl2::msg "bad gl-function-info table entry: ~x0" entry) nil)))))) (in-theory (disable geval-rule-alist)) (defun run-gified-case-breakdown (body) (case-match body (('if ('eql 'fn ('quote fnname)) ('(LAMBDA (MV) ((LAMBDA (RES HYP) (CONS 'T (CONS RES (CONS HYP 'NIL)))) (MV-NTH '0 MV) (MV-NTH '1 MV))) (gfnname . args)) rest) (mv nil fnname gfnname args rest)) (& (mv (acl2::msg "Malformed case: ~x0" body) nil nil nil nil)))) (local (defthm run-gified-case-breakdown-correct (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (implies (not erp) (equal (run-gified-ev body a) (let ((fn (cdr (assoc-equal 'fn a)))) (if (equal fn fnname) (list t (mv-nth 0 (run-gified-ev (cons gfnname args) a)) (mv-nth 1 (run-gified-ev (cons gfnname args) a))) (run-gified-ev rest a)))))) :rule-classes ((:rewrite :backchain-limit-lst 0)))) (local (defthm run-gified-case-breakdown-rest-smaller (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (declare (ignore fnname gfnname args)) (implies (not erp) (< (acl2-count rest) (acl2-count body)))) :rule-classes (:rewrite :linear))) (in-theory (disable run-gified-case-breakdown)) (defun evals-of-formalsp (formals evals geval env) (if (atom formals) (equal evals nil) (and (consp evals) (let ((term (car evals))) (case-match term ((term-geval arg the-env) (and (equal the-env env) (equal term-geval geval) (equal arg (car formals)))))) (evals-of-formalsp (cdr formals) (cdr evals) geval env)))) (defun make-evals-of-formals (formals geval env) (if (atom formals) nil (cons (list geval (car formals) env) (make-evals-of-formals (Cdr formals) geval env)))) (local (defthm evals-of-formalsp-correct (implies (evals-of-formalsp formals evals geval env) (equal evals (make-evals-of-formals formals geval env))) :rule-classes :forward-chaining)) (in-theory (disable evals-of-formalsp)) (defun run-gified-check-geval-thm (thm gfn fn geval) (case-match thm (('implies '(bfr-hyp-eval hyp (car env)) ('equal (the-geval ('mv-nth ''0 (!gfn . gformals)) . '(env)) (!fn . evals))) (let ((nformals (len gformals))) (if (<= 5 nformals) (let ((formals (take (- nformals 5) gformals))) (if (and (equal the-geval geval) (evals-of-formalsp formals evals geval 'env) (nonnil-symbol-listp gformals) (acl2::fast-no-duplicatesp gformals) (not (member 'env gformals)) (equal (nthcdr (- nformals 5) gformals) '(hyp clk config bvar-db state))) (mv nil gformals) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil))) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (& (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (local (defthmd my-equal-of-cons (implies (syntaxp (not (and (quotep b) (quotep c)))) (equal (equal a (cons b c)) (and (consp a) (equal (car a) b) (equal (cdr a) c)))))) (local (defthm append-take-nthcdr (implies (< n (len lst)) (equal (append (take n lst) (nthcdr n lst)) lst)))) ; [Removed by Matt K. to handle changes to member, assoc, etc. after ACL2 4.2.] ; (local ; (defthmd member-is-member-equal ; (equal (member x y) ; (member-equal x y)))) ; ; (local (in-theory (enable member-is-member-equal))) (local (defthm run-gified-check-geval-thm-formals (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (and (<= 5 (len formals)) (nonnil-symbol-listp formals) (no-duplicatesp-equal formals) (not (member-equal 'env formals)) (equal (nthcdr (+ -5 (len formals)) formals) '(hyp clk config bvar-db state))))) :rule-classes nil)) (local (defthmd run-gified-check-geval-thm-form (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (equal thm `(implies (bfr-hyp-eval hyp (car env)) (equal (,geval (mv-nth '0 (,gfn . ,formals)) env) (,fn . ,(make-evals-of-formals (take (- (len formals) 5) formals) geval 'env))))))) :rule-classes :forward-chaining)) (local (acl2::def-functional-instance run-gified-ev-lst-pairlis acl2::ifl-ev-lst-pairlis ((acl2::ifl-ev-lst run-gified-ev-lst) (acl2::ifl-ev run-gified-ev)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0)))))) (local (defthm nthcdr-nil (equal (nthcdr n nil) nil))) (local (defthm nth-of-nthcdr (equal (nth n (nthcdr m y)) (nth (+ (nfix n) (nfix m)) y)))) ;; (encapsulate nil ;; (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; (defthmd equal-nthcdr-cons ;; (equal (equal (nthcdr n x) (cons a b)) ;; (and (equal (nth n x) a) ;; (< (nfix n) (len x)) ;; (equal (nthcdr (+ 1 (nfix n)) x) b))) ;; :hints (("goal" :induct (nthcdr n x))))) (local (encapsulate nil (local (defun the-induction (n keys vals) (if (zp n) (list keys vals) (the-induction (1- n) (cdr keys) (cdr vals))))) (local (defthm member-when-equal-nth (implies (and (equal key (nth n keys)) (< (nfix n) (len keys))) (member-equal key keys)))) (defthm assoc-equal-pairlis-nth (implies (and (equal (len keys) (len vals)) (< n (len keys)) (no-duplicatesp-equal keys)) (equal (cdr (assoc-equal (nth n keys) (pairlis$ keys vals))) (nth n vals))) :hints (("goal" :induct (the-induction n keys vals)))))) (local (defthm len-run-gified-ev-lst (equal (len (run-gified-ev-lst x a)) (len x)))) (local (defthm nth-run-gified-ev-lst (equal (nth n (run-gified-ev-lst x a)) (run-gified-ev (nth n x) a)))) (local (progn (defevaluator equality-cp-ev equality-cp-ev-lst ((equal a b) (if a b c) (not a) (hide x))) (acl2::def-join-thms equality-cp-ev) (defun find-remv-equality-hyp (clause term) (if (atom clause) (mv nil nil nil nil) (let ((lit (car clause))) (mv-let (ok other) (case-match lit (('not ('equal term1 term2)) (cond ((equal term1 term) (mv t term2)) ((equal term2 term) (mv t term1)) (t (mv nil nil)))) (& (mv nil nil))) (if ok (mv ok other (cdr clause) `(hide ,lit)) (mv-let (ok new rest hide) (find-remv-equality-hyp (cdr clause) term) (if ok (mv ok new (cons lit rest) hide) (mv nil nil nil nil)))))))) (defthm find-remv-equality-hyp-correct (mv-let (ok other new hide) (find-remv-equality-hyp clause term) (implies ok (iff (equality-cp-ev (disjoin clause) a) (not (and (equal (equality-cp-ev term a) (equality-cp-ev other a)) (not (equality-cp-ev hide a)) (not (equality-cp-ev (disjoin new) a))))))) :hints(("Goal" :expand ((:free (x) (hide x)))))) (mutual-recursion (defun replace-term (new old avoid x) (cond ((equal x new) old) ((member-equal x avoid) x) ((atom x) x) ((eq (car x) 'quote) x) (t (cons (car x) (replace-term-list new old avoid (cdr x)))))) (defun replace-term-list (new old avoid x) (if (atom x) nil (cons (replace-term new old avoid (car x)) (replace-term-list new old avoid (cdr x)))))) (flag::make-flag replace-term-flg replace-term) (defthm-replace-term-flg replace-term-correct-lemma (replace-term (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev (replace-term new old avoid x) a) (equality-cp-ev x a))) :name replace-term-correct) (replace-term-list (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev-lst (replace-term-list new old avoid x) a) (equality-cp-ev-lst x a))) :name replace-term-list-correct) :hints (("goal" :induct (replace-term-flg flag new old avoid x)) (and stable-under-simplificationp '(:in-theory (enable equality-cp-ev-constraint-0))))) (in-theory (disable replace-term replace-term-list)) (defthm replace-term-list-correct-disjoin (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (iff (equality-cp-ev (disjoin (replace-term-list new old avoid x)) a) (equality-cp-ev (disjoin x) a))) :hints(("Goal" :in-theory (e/d (replace-term-list)) :induct (len x)))) (defun replace-equality-cp (clause hints) (b* (((list term avoid) hints) ((mv ok new-term new-clause hide) (find-remv-equality-hyp clause term)) ((unless ok) (list clause)) (repl-clause (replace-term-list term new-term avoid new-clause))) (list (cons hide repl-clause)))) (defthm replace-equality-cp-correct (implies (and (pseudo-term-listp clause) (alistp a) (equality-cp-ev (conjoin-clauses (replace-equality-cp clause hints)) a)) (equality-cp-ev (disjoin clause) a)) :hints(("Goal" :do-not-induct t)) :rule-classes :clause-processor))) (local (defthm run-gified-ev-lst-symbol-cdr-alist (implies (and (nonnil-symbol-listp vars) (not (member-equal key vars))) (equal (run-gified-ev-lst vars (cons (cons key val) alist)) (run-gified-ev-lst vars alist))))) (local (in-theory (disable acl2::reflexivity-of-qs-subset))) (local (defthm run-gified-ev-lst-make-evals-of-formals (implies (and (syntaxp (not (equal a ''nil))) (not (equal geval 'quote))) (equal (run-gified-ev-lst (make-evals-of-formals lst geval env) a) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (run-gified-ev-lst lst a)) geval `(quote ,(run-gified-ev env a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0))))) (local (defthm run-gified-ev-lst-take (equal (run-gified-ev-lst (acl2::take n x) a) (acl2::take n (run-gified-ev-lst x a))) :hints(("Goal" :in-theory (enable acl2::take))))) (local (defthm list-fix-run-gified-ev-lst (equal (acl2::list-fix (run-gified-ev-lst x a)) (run-gified-ev-lst x a)) :hints (("goal" :induct (len x))))) (local (defthm run-gified-check-geval-thm-correct (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev thm (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a)))) (not (eq geval 'quote)) (not (eq gfn 'quote)) (not (eq fn 'quote)) (equal (len formals) (len args)) (bfr-hyp-eval hyp (car env))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d () ;; equal-nthcdr-cons (nth-of-nthcdr acl2::car-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm)) :use ((:instance run-gified-check-geval-thm-form) (:instance run-gified-check-geval-thm-formals) (:instance nth-of-nthcdr (n 0) (m (+ -5 (len args))) (y (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval)))) (:instance assoc-equal-pairlis-nth (n (- (len args) 5)) (keys (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval))) (vals (run-gified-ev-lst args a))))) (and stable-under-simplificationp '(:clause-processor (replace-equality-cp clause (list 'thm (list `(run-gified-check-geval-thm thm gfn fn geval)))) :in-theory (e/d (run-gified-ev-constraint-0) (nth-of-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm))))) :rule-classes ((:rewrite :backchain-limit-lst (0 nil nil nil nil nil nil))))) (local (in-theory (disable run-gified-check-geval-thm))) (defun run-gified-get-geval-thm (gfn fn geval-alist geval) (b* ((look (hons-get gfn geval-alist)) ((unless look) (mv (acl2::msg "No information about gfn ~x0 found" gfn) nil nil)) (thmname (cadr look)) (thm (cddr look)) ((mv erp formals) (run-gified-check-geval-thm thm gfn fn geval)) ((when erp) (mv erp nil nil))) (mv nil `((not (use-by-hint ',thmname)) ,thm) formals))) (local (defthm run-gified-get-geval-thm-correct (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (use-by-hint) ()) :use ((:instance run-gified-ev-falsify (x (disjoin (mv-nth 1 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (a (let ((formals (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a))))))))))) (local (defthm run-gified-get-geval-thm-correct-corollary (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev (list geval (list 'quote (mv-nth 0 (run-gified-ev (cons gfn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) (list 'quote env)) nil) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-get-geval-thm-correct)) :use ((:instance run-gified-get-geval-thm-correct)))))) (in-theory (disable run-gified-get-geval-thm)) (defun run-gified-get-eval-thm (fnname formals evfn eval-alist world) (b* ((look (hons-get fnname eval-alist)) ((when (not look)) (acl2::msg "Function ~x0 not recognized by evaluator." fnname)) ((cons arity rune) (cdr look)) ((unless (equal arity (len formals))) (acl2::msg "~x0 arity: ~x1 eval-alist, ~x2 geval" fnname arity (len formals))) ((unless (acl2::check-ev-of-call evfn fnname arity (cadr rune) world)) (acl2::msg "bad constraint: ~x0" fnname))) nil)) (local (in-theory (disable w))) (local (defthm run-gified-get-eval-thm-correct (let ((erp (run-gified-get-eval-thm fn formals evfn eval-alist (w state)))) (let ((ex (run-gified-ev x a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (run-gified-ev-meta-extract-global-facts) (consp ex) (equal (car ex) fn) (not (equal evfn 'quote)) (not (equal fn 'quote))) (equal (run-gified-ev `(,evfn ,x ,ma) a) (run-gified-ev `(,fn . ,(acl2::ev-of-arglist (len formals) evfn (cdr (run-gified-ev x a)) (run-gified-ev ma a))) a))))))) (in-theory (disable run-gified-get-eval-thm)) (defun nths-matching-formalsp (idx formals varname list) (declare (xargs :measure (acl2-count formals))) (if (atom formals) (eq list nil) (and (consp list) (let ((car (car list))) (case-match car (('nth ('quote !idx) !varname) t))) (nths-matching-formalsp (1+ idx) (cdr formals) varname (cdr list))))) (local (progn (defun make-nths-matching-formals (idx formals varname) (if (atom formals) nil (cons `(nth ',idx ,varname) (make-nths-matching-formals (1+ idx) (cdr formals) varname)))) (defthm nths-matching-formalsp-make-nths-matching-formals (implies (nths-matching-formalsp idx formals varname list) (equal list (make-nths-matching-formals idx formals varname))) :hints(("Goal" :in-theory (enable my-equal-of-cons))) :rule-classes :forward-chaining))) (in-theory (disable nths-matching-formalsp)) (local (defthm len-take (Equal (len (acl2::take n lst)) (nfix n)))) (local (defthm car-nthcdr (equal (car (nthcdr n a)) (nth n a)))) (local (defthm nth-kwote-lst (implies (< (nfix n) (len lst)) (equal (nth n (acl2::kwote-lst lst)) (list 'quote (nth n lst)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (in-theory (disable equal-of-booleans-rewrite default-car default-cdr))) (defun geval-list-def-thm (geval-list geval) `((not (use-by-hint ',geval-list)) (equal (,geval-list x env) (if (atom x) 'nil (cons (,geval (car x) env) (,geval-list (cdr x) env)))))) (local (defthm geval-list-def-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) ;; (gobjectp (run-gified-ev x a)) ;; (or (atom (run-gified-ev x a)) ;; (gobjectp (car (run-gified-ev x a)))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (and (implies (atom (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) nil)) (implies (consp (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) (cons (run-gified-ev (list geval (kwote (car (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil) (run-gified-ev (list geval-list (kwote (cdr (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil)))))) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0 geval-list-def-thm) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-list-def-thm geval-list geval))) (a `((x . ,(run-gified-ev x a)) (env . ,(run-gified-ev env a)))))))))) ;; (defthm gobj-listp-simple-take-implies ;; (implies (and (gobj-listp (acl2::simple-take n x)) ;; (natp n) (< 0 n)) ;; (or (atom x) (gobjectp (car x)))) ;; :rule-classes nil) ;; (defthm geval-geval-list-def-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use (geval-geval-list-def-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-geval-list-def-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use geval-geval-list-def-thm-correct ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 1 nil)))) ;; (defun geval-consp-when-gobj-listp-thm (geval rune) ;; `((not (use-by-hint ',rune)) ;; ;; (not (gobjectp x)) ;; ;; (not (if (consp x) ;; ;; (gobjectp (car x)) ;; ;; 't)) ;; (not (gobj-listp x)) ;; (equal (consp (,geval x env)) ;; (consp x)))) ;; (local ;; (defthm geval-consp-when-gobj-listp-thm-correct ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; ;; (gobjectp (run-gified-ev x a)) ;; ;; (or (atom (run-gified-ev x a)) ;; ;; (gobjectp (car (run-gified-ev x a)))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) ;; :use ((:instance run-gified-ev-falsify ;; (x (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (a `((x . ,(run-gified-ev x a)) ;; (env . ,(run-gified-ev env a)))))))))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct) ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 0 nil nil nil)))) (defun geval-of-nil-thm (geval rune) `((not (use-by-hint ',rune)) (equal (,geval 'nil env) 'nil))) (local (defthm geval-of-nil-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval rune))) (not (equal geval 'quote))) (equal (run-gified-ev (list geval ''nil env) a) nil)) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-of-nil-thm geval rune))) (a `((env . ,(run-gified-ev env a)))))))))) (in-theory (disable geval-list-def-thm geval-of-nil-thm)) (local (defthm nthcdr-kwote-lst (equal (nthcdr n (acl2::kwote-lst lst)) (acl2::kwote-lst (nthcdr n lst))))) (local (progn (defun make-n-cdrs (n term) (if (zp n) term (make-n-cdrs (1- n) (list 'cdr term)))) (local (defthm cdr-nthcdr (equal (cdr (nthcdr n x)) (nthcdr (+ 1 (nfix n)) x)) :hints(("Goal" :in-theory (enable default-cdr))))) (defthm run-gified-ev-make-n-cdrs (equal (run-gified-ev (make-n-cdrs n term) a) (nthcdr n (run-gified-ev term a))) :hints(("Goal" :in-theory (enable nthcdr)))))) (local (progn (defun test-constraint-0-result (args a mfc state) (declare (xargs :mode :program :stobjs state)) (not (equal (acl2::mfc-rw+ `(acl2::kwote-lst (run-gified-ev-lst args a)) `((args . ,args) (a . ,a)) 'acl2::? nil mfc state) args))) (defthmd my-run-gified-ev-constraint-0 (implies (and (syntaxp (test-constraint-0-result args a mfc state)) (not (equal fn 'quote))) (equal (run-gified-ev (cons fn args) a) (run-gified-ev (cons fn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0)))) ;; (defthm gobjectp-nth-gobj-listp ;; (implies (gobj-listp lst) ;; (gobjectp (nth n lst))) ;; :hints(("Goal" :in-theory (enable gobj-listp)))) (defthmd listp-nthcdr-gobj-listp (implies (and (gobj-listp lst) (nthcdr n lst)) (consp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp))))) (defthm gobj-listp-nthcdr (implies (gobj-listp lst) (gobj-listp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp) (cdr-nthcdr))))) (defthm gobj-listp-take (implies (gobj-listp gobj) (gobj-listp (acl2::take n gobj))) :hints(("Goal" :in-theory (enable gobj-listp acl2::take acl2::replicate)))) (defun count-down2-cdr (n m l) (if (zp n) (list m l) (count-down2-cdr (1- (nfix n)) (1- (nfix m)) (cdr l)))) (defthm gobj-listp-take1 (implies (and (gobj-listp (acl2::take m gobj)) (< (nfix n) (nfix m))) (gobj-listp (acl2::take n gobj))) :hints (("goal" :induct (count-down2-cdr m n gobj) :in-theory (enable gobj-listp acl2::take nfix)))) ;; (Defthm gobjectp-nth-when-gobj-listp-take ;; (implies (and (gobj-listp (acl2::take m x)) ;; (< (nfix n) (nfix m))) ;; (gobjectp (nth n x))) ;; :hints (("goal" :induct (count-down2-cdr m n x) ;; :in-theory (enable gobj-listp)))) (defthm cheap-default-car (implies (not (consp x)) (equal (car x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm cheap-default-cdr (implies (not (consp x)) (equal (cdr x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm nthcdr-when-not-consp (implies (and (not (consp x)) (not (zp n))) (equal (nthcdr n x) nil))) (defthm nthcdr-of-cons (implies (not (zp n)) (equal (nthcdr n (cons a b)) (nthcdr (+ -1 n) b)))) (defthm nthcdr-run-gified-of-geval-list (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (not (equal geval 'quote)) (not (equal geval-list 'quote)) ;; (acl2::take n (run-gified-ev args a)) ) (equal (nthcdr n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval-list (make-n-cdrs n args) env) a))) :hints(("Goal" :in-theory (e/d (my-run-gified-ev-constraint-0) (nthcdr nth)) :induct (make-n-cdrs n args) :expand ((:free (x) (nthcdr 0 x)))))) (defthm nth-run-gified-of-geval (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval geval-nil))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (equal (nth n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval (list 'car (make-n-cdrs n args)) env) a))) :hints(("Goal" :use ((:instance car-nthcdr (a (run-gified-ev (list gevalfn args env) a)))) :in-theory (e/d (run-gified-ev-constraint-0) (car-nthcdr acl2::car-nthcdr)) :cases ((consp (run-gified-ev args a)))))) (defthm run-gified-ev-lst-kwote-lst (equal (run-gified-ev-lst (acl2::kwote-lst x) a) (acl2::list-fix x))) (defthm cdr-kwote-lst (equal (cdr (acl2::kwote-lst lst)) (acl2::kwote-lst (cdr lst)))) (defthm car-kwote-lst (equal (car (acl2::kwote-lst lst)) (and (consp lst) (list 'quote (car lst))))) (defthm consp-nthcdr (equal (consp (nthcdr n x)) (< (nfix n) (len x))) :hints(("Goal" :in-theory (enable equal-of-booleans-rewrite)))) (defthm kwote-lst-cons (equal (acl2::kwote-lst (cons a b)) (cons (list 'quote a) (acl2::kwote-lst b)))) (defthm kwote-lst-atom (implies (atom a) (equal (acl2::kwote-lst a) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (in-theory (disable acl2::kwote-lst nth)) ;; (in-theory (disable acl2::ev-apply-arglist-on-result)) (in-theory (disable nthcdr)) (in-theory (disable acl2::true-list-listp-forward-to-true-listp-assoc-equal equal-of-booleans-rewrite default-car default-cdr)) (defthm nth-when-len-smaller (implies (<= (len lst) (nfix n)) (equal (nth n lst) nil)) :hints(("Goal" :in-theory (enable nth)))) (defthm run-gified-ev-lst-make-nths-matching-formals (implies (natp n) (equal (run-gified-ev-lst (make-nths-matching-formals n formals actuals) a) (acl2::take (len formals) (nthcdr n (run-gified-ev actuals a))))) :hints(("Goal" :in-theory (enable nth nthcdr acl2::take)))) (defthm asdfasdfa ;; (let ((n (nfix (- (len actuals) ;; (len formals))))) (implies (and ;; (natp n) ;; (< n (len actuals)) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-meta-extract-global-facts) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (not (equal evalfn 'quote))) (equal (run-gified-ev-lst (acl2::ev-of-arglist ;; acl2::ev-apply-arglist-on-result n evalfn (acl2::kwote-lst (run-gified-ev (list geval-list (list 'quote actuals) env) nil)) nil) nil) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (acl2::take n actuals)) gevalfn env) nil))) :hints(("Goal" :induct t :in-theory (enable acl2::take) :expand ((:free (a b c) (acl2::ev-of-arglist n a b c)))) (and stable-under-simplificationp '(:in-theory (e/d (my-run-gified-ev-constraint-0 acl2::replicate)))))) (encapsulate nil (local (defthm nthcdr-is-nil (implies (< (len lst) (nfix n)) (equal (nthcdr n lst) nil)) :hints(("Goal" :in-theory (enable nthcdr))))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev (implies (and (nths-matching-formalsp idx formals varname list) (natp idx)) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (nthcdr idx (run-gified-ev varname a))))) :hints(("Goal" :in-theory (enable my-equal-of-cons acl2::take nths-matching-formalsp)))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev1 (implies (nths-matching-formalsp 0 formals varname list) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (run-gified-ev varname a)))) :hints(("Goal" :in-theory (enable nthcdr) :use ((:instance nths-matching-formalsp-make-nths-matching-formals-ev (idx 0))))))) (defthm get-geval-thm-success-impl-len (implies (not (mv-nth 0 (run-gified-get-geval-thm gfn fn geval-alist geval))) (<= 5 (len (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval))))) :hints(("Goal" :in-theory (enable run-gified-get-geval-thm run-gified-check-geval-thm))) :rule-classes :linear))) (local (in-theory (disable acl2-count))) (defun run-gified-process-body (body eval-alist evalfn geval-alist gevalfn clauses world) (if (equal body '((LAMBDA (HYP) (CONS 'NIL (CONS 'NIL (CONS HYP 'NIL)))) ((LAMBDA (HYP) HYP) (RETURN-LAST 'ACL2::MBE1-RAW HYP (RETURN-LAST 'PROGN (ACL2::THROW-NONEXEC-ERROR ':NON-EXEC '(BFR-HYP-FIX HYP)) (BFR-HYP-FIX HYP))))) ;; (cons 'nil (cons 'nil 'nil)) ) ;; done. (mv nil clauses) (b* (((mv erp fnname gfnname args rest) (run-gified-case-breakdown body)) ((when erp) (mv erp nil)) ((when (or (eq fnname 'quote) (eq gfnname 'quote))) (mv "A function name is QUOTE which is bizzaro." nil)) ((mv erp clauses) (run-gified-process-body rest eval-alist evalfn geval-alist gevalfn clauses world)) ((when erp) (mv erp nil)) ((mv erp geval-thm formals) (run-gified-get-geval-thm gfnname fnname geval-alist gevalfn)) ((when erp) (mv erp nil)) ((unless (equal (len args) (len formals))) (mv "The number of arguments doesn't match." nil)) (erp (run-gified-get-eval-thm fnname (take (- (len formals) 5) formals) evalfn eval-alist world)) ((when erp) (mv erp nil)) ((unless (and (nths-matching-formalsp 0 (take (- (len formals) 5) formals) 'actuals (take (- (len formals) 5) args)) (equal (nthcdr (- (len formals) 5) args) '(hyp clk config bvar-db state)))) (mv (acl2::msg "Malformed function args: ~x0" (caddr body)) nil)) (clauses (list* geval-thm clauses))) (mv nil clauses)))) (defun ev-constraint-for-search (lemmas hyp-terms ev-term) (if (atom lemmas) nil (b* (((acl2::access acl2::rewrite-rule equiv lhs hyps rune) (car lemmas))) (if (and (eq equiv 'equal) (equal lhs ev-term) (equal hyps hyp-terms)) rune (ev-constraint-for-search (cdr lemmas) hyp-terms ev-term))))) (defun ev-constraint-for-fn (ev fn world) (b* ((lemmas (fgetprop ev 'acl2::lemmas nil world)) ) (ev-constraint-for-search lemmas `((consp x) (equal (car x) ',fn)) `(,ev x a)))) (defmacro ev-constraint-for (ev fn) `(ev-constraint-for-fn ',ev ',fn world)) (local (Defthm take-of-run-gified-ev-lst (implies (<= (nfix n) (len x)) (equal (take n (run-gified-ev-lst x a)) (run-gified-ev-lst (take n x) a))))) (local (encapsulate nil (local (defthm nth-when-nthcdr (implies (and (equal v (nthcdr n x)) (syntaxp (quotep v))) (equal (nth n x) (car v))))) (local (in-theory (enable NTHS-MATCHING-FORMALSP-MAKE-NTHS-MATCHING-FORMALS-EV1))) (local (in-theory (disable run-gified-ev-lst-take))) (local (in-theory (disable cheap-default-car cheap-default-cdr acl2::take ;; ev-quote-clause-correct-for-run-gified-ev ;; ev-lookup-var-clause-correct-for-run-gified-ev nth-when-len-smaller check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev (:definition run-gified-process-body) ;; (:REWRITE RUN-GIFIED-EV-constraint-32) ;; (:REWRITE RUN-GIFIED-EV-constraint-31) ;; (:REWRITE RUN-GIFIED-EV-constraint-30) ;; (:REWRITE RUN-GIFIED-EV-constraint-29) ;; (:REWRITE RUN-GIFIED-EV-constraint-28) ;; (:REWRITE RUN-GIFIED-EV-constraint-26) ;; (:REWRITE RUN-GIFIED-EV-constraint-25) ;; (:REWRITE RUN-GIFIED-EV-constraint-24) ;; (:REWRITE RUN-GIFIED-EV-constraint-23) ;; (:REWRITE RUN-GIFIED-EV-constraint-22) ;; (:REWRITE RUN-GIFIED-EV-constraint-20) ;; (:REWRITE RUN-GIFIED-EV-constraint-19) ;; (:REWRITE RUN-GIFIED-EV-constraint-17) ;; (:REWRITE RUN-GIFIED-EV-constraint-11) ;; (:REWRITE RUN-GIFIED-EV-constraint-10) ;; (:REWRITE RUN-GIFIED-EV-constraint-9) ;; (:REWRITE RUN-GIFIED-EV-constraint-8) ;; (:REWRITE RUN-GIFIED-EV-constraint-15) ;; (:REWRITE RUN-GIFIED-EV-constraint-14) ;; (:REWRITE RUN-GIFIED-EV-constraint-13) ;; (:REWRITE RUN-GIFIED-EV-constraint-12) (:META ACL2::CANCEL_TIMES-EQUAL-CORRECT) (:META ACL2::CANCEL_PLUS-EQUAL-CORRECT) ; (:REWRITE RUN-GIFIED-EV-CONSTRAINT-3) ;; (:REWRITE ACL2::SYMBOLP-ASSOC-EQUAL) (:d acl2::list-fix) (:REWRITE GEVAL-LIST-DEF-THM-CORRECT) (:DEFINITION SYMBOL-LISTP) (:REWRITE CHEAP-DEFAULT-CDR) (:TYPE-PRESCRIPTION SYMBOL-LISTP)))) ;; (local ;; (in-theory (set-difference-theories ;; (current-theory :here) ;; (list ; (EV-CONSTRAINT-FOR RUN-GIFIED-EV GOBJ-LISTP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-HYP-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV FORCE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV MV-LIST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV RETURN-LAST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV HIDE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV PAIRLIS$) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV SYMBOLP) ;; ; [Changed by Matt K. to handle changes to member, assoc, etc. after ACL2 4.2 ;; ; (replaced assoc-eq by assoc-equal).] ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ASSOC-EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CONSP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NTH) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IF) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IMPLIES) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CAR) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ACL2::USE-THESE-HINTS) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV USE-BY-HINT) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NOT))))) (defthm run-gified-process-body-correct (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (and (equal (run-gified-ev `(,gevalfn (quote ,(mv-nth 1 (run-gified-ev body a))) (quote ,env)) nil) (run-gified-ev `(,evalfn (quote ,(cons (cdr (assoc 'fn a)) (kwote-lst (run-gified-ev `(,geval-list (quote ,(cdr (assoc 'actuals a))) (quote ,env)) nil)))) 'nil) nil)) ;; (equal (run-gified-ev ;; `(,gevalfn (mv-nth '2 ,body) env) ;; a) ;; (run-gified-ev ;; `(,evalfn (list 'mv-nth ''1 ;; (cons fn (acl2::kwote-lst ;; (,geval-list actuals env)))) ;; 'nil) ;; a)) ))) :hints (("goal" :induct (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) :expand ((run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)))) (and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0 my-run-gified-ev-constraint-0) :do-not-induct t)) ;; (and stable-under-simplificationp ;; '(:use ((:instance ;; nth-of-nthcdr ;; (n 0) ;; (y (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY))) ;; (m (+ -5 (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN ;; BODY)))))) ;; (:instance ;; nths-matching-formalsp-make-nths-matching-formals-ev1 ;; (list (ACL2::TAKE (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (formals (ACL2::TAKE ;; (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH ;; 2 ;; (RUN-GIFIED-GET-GEVAL-THM (MV-NTH 2 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; (MV-NTH 1 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; GEVAL-ALIST GEVALFN)))) ;; (varname 'ACTUALS))) ;; :in-theory (e/d (my-run-gified-ev-constraint-0) ;; (nth-of-nthcdr)))) )))) (local (defthm run-gified-process-body-correct1 (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (equal (run-gified-ev (list gevalfn (list 'quote (mv-nth 1 (run-gified-ev body a))) (list 'quote env)) nil) (run-gified-ev `(,evalfn (cons fn (acl2::kwote-lst (,geval-list actuals (quote ,env)))) 'nil) a)))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-process-body-correct)) :use ((:instance run-gified-process-body-correct)))))) (defun run-gified-clause-proc (clause geval-nil state) (declare ; (ignore hints) (xargs :stobjs state :verify-guards nil)) (b* (((mv ok subst) (acl2::simple-one-way-unify-lst '((implies (if (bfr-hyp-eval hyp (car env)) okp-term 'nil) (equal lhs-term rhs-term))) clause nil)) ((unless ok) (mv (acl2::msg "Clause didn't match pattern: ~x0~%" clause) nil state)) ((unless (and (eq (cdr (assoc-equal 'hyp subst)) 'hyp) (eq (cdr (assoc-equal 'env subst)) 'env))) (mv "Clause variables are different than expected" nil state)) (lhs (cdr (assoc-equal 'lhs-term subst))) (rhs (cdr (assoc-equal 'rhs-term subst))) (okp (cdr (assoc-equal 'okp-term subst))) ((mv erp geval-fn run-gified-fn) (run-gified-lhs-and-okp-breakdown lhs okp)) ((when erp) (mv erp nil state)) ((when (equal geval-fn 'quote)) (mv "The geval function is QUOTE which is silly." nil state)) ((when (equal run-gified-fn 'quote)) (mv "The run-gified function is QUOTE which is silly." nil state)) ((mv erp ev-fn geval-list-fn) (run-gified-rhs-breakdown rhs)) ((when (eq geval-list-fn 'quote)) (mv "The geval-list function is QUOTE which is silly." nil state)) ((when erp) (mv erp nil state)) ((mv ok ?formals body) (acl2::fn-get-def run-gified-fn state)) ((unless ok) (mv (msg "Failed to get the function definition for ~x0" run-gified-fn) nil state)) ((unless (equal formals '(fn actuals hyp clk config bvar-db state))) (mv (msg "Expected the formals of ~x0 to be ~x1" run-gified-fn '(fn actuals hyp clk config bvar-db state)) nil state)) (world (w state)) ((when (eq ev-fn 'quote)) (mv "The eval function is QUOTE which is silly." nil state)) (eval-rule-alist (acl2::ev-collect-apply-lemmas ev-fn nil world)) ((unless (acl2::check-ev-of-quote ev-fn (cadr (cdr (hons-get :quote eval-rule-alist))) world)) (mv "The eval function doesn't have the expected QUOTE constraint." nil state)) ((unless (acl2::check-ev-of-variable ev-fn (cadr (cdr (hons-get :lookup-var eval-rule-alist))) world)) (mv "The eval function doesn't have the expected variable-lookup constraint." nil state)) ((mv erp geval-rule-alist) (geval-rule-alist (table-alist 'gl-function-info world) geval-fn world)) ((when erp) (mv erp nil state)) ((mv erp clauses) (run-gified-process-body body eval-rule-alist ev-fn geval-rule-alist geval-fn nil world)) ((when erp) (mv erp nil state))) (value (list* (geval-list-def-thm geval-list-fn geval-fn) (geval-of-nil-thm geval-fn geval-nil) clauses)))) (local (acl2::def-unify run-gified-ev run-gified-ev-alist)) (local (defthm assoc-equal-run-gified-ev-alist (equal (cdr (assoc-equal x (run-gified-ev-alist subst a))) (run-gified-ev (cdr (assoc-equal x subst)) a)))) (local (encapsulate nil (local (defun cdr-down2 (a b) (if (atom a) b (cdr-down2 (cdr a) (cdr b))))) (local (defthm run-gified-ev-lst-equal-impl-disjoin-iff (implies (equal (run-gified-ev-lst lst a) (run-gified-ev-lst lst2 a2)) (iff (run-gified-ev (disjoin lst) a) (run-gified-ev (disjoin lst2) a2))) :hints (("goal" :induct (cdr-down2 lst lst2) :in-theory (enable run-gified-ev-disjoin-when-consp)) '(:cases ((consp lst2)))) :rule-classes nil)) (defthm simple-one-way-unify-lst-usage-disjoin (mv-let (ok subst) (acl2::simple-one-way-unify-lst template term alist) (implies (and ok (pseudo-term-listp term) (pseudo-term-listp template)) (iff (run-gified-ev (disjoin term) a) (run-gified-ev (disjoin template) (run-gified-ev-alist subst a))))) :hints (("goal" :use ((:instance run-gified-ev-lst-equal-impl-disjoin-iff (lst term) (a a) (lst2 template) (a2 (run-gified-ev-alist (mv-nth 1 (acl2::simple-one-way-unify-lst template term alist)) a))))))))) (local (defthm run-gified-lhs-and-okp-breakdown-correct-eval (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal (run-gified-ev lhs a) (run-gified-ev `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env) a)) (equal (run-gified-ev okp a) (run-gified-ev `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)) a))))) :hints (("goal" :use run-gified-lhs-and-okp-breakdown-correct :in-theory (disable run-gified-lhs-and-okp-breakdown-correct))))) (local (defthm run-gified-rhs-breakdown-correct-eval (mv-let (erp evfn geval-list-fn) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal (run-gified-ev rhs a) (run-gified-ev `(,evfn (cons fn (acl2::kwote-lst (,geval-list-fn actuals env))) 'nil) a)))))) (local (in-theory (disable run-gified-lhs-and-okp-breakdown-correct run-gified-rhs-breakdown-correct))) (local (in-theory (disable acl2::ev-collect-apply-lemmas body table-alist w))) (local (in-theory (disable run-gified-process-body assoc-equal))) (local (in-theory (disable SIMPLE-ONE-WAY-UNIFY-LST-WITH-RUN-GIFIED-EV check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev))) (local (defthm assoc-equal-of-cons (implies (syntaxp (and (quotep var) (quotep key))) (equal (assoc var (cons (cons key val) rest)) (if (equal var key) (cons key val) (assoc var rest)))) :hints(("Goal" :in-theory (enable assoc))))) (local (defthm pairlis-open (equal (pairlis$ (cons a b) c) (cons (cons a (car c)) (pairlis$ b (cdr c)))))) (local (in-theory (disable pairlis$))) (defthm run-gified-clause-proc-correct (implies (and (pseudo-term-listp clause) (alistp a) (run-gified-ev-meta-extract-global-facts) (run-gified-ev (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state))) (run-gified-ev-falsify (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state)))))) (run-gified-ev (disjoin clause) a)) :hints (("goal" :do-not-induct t :in-theory (enable run-gified-ev-constraint-0 ;; assoc-equal )) (and stable-under-simplificationp '(:computed-hint-replacement ('(:clause-processor (acl2::simple-generalize-cp clause '(((CDR (ASSOC-EQUAL 'LHS-TERM subst)) . lhs) ((CDR (ASSOC-EQUAL 'rhs-term subst)) . rhs) ((CDR (ASSOC-EQUAL 'OKP-TERM subst)) . okp) ((CDR (ASSOC-EQUAL 'hyp subst)) . hyp) ((CDR (ASSOC-EQUAL 'actuals subst)) . actuals) ((CDR (ASSOC-EQUAL 'env subst)) . env)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . geval-fn) ((MV-NTH '2 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . run-gified-fn)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . evalfn) ((MV-NTH '2 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . geval-list-fn) ((MV-NTH '1 (GEVAL-RULE-ALIST (TABLE-ALIST 'GL-FUNCTION-INFO (W STATE)) GEVAL-FN (W STATE))) . geval-alist)))) ;; '(:use ((:instance run-gified-ev-meta-extract-fn-check-def ;; (st state) ;; (fn run-gified-fn) ;; (formals (mv-nth 1 (acl2::fn-get-def geval-fn state))) ;; (body (mv-nth 2 (acl2::fn-get-def geval-fn state))) ;; (args (list (LIST ;; 'QUOTE ;; (MV-NTH 1 ;; (RUN-GIFIED-EV (LIST RUN-GIFIED-FN ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'FN A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ACTUALS A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'HYP A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'CLK A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'CONFIG A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'BVAR-DB A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'STATE A)))) ;; NIL))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ENV A))))) ;; (a nil)))) ;; '(:clause-processor ;; (acl2::simple-generalize-cp ;; clause '(((ACL2::EV-COLLECT-APPLY-LEMMAS ;; evalfn 'NIL (W STATE)) . eval-alist)))) ;; '(:use ((:instance run-gified-ev-falsify ;; (x (disjoin (function-def-clause ;; run-gified-fn run-gified-fn ;; '(fn actuals hyp clk config bvar-db state) ;; (MV-NTH 2 (ACL2::FN-GET-DEF GEVAL-FN STATE))))) ;; (a a))) ;; :in-theory (enable run-gified-ev-constraint-0)) ) :clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (ACL2::SIMPLE-ONE-WAY-UNIFY-LST '((IMPLIES (IF (BFR-HYP-EVAL HYP (CAR ENV)) OKP-TERM 'NIL) (EQUAL LHS-TERM RHS-TERM))) CLAUSE 'NIL)) . subst)))))) :rule-classes :clause-processor)
91925
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> (in-package "GL") (include-book "bfr") (include-book "gtypes") (include-book "tools/mv-nth" :dir :system) (include-book "std/util/bstar" :dir :system) (include-book "tools/defevaluator-fast" :dir :system) (include-book "clause-processors/unify-subst" :dir :system) (include-book "centaur/misc/evaluator-metatheorems" :dir :system) (include-book "centaur/misc/interp-function-lookup" :dir :system) (include-book "centaur/ubdds/witness" :dir :system) (include-book "hyp-fix") (local (include-book "std/lists/take" :dir :system)) (local (include-book "gtype-thms")) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (include-book "std/basic/arith-equivs" :dir :system)) (local (defun before-run-gified-ev-tag () nil)) (acl2::defevaluator-fast run-gified-ev run-gified-ev-lst ((eql a b) (equal a b) (implies a b) (if a b c) (not a) (use-by-hint a) (acl2::use-these-hints a) (car x) (cdr x) (nth n x) (cons a b) (consp x) (synp vars form term) ; [Changed by <NAME>. to handle changes to member, assoc, etc. after ACL2 4.2 ; (replaced assoc-eq by assoc-equal).] (assoc-equal x a) (acl2::kwote-lst lst) (symbolp x) (pairlis$ a b) (cons a b) (atom a) (binary-+ a b) (hide a) (mv-nth n x) (mv-list n x) (acl2::return-last a b c) (force x) (bfr-eval x env) (bfr-hyp-eval x env) (acl2::typespec-check ts x) (iff a b) (binary-+ a b) (unary-- a) (len x) (return-last a b c))) (defchoose run-gified-ev-falsify (a) (x) (not (run-gified-ev x a))) (local (def-ruleset! run-gified-ev-constraints (set-difference-theories (current-theory :here) (current-theory 'before-run-gified-ev-tag)))) (acl2::def-meta-extract run-gified-ev run-gified-ev-lst) (local (progn (include-book "tools/def-functional-instance" :dir :system) (acl2::def-functional-instance check-ev-of-fncall-args-correct-for-run-gified-ev acl2::check-ev-of-fncall-args-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify) (:instance run-gified-ev-meta-extract-global-badguy)))))) (acl2::def-functional-instance check-ev-of-variable-correct-for-run-gified-ev acl2::check-ev-of-variable-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-quote-correct-for-run-gified-ev acl2::check-ev-of-quote-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-lambda-correct-for-run-gified-ev acl2::check-ev-of-lambda-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-nonsymbol-atom-correct-for-run-gified-ev acl2::check-ev-of-nonsymbol-atom-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-bad-fncall-correct-for-run-gified-ev acl2::check-ev-of-bad-fncall-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-call-correct-for-run-gified-ev acl2::check-ev-of-call-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance ev-of-arglist-is-ground-for-run-gified-ev acl2::ev-of-arglist-is-ground ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))))) (defun run-gified-lhs-and-okp-breakdown (lhs okp) (case-match okp (('mv-nth ''0 (fn . '(fn actuals hyp clk config bvar-db state))) (case-match lhs ((ev ('mv-nth ''1 (!fn . '(fn actuals hyp clk config bvar-db state))) 'env) (mv nil ev fn)) (& (mv "lhs mismatched" nil nil)))) (& (mv "okp mismatched" nil nil)))) (local (defthm run-gified-lhs-and-okp-breakdown-correct (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal lhs `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env)) (equal okp `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)))))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-lhs-and-okp-breakdown)) (defun run-gified-rhs-breakdown (rhs) (case-match rhs ((ev ('cons 'fn ('acl2::kwote-lst (geval-list . '(actuals env)))) . '('nil)) (mv nil ev geval-list)) (& (mv "rhs mismatched" nil nil)))) (local (defthm run-gified-rhs-breakdown-correct (mv-let (erp evfn geval-list) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal rhs `(,evfn (cons fn (acl2::kwote-lst (,geval-list actuals env))) 'nil)))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-rhs-breakdown)) (defun function-def-clause (rule fn formals body) `((not (use-by-hint ',rule)) (equal (,fn . ,formals) ,body))) (local (defthm function-def-clause-correct (implies (run-gified-ev (disjoin (function-def-clause rule fn formals body)) env) (equal (run-gified-ev (cons fn formals) env) (run-gified-ev body env))) :hints(("Goal" :in-theory (enable use-by-hint function-def-clause))))) (in-theory (disable function-def-clause)) (include-book "gl-util") (defun f-i-thmname (thm eval) (incat 'gl-thm::foo (symbol-name thm) "-FOR-" (symbol-name eval))) (defun geval-rule-alist (table geval world) (if (atom table) (mv nil nil) (let ((entry (car table))) (case-match entry ((& gfn (thm . thm-geval) . &) (b* (((mv erp alist) (geval-rule-alist (cdr table) geval world)) ((when erp) (mv erp alist)) (thmname (if (eq thm-geval geval) thm (f-i-thmname thm geval))) (theorem (fgetprop thmname 'theorem nil world)) ((unless theorem) (mv (acl2::msg "theorem not found: ~x0" thmname) nil))) (mv nil (hons-acons gfn (cons thmname theorem) alist)))) (& (mv (acl2::msg "bad gl-function-info table entry: ~x0" entry) nil)))))) (in-theory (disable geval-rule-alist)) (defun run-gified-case-breakdown (body) (case-match body (('if ('eql 'fn ('quote fnname)) ('(LAMBDA (MV) ((LAMBDA (RES HYP) (CONS 'T (CONS RES (CONS HYP 'NIL)))) (MV-NTH '0 MV) (MV-NTH '1 MV))) (gfnname . args)) rest) (mv nil fnname gfnname args rest)) (& (mv (acl2::msg "Malformed case: ~x0" body) nil nil nil nil)))) (local (defthm run-gified-case-breakdown-correct (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (implies (not erp) (equal (run-gified-ev body a) (let ((fn (cdr (assoc-equal 'fn a)))) (if (equal fn fnname) (list t (mv-nth 0 (run-gified-ev (cons gfnname args) a)) (mv-nth 1 (run-gified-ev (cons gfnname args) a))) (run-gified-ev rest a)))))) :rule-classes ((:rewrite :backchain-limit-lst 0)))) (local (defthm run-gified-case-breakdown-rest-smaller (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (declare (ignore fnname gfnname args)) (implies (not erp) (< (acl2-count rest) (acl2-count body)))) :rule-classes (:rewrite :linear))) (in-theory (disable run-gified-case-breakdown)) (defun evals-of-formalsp (formals evals geval env) (if (atom formals) (equal evals nil) (and (consp evals) (let ((term (car evals))) (case-match term ((term-geval arg the-env) (and (equal the-env env) (equal term-geval geval) (equal arg (car formals)))))) (evals-of-formalsp (cdr formals) (cdr evals) geval env)))) (defun make-evals-of-formals (formals geval env) (if (atom formals) nil (cons (list geval (car formals) env) (make-evals-of-formals (Cdr formals) geval env)))) (local (defthm evals-of-formalsp-correct (implies (evals-of-formalsp formals evals geval env) (equal evals (make-evals-of-formals formals geval env))) :rule-classes :forward-chaining)) (in-theory (disable evals-of-formalsp)) (defun run-gified-check-geval-thm (thm gfn fn geval) (case-match thm (('implies '(bfr-hyp-eval hyp (car env)) ('equal (the-geval ('mv-nth ''0 (!gfn . gformals)) . '(env)) (!fn . evals))) (let ((nformals (len gformals))) (if (<= 5 nformals) (let ((formals (take (- nformals 5) gformals))) (if (and (equal the-geval geval) (evals-of-formalsp formals evals geval 'env) (nonnil-symbol-listp gformals) (acl2::fast-no-duplicatesp gformals) (not (member 'env gformals)) (equal (nthcdr (- nformals 5) gformals) '(hyp clk config bvar-db state))) (mv nil gformals) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil))) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (& (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (local (defthmd my-equal-of-cons (implies (syntaxp (not (and (quotep b) (quotep c)))) (equal (equal a (cons b c)) (and (consp a) (equal (car a) b) (equal (cdr a) c)))))) (local (defthm append-take-nthcdr (implies (< n (len lst)) (equal (append (take n lst) (nthcdr n lst)) lst)))) ; [Removed by <NAME>. to handle changes to member, assoc, etc. after ACL2 4.2.] ; (local ; (defthmd member-is-member-equal ; (equal (member x y) ; (member-equal x y)))) ; ; (local (in-theory (enable member-is-member-equal))) (local (defthm run-gified-check-geval-thm-formals (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (and (<= 5 (len formals)) (nonnil-symbol-listp formals) (no-duplicatesp-equal formals) (not (member-equal 'env formals)) (equal (nthcdr (+ -5 (len formals)) formals) '(hyp clk config bvar-db state))))) :rule-classes nil)) (local (defthmd run-gified-check-geval-thm-form (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (equal thm `(implies (bfr-hyp-eval hyp (car env)) (equal (,geval (mv-nth '0 (,gfn . ,formals)) env) (,fn . ,(make-evals-of-formals (take (- (len formals) 5) formals) geval 'env))))))) :rule-classes :forward-chaining)) (local (acl2::def-functional-instance run-gified-ev-lst-pairlis acl2::ifl-ev-lst-pairlis ((acl2::ifl-ev-lst run-gified-ev-lst) (acl2::ifl-ev run-gified-ev)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0)))))) (local (defthm nthcdr-nil (equal (nthcdr n nil) nil))) (local (defthm nth-of-nthcdr (equal (nth n (nthcdr m y)) (nth (+ (nfix n) (nfix m)) y)))) ;; (encapsulate nil ;; (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; (defthmd equal-nthcdr-cons ;; (equal (equal (nthcdr n x) (cons a b)) ;; (and (equal (nth n x) a) ;; (< (nfix n) (len x)) ;; (equal (nthcdr (+ 1 (nfix n)) x) b))) ;; :hints (("goal" :induct (nthcdr n x))))) (local (encapsulate nil (local (defun the-induction (n keys vals) (if (zp n) (list keys vals) (the-induction (1- n) (cdr keys) (cdr vals))))) (local (defthm member-when-equal-nth (implies (and (equal key (nth n keys)) (< (nfix n) (len keys))) (member-equal key keys)))) (defthm assoc-equal-pairlis-nth (implies (and (equal (len keys) (len vals)) (< n (len keys)) (no-duplicatesp-equal keys)) (equal (cdr (assoc-equal (nth n keys) (pairlis$ keys vals))) (nth n vals))) :hints (("goal" :induct (the-induction n keys vals)))))) (local (defthm len-run-gified-ev-lst (equal (len (run-gified-ev-lst x a)) (len x)))) (local (defthm nth-run-gified-ev-lst (equal (nth n (run-gified-ev-lst x a)) (run-gified-ev (nth n x) a)))) (local (progn (defevaluator equality-cp-ev equality-cp-ev-lst ((equal a b) (if a b c) (not a) (hide x))) (acl2::def-join-thms equality-cp-ev) (defun find-remv-equality-hyp (clause term) (if (atom clause) (mv nil nil nil nil) (let ((lit (car clause))) (mv-let (ok other) (case-match lit (('not ('equal term1 term2)) (cond ((equal term1 term) (mv t term2)) ((equal term2 term) (mv t term1)) (t (mv nil nil)))) (& (mv nil nil))) (if ok (mv ok other (cdr clause) `(hide ,lit)) (mv-let (ok new rest hide) (find-remv-equality-hyp (cdr clause) term) (if ok (mv ok new (cons lit rest) hide) (mv nil nil nil nil)))))))) (defthm find-remv-equality-hyp-correct (mv-let (ok other new hide) (find-remv-equality-hyp clause term) (implies ok (iff (equality-cp-ev (disjoin clause) a) (not (and (equal (equality-cp-ev term a) (equality-cp-ev other a)) (not (equality-cp-ev hide a)) (not (equality-cp-ev (disjoin new) a))))))) :hints(("Goal" :expand ((:free (x) (hide x)))))) (mutual-recursion (defun replace-term (new old avoid x) (cond ((equal x new) old) ((member-equal x avoid) x) ((atom x) x) ((eq (car x) 'quote) x) (t (cons (car x) (replace-term-list new old avoid (cdr x)))))) (defun replace-term-list (new old avoid x) (if (atom x) nil (cons (replace-term new old avoid (car x)) (replace-term-list new old avoid (cdr x)))))) (flag::make-flag replace-term-flg replace-term) (defthm-replace-term-flg replace-term-correct-lemma (replace-term (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev (replace-term new old avoid x) a) (equality-cp-ev x a))) :name replace-term-correct) (replace-term-list (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev-lst (replace-term-list new old avoid x) a) (equality-cp-ev-lst x a))) :name replace-term-list-correct) :hints (("goal" :induct (replace-term-flg flag new old avoid x)) (and stable-under-simplificationp '(:in-theory (enable equality-cp-ev-constraint-0))))) (in-theory (disable replace-term replace-term-list)) (defthm replace-term-list-correct-disjoin (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (iff (equality-cp-ev (disjoin (replace-term-list new old avoid x)) a) (equality-cp-ev (disjoin x) a))) :hints(("Goal" :in-theory (e/d (replace-term-list)) :induct (len x)))) (defun replace-equality-cp (clause hints) (b* (((list term avoid) hints) ((mv ok new-term new-clause hide) (find-remv-equality-hyp clause term)) ((unless ok) (list clause)) (repl-clause (replace-term-list term new-term avoid new-clause))) (list (cons hide repl-clause)))) (defthm replace-equality-cp-correct (implies (and (pseudo-term-listp clause) (alistp a) (equality-cp-ev (conjoin-clauses (replace-equality-cp clause hints)) a)) (equality-cp-ev (disjoin clause) a)) :hints(("Goal" :do-not-induct t)) :rule-classes :clause-processor))) (local (defthm run-gified-ev-lst-symbol-cdr-alist (implies (and (nonnil-symbol-listp vars) (not (member-equal key vars))) (equal (run-gified-ev-lst vars (cons (cons key val) alist)) (run-gified-ev-lst vars alist))))) (local (in-theory (disable acl2::reflexivity-of-qs-subset))) (local (defthm run-gified-ev-lst-make-evals-of-formals (implies (and (syntaxp (not (equal a ''nil))) (not (equal geval 'quote))) (equal (run-gified-ev-lst (make-evals-of-formals lst geval env) a) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (run-gified-ev-lst lst a)) geval `(quote ,(run-gified-ev env a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0))))) (local (defthm run-gified-ev-lst-take (equal (run-gified-ev-lst (acl2::take n x) a) (acl2::take n (run-gified-ev-lst x a))) :hints(("Goal" :in-theory (enable acl2::take))))) (local (defthm list-fix-run-gified-ev-lst (equal (acl2::list-fix (run-gified-ev-lst x a)) (run-gified-ev-lst x a)) :hints (("goal" :induct (len x))))) (local (defthm run-gified-check-geval-thm-correct (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev thm (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a)))) (not (eq geval 'quote)) (not (eq gfn 'quote)) (not (eq fn 'quote)) (equal (len formals) (len args)) (bfr-hyp-eval hyp (car env))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d () ;; equal-nthcdr-cons (nth-of-nthcdr acl2::car-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm)) :use ((:instance run-gified-check-geval-thm-form) (:instance run-gified-check-geval-thm-formals) (:instance nth-of-nthcdr (n 0) (m (+ -5 (len args))) (y (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval)))) (:instance assoc-equal-pairlis-nth (n (- (len args) 5)) (keys (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval))) (vals (run-gified-ev-lst args a))))) (and stable-under-simplificationp '(:clause-processor (replace-equality-cp clause (list 'thm (list `(run-gified-check-geval-thm thm gfn fn geval)))) :in-theory (e/d (run-gified-ev-constraint-0) (nth-of-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm))))) :rule-classes ((:rewrite :backchain-limit-lst (0 nil nil nil nil nil nil))))) (local (in-theory (disable run-gified-check-geval-thm))) (defun run-gified-get-geval-thm (gfn fn geval-alist geval) (b* ((look (hons-get gfn geval-alist)) ((unless look) (mv (acl2::msg "No information about gfn ~x0 found" gfn) nil nil)) (thmname (cadr look)) (thm (cddr look)) ((mv erp formals) (run-gified-check-geval-thm thm gfn fn geval)) ((when erp) (mv erp nil nil))) (mv nil `((not (use-by-hint ',thmname)) ,thm) formals))) (local (defthm run-gified-get-geval-thm-correct (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (use-by-hint) ()) :use ((:instance run-gified-ev-falsify (x (disjoin (mv-nth 1 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (a (let ((formals (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a))))))))))) (local (defthm run-gified-get-geval-thm-correct-corollary (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev (list geval (list 'quote (mv-nth 0 (run-gified-ev (cons gfn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) (list 'quote env)) nil) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-get-geval-thm-correct)) :use ((:instance run-gified-get-geval-thm-correct)))))) (in-theory (disable run-gified-get-geval-thm)) (defun run-gified-get-eval-thm (fnname formals evfn eval-alist world) (b* ((look (hons-get fnname eval-alist)) ((when (not look)) (acl2::msg "Function ~x0 not recognized by evaluator." fnname)) ((cons arity rune) (cdr look)) ((unless (equal arity (len formals))) (acl2::msg "~x0 arity: ~x1 eval-alist, ~x2 geval" fnname arity (len formals))) ((unless (acl2::check-ev-of-call evfn fnname arity (cadr rune) world)) (acl2::msg "bad constraint: ~x0" fnname))) nil)) (local (in-theory (disable w))) (local (defthm run-gified-get-eval-thm-correct (let ((erp (run-gified-get-eval-thm fn formals evfn eval-alist (w state)))) (let ((ex (run-gified-ev x a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (run-gified-ev-meta-extract-global-facts) (consp ex) (equal (car ex) fn) (not (equal evfn 'quote)) (not (equal fn 'quote))) (equal (run-gified-ev `(,evfn ,x ,ma) a) (run-gified-ev `(,fn . ,(acl2::ev-of-arglist (len formals) evfn (cdr (run-gified-ev x a)) (run-gified-ev ma a))) a))))))) (in-theory (disable run-gified-get-eval-thm)) (defun nths-matching-formalsp (idx formals varname list) (declare (xargs :measure (acl2-count formals))) (if (atom formals) (eq list nil) (and (consp list) (let ((car (car list))) (case-match car (('nth ('quote !idx) !varname) t))) (nths-matching-formalsp (1+ idx) (cdr formals) varname (cdr list))))) (local (progn (defun make-nths-matching-formals (idx formals varname) (if (atom formals) nil (cons `(nth ',idx ,varname) (make-nths-matching-formals (1+ idx) (cdr formals) varname)))) (defthm nths-matching-formalsp-make-nths-matching-formals (implies (nths-matching-formalsp idx formals varname list) (equal list (make-nths-matching-formals idx formals varname))) :hints(("Goal" :in-theory (enable my-equal-of-cons))) :rule-classes :forward-chaining))) (in-theory (disable nths-matching-formalsp)) (local (defthm len-take (Equal (len (acl2::take n lst)) (nfix n)))) (local (defthm car-nthcdr (equal (car (nthcdr n a)) (nth n a)))) (local (defthm nth-kwote-lst (implies (< (nfix n) (len lst)) (equal (nth n (acl2::kwote-lst lst)) (list 'quote (nth n lst)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (in-theory (disable equal-of-booleans-rewrite default-car default-cdr))) (defun geval-list-def-thm (geval-list geval) `((not (use-by-hint ',geval-list)) (equal (,geval-list x env) (if (atom x) 'nil (cons (,geval (car x) env) (,geval-list (cdr x) env)))))) (local (defthm geval-list-def-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) ;; (gobjectp (run-gified-ev x a)) ;; (or (atom (run-gified-ev x a)) ;; (gobjectp (car (run-gified-ev x a)))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (and (implies (atom (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) nil)) (implies (consp (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) (cons (run-gified-ev (list geval (kwote (car (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil) (run-gified-ev (list geval-list (kwote (cdr (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil)))))) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0 geval-list-def-thm) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-list-def-thm geval-list geval))) (a `((x . ,(run-gified-ev x a)) (env . ,(run-gified-ev env a)))))))))) ;; (defthm gobj-listp-simple-take-implies ;; (implies (and (gobj-listp (acl2::simple-take n x)) ;; (natp n) (< 0 n)) ;; (or (atom x) (gobjectp (car x)))) ;; :rule-classes nil) ;; (defthm geval-geval-list-def-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use (geval-geval-list-def-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-geval-list-def-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use geval-geval-list-def-thm-correct ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 1 nil)))) ;; (defun geval-consp-when-gobj-listp-thm (geval rune) ;; `((not (use-by-hint ',rune)) ;; ;; (not (gobjectp x)) ;; ;; (not (if (consp x) ;; ;; (gobjectp (car x)) ;; ;; 't)) ;; (not (gobj-listp x)) ;; (equal (consp (,geval x env)) ;; (consp x)))) ;; (local ;; (defthm geval-consp-when-gobj-listp-thm-correct ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; ;; (gobjectp (run-gified-ev x a)) ;; ;; (or (atom (run-gified-ev x a)) ;; ;; (gobjectp (car (run-gified-ev x a)))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) ;; :use ((:instance run-gified-ev-falsify ;; (x (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (a `((x . ,(run-gified-ev x a)) ;; (env . ,(run-gified-ev env a)))))))))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct) ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 0 nil nil nil)))) (defun geval-of-nil-thm (geval rune) `((not (use-by-hint ',rune)) (equal (,geval 'nil env) 'nil))) (local (defthm geval-of-nil-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval rune))) (not (equal geval 'quote))) (equal (run-gified-ev (list geval ''nil env) a) nil)) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-of-nil-thm geval rune))) (a `((env . ,(run-gified-ev env a)))))))))) (in-theory (disable geval-list-def-thm geval-of-nil-thm)) (local (defthm nthcdr-kwote-lst (equal (nthcdr n (acl2::kwote-lst lst)) (acl2::kwote-lst (nthcdr n lst))))) (local (progn (defun make-n-cdrs (n term) (if (zp n) term (make-n-cdrs (1- n) (list 'cdr term)))) (local (defthm cdr-nthcdr (equal (cdr (nthcdr n x)) (nthcdr (+ 1 (nfix n)) x)) :hints(("Goal" :in-theory (enable default-cdr))))) (defthm run-gified-ev-make-n-cdrs (equal (run-gified-ev (make-n-cdrs n term) a) (nthcdr n (run-gified-ev term a))) :hints(("Goal" :in-theory (enable nthcdr)))))) (local (progn (defun test-constraint-0-result (args a mfc state) (declare (xargs :mode :program :stobjs state)) (not (equal (acl2::mfc-rw+ `(acl2::kwote-lst (run-gified-ev-lst args a)) `((args . ,args) (a . ,a)) 'acl2::? nil mfc state) args))) (defthmd my-run-gified-ev-constraint-0 (implies (and (syntaxp (test-constraint-0-result args a mfc state)) (not (equal fn 'quote))) (equal (run-gified-ev (cons fn args) a) (run-gified-ev (cons fn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0)))) ;; (defthm gobjectp-nth-gobj-listp ;; (implies (gobj-listp lst) ;; (gobjectp (nth n lst))) ;; :hints(("Goal" :in-theory (enable gobj-listp)))) (defthmd listp-nthcdr-gobj-listp (implies (and (gobj-listp lst) (nthcdr n lst)) (consp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp))))) (defthm gobj-listp-nthcdr (implies (gobj-listp lst) (gobj-listp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp) (cdr-nthcdr))))) (defthm gobj-listp-take (implies (gobj-listp gobj) (gobj-listp (acl2::take n gobj))) :hints(("Goal" :in-theory (enable gobj-listp acl2::take acl2::replicate)))) (defun count-down2-cdr (n m l) (if (zp n) (list m l) (count-down2-cdr (1- (nfix n)) (1- (nfix m)) (cdr l)))) (defthm gobj-listp-take1 (implies (and (gobj-listp (acl2::take m gobj)) (< (nfix n) (nfix m))) (gobj-listp (acl2::take n gobj))) :hints (("goal" :induct (count-down2-cdr m n gobj) :in-theory (enable gobj-listp acl2::take nfix)))) ;; (Defthm gobjectp-nth-when-gobj-listp-take ;; (implies (and (gobj-listp (acl2::take m x)) ;; (< (nfix n) (nfix m))) ;; (gobjectp (nth n x))) ;; :hints (("goal" :induct (count-down2-cdr m n x) ;; :in-theory (enable gobj-listp)))) (defthm cheap-default-car (implies (not (consp x)) (equal (car x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm cheap-default-cdr (implies (not (consp x)) (equal (cdr x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm nthcdr-when-not-consp (implies (and (not (consp x)) (not (zp n))) (equal (nthcdr n x) nil))) (defthm nthcdr-of-cons (implies (not (zp n)) (equal (nthcdr n (cons a b)) (nthcdr (+ -1 n) b)))) (defthm nthcdr-run-gified-of-geval-list (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (not (equal geval 'quote)) (not (equal geval-list 'quote)) ;; (acl2::take n (run-gified-ev args a)) ) (equal (nthcdr n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval-list (make-n-cdrs n args) env) a))) :hints(("Goal" :in-theory (e/d (my-run-gified-ev-constraint-0) (nthcdr nth)) :induct (make-n-cdrs n args) :expand ((:free (x) (nthcdr 0 x)))))) (defthm nth-run-gified-of-geval (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval geval-nil))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (equal (nth n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval (list 'car (make-n-cdrs n args)) env) a))) :hints(("Goal" :use ((:instance car-nthcdr (a (run-gified-ev (list gevalfn args env) a)))) :in-theory (e/d (run-gified-ev-constraint-0) (car-nthcdr acl2::car-nthcdr)) :cases ((consp (run-gified-ev args a)))))) (defthm run-gified-ev-lst-kwote-lst (equal (run-gified-ev-lst (acl2::kwote-lst x) a) (acl2::list-fix x))) (defthm cdr-kwote-lst (equal (cdr (acl2::kwote-lst lst)) (acl2::kwote-lst (cdr lst)))) (defthm car-kwote-lst (equal (car (acl2::kwote-lst lst)) (and (consp lst) (list 'quote (car lst))))) (defthm consp-nthcdr (equal (consp (nthcdr n x)) (< (nfix n) (len x))) :hints(("Goal" :in-theory (enable equal-of-booleans-rewrite)))) (defthm kwote-lst-cons (equal (acl2::kwote-lst (cons a b)) (cons (list 'quote a) (acl2::kwote-lst b)))) (defthm kwote-lst-atom (implies (atom a) (equal (acl2::kwote-lst a) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (in-theory (disable acl2::kwote-lst nth)) ;; (in-theory (disable acl2::ev-apply-arglist-on-result)) (in-theory (disable nthcdr)) (in-theory (disable acl2::true-list-listp-forward-to-true-listp-assoc-equal equal-of-booleans-rewrite default-car default-cdr)) (defthm nth-when-len-smaller (implies (<= (len lst) (nfix n)) (equal (nth n lst) nil)) :hints(("Goal" :in-theory (enable nth)))) (defthm run-gified-ev-lst-make-nths-matching-formals (implies (natp n) (equal (run-gified-ev-lst (make-nths-matching-formals n formals actuals) a) (acl2::take (len formals) (nthcdr n (run-gified-ev actuals a))))) :hints(("Goal" :in-theory (enable nth nthcdr acl2::take)))) (defthm asdfasdfa ;; (let ((n (nfix (- (len actuals) ;; (len formals))))) (implies (and ;; (natp n) ;; (< n (len actuals)) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-meta-extract-global-facts) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (not (equal evalfn 'quote))) (equal (run-gified-ev-lst (acl2::ev-of-arglist ;; acl2::ev-apply-arglist-on-result n evalfn (acl2::kwote-lst (run-gified-ev (list geval-list (list 'quote actuals) env) nil)) nil) nil) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (acl2::take n actuals)) gevalfn env) nil))) :hints(("Goal" :induct t :in-theory (enable acl2::take) :expand ((:free (a b c) (acl2::ev-of-arglist n a b c)))) (and stable-under-simplificationp '(:in-theory (e/d (my-run-gified-ev-constraint-0 acl2::replicate)))))) (encapsulate nil (local (defthm nthcdr-is-nil (implies (< (len lst) (nfix n)) (equal (nthcdr n lst) nil)) :hints(("Goal" :in-theory (enable nthcdr))))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev (implies (and (nths-matching-formalsp idx formals varname list) (natp idx)) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (nthcdr idx (run-gified-ev varname a))))) :hints(("Goal" :in-theory (enable my-equal-of-cons acl2::take nths-matching-formalsp)))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev1 (implies (nths-matching-formalsp 0 formals varname list) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (run-gified-ev varname a)))) :hints(("Goal" :in-theory (enable nthcdr) :use ((:instance nths-matching-formalsp-make-nths-matching-formals-ev (idx 0))))))) (defthm get-geval-thm-success-impl-len (implies (not (mv-nth 0 (run-gified-get-geval-thm gfn fn geval-alist geval))) (<= 5 (len (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval))))) :hints(("Goal" :in-theory (enable run-gified-get-geval-thm run-gified-check-geval-thm))) :rule-classes :linear))) (local (in-theory (disable acl2-count))) (defun run-gified-process-body (body eval-alist evalfn geval-alist gevalfn clauses world) (if (equal body '((LAMBDA (HYP) (CONS 'NIL (CONS 'NIL (CONS HYP 'NIL)))) ((LAMBDA (HYP) HYP) (RETURN-LAST 'ACL2::MBE1-RAW HYP (RETURN-LAST 'PROGN (ACL2::THROW-NONEXEC-ERROR ':NON-EXEC '(BFR-HYP-FIX HYP)) (BFR-HYP-FIX HYP))))) ;; (cons 'nil (cons 'nil 'nil)) ) ;; done. (mv nil clauses) (b* (((mv erp fnname gfnname args rest) (run-gified-case-breakdown body)) ((when erp) (mv erp nil)) ((when (or (eq fnname 'quote) (eq gfnname 'quote))) (mv "A function name is QUOTE which is bizzaro." nil)) ((mv erp clauses) (run-gified-process-body rest eval-alist evalfn geval-alist gevalfn clauses world)) ((when erp) (mv erp nil)) ((mv erp geval-thm formals) (run-gified-get-geval-thm gfnname fnname geval-alist gevalfn)) ((when erp) (mv erp nil)) ((unless (equal (len args) (len formals))) (mv "The number of arguments doesn't match." nil)) (erp (run-gified-get-eval-thm fnname (take (- (len formals) 5) formals) evalfn eval-alist world)) ((when erp) (mv erp nil)) ((unless (and (nths-matching-formalsp 0 (take (- (len formals) 5) formals) 'actuals (take (- (len formals) 5) args)) (equal (nthcdr (- (len formals) 5) args) '(hyp clk config bvar-db state)))) (mv (acl2::msg "Malformed function args: ~x0" (caddr body)) nil)) (clauses (list* geval-thm clauses))) (mv nil clauses)))) (defun ev-constraint-for-search (lemmas hyp-terms ev-term) (if (atom lemmas) nil (b* (((acl2::access acl2::rewrite-rule equiv lhs hyps rune) (car lemmas))) (if (and (eq equiv 'equal) (equal lhs ev-term) (equal hyps hyp-terms)) rune (ev-constraint-for-search (cdr lemmas) hyp-terms ev-term))))) (defun ev-constraint-for-fn (ev fn world) (b* ((lemmas (fgetprop ev 'acl2::lemmas nil world)) ) (ev-constraint-for-search lemmas `((consp x) (equal (car x) ',fn)) `(,ev x a)))) (defmacro ev-constraint-for (ev fn) `(ev-constraint-for-fn ',ev ',fn world)) (local (Defthm take-of-run-gified-ev-lst (implies (<= (nfix n) (len x)) (equal (take n (run-gified-ev-lst x a)) (run-gified-ev-lst (take n x) a))))) (local (encapsulate nil (local (defthm nth-when-nthcdr (implies (and (equal v (nthcdr n x)) (syntaxp (quotep v))) (equal (nth n x) (car v))))) (local (in-theory (enable NTHS-MATCHING-FORMALSP-MAKE-NTHS-MATCHING-FORMALS-EV1))) (local (in-theory (disable run-gified-ev-lst-take))) (local (in-theory (disable cheap-default-car cheap-default-cdr acl2::take ;; ev-quote-clause-correct-for-run-gified-ev ;; ev-lookup-var-clause-correct-for-run-gified-ev nth-when-len-smaller check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev (:definition run-gified-process-body) ;; (:REWRITE RUN-GIFIED-EV-constraint-32) ;; (:REWRITE RUN-GIFIED-EV-constraint-31) ;; (:REWRITE RUN-GIFIED-EV-constraint-30) ;; (:REWRITE RUN-GIFIED-EV-constraint-29) ;; (:REWRITE RUN-GIFIED-EV-constraint-28) ;; (:REWRITE RUN-GIFIED-EV-constraint-26) ;; (:REWRITE RUN-GIFIED-EV-constraint-25) ;; (:REWRITE RUN-GIFIED-EV-constraint-24) ;; (:REWRITE RUN-GIFIED-EV-constraint-23) ;; (:REWRITE RUN-GIFIED-EV-constraint-22) ;; (:REWRITE RUN-GIFIED-EV-constraint-20) ;; (:REWRITE RUN-GIFIED-EV-constraint-19) ;; (:REWRITE RUN-GIFIED-EV-constraint-17) ;; (:REWRITE RUN-GIFIED-EV-constraint-11) ;; (:REWRITE RUN-GIFIED-EV-constraint-10) ;; (:REWRITE RUN-GIFIED-EV-constraint-9) ;; (:REWRITE RUN-GIFIED-EV-constraint-8) ;; (:REWRITE RUN-GIFIED-EV-constraint-15) ;; (:REWRITE RUN-GIFIED-EV-constraint-14) ;; (:REWRITE RUN-GIFIED-EV-constraint-13) ;; (:REWRITE RUN-GIFIED-EV-constraint-12) (:META ACL2::CANCEL_TIMES-EQUAL-CORRECT) (:META ACL2::CANCEL_PLUS-EQUAL-CORRECT) ; (:REWRITE RUN-GIFIED-EV-CONSTRAINT-3) ;; (:REWRITE ACL2::SYMBOLP-ASSOC-EQUAL) (:d acl2::list-fix) (:REWRITE GEVAL-LIST-DEF-THM-CORRECT) (:DEFINITION SYMBOL-LISTP) (:REWRITE CHEAP-DEFAULT-CDR) (:TYPE-PRESCRIPTION SYMBOL-LISTP)))) ;; (local ;; (in-theory (set-difference-theories ;; (current-theory :here) ;; (list ; (EV-CONSTRAINT-FOR RUN-GIFIED-EV GOBJ-LISTP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-HYP-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV FORCE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV MV-LIST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV RETURN-LAST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV HIDE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV PAIRLIS$) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV SYMBOLP) ;; ; [Changed by <NAME>. to handle changes to member, assoc, etc. after ACL2 4.2 ;; ; (replaced assoc-eq by assoc-equal).] ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ASSOC-EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CONSP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NTH) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IF) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IMPLIES) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CAR) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ACL2::USE-THESE-HINTS) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV USE-BY-HINT) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NOT))))) (defthm run-gified-process-body-correct (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (and (equal (run-gified-ev `(,gevalfn (quote ,(mv-nth 1 (run-gified-ev body a))) (quote ,env)) nil) (run-gified-ev `(,evalfn (quote ,(cons (cdr (assoc 'fn a)) (kwote-lst (run-gified-ev `(,geval-list (quote ,(cdr (assoc 'actuals a))) (quote ,env)) nil)))) 'nil) nil)) ;; (equal (run-gified-ev ;; `(,gevalfn (mv-nth '2 ,body) env) ;; a) ;; (run-gified-ev ;; `(,evalfn (list 'mv-nth ''1 ;; (cons fn (acl2::kwote-lst ;; (,geval-list actuals env)))) ;; 'nil) ;; a)) ))) :hints (("goal" :induct (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) :expand ((run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)))) (and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0 my-run-gified-ev-constraint-0) :do-not-induct t)) ;; (and stable-under-simplificationp ;; '(:use ((:instance ;; nth-of-nthcdr ;; (n 0) ;; (y (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY))) ;; (m (+ -5 (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN ;; BODY)))))) ;; (:instance ;; nths-matching-formalsp-make-nths-matching-formals-ev1 ;; (list (ACL2::TAKE (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (formals (ACL2::TAKE ;; (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH ;; 2 ;; (RUN-GIFIED-GET-GEVAL-THM (MV-NTH 2 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; (MV-NTH 1 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; GEVAL-ALIST GEVALFN)))) ;; (varname 'ACTUALS))) ;; :in-theory (e/d (my-run-gified-ev-constraint-0) ;; (nth-of-nthcdr)))) )))) (local (defthm run-gified-process-body-correct1 (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (equal (run-gified-ev (list gevalfn (list 'quote (mv-nth 1 (run-gified-ev body a))) (list 'quote env)) nil) (run-gified-ev `(,evalfn (cons fn (acl2::kwote-lst (,geval-list actuals (quote ,env)))) 'nil) a)))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-process-body-correct)) :use ((:instance run-gified-process-body-correct)))))) (defun run-gified-clause-proc (clause geval-nil state) (declare ; (ignore hints) (xargs :stobjs state :verify-guards nil)) (b* (((mv ok subst) (acl2::simple-one-way-unify-lst '((implies (if (bfr-hyp-eval hyp (car env)) okp-term 'nil) (equal lhs-term rhs-term))) clause nil)) ((unless ok) (mv (acl2::msg "Clause didn't match pattern: ~x0~%" clause) nil state)) ((unless (and (eq (cdr (assoc-equal 'hyp subst)) 'hyp) (eq (cdr (assoc-equal 'env subst)) 'env))) (mv "Clause variables are different than expected" nil state)) (lhs (cdr (assoc-equal 'lhs-term subst))) (rhs (cdr (assoc-equal 'rhs-term subst))) (okp (cdr (assoc-equal 'okp-term subst))) ((mv erp geval-fn run-gified-fn) (run-gified-lhs-and-okp-breakdown lhs okp)) ((when erp) (mv erp nil state)) ((when (equal geval-fn 'quote)) (mv "The geval function is QUOTE which is silly." nil state)) ((when (equal run-gified-fn 'quote)) (mv "The run-gified function is QUOTE which is silly." nil state)) ((mv erp ev-fn geval-list-fn) (run-gified-rhs-breakdown rhs)) ((when (eq geval-list-fn 'quote)) (mv "The geval-list function is QUOTE which is silly." nil state)) ((when erp) (mv erp nil state)) ((mv ok ?formals body) (acl2::fn-get-def run-gified-fn state)) ((unless ok) (mv (msg "Failed to get the function definition for ~x0" run-gified-fn) nil state)) ((unless (equal formals '(fn actuals hyp clk config bvar-db state))) (mv (msg "Expected the formals of ~x0 to be ~x1" run-gified-fn '(fn actuals hyp clk config bvar-db state)) nil state)) (world (w state)) ((when (eq ev-fn 'quote)) (mv "The eval function is QUOTE which is silly." nil state)) (eval-rule-alist (acl2::ev-collect-apply-lemmas ev-fn nil world)) ((unless (acl2::check-ev-of-quote ev-fn (cadr (cdr (hons-get :quote eval-rule-alist))) world)) (mv "The eval function doesn't have the expected QUOTE constraint." nil state)) ((unless (acl2::check-ev-of-variable ev-fn (cadr (cdr (hons-get :lookup-var eval-rule-alist))) world)) (mv "The eval function doesn't have the expected variable-lookup constraint." nil state)) ((mv erp geval-rule-alist) (geval-rule-alist (table-alist 'gl-function-info world) geval-fn world)) ((when erp) (mv erp nil state)) ((mv erp clauses) (run-gified-process-body body eval-rule-alist ev-fn geval-rule-alist geval-fn nil world)) ((when erp) (mv erp nil state))) (value (list* (geval-list-def-thm geval-list-fn geval-fn) (geval-of-nil-thm geval-fn geval-nil) clauses)))) (local (acl2::def-unify run-gified-ev run-gified-ev-alist)) (local (defthm assoc-equal-run-gified-ev-alist (equal (cdr (assoc-equal x (run-gified-ev-alist subst a))) (run-gified-ev (cdr (assoc-equal x subst)) a)))) (local (encapsulate nil (local (defun cdr-down2 (a b) (if (atom a) b (cdr-down2 (cdr a) (cdr b))))) (local (defthm run-gified-ev-lst-equal-impl-disjoin-iff (implies (equal (run-gified-ev-lst lst a) (run-gified-ev-lst lst2 a2)) (iff (run-gified-ev (disjoin lst) a) (run-gified-ev (disjoin lst2) a2))) :hints (("goal" :induct (cdr-down2 lst lst2) :in-theory (enable run-gified-ev-disjoin-when-consp)) '(:cases ((consp lst2)))) :rule-classes nil)) (defthm simple-one-way-unify-lst-usage-disjoin (mv-let (ok subst) (acl2::simple-one-way-unify-lst template term alist) (implies (and ok (pseudo-term-listp term) (pseudo-term-listp template)) (iff (run-gified-ev (disjoin term) a) (run-gified-ev (disjoin template) (run-gified-ev-alist subst a))))) :hints (("goal" :use ((:instance run-gified-ev-lst-equal-impl-disjoin-iff (lst term) (a a) (lst2 template) (a2 (run-gified-ev-alist (mv-nth 1 (acl2::simple-one-way-unify-lst template term alist)) a))))))))) (local (defthm run-gified-lhs-and-okp-breakdown-correct-eval (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal (run-gified-ev lhs a) (run-gified-ev `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env) a)) (equal (run-gified-ev okp a) (run-gified-ev `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)) a))))) :hints (("goal" :use run-gified-lhs-and-okp-breakdown-correct :in-theory (disable run-gified-lhs-and-okp-breakdown-correct))))) (local (defthm run-gified-rhs-breakdown-correct-eval (mv-let (erp evfn geval-list-fn) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal (run-gified-ev rhs a) (run-gified-ev `(,evfn (cons fn (acl2::kwote-lst (,geval-list-fn actuals env))) 'nil) a)))))) (local (in-theory (disable run-gified-lhs-and-okp-breakdown-correct run-gified-rhs-breakdown-correct))) (local (in-theory (disable acl2::ev-collect-apply-lemmas body table-alist w))) (local (in-theory (disable run-gified-process-body assoc-equal))) (local (in-theory (disable SIMPLE-ONE-WAY-UNIFY-LST-WITH-RUN-GIFIED-EV check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev))) (local (defthm assoc-equal-of-cons (implies (syntaxp (and (quotep var) (quotep key))) (equal (assoc var (cons (cons key val) rest)) (if (equal var key) (cons key val) (assoc var rest)))) :hints(("Goal" :in-theory (enable assoc))))) (local (defthm pairlis-open (equal (pairlis$ (cons a b) c) (cons (cons a (car c)) (pairlis$ b (cdr c)))))) (local (in-theory (disable pairlis$))) (defthm run-gified-clause-proc-correct (implies (and (pseudo-term-listp clause) (alistp a) (run-gified-ev-meta-extract-global-facts) (run-gified-ev (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state))) (run-gified-ev-falsify (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state)))))) (run-gified-ev (disjoin clause) a)) :hints (("goal" :do-not-induct t :in-theory (enable run-gified-ev-constraint-0 ;; assoc-equal )) (and stable-under-simplificationp '(:computed-hint-replacement ('(:clause-processor (acl2::simple-generalize-cp clause '(((CDR (ASSOC-EQUAL 'LHS-TERM subst)) . lhs) ((CDR (ASSOC-EQUAL 'rhs-term subst)) . rhs) ((CDR (ASSOC-EQUAL 'OKP-TERM subst)) . okp) ((CDR (ASSOC-EQUAL 'hyp subst)) . hyp) ((CDR (ASSOC-EQUAL 'actuals subst)) . actuals) ((CDR (ASSOC-EQUAL 'env subst)) . env)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . geval-fn) ((MV-NTH '2 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . run-gified-fn)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . evalfn) ((MV-NTH '2 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . geval-list-fn) ((MV-NTH '1 (GEVAL-RULE-ALIST (TABLE-ALIST 'GL-FUNCTION-INFO (W STATE)) GEVAL-FN (W STATE))) . geval-alist)))) ;; '(:use ((:instance run-gified-ev-meta-extract-fn-check-def ;; (st state) ;; (fn run-gified-fn) ;; (formals (mv-nth 1 (acl2::fn-get-def geval-fn state))) ;; (body (mv-nth 2 (acl2::fn-get-def geval-fn state))) ;; (args (list (LIST ;; 'QUOTE ;; (MV-NTH 1 ;; (RUN-GIFIED-EV (LIST RUN-GIFIED-FN ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'FN A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ACTUALS A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'HYP A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'CLK A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'CONFIG A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'BVAR-DB A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'STATE A)))) ;; NIL))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ENV A))))) ;; (a nil)))) ;; '(:clause-processor ;; (acl2::simple-generalize-cp ;; clause '(((ACL2::EV-COLLECT-APPLY-LEMMAS ;; evalfn 'NIL (W STATE)) . eval-alist)))) ;; '(:use ((:instance run-gified-ev-falsify ;; (x (disjoin (function-def-clause ;; run-gified-fn run-gified-fn ;; '(fn actuals hyp clk config bvar-db state) ;; (MV-NTH 2 (ACL2::FN-GET-DEF GEVAL-FN STATE))))) ;; (a a))) ;; :in-theory (enable run-gified-ev-constraint-0)) ) :clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (ACL2::SIMPLE-ONE-WAY-UNIFY-LST '((IMPLIES (IF (BFR-HYP-EVAL HYP (CAR ENV)) OKP-TERM 'NIL) (EQUAL LHS-TERM RHS-TERM))) CLAUSE 'NIL)) . subst)))))) :rule-classes :clause-processor)
true
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "GL") (include-book "bfr") (include-book "gtypes") (include-book "tools/mv-nth" :dir :system) (include-book "std/util/bstar" :dir :system) (include-book "tools/defevaluator-fast" :dir :system) (include-book "clause-processors/unify-subst" :dir :system) (include-book "centaur/misc/evaluator-metatheorems" :dir :system) (include-book "centaur/misc/interp-function-lookup" :dir :system) (include-book "centaur/ubdds/witness" :dir :system) (include-book "hyp-fix") (local (include-book "std/lists/take" :dir :system)) (local (include-book "gtype-thms")) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (include-book "std/basic/arith-equivs" :dir :system)) (local (defun before-run-gified-ev-tag () nil)) (acl2::defevaluator-fast run-gified-ev run-gified-ev-lst ((eql a b) (equal a b) (implies a b) (if a b c) (not a) (use-by-hint a) (acl2::use-these-hints a) (car x) (cdr x) (nth n x) (cons a b) (consp x) (synp vars form term) ; [Changed by PI:NAME:<NAME>END_PI. to handle changes to member, assoc, etc. after ACL2 4.2 ; (replaced assoc-eq by assoc-equal).] (assoc-equal x a) (acl2::kwote-lst lst) (symbolp x) (pairlis$ a b) (cons a b) (atom a) (binary-+ a b) (hide a) (mv-nth n x) (mv-list n x) (acl2::return-last a b c) (force x) (bfr-eval x env) (bfr-hyp-eval x env) (acl2::typespec-check ts x) (iff a b) (binary-+ a b) (unary-- a) (len x) (return-last a b c))) (defchoose run-gified-ev-falsify (a) (x) (not (run-gified-ev x a))) (local (def-ruleset! run-gified-ev-constraints (set-difference-theories (current-theory :here) (current-theory 'before-run-gified-ev-tag)))) (acl2::def-meta-extract run-gified-ev run-gified-ev-lst) (local (progn (include-book "tools/def-functional-instance" :dir :system) (acl2::def-functional-instance check-ev-of-fncall-args-correct-for-run-gified-ev acl2::check-ev-of-fncall-args-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify) (:instance run-gified-ev-meta-extract-global-badguy)))))) (acl2::def-functional-instance check-ev-of-variable-correct-for-run-gified-ev acl2::check-ev-of-variable-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-quote-correct-for-run-gified-ev acl2::check-ev-of-quote-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-lambda-correct-for-run-gified-ev acl2::check-ev-of-lambda-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-nonsymbol-atom-correct-for-run-gified-ev acl2::check-ev-of-nonsymbol-atom-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-bad-fncall-correct-for-run-gified-ev acl2::check-ev-of-bad-fncall-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance check-ev-of-call-correct-for-run-gified-ev acl2::check-ev-of-call-correct ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))) (acl2::def-functional-instance ev-of-arglist-is-ground-for-run-gified-ev acl2::ev-of-arglist-is-ground ((acl2::evmeta-ev run-gified-ev) (acl2::evmeta-ev-lst run-gified-ev-lst) (acl2::evmeta-ev-falsify run-gified-ev-falsify) (acl2::evmeta-ev-meta-extract-global-badguy run-gified-ev-meta-extract-global-badguy))))) (defun run-gified-lhs-and-okp-breakdown (lhs okp) (case-match okp (('mv-nth ''0 (fn . '(fn actuals hyp clk config bvar-db state))) (case-match lhs ((ev ('mv-nth ''1 (!fn . '(fn actuals hyp clk config bvar-db state))) 'env) (mv nil ev fn)) (& (mv "lhs mismatched" nil nil)))) (& (mv "okp mismatched" nil nil)))) (local (defthm run-gified-lhs-and-okp-breakdown-correct (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal lhs `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env)) (equal okp `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)))))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-lhs-and-okp-breakdown)) (defun run-gified-rhs-breakdown (rhs) (case-match rhs ((ev ('cons 'fn ('acl2::kwote-lst (geval-list . '(actuals env)))) . '('nil)) (mv nil ev geval-list)) (& (mv "rhs mismatched" nil nil)))) (local (defthm run-gified-rhs-breakdown-correct (mv-let (erp evfn geval-list) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal rhs `(,evfn (cons fn (acl2::kwote-lst (,geval-list actuals env))) 'nil)))) :rule-classes :forward-chaining)) (in-theory (disable run-gified-rhs-breakdown)) (defun function-def-clause (rule fn formals body) `((not (use-by-hint ',rule)) (equal (,fn . ,formals) ,body))) (local (defthm function-def-clause-correct (implies (run-gified-ev (disjoin (function-def-clause rule fn formals body)) env) (equal (run-gified-ev (cons fn formals) env) (run-gified-ev body env))) :hints(("Goal" :in-theory (enable use-by-hint function-def-clause))))) (in-theory (disable function-def-clause)) (include-book "gl-util") (defun f-i-thmname (thm eval) (incat 'gl-thm::foo (symbol-name thm) "-FOR-" (symbol-name eval))) (defun geval-rule-alist (table geval world) (if (atom table) (mv nil nil) (let ((entry (car table))) (case-match entry ((& gfn (thm . thm-geval) . &) (b* (((mv erp alist) (geval-rule-alist (cdr table) geval world)) ((when erp) (mv erp alist)) (thmname (if (eq thm-geval geval) thm (f-i-thmname thm geval))) (theorem (fgetprop thmname 'theorem nil world)) ((unless theorem) (mv (acl2::msg "theorem not found: ~x0" thmname) nil))) (mv nil (hons-acons gfn (cons thmname theorem) alist)))) (& (mv (acl2::msg "bad gl-function-info table entry: ~x0" entry) nil)))))) (in-theory (disable geval-rule-alist)) (defun run-gified-case-breakdown (body) (case-match body (('if ('eql 'fn ('quote fnname)) ('(LAMBDA (MV) ((LAMBDA (RES HYP) (CONS 'T (CONS RES (CONS HYP 'NIL)))) (MV-NTH '0 MV) (MV-NTH '1 MV))) (gfnname . args)) rest) (mv nil fnname gfnname args rest)) (& (mv (acl2::msg "Malformed case: ~x0" body) nil nil nil nil)))) (local (defthm run-gified-case-breakdown-correct (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (implies (not erp) (equal (run-gified-ev body a) (let ((fn (cdr (assoc-equal 'fn a)))) (if (equal fn fnname) (list t (mv-nth 0 (run-gified-ev (cons gfnname args) a)) (mv-nth 1 (run-gified-ev (cons gfnname args) a))) (run-gified-ev rest a)))))) :rule-classes ((:rewrite :backchain-limit-lst 0)))) (local (defthm run-gified-case-breakdown-rest-smaller (mv-let (erp fnname gfnname args rest) (run-gified-case-breakdown body) (declare (ignore fnname gfnname args)) (implies (not erp) (< (acl2-count rest) (acl2-count body)))) :rule-classes (:rewrite :linear))) (in-theory (disable run-gified-case-breakdown)) (defun evals-of-formalsp (formals evals geval env) (if (atom formals) (equal evals nil) (and (consp evals) (let ((term (car evals))) (case-match term ((term-geval arg the-env) (and (equal the-env env) (equal term-geval geval) (equal arg (car formals)))))) (evals-of-formalsp (cdr formals) (cdr evals) geval env)))) (defun make-evals-of-formals (formals geval env) (if (atom formals) nil (cons (list geval (car formals) env) (make-evals-of-formals (Cdr formals) geval env)))) (local (defthm evals-of-formalsp-correct (implies (evals-of-formalsp formals evals geval env) (equal evals (make-evals-of-formals formals geval env))) :rule-classes :forward-chaining)) (in-theory (disable evals-of-formalsp)) (defun run-gified-check-geval-thm (thm gfn fn geval) (case-match thm (('implies '(bfr-hyp-eval hyp (car env)) ('equal (the-geval ('mv-nth ''0 (!gfn . gformals)) . '(env)) (!fn . evals))) (let ((nformals (len gformals))) (if (<= 5 nformals) (let ((formals (take (- nformals 5) gformals))) (if (and (equal the-geval geval) (evals-of-formalsp formals evals geval 'env) (nonnil-symbol-listp gformals) (acl2::fast-no-duplicatesp gformals) (not (member 'env gformals)) (equal (nthcdr (- nformals 5) gformals) '(hyp clk config bvar-db state))) (mv nil gformals) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil))) (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (& (mv (acl2::msg "Malformed geval theorem: ~x0" thm) nil)))) (local (defthmd my-equal-of-cons (implies (syntaxp (not (and (quotep b) (quotep c)))) (equal (equal a (cons b c)) (and (consp a) (equal (car a) b) (equal (cdr a) c)))))) (local (defthm append-take-nthcdr (implies (< n (len lst)) (equal (append (take n lst) (nthcdr n lst)) lst)))) ; [Removed by PI:NAME:<NAME>END_PI. to handle changes to member, assoc, etc. after ACL2 4.2.] ; (local ; (defthmd member-is-member-equal ; (equal (member x y) ; (member-equal x y)))) ; ; (local (in-theory (enable member-is-member-equal))) (local (defthm run-gified-check-geval-thm-formals (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (and (<= 5 (len formals)) (nonnil-symbol-listp formals) (no-duplicatesp-equal formals) (not (member-equal 'env formals)) (equal (nthcdr (+ -5 (len formals)) formals) '(hyp clk config bvar-db state))))) :rule-classes nil)) (local (defthmd run-gified-check-geval-thm-form (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (implies (not erp) (equal thm `(implies (bfr-hyp-eval hyp (car env)) (equal (,geval (mv-nth '0 (,gfn . ,formals)) env) (,fn . ,(make-evals-of-formals (take (- (len formals) 5) formals) geval 'env))))))) :rule-classes :forward-chaining)) (local (acl2::def-functional-instance run-gified-ev-lst-pairlis acl2::ifl-ev-lst-pairlis ((acl2::ifl-ev-lst run-gified-ev-lst) (acl2::ifl-ev run-gified-ev)) :hints ((and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0)))))) (local (defthm nthcdr-nil (equal (nthcdr n nil) nil))) (local (defthm nth-of-nthcdr (equal (nth n (nthcdr m y)) (nth (+ (nfix n) (nfix m)) y)))) ;; (encapsulate nil ;; (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; (defthmd equal-nthcdr-cons ;; (equal (equal (nthcdr n x) (cons a b)) ;; (and (equal (nth n x) a) ;; (< (nfix n) (len x)) ;; (equal (nthcdr (+ 1 (nfix n)) x) b))) ;; :hints (("goal" :induct (nthcdr n x))))) (local (encapsulate nil (local (defun the-induction (n keys vals) (if (zp n) (list keys vals) (the-induction (1- n) (cdr keys) (cdr vals))))) (local (defthm member-when-equal-nth (implies (and (equal key (nth n keys)) (< (nfix n) (len keys))) (member-equal key keys)))) (defthm assoc-equal-pairlis-nth (implies (and (equal (len keys) (len vals)) (< n (len keys)) (no-duplicatesp-equal keys)) (equal (cdr (assoc-equal (nth n keys) (pairlis$ keys vals))) (nth n vals))) :hints (("goal" :induct (the-induction n keys vals)))))) (local (defthm len-run-gified-ev-lst (equal (len (run-gified-ev-lst x a)) (len x)))) (local (defthm nth-run-gified-ev-lst (equal (nth n (run-gified-ev-lst x a)) (run-gified-ev (nth n x) a)))) (local (progn (defevaluator equality-cp-ev equality-cp-ev-lst ((equal a b) (if a b c) (not a) (hide x))) (acl2::def-join-thms equality-cp-ev) (defun find-remv-equality-hyp (clause term) (if (atom clause) (mv nil nil nil nil) (let ((lit (car clause))) (mv-let (ok other) (case-match lit (('not ('equal term1 term2)) (cond ((equal term1 term) (mv t term2)) ((equal term2 term) (mv t term1)) (t (mv nil nil)))) (& (mv nil nil))) (if ok (mv ok other (cdr clause) `(hide ,lit)) (mv-let (ok new rest hide) (find-remv-equality-hyp (cdr clause) term) (if ok (mv ok new (cons lit rest) hide) (mv nil nil nil nil)))))))) (defthm find-remv-equality-hyp-correct (mv-let (ok other new hide) (find-remv-equality-hyp clause term) (implies ok (iff (equality-cp-ev (disjoin clause) a) (not (and (equal (equality-cp-ev term a) (equality-cp-ev other a)) (not (equality-cp-ev hide a)) (not (equality-cp-ev (disjoin new) a))))))) :hints(("Goal" :expand ((:free (x) (hide x)))))) (mutual-recursion (defun replace-term (new old avoid x) (cond ((equal x new) old) ((member-equal x avoid) x) ((atom x) x) ((eq (car x) 'quote) x) (t (cons (car x) (replace-term-list new old avoid (cdr x)))))) (defun replace-term-list (new old avoid x) (if (atom x) nil (cons (replace-term new old avoid (car x)) (replace-term-list new old avoid (cdr x)))))) (flag::make-flag replace-term-flg replace-term) (defthm-replace-term-flg replace-term-correct-lemma (replace-term (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev (replace-term new old avoid x) a) (equality-cp-ev x a))) :name replace-term-correct) (replace-term-list (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (equal (equality-cp-ev-lst (replace-term-list new old avoid x) a) (equality-cp-ev-lst x a))) :name replace-term-list-correct) :hints (("goal" :induct (replace-term-flg flag new old avoid x)) (and stable-under-simplificationp '(:in-theory (enable equality-cp-ev-constraint-0))))) (in-theory (disable replace-term replace-term-list)) (defthm replace-term-list-correct-disjoin (implies (equal (equality-cp-ev old a) (equality-cp-ev new a)) (iff (equality-cp-ev (disjoin (replace-term-list new old avoid x)) a) (equality-cp-ev (disjoin x) a))) :hints(("Goal" :in-theory (e/d (replace-term-list)) :induct (len x)))) (defun replace-equality-cp (clause hints) (b* (((list term avoid) hints) ((mv ok new-term new-clause hide) (find-remv-equality-hyp clause term)) ((unless ok) (list clause)) (repl-clause (replace-term-list term new-term avoid new-clause))) (list (cons hide repl-clause)))) (defthm replace-equality-cp-correct (implies (and (pseudo-term-listp clause) (alistp a) (equality-cp-ev (conjoin-clauses (replace-equality-cp clause hints)) a)) (equality-cp-ev (disjoin clause) a)) :hints(("Goal" :do-not-induct t)) :rule-classes :clause-processor))) (local (defthm run-gified-ev-lst-symbol-cdr-alist (implies (and (nonnil-symbol-listp vars) (not (member-equal key vars))) (equal (run-gified-ev-lst vars (cons (cons key val) alist)) (run-gified-ev-lst vars alist))))) (local (in-theory (disable acl2::reflexivity-of-qs-subset))) (local (defthm run-gified-ev-lst-make-evals-of-formals (implies (and (syntaxp (not (equal a ''nil))) (not (equal geval 'quote))) (equal (run-gified-ev-lst (make-evals-of-formals lst geval env) a) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (run-gified-ev-lst lst a)) geval `(quote ,(run-gified-ev env a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0))))) (local (defthm run-gified-ev-lst-take (equal (run-gified-ev-lst (acl2::take n x) a) (acl2::take n (run-gified-ev-lst x a))) :hints(("Goal" :in-theory (enable acl2::take))))) (local (defthm list-fix-run-gified-ev-lst (equal (acl2::list-fix (run-gified-ev-lst x a)) (run-gified-ev-lst x a)) :hints (("goal" :induct (len x))))) (local (defthm run-gified-check-geval-thm-correct (mv-let (erp formals) (run-gified-check-geval-thm thm gfn fn geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev thm (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a)))) (not (eq geval 'quote)) (not (eq gfn 'quote)) (not (eq fn 'quote)) (equal (len formals) (len args)) (bfr-hyp-eval hyp (car env))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d () ;; equal-nthcdr-cons (nth-of-nthcdr acl2::car-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm)) :use ((:instance run-gified-check-geval-thm-form) (:instance run-gified-check-geval-thm-formals) (:instance nth-of-nthcdr (n 0) (m (+ -5 (len args))) (y (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval)))) (:instance assoc-equal-pairlis-nth (n (- (len args) 5)) (keys (mv-nth 1 (run-gified-check-geval-thm thm gfn fn geval))) (vals (run-gified-ev-lst args a))))) (and stable-under-simplificationp '(:clause-processor (replace-equality-cp clause (list 'thm (list `(run-gified-check-geval-thm thm gfn fn geval)))) :in-theory (e/d (run-gified-ev-constraint-0) (nth-of-nthcdr assoc-equal-pairlis-nth run-gified-check-geval-thm))))) :rule-classes ((:rewrite :backchain-limit-lst (0 nil nil nil nil nil nil))))) (local (in-theory (disable run-gified-check-geval-thm))) (defun run-gified-get-geval-thm (gfn fn geval-alist geval) (b* ((look (hons-get gfn geval-alist)) ((unless look) (mv (acl2::msg "No information about gfn ~x0 found" gfn) nil nil)) (thmname (cadr look)) (thm (cddr look)) ((mv erp formals) (run-gified-check-geval-thm thm gfn fn geval)) ((when erp) (mv erp nil nil))) (mv nil `((not (use-by-hint ',thmname)) ,thm) formals))) (local (defthm run-gified-get-geval-thm-correct (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a)) ;; (env (cdr (assoc-equal 'env a))) ) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev `(,geval (mv-nth '0 (,gfn . ,args)) (quote ,env)) a) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (use-by-hint) ()) :use ((:instance run-gified-ev-falsify (x (disjoin (mv-nth 1 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (a (let ((formals (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval)))) (cons (cons 'env env) (pairlis$ formals (run-gified-ev-lst args a))))))))))) (local (defthm run-gified-get-geval-thm-correct-corollary (mv-let (erp thm formals) (run-gified-get-geval-thm gfn fn geval-alist geval) (let ((hyp (run-gified-ev (nth (+ -5 (len formals)) args) a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (bfr-hyp-eval hyp (car env)) (not (equal geval 'quote)) (not (equal gfn 'quote)) (not (equal fn 'quote)) (equal (len args) (len formals))) (equal (run-gified-ev (list geval (list 'quote (mv-nth 0 (run-gified-ev (cons gfn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) (list 'quote env)) nil) (run-gified-ev `(,fn . ,(make-evals-of-formals (take (- (len formals) 5) args) geval (kwote env))) a))))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-get-geval-thm-correct)) :use ((:instance run-gified-get-geval-thm-correct)))))) (in-theory (disable run-gified-get-geval-thm)) (defun run-gified-get-eval-thm (fnname formals evfn eval-alist world) (b* ((look (hons-get fnname eval-alist)) ((when (not look)) (acl2::msg "Function ~x0 not recognized by evaluator." fnname)) ((cons arity rune) (cdr look)) ((unless (equal arity (len formals))) (acl2::msg "~x0 arity: ~x1 eval-alist, ~x2 geval" fnname arity (len formals))) ((unless (acl2::check-ev-of-call evfn fnname arity (cadr rune) world)) (acl2::msg "bad constraint: ~x0" fnname))) nil)) (local (in-theory (disable w))) (local (defthm run-gified-get-eval-thm-correct (let ((erp (run-gified-get-eval-thm fn formals evfn eval-alist (w state)))) (let ((ex (run-gified-ev x a))) (implies (and (not erp) (run-gified-ev-theoremp (disjoin thm)) (run-gified-ev-meta-extract-global-facts) (consp ex) (equal (car ex) fn) (not (equal evfn 'quote)) (not (equal fn 'quote))) (equal (run-gified-ev `(,evfn ,x ,ma) a) (run-gified-ev `(,fn . ,(acl2::ev-of-arglist (len formals) evfn (cdr (run-gified-ev x a)) (run-gified-ev ma a))) a))))))) (in-theory (disable run-gified-get-eval-thm)) (defun nths-matching-formalsp (idx formals varname list) (declare (xargs :measure (acl2-count formals))) (if (atom formals) (eq list nil) (and (consp list) (let ((car (car list))) (case-match car (('nth ('quote !idx) !varname) t))) (nths-matching-formalsp (1+ idx) (cdr formals) varname (cdr list))))) (local (progn (defun make-nths-matching-formals (idx formals varname) (if (atom formals) nil (cons `(nth ',idx ,varname) (make-nths-matching-formals (1+ idx) (cdr formals) varname)))) (defthm nths-matching-formalsp-make-nths-matching-formals (implies (nths-matching-formalsp idx formals varname list) (equal list (make-nths-matching-formals idx formals varname))) :hints(("Goal" :in-theory (enable my-equal-of-cons))) :rule-classes :forward-chaining))) (in-theory (disable nths-matching-formalsp)) (local (defthm len-take (Equal (len (acl2::take n lst)) (nfix n)))) (local (defthm car-nthcdr (equal (car (nthcdr n a)) (nth n a)))) (local (defthm nth-kwote-lst (implies (< (nfix n) (len lst)) (equal (nth n (acl2::kwote-lst lst)) (list 'quote (nth n lst)))))) (local (include-book "arithmetic/top-with-meta" :dir :system)) (local (in-theory (disable equal-of-booleans-rewrite default-car default-cdr))) (defun geval-list-def-thm (geval-list geval) `((not (use-by-hint ',geval-list)) (equal (,geval-list x env) (if (atom x) 'nil (cons (,geval (car x) env) (,geval-list (cdr x) env)))))) (local (defthm geval-list-def-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) ;; (gobjectp (run-gified-ev x a)) ;; (or (atom (run-gified-ev x a)) ;; (gobjectp (car (run-gified-ev x a)))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (and (implies (atom (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) nil)) (implies (consp (run-gified-ev x a)) (equal (run-gified-ev (list geval-list x env) a) (cons (run-gified-ev (list geval (kwote (car (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil) (run-gified-ev (list geval-list (kwote (cdr (run-gified-ev x a))) (kwote (run-gified-ev env a))) nil)))))) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0 geval-list-def-thm) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-list-def-thm geval-list geval))) (a `((x . ,(run-gified-ev x a)) (env . ,(run-gified-ev env a)))))))))) ;; (defthm gobj-listp-simple-take-implies ;; (implies (and (gobj-listp (acl2::simple-take n x)) ;; (natp n) (< 0 n)) ;; (or (atom x) (gobjectp (car x)))) ;; :rule-classes nil) ;; (defthm geval-geval-list-def-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use (geval-geval-list-def-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-geval-list-def-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-geval-list-def-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (and (equal (car (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(car ,x) env) a)) ;; (equal (cdr (run-gified-ev (list geval x env) a)) ;; (run-gified-ev (list geval `(cdr ,x) env) a)))) ;; :hints(("Goal" :use geval-geval-list-def-thm-correct ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-geval-list-def-thm ;; geval-geval-list-def-thm-correct)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 1 nil)))) ;; (defun geval-consp-when-gobj-listp-thm (geval rune) ;; `((not (use-by-hint ',rune)) ;; ;; (not (gobjectp x)) ;; ;; (not (if (consp x) ;; ;; (gobjectp (car x)) ;; ;; 't)) ;; (not (gobj-listp x)) ;; (equal (consp (,geval x env)) ;; (consp x)))) ;; (local ;; (defthm geval-consp-when-gobj-listp-thm-correct ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; ;; (gobjectp (run-gified-ev x a)) ;; ;; (or (atom (run-gified-ev x a)) ;; ;; (gobjectp (car (run-gified-ev x a)))) ;; (gobj-listp (run-gified-ev x a)) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) ;; :use ((:instance run-gified-ev-falsify ;; (x (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (a `((x . ,(run-gified-ev x a)) ;; (env . ,(run-gified-ev env a)))))))))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobjectp (run-gified-ev x a)) ;; (gobj-listp (acl2::simple-take n (run-gified-ev x a))) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct ;; (:instance gobj-listp-simple-take-implies ;; (x (run-gified-ev x a)))) ;; :in-theory (disable geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 nil 0 nil nil nil)))) ;; (defthm geval-consp-when-gobj-listp-thm-correct-corollary2 ;; (implies (and (run-gified-ev-theoremp ;; (disjoin (geval-consp-when-gobj-listp-thm ;; geval rune))) ;; (gobj-listp (run-gified-ev x a)) ;; (natp n) (< 0 n) ;; (not (equal geval 'quote))) ;; (equal (consp (run-gified-ev (list geval x env) a)) ;; (consp (run-gified-ev x a)))) ;; :hints(("Goal" :use (geval-consp-when-gobj-listp-thm-correct) ;; :in-theory (e/d (gobj-listp-impl-gobjectp) ;; (geval-consp-when-gobj-listp-thm-correct ;; geval-consp-when-gobj-listp-thm)) ;; :do-not-induct t)) ;; :rule-classes ((:rewrite :backchain-limit-lst (0 0 nil nil nil)))) (defun geval-of-nil-thm (geval rune) `((not (use-by-hint ',rune)) (equal (,geval 'nil env) 'nil))) (local (defthm geval-of-nil-thm-correct (implies (and (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval rune))) (not (equal geval 'quote))) (equal (run-gified-ev (list geval ''nil env) a) nil)) :hints(("Goal" :in-theory (enable use-by-hint run-gified-ev-constraint-0) :use ((:instance run-gified-ev-falsify (x (disjoin (geval-of-nil-thm geval rune))) (a `((env . ,(run-gified-ev env a)))))))))) (in-theory (disable geval-list-def-thm geval-of-nil-thm)) (local (defthm nthcdr-kwote-lst (equal (nthcdr n (acl2::kwote-lst lst)) (acl2::kwote-lst (nthcdr n lst))))) (local (progn (defun make-n-cdrs (n term) (if (zp n) term (make-n-cdrs (1- n) (list 'cdr term)))) (local (defthm cdr-nthcdr (equal (cdr (nthcdr n x)) (nthcdr (+ 1 (nfix n)) x)) :hints(("Goal" :in-theory (enable default-cdr))))) (defthm run-gified-ev-make-n-cdrs (equal (run-gified-ev (make-n-cdrs n term) a) (nthcdr n (run-gified-ev term a))) :hints(("Goal" :in-theory (enable nthcdr)))))) (local (progn (defun test-constraint-0-result (args a mfc state) (declare (xargs :mode :program :stobjs state)) (not (equal (acl2::mfc-rw+ `(acl2::kwote-lst (run-gified-ev-lst args a)) `((args . ,args) (a . ,a)) 'acl2::? nil mfc state) args))) (defthmd my-run-gified-ev-constraint-0 (implies (and (syntaxp (test-constraint-0-result args a mfc state)) (not (equal fn 'quote))) (equal (run-gified-ev (cons fn args) a) (run-gified-ev (cons fn (acl2::kwote-lst (run-gified-ev-lst args a))) nil))) :hints(("Goal" :in-theory (enable run-gified-ev-constraint-0)))) ;; (defthm gobjectp-nth-gobj-listp ;; (implies (gobj-listp lst) ;; (gobjectp (nth n lst))) ;; :hints(("Goal" :in-theory (enable gobj-listp)))) (defthmd listp-nthcdr-gobj-listp (implies (and (gobj-listp lst) (nthcdr n lst)) (consp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp))))) (defthm gobj-listp-nthcdr (implies (gobj-listp lst) (gobj-listp (nthcdr n lst))) :hints(("Goal" :in-theory (e/d (gobj-listp) (cdr-nthcdr))))) (defthm gobj-listp-take (implies (gobj-listp gobj) (gobj-listp (acl2::take n gobj))) :hints(("Goal" :in-theory (enable gobj-listp acl2::take acl2::replicate)))) (defun count-down2-cdr (n m l) (if (zp n) (list m l) (count-down2-cdr (1- (nfix n)) (1- (nfix m)) (cdr l)))) (defthm gobj-listp-take1 (implies (and (gobj-listp (acl2::take m gobj)) (< (nfix n) (nfix m))) (gobj-listp (acl2::take n gobj))) :hints (("goal" :induct (count-down2-cdr m n gobj) :in-theory (enable gobj-listp acl2::take nfix)))) ;; (Defthm gobjectp-nth-when-gobj-listp-take ;; (implies (and (gobj-listp (acl2::take m x)) ;; (< (nfix n) (nfix m))) ;; (gobjectp (nth n x))) ;; :hints (("goal" :induct (count-down2-cdr m n x) ;; :in-theory (enable gobj-listp)))) (defthm cheap-default-car (implies (not (consp x)) (equal (car x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm cheap-default-cdr (implies (not (consp x)) (equal (cdr x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (defthm nthcdr-when-not-consp (implies (and (not (consp x)) (not (zp n))) (equal (nthcdr n x) nil))) (defthm nthcdr-of-cons (implies (not (zp n)) (equal (nthcdr n (cons a b)) (nthcdr (+ -1 n) b)))) (defthm nthcdr-run-gified-of-geval-list (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (not (equal geval 'quote)) (not (equal geval-list 'quote)) ;; (acl2::take n (run-gified-ev args a)) ) (equal (nthcdr n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval-list (make-n-cdrs n args) env) a))) :hints(("Goal" :in-theory (e/d (my-run-gified-ev-constraint-0) (nthcdr nth)) :induct (make-n-cdrs n args) :expand ((:free (x) (nthcdr 0 x)))))) (defthm nth-run-gified-of-geval (implies (and (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list geval))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm geval geval-nil))) (not (equal geval 'quote)) (not (equal geval-list 'quote))) (equal (nth n (run-gified-ev (list geval-list args env) a)) (run-gified-ev (list geval (list 'car (make-n-cdrs n args)) env) a))) :hints(("Goal" :use ((:instance car-nthcdr (a (run-gified-ev (list gevalfn args env) a)))) :in-theory (e/d (run-gified-ev-constraint-0) (car-nthcdr acl2::car-nthcdr)) :cases ((consp (run-gified-ev args a)))))) (defthm run-gified-ev-lst-kwote-lst (equal (run-gified-ev-lst (acl2::kwote-lst x) a) (acl2::list-fix x))) (defthm cdr-kwote-lst (equal (cdr (acl2::kwote-lst lst)) (acl2::kwote-lst (cdr lst)))) (defthm car-kwote-lst (equal (car (acl2::kwote-lst lst)) (and (consp lst) (list 'quote (car lst))))) (defthm consp-nthcdr (equal (consp (nthcdr n x)) (< (nfix n) (len x))) :hints(("Goal" :in-theory (enable equal-of-booleans-rewrite)))) (defthm kwote-lst-cons (equal (acl2::kwote-lst (cons a b)) (cons (list 'quote a) (acl2::kwote-lst b)))) (defthm kwote-lst-atom (implies (atom a) (equal (acl2::kwote-lst a) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0))) (in-theory (disable acl2::kwote-lst nth)) ;; (in-theory (disable acl2::ev-apply-arglist-on-result)) (in-theory (disable nthcdr)) (in-theory (disable acl2::true-list-listp-forward-to-true-listp-assoc-equal equal-of-booleans-rewrite default-car default-cdr)) (defthm nth-when-len-smaller (implies (<= (len lst) (nfix n)) (equal (nth n lst) nil)) :hints(("Goal" :in-theory (enable nth)))) (defthm run-gified-ev-lst-make-nths-matching-formals (implies (natp n) (equal (run-gified-ev-lst (make-nths-matching-formals n formals actuals) a) (acl2::take (len formals) (nthcdr n (run-gified-ev actuals a))))) :hints(("Goal" :in-theory (enable nth nthcdr acl2::take)))) (defthm asdfasdfa ;; (let ((n (nfix (- (len actuals) ;; (len formals))))) (implies (and ;; (natp n) ;; (< n (len actuals)) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-meta-extract-global-facts) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (not (equal evalfn 'quote))) (equal (run-gified-ev-lst (acl2::ev-of-arglist ;; acl2::ev-apply-arglist-on-result n evalfn (acl2::kwote-lst (run-gified-ev (list geval-list (list 'quote actuals) env) nil)) nil) nil) (run-gified-ev-lst (make-evals-of-formals (acl2::kwote-lst (acl2::take n actuals)) gevalfn env) nil))) :hints(("Goal" :induct t :in-theory (enable acl2::take) :expand ((:free (a b c) (acl2::ev-of-arglist n a b c)))) (and stable-under-simplificationp '(:in-theory (e/d (my-run-gified-ev-constraint-0 acl2::replicate)))))) (encapsulate nil (local (defthm nthcdr-is-nil (implies (< (len lst) (nfix n)) (equal (nthcdr n lst) nil)) :hints(("Goal" :in-theory (enable nthcdr))))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev (implies (and (nths-matching-formalsp idx formals varname list) (natp idx)) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (nthcdr idx (run-gified-ev varname a))))) :hints(("Goal" :in-theory (enable my-equal-of-cons acl2::take nths-matching-formalsp)))) (defthmd nths-matching-formalsp-make-nths-matching-formals-ev1 (implies (nths-matching-formalsp 0 formals varname list) (equal (run-gified-ev-lst list a) (acl2::take (len formals) (run-gified-ev varname a)))) :hints(("Goal" :in-theory (enable nthcdr) :use ((:instance nths-matching-formalsp-make-nths-matching-formals-ev (idx 0))))))) (defthm get-geval-thm-success-impl-len (implies (not (mv-nth 0 (run-gified-get-geval-thm gfn fn geval-alist geval))) (<= 5 (len (mv-nth 2 (run-gified-get-geval-thm gfn fn geval-alist geval))))) :hints(("Goal" :in-theory (enable run-gified-get-geval-thm run-gified-check-geval-thm))) :rule-classes :linear))) (local (in-theory (disable acl2-count))) (defun run-gified-process-body (body eval-alist evalfn geval-alist gevalfn clauses world) (if (equal body '((LAMBDA (HYP) (CONS 'NIL (CONS 'NIL (CONS HYP 'NIL)))) ((LAMBDA (HYP) HYP) (RETURN-LAST 'ACL2::MBE1-RAW HYP (RETURN-LAST 'PROGN (ACL2::THROW-NONEXEC-ERROR ':NON-EXEC '(BFR-HYP-FIX HYP)) (BFR-HYP-FIX HYP))))) ;; (cons 'nil (cons 'nil 'nil)) ) ;; done. (mv nil clauses) (b* (((mv erp fnname gfnname args rest) (run-gified-case-breakdown body)) ((when erp) (mv erp nil)) ((when (or (eq fnname 'quote) (eq gfnname 'quote))) (mv "A function name is QUOTE which is bizzaro." nil)) ((mv erp clauses) (run-gified-process-body rest eval-alist evalfn geval-alist gevalfn clauses world)) ((when erp) (mv erp nil)) ((mv erp geval-thm formals) (run-gified-get-geval-thm gfnname fnname geval-alist gevalfn)) ((when erp) (mv erp nil)) ((unless (equal (len args) (len formals))) (mv "The number of arguments doesn't match." nil)) (erp (run-gified-get-eval-thm fnname (take (- (len formals) 5) formals) evalfn eval-alist world)) ((when erp) (mv erp nil)) ((unless (and (nths-matching-formalsp 0 (take (- (len formals) 5) formals) 'actuals (take (- (len formals) 5) args)) (equal (nthcdr (- (len formals) 5) args) '(hyp clk config bvar-db state)))) (mv (acl2::msg "Malformed function args: ~x0" (caddr body)) nil)) (clauses (list* geval-thm clauses))) (mv nil clauses)))) (defun ev-constraint-for-search (lemmas hyp-terms ev-term) (if (atom lemmas) nil (b* (((acl2::access acl2::rewrite-rule equiv lhs hyps rune) (car lemmas))) (if (and (eq equiv 'equal) (equal lhs ev-term) (equal hyps hyp-terms)) rune (ev-constraint-for-search (cdr lemmas) hyp-terms ev-term))))) (defun ev-constraint-for-fn (ev fn world) (b* ((lemmas (fgetprop ev 'acl2::lemmas nil world)) ) (ev-constraint-for-search lemmas `((consp x) (equal (car x) ',fn)) `(,ev x a)))) (defmacro ev-constraint-for (ev fn) `(ev-constraint-for-fn ',ev ',fn world)) (local (Defthm take-of-run-gified-ev-lst (implies (<= (nfix n) (len x)) (equal (take n (run-gified-ev-lst x a)) (run-gified-ev-lst (take n x) a))))) (local (encapsulate nil (local (defthm nth-when-nthcdr (implies (and (equal v (nthcdr n x)) (syntaxp (quotep v))) (equal (nth n x) (car v))))) (local (in-theory (enable NTHS-MATCHING-FORMALSP-MAKE-NTHS-MATCHING-FORMALS-EV1))) (local (in-theory (disable run-gified-ev-lst-take))) (local (in-theory (disable cheap-default-car cheap-default-cdr acl2::take ;; ev-quote-clause-correct-for-run-gified-ev ;; ev-lookup-var-clause-correct-for-run-gified-ev nth-when-len-smaller check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev (:definition run-gified-process-body) ;; (:REWRITE RUN-GIFIED-EV-constraint-32) ;; (:REWRITE RUN-GIFIED-EV-constraint-31) ;; (:REWRITE RUN-GIFIED-EV-constraint-30) ;; (:REWRITE RUN-GIFIED-EV-constraint-29) ;; (:REWRITE RUN-GIFIED-EV-constraint-28) ;; (:REWRITE RUN-GIFIED-EV-constraint-26) ;; (:REWRITE RUN-GIFIED-EV-constraint-25) ;; (:REWRITE RUN-GIFIED-EV-constraint-24) ;; (:REWRITE RUN-GIFIED-EV-constraint-23) ;; (:REWRITE RUN-GIFIED-EV-constraint-22) ;; (:REWRITE RUN-GIFIED-EV-constraint-20) ;; (:REWRITE RUN-GIFIED-EV-constraint-19) ;; (:REWRITE RUN-GIFIED-EV-constraint-17) ;; (:REWRITE RUN-GIFIED-EV-constraint-11) ;; (:REWRITE RUN-GIFIED-EV-constraint-10) ;; (:REWRITE RUN-GIFIED-EV-constraint-9) ;; (:REWRITE RUN-GIFIED-EV-constraint-8) ;; (:REWRITE RUN-GIFIED-EV-constraint-15) ;; (:REWRITE RUN-GIFIED-EV-constraint-14) ;; (:REWRITE RUN-GIFIED-EV-constraint-13) ;; (:REWRITE RUN-GIFIED-EV-constraint-12) (:META ACL2::CANCEL_TIMES-EQUAL-CORRECT) (:META ACL2::CANCEL_PLUS-EQUAL-CORRECT) ; (:REWRITE RUN-GIFIED-EV-CONSTRAINT-3) ;; (:REWRITE ACL2::SYMBOLP-ASSOC-EQUAL) (:d acl2::list-fix) (:REWRITE GEVAL-LIST-DEF-THM-CORRECT) (:DEFINITION SYMBOL-LISTP) (:REWRITE CHEAP-DEFAULT-CDR) (:TYPE-PRESCRIPTION SYMBOL-LISTP)))) ;; (local ;; (in-theory (set-difference-theories ;; (current-theory :here) ;; (list ; (EV-CONSTRAINT-FOR RUN-GIFIED-EV GOBJ-LISTP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV BFR-HYP-EVAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV FORCE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV MV-LIST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV RETURN-LAST) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV HIDE) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV PAIRLIS$) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV SYMBOLP) ;; ; [Changed by PI:NAME:<NAME>END_PI. to handle changes to member, assoc, etc. after ACL2 4.2 ;; ; (replaced assoc-eq by assoc-equal).] ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ASSOC-EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CONSP) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NTH) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IF) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV IMPLIES) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQUAL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV EQL) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV CAR) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV ACL2::USE-THESE-HINTS) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV USE-BY-HINT) ;; (EV-CONSTRAINT-FOR RUN-GIFIED-EV NOT))))) (defthm run-gified-process-body-correct (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (and (equal (run-gified-ev `(,gevalfn (quote ,(mv-nth 1 (run-gified-ev body a))) (quote ,env)) nil) (run-gified-ev `(,evalfn (quote ,(cons (cdr (assoc 'fn a)) (kwote-lst (run-gified-ev `(,geval-list (quote ,(cdr (assoc 'actuals a))) (quote ,env)) nil)))) 'nil) nil)) ;; (equal (run-gified-ev ;; `(,gevalfn (mv-nth '2 ,body) env) ;; a) ;; (run-gified-ev ;; `(,evalfn (list 'mv-nth ''1 ;; (cons fn (acl2::kwote-lst ;; (,geval-list actuals env)))) ;; 'nil) ;; a)) ))) :hints (("goal" :induct (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) :expand ((run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)))) (and stable-under-simplificationp '(:in-theory (enable run-gified-ev-constraint-0 my-run-gified-ev-constraint-0) :do-not-induct t)) ;; (and stable-under-simplificationp ;; '(:use ((:instance ;; nth-of-nthcdr ;; (n 0) ;; (y (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY))) ;; (m (+ -5 (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN ;; BODY)))))) ;; (:instance ;; nths-matching-formalsp-make-nths-matching-formals-ev1 ;; (list (ACL2::TAKE (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (formals (ACL2::TAKE ;; (+ -5 ;; (LEN (MV-NTH 3 (RUN-GIFIED-CASE-BREAKDOWN BODY)))) ;; (MV-NTH ;; 2 ;; (RUN-GIFIED-GET-GEVAL-THM (MV-NTH 2 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; (MV-NTH 1 (RUN-GIFIED-CASE-BREAKDOWN BODY)) ;; GEVAL-ALIST GEVALFN)))) ;; (varname 'ACTUALS))) ;; :in-theory (e/d (my-run-gified-ev-constraint-0) ;; (nth-of-nthcdr)))) )))) (local (defthm run-gified-process-body-correct1 (mv-let (erp clauses) (run-gified-process-body body eval-alist evalfn geval-alist gevalfn in-clauses (w state)) (implies (and (not erp) (run-gified-ev-meta-extract-global-facts) (acl2::check-ev-of-quote evalfn quote-name (w state)) (acl2::check-ev-of-variable evalfn var-name (w state)) (run-gified-ev-theoremp (conjoin-clauses clauses)) (run-gified-ev-theoremp (disjoin (geval-list-def-thm geval-list gevalfn))) (run-gified-ev-theoremp (disjoin (geval-of-nil-thm gevalfn geval-nil))) (not (equal evalfn 'quote)) (not (equal gevalfn 'quote)) (not (equal geval-list 'quote)) (mv-nth 0 (run-gified-ev body a)) (bfr-hyp-eval (cdr (assoc-equal 'hyp a)) (car env))) (equal (run-gified-ev (list gevalfn (list 'quote (mv-nth 1 (run-gified-ev body a))) (list 'quote env)) nil) (run-gified-ev `(,evalfn (cons fn (acl2::kwote-lst (,geval-list actuals (quote ,env)))) 'nil) a)))) :hints(("Goal" :in-theory (e/d (run-gified-ev-constraint-0) (run-gified-process-body-correct)) :use ((:instance run-gified-process-body-correct)))))) (defun run-gified-clause-proc (clause geval-nil state) (declare ; (ignore hints) (xargs :stobjs state :verify-guards nil)) (b* (((mv ok subst) (acl2::simple-one-way-unify-lst '((implies (if (bfr-hyp-eval hyp (car env)) okp-term 'nil) (equal lhs-term rhs-term))) clause nil)) ((unless ok) (mv (acl2::msg "Clause didn't match pattern: ~x0~%" clause) nil state)) ((unless (and (eq (cdr (assoc-equal 'hyp subst)) 'hyp) (eq (cdr (assoc-equal 'env subst)) 'env))) (mv "Clause variables are different than expected" nil state)) (lhs (cdr (assoc-equal 'lhs-term subst))) (rhs (cdr (assoc-equal 'rhs-term subst))) (okp (cdr (assoc-equal 'okp-term subst))) ((mv erp geval-fn run-gified-fn) (run-gified-lhs-and-okp-breakdown lhs okp)) ((when erp) (mv erp nil state)) ((when (equal geval-fn 'quote)) (mv "The geval function is QUOTE which is silly." nil state)) ((when (equal run-gified-fn 'quote)) (mv "The run-gified function is QUOTE which is silly." nil state)) ((mv erp ev-fn geval-list-fn) (run-gified-rhs-breakdown rhs)) ((when (eq geval-list-fn 'quote)) (mv "The geval-list function is QUOTE which is silly." nil state)) ((when erp) (mv erp nil state)) ((mv ok ?formals body) (acl2::fn-get-def run-gified-fn state)) ((unless ok) (mv (msg "Failed to get the function definition for ~x0" run-gified-fn) nil state)) ((unless (equal formals '(fn actuals hyp clk config bvar-db state))) (mv (msg "Expected the formals of ~x0 to be ~x1" run-gified-fn '(fn actuals hyp clk config bvar-db state)) nil state)) (world (w state)) ((when (eq ev-fn 'quote)) (mv "The eval function is QUOTE which is silly." nil state)) (eval-rule-alist (acl2::ev-collect-apply-lemmas ev-fn nil world)) ((unless (acl2::check-ev-of-quote ev-fn (cadr (cdr (hons-get :quote eval-rule-alist))) world)) (mv "The eval function doesn't have the expected QUOTE constraint." nil state)) ((unless (acl2::check-ev-of-variable ev-fn (cadr (cdr (hons-get :lookup-var eval-rule-alist))) world)) (mv "The eval function doesn't have the expected variable-lookup constraint." nil state)) ((mv erp geval-rule-alist) (geval-rule-alist (table-alist 'gl-function-info world) geval-fn world)) ((when erp) (mv erp nil state)) ((mv erp clauses) (run-gified-process-body body eval-rule-alist ev-fn geval-rule-alist geval-fn nil world)) ((when erp) (mv erp nil state))) (value (list* (geval-list-def-thm geval-list-fn geval-fn) (geval-of-nil-thm geval-fn geval-nil) clauses)))) (local (acl2::def-unify run-gified-ev run-gified-ev-alist)) (local (defthm assoc-equal-run-gified-ev-alist (equal (cdr (assoc-equal x (run-gified-ev-alist subst a))) (run-gified-ev (cdr (assoc-equal x subst)) a)))) (local (encapsulate nil (local (defun cdr-down2 (a b) (if (atom a) b (cdr-down2 (cdr a) (cdr b))))) (local (defthm run-gified-ev-lst-equal-impl-disjoin-iff (implies (equal (run-gified-ev-lst lst a) (run-gified-ev-lst lst2 a2)) (iff (run-gified-ev (disjoin lst) a) (run-gified-ev (disjoin lst2) a2))) :hints (("goal" :induct (cdr-down2 lst lst2) :in-theory (enable run-gified-ev-disjoin-when-consp)) '(:cases ((consp lst2)))) :rule-classes nil)) (defthm simple-one-way-unify-lst-usage-disjoin (mv-let (ok subst) (acl2::simple-one-way-unify-lst template term alist) (implies (and ok (pseudo-term-listp term) (pseudo-term-listp template)) (iff (run-gified-ev (disjoin term) a) (run-gified-ev (disjoin template) (run-gified-ev-alist subst a))))) :hints (("goal" :use ((:instance run-gified-ev-lst-equal-impl-disjoin-iff (lst term) (a a) (lst2 template) (a2 (run-gified-ev-alist (mv-nth 1 (acl2::simple-one-way-unify-lst template term alist)) a))))))))) (local (defthm run-gified-lhs-and-okp-breakdown-correct-eval (mv-let (erp geval run-gified) (run-gified-lhs-and-okp-breakdown lhs okp) (implies (not erp) (and (equal (run-gified-ev lhs a) (run-gified-ev `(,geval (mv-nth '1 (,run-gified fn actuals hyp clk config bvar-db state)) env) a)) (equal (run-gified-ev okp a) (run-gified-ev `(mv-nth '0 (,run-gified fn actuals hyp clk config bvar-db state)) a))))) :hints (("goal" :use run-gified-lhs-and-okp-breakdown-correct :in-theory (disable run-gified-lhs-and-okp-breakdown-correct))))) (local (defthm run-gified-rhs-breakdown-correct-eval (mv-let (erp evfn geval-list-fn) (run-gified-rhs-breakdown rhs) (implies (not erp) (equal (run-gified-ev rhs a) (run-gified-ev `(,evfn (cons fn (acl2::kwote-lst (,geval-list-fn actuals env))) 'nil) a)))))) (local (in-theory (disable run-gified-lhs-and-okp-breakdown-correct run-gified-rhs-breakdown-correct))) (local (in-theory (disable acl2::ev-collect-apply-lemmas body table-alist w))) (local (in-theory (disable run-gified-process-body assoc-equal))) (local (in-theory (disable SIMPLE-ONE-WAY-UNIFY-LST-WITH-RUN-GIFIED-EV check-ev-of-bad-fncall-correct-for-run-gified-ev check-ev-of-nonsymbol-atom-correct-for-run-gified-ev check-ev-of-fncall-args-correct-for-run-gified-ev check-ev-of-quote-correct-for-run-gified-ev check-ev-of-lambda-correct-for-run-gified-ev check-ev-of-variable-correct-for-run-gified-ev))) (local (defthm assoc-equal-of-cons (implies (syntaxp (and (quotep var) (quotep key))) (equal (assoc var (cons (cons key val) rest)) (if (equal var key) (cons key val) (assoc var rest)))) :hints(("Goal" :in-theory (enable assoc))))) (local (defthm pairlis-open (equal (pairlis$ (cons a b) c) (cons (cons a (car c)) (pairlis$ b (cdr c)))))) (local (in-theory (disable pairlis$))) (defthm run-gified-clause-proc-correct (implies (and (pseudo-term-listp clause) (alistp a) (run-gified-ev-meta-extract-global-facts) (run-gified-ev (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state))) (run-gified-ev-falsify (conjoin-clauses (acl2::clauses-result (run-gified-clause-proc clause hints state)))))) (run-gified-ev (disjoin clause) a)) :hints (("goal" :do-not-induct t :in-theory (enable run-gified-ev-constraint-0 ;; assoc-equal )) (and stable-under-simplificationp '(:computed-hint-replacement ('(:clause-processor (acl2::simple-generalize-cp clause '(((CDR (ASSOC-EQUAL 'LHS-TERM subst)) . lhs) ((CDR (ASSOC-EQUAL 'rhs-term subst)) . rhs) ((CDR (ASSOC-EQUAL 'OKP-TERM subst)) . okp) ((CDR (ASSOC-EQUAL 'hyp subst)) . hyp) ((CDR (ASSOC-EQUAL 'actuals subst)) . actuals) ((CDR (ASSOC-EQUAL 'env subst)) . env)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . geval-fn) ((MV-NTH '2 (RUN-GIFIED-LHS-AND-OKP-BREAKDOWN LHS OKP)) . run-gified-fn)))) '(:clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . evalfn) ((MV-NTH '2 (RUN-GIFIED-RHS-BREAKDOWN RHS)) . geval-list-fn) ((MV-NTH '1 (GEVAL-RULE-ALIST (TABLE-ALIST 'GL-FUNCTION-INFO (W STATE)) GEVAL-FN (W STATE))) . geval-alist)))) ;; '(:use ((:instance run-gified-ev-meta-extract-fn-check-def ;; (st state) ;; (fn run-gified-fn) ;; (formals (mv-nth 1 (acl2::fn-get-def geval-fn state))) ;; (body (mv-nth 2 (acl2::fn-get-def geval-fn state))) ;; (args (list (LIST ;; 'QUOTE ;; (MV-NTH 1 ;; (RUN-GIFIED-EV (LIST RUN-GIFIED-FN ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'FN A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ACTUALS A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'HYP A))) ;; (LIST 'QUOTE (CDR (ASSOC-EQUAL 'CLK A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'CONFIG A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'BVAR-DB A))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'STATE A)))) ;; NIL))) ;; (LIST 'QUOTE ;; (CDR (ASSOC-EQUAL 'ENV A))))) ;; (a nil)))) ;; '(:clause-processor ;; (acl2::simple-generalize-cp ;; clause '(((ACL2::EV-COLLECT-APPLY-LEMMAS ;; evalfn 'NIL (W STATE)) . eval-alist)))) ;; '(:use ((:instance run-gified-ev-falsify ;; (x (disjoin (function-def-clause ;; run-gified-fn run-gified-fn ;; '(fn actuals hyp clk config bvar-db state) ;; (MV-NTH 2 (ACL2::FN-GET-DEF GEVAL-FN STATE))))) ;; (a a))) ;; :in-theory (enable run-gified-ev-constraint-0)) ) :clause-processor (acl2::simple-generalize-cp clause '(((MV-NTH '1 (ACL2::SIMPLE-ONE-WAY-UNIFY-LST '((IMPLIES (IF (BFR-HYP-EVAL HYP (CAR ENV)) OKP-TERM 'NIL) (EQUAL LHS-TERM RHS-TERM))) CLAUSE 'NIL)) . subst)))))) :rule-classes :clause-processor)
[ { "context": ";;; Copyright (c) 2007 Zachary Beane, All Rights Reserved\n;;;\n;;; Redistribution and u", "end": 36, "score": 0.9998342394828796, "start": 23, "tag": "NAME", "value": "Zachary Beane" } ]
text.lisp
xach/vecto
20
;;; Copyright (c) 2007 Zachary Beane, All Rights Reserved ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; ;;; $Id: text.lisp,v 1.8 2007/09/21 17:39:36 xach Exp $ (in-package #:vecto) (defclass font () ((loader :initarg :loader :accessor loader) (transform-matrix :initarg :transform-matrix :accessor transform-matrix) (size :initarg :size :accessor size))) (defun glyph-path-point (point) (paths:make-point (zpb-ttf:x point) (zpb-ttf:y point))) (defun glyph-paths (glyph) (let* ((paths '()) (path nil)) (zpb-ttf:do-contours (contour glyph (nreverse paths)) (when (plusp (length contour)) (let ((first-point (aref contour 0))) (setf path (paths:create-path :closed-polyline)) (push path paths) (paths:path-reset path (glyph-path-point first-point)) (zpb-ttf:do-contour-segments* (control end) contour (if control (paths:path-extend path (paths:make-bezier-curve (list (glyph-path-point control))) (glyph-path-point end)) (paths:path-extend path (paths:make-straight-line) (glyph-path-point end))))))))) (defun string-glyphs (string loader) "Return STRING converted to a list of ZPB-TTF glyph objects from FONT." (map 'list (lambda (char) (zpb-ttf:find-glyph char loader)) string)) (defun string-primitive-paths (x y string font &key (character-spacing 1.0d0)) "Return the paths of STRING, transformed by the font scale of FONT." (let ((glyphs (string-glyphs string (loader font))) (loader (loader font)) (matrix (mult (transform-matrix font) (translation-matrix x y))) (paths '())) (loop for (glyph . rest) on glyphs do (let ((glyph-paths (glyph-paths glyph)) (fun (make-transform-function matrix))) (dolist (path glyph-paths) (push (transform-path path fun) paths)) (when rest (let* ((next (first rest)) (offset (+ (zpb-ttf:advance-width glyph) (zpb-ttf:kerning-offset glyph next loader)))) (setf matrix (nmult (translation-matrix (* offset character-spacing) 0) matrix)))))) paths)) (defun nmerge-bounding-boxes (b1 b2) "Create a minimal bounding box that covers both B1 and B2 and destructively update B1 with its values. Returns the new box." (setf (xmin b1) (min (xmin b1) (xmin b2)) (ymin b1) (min (ymin b1) (ymin b2)) (xmax b1) (max (xmax b1) (xmax b2)) (ymax b1) (max (ymax b1) (ymax b2))) b1) (defun advance-bounding-box (bbox offset) "Return a bounding box advanced OFFSET units horizontally." (vector (+ (xmin bbox) offset) (ymin bbox) (+ (xmax bbox) offset) (ymax bbox))) (defun empty-bounding-box () (vector most-positive-fixnum most-positive-fixnum most-negative-fixnum most-negative-fixnum)) (defun ntransform-bounding-box (bbox fun) "Return BBOX transformed by FUN; destructively modifies BBOX with the new values." (setf (values (xmin bbox) (ymin bbox)) (funcall fun (xmin bbox) (ymin bbox)) (values (xmax bbox) (ymax bbox)) (funcall fun (xmax bbox) (ymax bbox))) bbox) (defun loader-font-scale (size loader) "Return the horizontal and vertical scaling needed to draw the glyphs of LOADER at SIZE units." (float (/ size (zpb-ttf:units/em loader)))) (defun string-bounding-box (string size loader &key (character-spacing 1.0d0)) (let* ((bbox (empty-bounding-box)) (scale (loader-font-scale size loader)) (fun (make-transform-function (scaling-matrix scale scale))) (glyphs (string-glyphs string loader)) (offset 0)) (loop for (glyph . rest) on glyphs do (let ((glyph-box (advance-bounding-box (bounding-box glyph) (* offset character-spacing)))) (setf bbox (nmerge-bounding-boxes bbox glyph-box)) (incf offset (zpb-ttf:advance-width glyph)) (when rest (let* ((next-glyph (first rest)) (kerning (zpb-ttf:kerning-offset glyph next-glyph loader))) (incf offset kerning))))) (ntransform-bounding-box bbox fun)))
21283
;;; Copyright (c) 2007 <NAME>, All Rights Reserved ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; ;;; $Id: text.lisp,v 1.8 2007/09/21 17:39:36 xach Exp $ (in-package #:vecto) (defclass font () ((loader :initarg :loader :accessor loader) (transform-matrix :initarg :transform-matrix :accessor transform-matrix) (size :initarg :size :accessor size))) (defun glyph-path-point (point) (paths:make-point (zpb-ttf:x point) (zpb-ttf:y point))) (defun glyph-paths (glyph) (let* ((paths '()) (path nil)) (zpb-ttf:do-contours (contour glyph (nreverse paths)) (when (plusp (length contour)) (let ((first-point (aref contour 0))) (setf path (paths:create-path :closed-polyline)) (push path paths) (paths:path-reset path (glyph-path-point first-point)) (zpb-ttf:do-contour-segments* (control end) contour (if control (paths:path-extend path (paths:make-bezier-curve (list (glyph-path-point control))) (glyph-path-point end)) (paths:path-extend path (paths:make-straight-line) (glyph-path-point end))))))))) (defun string-glyphs (string loader) "Return STRING converted to a list of ZPB-TTF glyph objects from FONT." (map 'list (lambda (char) (zpb-ttf:find-glyph char loader)) string)) (defun string-primitive-paths (x y string font &key (character-spacing 1.0d0)) "Return the paths of STRING, transformed by the font scale of FONT." (let ((glyphs (string-glyphs string (loader font))) (loader (loader font)) (matrix (mult (transform-matrix font) (translation-matrix x y))) (paths '())) (loop for (glyph . rest) on glyphs do (let ((glyph-paths (glyph-paths glyph)) (fun (make-transform-function matrix))) (dolist (path glyph-paths) (push (transform-path path fun) paths)) (when rest (let* ((next (first rest)) (offset (+ (zpb-ttf:advance-width glyph) (zpb-ttf:kerning-offset glyph next loader)))) (setf matrix (nmult (translation-matrix (* offset character-spacing) 0) matrix)))))) paths)) (defun nmerge-bounding-boxes (b1 b2) "Create a minimal bounding box that covers both B1 and B2 and destructively update B1 with its values. Returns the new box." (setf (xmin b1) (min (xmin b1) (xmin b2)) (ymin b1) (min (ymin b1) (ymin b2)) (xmax b1) (max (xmax b1) (xmax b2)) (ymax b1) (max (ymax b1) (ymax b2))) b1) (defun advance-bounding-box (bbox offset) "Return a bounding box advanced OFFSET units horizontally." (vector (+ (xmin bbox) offset) (ymin bbox) (+ (xmax bbox) offset) (ymax bbox))) (defun empty-bounding-box () (vector most-positive-fixnum most-positive-fixnum most-negative-fixnum most-negative-fixnum)) (defun ntransform-bounding-box (bbox fun) "Return BBOX transformed by FUN; destructively modifies BBOX with the new values." (setf (values (xmin bbox) (ymin bbox)) (funcall fun (xmin bbox) (ymin bbox)) (values (xmax bbox) (ymax bbox)) (funcall fun (xmax bbox) (ymax bbox))) bbox) (defun loader-font-scale (size loader) "Return the horizontal and vertical scaling needed to draw the glyphs of LOADER at SIZE units." (float (/ size (zpb-ttf:units/em loader)))) (defun string-bounding-box (string size loader &key (character-spacing 1.0d0)) (let* ((bbox (empty-bounding-box)) (scale (loader-font-scale size loader)) (fun (make-transform-function (scaling-matrix scale scale))) (glyphs (string-glyphs string loader)) (offset 0)) (loop for (glyph . rest) on glyphs do (let ((glyph-box (advance-bounding-box (bounding-box glyph) (* offset character-spacing)))) (setf bbox (nmerge-bounding-boxes bbox glyph-box)) (incf offset (zpb-ttf:advance-width glyph)) (when rest (let* ((next-glyph (first rest)) (kerning (zpb-ttf:kerning-offset glyph next-glyph loader))) (incf offset kerning))))) (ntransform-bounding-box bbox fun)))
true
;;; Copyright (c) 2007 PI:NAME:<NAME>END_PI, All Rights Reserved ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; ;;; $Id: text.lisp,v 1.8 2007/09/21 17:39:36 xach Exp $ (in-package #:vecto) (defclass font () ((loader :initarg :loader :accessor loader) (transform-matrix :initarg :transform-matrix :accessor transform-matrix) (size :initarg :size :accessor size))) (defun glyph-path-point (point) (paths:make-point (zpb-ttf:x point) (zpb-ttf:y point))) (defun glyph-paths (glyph) (let* ((paths '()) (path nil)) (zpb-ttf:do-contours (contour glyph (nreverse paths)) (when (plusp (length contour)) (let ((first-point (aref contour 0))) (setf path (paths:create-path :closed-polyline)) (push path paths) (paths:path-reset path (glyph-path-point first-point)) (zpb-ttf:do-contour-segments* (control end) contour (if control (paths:path-extend path (paths:make-bezier-curve (list (glyph-path-point control))) (glyph-path-point end)) (paths:path-extend path (paths:make-straight-line) (glyph-path-point end))))))))) (defun string-glyphs (string loader) "Return STRING converted to a list of ZPB-TTF glyph objects from FONT." (map 'list (lambda (char) (zpb-ttf:find-glyph char loader)) string)) (defun string-primitive-paths (x y string font &key (character-spacing 1.0d0)) "Return the paths of STRING, transformed by the font scale of FONT." (let ((glyphs (string-glyphs string (loader font))) (loader (loader font)) (matrix (mult (transform-matrix font) (translation-matrix x y))) (paths '())) (loop for (glyph . rest) on glyphs do (let ((glyph-paths (glyph-paths glyph)) (fun (make-transform-function matrix))) (dolist (path glyph-paths) (push (transform-path path fun) paths)) (when rest (let* ((next (first rest)) (offset (+ (zpb-ttf:advance-width glyph) (zpb-ttf:kerning-offset glyph next loader)))) (setf matrix (nmult (translation-matrix (* offset character-spacing) 0) matrix)))))) paths)) (defun nmerge-bounding-boxes (b1 b2) "Create a minimal bounding box that covers both B1 and B2 and destructively update B1 with its values. Returns the new box." (setf (xmin b1) (min (xmin b1) (xmin b2)) (ymin b1) (min (ymin b1) (ymin b2)) (xmax b1) (max (xmax b1) (xmax b2)) (ymax b1) (max (ymax b1) (ymax b2))) b1) (defun advance-bounding-box (bbox offset) "Return a bounding box advanced OFFSET units horizontally." (vector (+ (xmin bbox) offset) (ymin bbox) (+ (xmax bbox) offset) (ymax bbox))) (defun empty-bounding-box () (vector most-positive-fixnum most-positive-fixnum most-negative-fixnum most-negative-fixnum)) (defun ntransform-bounding-box (bbox fun) "Return BBOX transformed by FUN; destructively modifies BBOX with the new values." (setf (values (xmin bbox) (ymin bbox)) (funcall fun (xmin bbox) (ymin bbox)) (values (xmax bbox) (ymax bbox)) (funcall fun (xmax bbox) (ymax bbox))) bbox) (defun loader-font-scale (size loader) "Return the horizontal and vertical scaling needed to draw the glyphs of LOADER at SIZE units." (float (/ size (zpb-ttf:units/em loader)))) (defun string-bounding-box (string size loader &key (character-spacing 1.0d0)) (let* ((bbox (empty-bounding-box)) (scale (loader-font-scale size loader)) (fun (make-transform-function (scaling-matrix scale scale))) (glyphs (string-glyphs string loader)) (offset 0)) (loop for (glyph . rest) on glyphs do (let ((glyph-box (advance-bounding-box (bounding-box glyph) (* offset character-spacing)))) (setf bbox (nmerge-bounding-boxes bbox glyph-box)) (incf offset (zpb-ttf:advance-width glyph)) (when rest (let* ((next-glyph (first rest)) (kerning (zpb-ttf:kerning-offset glyph next-glyph loader))) (incf offset kerning))))) (ntransform-bounding-box bbox fun)))
[ { "context": ";; Copyright Mark Watson 2001-2013. All Rights Reserved. http://markwatso", "end": 24, "score": 0.9982759356498718, "start": 13, "tag": "NAME", "value": "Mark Watson" } ]
src/myutils/myutils.lisp
metayan/loving-common-lisp
170
;; Copyright Mark Watson 2001-2013. All Rights Reserved. http://markwatson.com ;; License: AGPL version 3 (http://www.gnu.org/licenses/agpl-3.0.txt) ;; Alternative license: you may also use this software under the Apache 2 License. ;; This copyright notice should not be removed from this file and in files derived from this file. (in-package #:myutils) ;; utility from http://cl-cookbook.sourceforge.net/strings.html#manip: (defun replace-all (string part replacement &key (test #'char=)) "Returns a new string in which all the occurrences of the part is replaced with replacement." (with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-string replacement out) while pos))) (defun words-from-string (str) (let ((ss (tokenize-string str))) (make-array (list (length ss)) :initial-contents ss))) (defun tokenize-string-keep-uri (string) (tokenize-string string :delimiters '(#\Space #\Return #\Linefeed #\Newline #\, #\; #\( #\)) ;; #\?) ;; will fail with URIs with '?' or "\"" :discard '(#\Space #\Return #\Linefeed #\Newline #\,))) (defun tokenize-string (string &key (delimiters '(#\Space #\Return #\Linefeed #\Newline #\. #\, #\; #\: #\! #\" #\' #\? #\/ #\( #\) #\- #\< #\>)) (discard '(#\Space #\Return #\Linefeed #\Newline #\, #\" #\' #\- #\< #\>)) (test (lambda (c) (find c delimiters))) (start 0) (end (length string)) (omit-delimiters nil)) (flet ((get-token (start) (if (< start end) (let* ((delimiterp (funcall test (char string start))) (end-of-token (funcall (if delimiterp #'position-if-not #'position-if) test string :start start))) (values (subseq string start end-of-token) end-of-token delimiterp)) (values nil nil nil)))) (let ((tokens nil) token delimiterp) (loop (multiple-value-setq (token start delimiterp) (get-token start)) (unless (and delimiterp omit-delimiters) (let ((tok (string-trim discard token))) ;;(print (list "tok:" tok)) (if (not (find tok discard)) (if (> (length tok) 0) (push tok tokens))))) (unless start (return-from tokenize-string (nreverse tokens))))))) (defun file-to-string (filename) (with-open-file (stream filename) (let ((contents (make-string (file-length stream)))) (read-sequence contents stream) contents))) ;; really baroque: improve this: (defun node-name-from-uri (uri) (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all uri "https://" "") "http://" "") "/" "_") "." "_") " " "_") "-" "_") "(" "") ")" "") "<" "") ">" "") "?" "") "=" "_") "'" ""))
58246
;; Copyright <NAME> 2001-2013. All Rights Reserved. http://markwatson.com ;; License: AGPL version 3 (http://www.gnu.org/licenses/agpl-3.0.txt) ;; Alternative license: you may also use this software under the Apache 2 License. ;; This copyright notice should not be removed from this file and in files derived from this file. (in-package #:myutils) ;; utility from http://cl-cookbook.sourceforge.net/strings.html#manip: (defun replace-all (string part replacement &key (test #'char=)) "Returns a new string in which all the occurrences of the part is replaced with replacement." (with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-string replacement out) while pos))) (defun words-from-string (str) (let ((ss (tokenize-string str))) (make-array (list (length ss)) :initial-contents ss))) (defun tokenize-string-keep-uri (string) (tokenize-string string :delimiters '(#\Space #\Return #\Linefeed #\Newline #\, #\; #\( #\)) ;; #\?) ;; will fail with URIs with '?' or "\"" :discard '(#\Space #\Return #\Linefeed #\Newline #\,))) (defun tokenize-string (string &key (delimiters '(#\Space #\Return #\Linefeed #\Newline #\. #\, #\; #\: #\! #\" #\' #\? #\/ #\( #\) #\- #\< #\>)) (discard '(#\Space #\Return #\Linefeed #\Newline #\, #\" #\' #\- #\< #\>)) (test (lambda (c) (find c delimiters))) (start 0) (end (length string)) (omit-delimiters nil)) (flet ((get-token (start) (if (< start end) (let* ((delimiterp (funcall test (char string start))) (end-of-token (funcall (if delimiterp #'position-if-not #'position-if) test string :start start))) (values (subseq string start end-of-token) end-of-token delimiterp)) (values nil nil nil)))) (let ((tokens nil) token delimiterp) (loop (multiple-value-setq (token start delimiterp) (get-token start)) (unless (and delimiterp omit-delimiters) (let ((tok (string-trim discard token))) ;;(print (list "tok:" tok)) (if (not (find tok discard)) (if (> (length tok) 0) (push tok tokens))))) (unless start (return-from tokenize-string (nreverse tokens))))))) (defun file-to-string (filename) (with-open-file (stream filename) (let ((contents (make-string (file-length stream)))) (read-sequence contents stream) contents))) ;; really baroque: improve this: (defun node-name-from-uri (uri) (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all uri "https://" "") "http://" "") "/" "_") "." "_") " " "_") "-" "_") "(" "") ")" "") "<" "") ">" "") "?" "") "=" "_") "'" ""))
true
;; Copyright PI:NAME:<NAME>END_PI 2001-2013. All Rights Reserved. http://markwatson.com ;; License: AGPL version 3 (http://www.gnu.org/licenses/agpl-3.0.txt) ;; Alternative license: you may also use this software under the Apache 2 License. ;; This copyright notice should not be removed from this file and in files derived from this file. (in-package #:myutils) ;; utility from http://cl-cookbook.sourceforge.net/strings.html#manip: (defun replace-all (string part replacement &key (test #'char=)) "Returns a new string in which all the occurrences of the part is replaced with replacement." (with-output-to-string (out) (loop with part-length = (length part) for old-pos = 0 then (+ pos part-length) for pos = (search part string :start2 old-pos :test test) do (write-string string out :start old-pos :end (or pos (length string))) when pos do (write-string replacement out) while pos))) (defun words-from-string (str) (let ((ss (tokenize-string str))) (make-array (list (length ss)) :initial-contents ss))) (defun tokenize-string-keep-uri (string) (tokenize-string string :delimiters '(#\Space #\Return #\Linefeed #\Newline #\, #\; #\( #\)) ;; #\?) ;; will fail with URIs with '?' or "\"" :discard '(#\Space #\Return #\Linefeed #\Newline #\,))) (defun tokenize-string (string &key (delimiters '(#\Space #\Return #\Linefeed #\Newline #\. #\, #\; #\: #\! #\" #\' #\? #\/ #\( #\) #\- #\< #\>)) (discard '(#\Space #\Return #\Linefeed #\Newline #\, #\" #\' #\- #\< #\>)) (test (lambda (c) (find c delimiters))) (start 0) (end (length string)) (omit-delimiters nil)) (flet ((get-token (start) (if (< start end) (let* ((delimiterp (funcall test (char string start))) (end-of-token (funcall (if delimiterp #'position-if-not #'position-if) test string :start start))) (values (subseq string start end-of-token) end-of-token delimiterp)) (values nil nil nil)))) (let ((tokens nil) token delimiterp) (loop (multiple-value-setq (token start delimiterp) (get-token start)) (unless (and delimiterp omit-delimiters) (let ((tok (string-trim discard token))) ;;(print (list "tok:" tok)) (if (not (find tok discard)) (if (> (length tok) 0) (push tok tokens))))) (unless start (return-from tokenize-string (nreverse tokens))))))) (defun file-to-string (filename) (with-open-file (stream filename) (let ((contents (make-string (file-length stream)))) (read-sequence contents stream) contents))) ;; really baroque: improve this: (defun node-name-from-uri (uri) (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all (replace-all uri "https://" "") "http://" "") "/" "_") "." "_") " " "_") "-" "_") "(" "") ")" "") "<" "") ">" "") "?" "") "=" "_") "'" ""))
[ { "context": "dds ratios using Bayesian statistics.\"\n :author \"Renee Klawitter <[email protected]>\"\n :license \"Apache 2.", "end": 224, "score": 0.9998358488082886, "start": 209, "tag": "NAME", "value": "Renee Klawitter" }, { "context": "Bayesian statistics.\"\n :author \"Renee Klawitter <[email protected]>\"\n :license \"Apache 2.0\"\n :version \"0.0.1\"\n :d", "end": 250, "score": 0.9999309182167053, "start": 226, "tag": "EMAIL", "value": "[email protected]" } ]
bayesian-analysis.asd
deepestthought42/bayesian-analysis
0
;;;; bayesian-analysis.asd (asdf:defsystem #:bayesian-analysis :description "Package to specify a model and calculate posterior distributions as well as odds ratios using Bayesian statistics." :author "Renee Klawitter <[email protected]>" :license "Apache 2.0" :version "0.0.1" :depends-on (#:alexandria #:iterate #:let-plus #:gsl-cffi #:mgl-gnuplot #:math-utils #:cffi-nlopt #:lla #:verbose) :serial t :components ((:file "package") (:file "bayesian-analysis") (:file "utils") (:file "init") (:file "algorithm") (:file "data") (:file "priors") (:file "sampling") (:file "likelihood") (:file "model-function") (:file "model") (:file "metropolis-hastings") (:file "levenberg-marquardt") (:file "integration") (:file "nlopt") (:file "fisher-information") (:file "odds") (:file "plot")))
23982
;;;; bayesian-analysis.asd (asdf:defsystem #:bayesian-analysis :description "Package to specify a model and calculate posterior distributions as well as odds ratios using Bayesian statistics." :author "<NAME> <<EMAIL>>" :license "Apache 2.0" :version "0.0.1" :depends-on (#:alexandria #:iterate #:let-plus #:gsl-cffi #:mgl-gnuplot #:math-utils #:cffi-nlopt #:lla #:verbose) :serial t :components ((:file "package") (:file "bayesian-analysis") (:file "utils") (:file "init") (:file "algorithm") (:file "data") (:file "priors") (:file "sampling") (:file "likelihood") (:file "model-function") (:file "model") (:file "metropolis-hastings") (:file "levenberg-marquardt") (:file "integration") (:file "nlopt") (:file "fisher-information") (:file "odds") (:file "plot")))
true
;;;; bayesian-analysis.asd (asdf:defsystem #:bayesian-analysis :description "Package to specify a model and calculate posterior distributions as well as odds ratios using Bayesian statistics." :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "Apache 2.0" :version "0.0.1" :depends-on (#:alexandria #:iterate #:let-plus #:gsl-cffi #:mgl-gnuplot #:math-utils #:cffi-nlopt #:lla #:verbose) :serial t :components ((:file "package") (:file "bayesian-analysis") (:file "utils") (:file "init") (:file "algorithm") (:file "data") (:file "priors") (:file "sampling") (:file "likelihood") (:file "model-function") (:file "model") (:file "metropolis-hastings") (:file "levenberg-marquardt") (:file "integration") (:file "nlopt") (:file "fisher-information") (:file "odds") (:file "plot")))
[ { "context": ";;;\n;;; File: cl-yold.lisp\n;;; Author: David Selivanov <[email protected]>\n;;;\n;;; Created: Setting Or", "end": 54, "score": 0.9998888969421387, "start": 39, "tag": "NAME", "value": "David Selivanov" }, { "context": "; File: cl-yold.lisp\n;;; Author: David Selivanov <[email protected]>\n;;;\n;;; Created: Setting Orange, the 35th day of", "end": 75, "score": 0.9999293088912964, "start": 56, "tag": "EMAIL", "value": "[email protected]" }, { "context": "of Chaos in the YOLD 3182\n;;;\n;;; Copyright © 2016 David Selivanov <[email protected]>\n;;; This program is free so", "end": 189, "score": 0.9998598098754883, "start": 174, "tag": "NAME", "value": "David Selivanov" }, { "context": "LD 3182\n;;;\n;;; Copyright © 2016 David Selivanov <[email protected]>\n;;; This program is free software. It comes with", "end": 210, "score": 0.999930739402771, "start": 191, "tag": "EMAIL", "value": "[email protected]" } ]
cl-yold.lisp
davidselivanov/cl-yold
0
;;; ;;; File: cl-yold.lisp ;;; Author: David Selivanov <[email protected]> ;;; ;;; Created: Setting Orange, the 35th day of Chaos in the YOLD 3182 ;;; ;;; Copyright © 2016 David Selivanov <[email protected]> ;;; This program is free software. It comes without any warranty, to ;;; the extent permitted by applicable law. You can redistribute it ;;; and/or modify it under the terms of the Do What The Fuck You Want ;;; To Public License, Version 2, as published by Sam Hocevar. ;;; See the COPYING file for more details. (in-package :cl-user) (defpackage cl-yold (:use :cl) (:export :yold)) (in-package :cl-yold) (defparameter *days* (list "Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange")) (defparameter *seasons* (list "Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath")) (defparameter *holydays* (list '("Mungday" "Chaoflux") '("Mojoday" "Discoflux") '("Syaday" "Confuflux") '("Zaraday" "Bureflux") '("Maladay" "Afflux"))) (defun holydayp (day) (or (= 4 day) (= 49 day))) (defun get-holyday (season day) (print day) (nth (if (> day 4) 1 0) (nth season *holydays*))) (defun leapp (year) (if (not (zerop (mod year 4))) nil (if (not (zerop (mod year 100))) t (if (not (zerop (mod year 400))) nil t)))) (defun yold (&optional (date (get-universal-time))) (multiple-value-bind (sec min hour mon-d mon year day dp zone) (decode-universal-time date) (let* ((days (floor (/ (- date (encode-universal-time 0 0 0 1 1 year zone)) (* 60 60 24))))) (if (and (leapp year) (= days 60)) (format nil "It's St. Tib's Day, ~a YOLD!" (+ year 1166)) (progn (if (and (leapp year) (> days 60)) (decf days)) (format nil "~@[It's ~a! ~]~a, the ~:r day of ~a, YOLD ~a" (if (holydayp (floor (mod days 73))) (get-holyday (floor (/ days 73)) days) nil) (nth (floor (mod days 5)) *days*) (mod (1+ days) 73) (nth (floor (/ days 73)) *seasons*) (+ year 1166)))))))
66590
;;; ;;; File: cl-yold.lisp ;;; Author: <NAME> <<EMAIL>> ;;; ;;; Created: Setting Orange, the 35th day of Chaos in the YOLD 3182 ;;; ;;; Copyright © 2016 <NAME> <<EMAIL>> ;;; This program is free software. It comes without any warranty, to ;;; the extent permitted by applicable law. You can redistribute it ;;; and/or modify it under the terms of the Do What The Fuck You Want ;;; To Public License, Version 2, as published by Sam Hocevar. ;;; See the COPYING file for more details. (in-package :cl-user) (defpackage cl-yold (:use :cl) (:export :yold)) (in-package :cl-yold) (defparameter *days* (list "Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange")) (defparameter *seasons* (list "Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath")) (defparameter *holydays* (list '("Mungday" "Chaoflux") '("Mojoday" "Discoflux") '("Syaday" "Confuflux") '("Zaraday" "Bureflux") '("Maladay" "Afflux"))) (defun holydayp (day) (or (= 4 day) (= 49 day))) (defun get-holyday (season day) (print day) (nth (if (> day 4) 1 0) (nth season *holydays*))) (defun leapp (year) (if (not (zerop (mod year 4))) nil (if (not (zerop (mod year 100))) t (if (not (zerop (mod year 400))) nil t)))) (defun yold (&optional (date (get-universal-time))) (multiple-value-bind (sec min hour mon-d mon year day dp zone) (decode-universal-time date) (let* ((days (floor (/ (- date (encode-universal-time 0 0 0 1 1 year zone)) (* 60 60 24))))) (if (and (leapp year) (= days 60)) (format nil "It's St. Tib's Day, ~a YOLD!" (+ year 1166)) (progn (if (and (leapp year) (> days 60)) (decf days)) (format nil "~@[It's ~a! ~]~a, the ~:r day of ~a, YOLD ~a" (if (holydayp (floor (mod days 73))) (get-holyday (floor (/ days 73)) days) nil) (nth (floor (mod days 5)) *days*) (mod (1+ days) 73) (nth (floor (/ days 73)) *seasons*) (+ year 1166)))))))
true
;;; ;;; File: cl-yold.lisp ;;; Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; ;;; Created: Setting Orange, the 35th day of Chaos in the YOLD 3182 ;;; ;;; Copyright © 2016 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; This program is free software. It comes without any warranty, to ;;; the extent permitted by applicable law. You can redistribute it ;;; and/or modify it under the terms of the Do What The Fuck You Want ;;; To Public License, Version 2, as published by Sam Hocevar. ;;; See the COPYING file for more details. (in-package :cl-user) (defpackage cl-yold (:use :cl) (:export :yold)) (in-package :cl-yold) (defparameter *days* (list "Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange")) (defparameter *seasons* (list "Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath")) (defparameter *holydays* (list '("Mungday" "Chaoflux") '("Mojoday" "Discoflux") '("Syaday" "Confuflux") '("Zaraday" "Bureflux") '("Maladay" "Afflux"))) (defun holydayp (day) (or (= 4 day) (= 49 day))) (defun get-holyday (season day) (print day) (nth (if (> day 4) 1 0) (nth season *holydays*))) (defun leapp (year) (if (not (zerop (mod year 4))) nil (if (not (zerop (mod year 100))) t (if (not (zerop (mod year 400))) nil t)))) (defun yold (&optional (date (get-universal-time))) (multiple-value-bind (sec min hour mon-d mon year day dp zone) (decode-universal-time date) (let* ((days (floor (/ (- date (encode-universal-time 0 0 0 1 1 year zone)) (* 60 60 24))))) (if (and (leapp year) (= days 60)) (format nil "It's St. Tib's Day, ~a YOLD!" (+ year 1166)) (progn (if (and (leapp year) (> days 60)) (decf days)) (format nil "~@[It's ~a! ~]~a, the ~:r day of ~a, YOLD ~a" (if (holydayp (floor (mod days 73))) (get-holyday (floor (/ days 73)) days) nil) (nth (floor (mod days 5)) *days*) (mod (1+ days) 73) (nth (floor (/ days 73)) *seasons*) (+ year 1166)))))))
[ { "context": "cture test runner.\"\n :version \"0.0.1\"\n :author \"Joel Rivera <[email protected]>\"\n :licence \"MIT\"\n :depends-on ", "end": 112, "score": 0.9998835325241089, "start": 101, "tag": "NAME", "value": "Joel Rivera" }, { "context": "nner.\"\n :version \"0.0.1\"\n :author \"Joel Rivera <[email protected]>\"\n :licence \"MIT\"\n :depends-on (:unix-options :", "end": 128, "score": 0.9999269843101501, "start": 114, "tag": "EMAIL", "value": "[email protected]" } ]
taste.asd
cyraxjoe/taste
0
(defsystem "taste" :description "taste: Infrastructure test runner." :version "0.0.1" :author "Joel Rivera <[email protected]>" :licence "MIT" :depends-on (:unix-options :prove :cl-ppcre) :components ((:file "src/packages") (:file "src/taste" :depends-on ("src/packages")) (:file "src/file" :depends-on ("src/packages"))))
48061
(defsystem "taste" :description "taste: Infrastructure test runner." :version "0.0.1" :author "<NAME> <<EMAIL>>" :licence "MIT" :depends-on (:unix-options :prove :cl-ppcre) :components ((:file "src/packages") (:file "src/taste" :depends-on ("src/packages")) (:file "src/file" :depends-on ("src/packages"))))
true
(defsystem "taste" :description "taste: Infrastructure test runner." :version "0.0.1" :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :licence "MIT" :depends-on (:unix-options :prove :cl-ppcre) :components ((:file "src/packages") (:file "src/taste" :depends-on ("src/packages")) (:file "src/file" :depends-on ("src/packages"))))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 263, "score": 0.9998731017112732, "start": 246, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 283, "score": 0.9999313950538635, "start": 265, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/c/atc/proof-support.lisp
airbornemihir/acl2
0
; C Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; Copyright (C) 2021 Kestrel Technology LLC (http://kestreltechnology.com) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "C") (include-book "dynamic-semantics") (include-book "kestrel/utilities/defopeners" :dir :system) (include-book "tools/rulesets" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc+ atc-proof-support :parents (atc-implementation) :short "Rules to support the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "Currently, the generated proofs of function correctness are carried out via symbolic execution of the C code. The C code is a constant value, because we are generating proofs over specific C functions.") (xdoc::p "In order to make these generated proofs more robust, we carry them out in a theory that consists exactly of (what we believe to be) all and only the needed rules. This file defines that theory, which consists of rules introduced elsewhere and rules introduced in this file. This set of rules has been defined by experimenting with several symbolic execution proofs, starting with the empty theory and adding rules as needed to advance the symbolic execution, and also by looking at the C dynamic semantics. There is no guarantee (meta proof) that these rules will suffice for every use of ATC; there is also no guarantee that the proof will not be defeated by some ACL2 heuristic in some cases. Nonetheless, the proof strategy seems sound and robust, and if a generated proof fails it should be possible to (prove and) use additional rules.")) :order-subtopics t :default-parent t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-opener-rules :short "Opener rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "To symbolically execute the generated C code, we need to unfold the recursive execution functions, as well as other recursive functions.") (xdoc::p "In general, just enabling recursive functions in ACL2 does not guarantee that their calls will be expanded when desired: ACL2 has heuristics to inhibit the unfolding sometimes, to avoid infinite loops. When the values over which a recursive function recurses are constant, as it happens in our symbolic execution, then we know that the expansion is always safe, but experiments suggest that ACL2's heuristics sometimes block those expansions. For this reason, it is better to have opener rules, i.e. rules that expand function calls, according to the function definitions, under suitable conditions.") (xdoc::p "We use the @('defopeners') utility from @('[books]/kestrel/utilities/defopeners'). Compared to the @(tsee defopener) utility, @('defopeners') generates multiple opener rules (note the plural vs. singular name), corresponding to the conditional structure of the function. In general, there will be some base cases and some step cases; the former have @('base') in the generated rule names, while the latter have @('unroll') in the generated rule names. The names of the generated rules are automatically obtained via the @('defopeners-names') companion tool of @('defopeners'). While @(tsee defopener) simplifies the expansion, @('defopeners') does not; since we use the rules in a symbolic execution, we expect that the simplification will take place there.") (xdoc::p "We generate opener rules for all the (singly and mutually) recursive @('exec-...') functions except @(tsee exec-fun) (more on this below), as well as for some other recursive functions. The opener rules have hypotheses saying that certain arguments are (quoted) constants, which is what we expect in the symbolic execution. For @(tsee read-var-aux) and @(tsee write-var-aux), we also add @(tsee syntaxp) hypotheses saying that the list of scopes has the form @('(cons ...)'), because this is what we expect to happen during symbolic execution. The latter is motivated by the fact that, during the symbolic execution, the list of scopes in a frame has the form of a nest of @(tsee cons)es, with some constant and some non-constant parts.") (xdoc::p "We avoid opener rules for @(tsee exec-fun) because we use the correctness theorems of callees in the correctness proofs of callers. Those correctness theorems are expressed in terms of @(tsee exec-fun), so we do not want to expand @(tsee exec-fun). See the proof generation code for more details.") (xdoc::p "We collect all the openers rules in a ruleset, to make it easier to collect them incrementally as they are introduced.")) (def-ruleset atc-openers nil) (progn (defopeners exec-expr-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure))) (progn (defopeners exec-expr-pure-list :hyps ((syntaxp (quotep es))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure-list))) (progn (defopeners exec-expr-call-or-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-call-or-pure))) (progn (defopeners exec-expr-asg :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-asg))) (progn (defopeners exec-stmt :hyps ((syntaxp (quotep s))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt))) (progn (defopeners exec-stmt-while :hyps ((syntaxp (quote test)) (syntaxp (quote body))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt-while))) (progn (defopeners exec-block-item :hyps ((syntaxp item)) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item))) (progn (defopeners exec-block-item-list :hyps ((syntaxp (quotep items))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item-list))) (progn (defopeners init-scope :hyps ((syntaxp formals)) :disable t) (add-to-ruleset atc-openers (defopeners-names init-scope))) (progn (defopeners read-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names read-var-aux))) (progn (defopeners write-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names write-var-aux)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (make-event `(defval *atc-opener-rules* :short "List of opener rules for the proofs generated by ATC." ',(get-ruleset 'atc-openers (w state)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-executable-counterpart-rules* :short "List of executable counterpart rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, some data is constant, especially the C abstract sytactic entities being executed. In the course of the symbolic execution, terms appear with functions applied to quoted constants. Those can be simplified via the executable counterparts of such functions. We collect all such rules here. Many of them are fixtype deconstructors; there are also some fixers and some constructors. The one for @(tsee zp) serves when testing the limit value, which is a (large) constant. This list may not be exhaustive; we may add more as needed.")) '((:e binop-fix) (:e binop-kind) (:e binop-purep) (:e binop-strictp) (:e block-item-declon->get) (:e block-item-kind) (:e block-item-stmt->get) (:e booleanp) (:e compustate) (:e compustate->frames) (:e compustate-fix) (:e const-int->get) (:e const-kind) (:e declon->init) (:e declon->declor) (:e declon->type) (:e declor->ident) (:e declor->pointerp) (:e expr-arrsub->arr) (:e expr-arrsub->sub) (:e expr-binary->arg1) (:e expr-binary->arg2) (:e expr-binary->op) (:e expr-call->args) (:e expr-call->fun) (:e expr-cast->type) (:e expr-cast->arg) (:e expr-cond->else) (:e expr-cond->test) (:e expr-cond->then) (:e expr-const->get) (:e expr-fix) (:e expr-ident->get) (:e expr-kind) (:e expr-unary->arg) (:e expr-unary->op) (:e exprp) (:e frame-list-fix) (:e fun-env-lookup) (:e fun-info->body) (:e fun-info->params) (:e fun-info->result) (:e iconst->base) (:e iconst->type) (:e iconst->unsignedp) (:e iconst->value) (:e iconst-fix) (:e iconst-tysuffix-kind) (:e ident) (:e ident-fix) (:e identp) (:e init-fun-env) (:e len) (:e natp) (:e omap::in) (:e param-declon->declor) (:e param-declon->type) (:e param-declon-list-fix) (:e scope-list-fix) (:e scope-listp) (:e scopep) (:e schar-integerp) (:e uchar-integerp) (:e sshort-integerp) (:e ushort-integerp) (:e sint-integerp) (:e uint-integerp) (:e slong-integerp) (:e ulong-integerp) (:e sllong-integerp) (:e ullong-integerp) (:e stmt-compound->items) (:e stmt-expr->get) (:e stmt-fix) (:e stmt-if->test) (:e stmt-if->then) (:e stmt-ifelse->else) (:e stmt-ifelse->test) (:e stmt-ifelse->then) (:e stmt-kind) (:e stmt-return->value) (:e stmt-while->test) (:e stmt-while->body) (:e tyname) (:e type-kind) (:e type-name-to-type) (:e type-pointer) (:e type-schar) (:e type-uchar) (:e type-sshort) (:e type-ushort) (:e type-sint) (:e type-uint) (:e type-slong) (:e type-ulong) (:e type-sllong) (:e type-ullong) (:e unop-fix) (:e unop-kind) (:e valuep) (:e value-list-fix) (:e value-listp) (:e zp))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-shift-definition-rules* :short "List of definition rules for shift operations for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ACL2 functions that model shift operations on C integers. They are expanded in proofs because they are defined in terms of the ACL2 functions that model shift operations on C integers (first argument) and ACL2 integers (second argument). We include in this list not only the function themselves, but also the ones expressing their guards.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-shl/shr-names-loop-left-types types types)) :prepwork ((define atc-shl/shr-names-loop-right-types ((ltype typep) (rtypes type-listp)) :guard (and (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype (car rtypes))) (shl (pack 'shl- lfixtype '- rfixtype)) (shr (pack 'shr- lfixtype '- rfixtype)) (shl-okp (pack shl '-okp)) (shr-okp (pack shr '-okp))) (list* shl shr shl-okp shr-okp (atc-shl/shr-names-loop-right-types ltype (cdr rtypes))))))) (define atc-shl/shr-names-loop-left-types ((ltypes type-listp) (rtypes type-listp)) :guard (and (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-shl/shr-names-loop-right-types (car ltypes) rtypes) (atc-shl/shr-names-loop-left-types (cdr ltypes) rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-conv-definition-rules* :short "List of definition rules for operations that involve one C integer type and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types of rank lower than @('int'): these involve conversions in the sense that the operand is promoted prior to being operated upon. We exclude logical negation from the operations here, because that operation does not promote the operand. We include the shift operations with ACL2 integers as second arguments.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort)))) (atc-integer-ops-1-conv-names-loop-ops '(plus minus bitnot shl shr) types)) :prepwork ((define atc-integer-ops-1-conv-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (name symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type)) (names (if (and (eq op 'minus) (type-signed-integerp type)) (list (pack op '- fixtype) (pack op '- fixtype '-okp)) (list (pack op '- fixtype)))) (more-names (atc-integer-ops-1-conv-names-loop-types op (cdr types)))) (append names more-names))))) (define atc-integer-ops-1-conv-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-conv-names-loop-types (car ops) types) (atc-integer-ops-1-conv-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-conv-definition-rules* :short "List of definition rules for operations that involve two C integer types and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types that differ or that have rank lower than @('int'): these involve conversions in the sense that the operands are subjected to the usual arithmetic conversions prior to being operated upon.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on equal types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-conv-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-conv-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) ((when (and (equal type ltype) (equal type rtype))) (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (names (if (or (member-eq op '(div rem)) (and (type-signed-integerp type) (member-eq op '(add sub mul)))) (list (pack op '- lfixtype '- rfixtype) (pack op '- lfixtype '- rfixtype '-okp)) (list (pack op '- lfixtype '- rfixtype)))) (more-names (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes)))) (append names more-names)))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-conv-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-conv-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-conv-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-conv-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-conv-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-conv-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-definition-rules* :short "List of definition rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, terms appear with certain non-recursive functions applied to terms that are not constant, but contain constant parts. These can be simplified by opening the function definition, which ACL2's heuristics (we believe) should never block, given that they are not recursive. Some are @('exec-...') functions, others are functions to manipulate the frame stack, etc.") (xdoc::p "We expand @(tsee condexpr) because it is just a wrapper that signifies a conditional expression instead of statement.") (xdoc::p "It may seem surprising that we expand functions like @(tsee sint-dec-const), since those correspond to C constructs; we certainly do not expand functions like @(tsee add-sint-sint). The reason is that functions like @(tsee sint-dec-const) are used to represent C constants in ACL2 functions, but in the dynamic semantics, @(tsee exec-iconst) (which we expand, obviously) produces terms of the form @('(sint <quoted-integer>)'). By expanding @(tsee sint-dec-const) in the ACL2 functions, we produce terms of the form @('(sint <quoted-integer>)'), which therefore match the ones from @(tsee exec-iconst).") (xdoc::p "We do not expand any fixtype constructors. This is because such expansions would expose the internal representational details of the fixtype's values. Instead, we want to operate on those as more abstract entities, and use deconstructors to obtain their components. In fact, as explained elsewhere, we enable rules that simplify applications of deconstructors to constructors.") (xdoc::p "We expand @(tsee sint-from-boolean), because it is really just an abbreviation. In fact, we want to expose its @(tsee if) structure in the symbolic execution.")) (append '(compustate-frames-number condexpr declar assign create-var endp enter-scope exit-scope exec-iconst exec-const exec-ident exec-plus exec-minus exec-bitnot exec-lognot exec-unary exec-mul exec-div exec-rem exec-add exec-sub exec-shl exec-shr exec-lt exec-gt exec-le exec-ge exec-eq exec-ne exec-bitand exec-bitxor exec-bitior exec-binary-strict-pure exec-test exec-integer exec-binary-logand exec-binary-logor exec-binary-pure exec-cast exec-arrsub promote-value mv-nth pop-frame push-frame read-var sint-from-boolean sint-dec-const sint-oct-const sint-hex-const uint-dec-const uint-oct-const uint-hex-const slong-dec-const slong-oct-const slong-hex-const ulong-dec-const ulong-oct-const ulong-hex-const sllong-dec-const sllong-oct-const sllong-hex-const ullong-dec-const ullong-oct-const ullong-hex-const top-frame type-of-value uaconvert-values uchar-array-sint-index-okp uchar-array-read-sint uchar-array-write-sint value-unsigned-integerp value-signed-integerp value-integerp value-realp value-arithmeticp value-scalarp write-var) *atc-shift-definition-rules* *atc-integer-ops-1-conv-definition-rules* *atc-integer-ops-2-conv-definition-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-rewrite-rules :short "Rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, certain term patterns appear, which are amenable to simplification via the following rewrite rules. These are non-opener rewrite rules; opener rules are considered separately (see @(tsee atc-opener-rules)).") (xdoc::p "The following rules are general and should be probably moved to a more general place. For now we put them here, disabled.") (xdoc::p "Some of the following rewrite rules, in combinations with external ones, may exhibit backchaining circularities. However, it looks like ACL2's ancestor checks should avoid actual circularities, in effect limiting the application of different partial ``arcs'' of the circles in different situations. Anyways, this is being flagged here as something to watch for.") (xdoc::p "The rule @('c::len-of-cons') below is a duplicate of @('acl2::len-of-cons') from at least two list libraries, but this way we avoid having this file depend on those list libraries; the theorem is very simple and small, so it is not a lot of duplication.") (xdoc::p "We also have two rules to simplify applications of @(tsee boolean-from-sint) to @('(sint 0)') and @('(sint 1)'). These applications appear during symbolic execution, because in C certain ``boolean'' expressions produce those @('int') values, and @(tsee boolean-from-sint) is used to turn those into ACL2 booleans, which are uses in @(tsee if)s, and thus we clearly want to simplify those application to @('t') and @('nil'), which further simplifies the @(tsee if)s.") (xdoc::p "We also have two rules to simplify applications of @(tsee lognot-sint) to @('(sint 0)') and @('(sint 1)'). Terms of this form may arise in the process of simplifying C non-strict expressions involving @('&&') and @('||').") (xdoc::p "We also found it necessary to include rules to distribute two specific functions over @(tsee if)s. It seems that, in the course of these symbolic execution proofs, we will always want to distribute functions over @(tsee if)s. This distribution happens at the goal level, but not in the rewriter by default.") (xdoc::p "The two @('not-zp-of-limit-...') rules serve to relieve the recurring hypothesis that the limit is never 0 during the symbolic execution. Initially the limit is a variable, and the first rule applies; the hypothesis of this rule is easily discharged by the inequality assumption over the initial limit in the symbolic execution theorem, via ACL2's linear arithmetic. The @(tsee syntaxp) hypothesis restricts the application of the rule to the case in which the limit is a variable (which is true initially). As the symbolic execution proceeds, 1 gets repeatedly subtracted from the initial limit variable, and it appears that ACL2 automatically combines multiple 1s into constants larger than 1, giving the pattern @('(binary-+ \'<negative-integer> <limit-variable>)'). This is the pattern in the second rule @('not-zp-of-limit-...'), whose hypothesis about the limit variable is easily discharged via linear arithmetic.")) (defruled not-zp-of-limit-variable (implies (and (syntaxp (symbolp limit)) (integerp limit) (> limit 0)) (not (zp limit)))) (defruled not-zp-of-limit-minus-const (implies (and (syntaxp (quotep -c)) (integerp -c) (< -c 0) (integerp limit) (> limit (- -c))) (not (zp (binary-+ -c limit))))) (defruled value-result-fix-when-valuep (implies (valuep x) (equal (value-result-fix x) x))) (defruled not-errorp-when-valuep (implies (valuep x) (not (errorp x))) :enable (errorp valuep ucharp scharp ushortp sshortp uintp sintp ulongp slongp ullongp sllongp pointerp)) (defruled not-errorp-when-value-listp (implies (value-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-scopep (implies (scopep x) (not (errorp x))) :enable (errorp scopep)) (defruled not-errorp-when-scope-listp (implies (scope-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-uchar-arrayp (implies (uchar-arrayp x) (not (errorp x))) :enable (errorp uchar-arrayp)) (defruled not-errorp-when-booleanp (implies (booleanp x) (not (errorp x))) :enable errorp) (defruled len-of-cons (equal (len (cons x y)) (1+ (len y))) :prep-books ((include-book "std/lists/len" :dir :system))) (defruled 1+len-greater-than-0 (> (1+ (len x)) 0)) (defruled boolean-from-sint-of-0 (equal (boolean-from-sint (sint 0)) nil)) (defruled boolean-from-sint-of-1 (equal (boolean-from-sint (sint 1)) t)) (defruled lognot-sint-of-0 (equal (lognot-sint (sint 0)) (sint 1))) (defruled lognot-sint-of-1 (equal (lognot-sint (sint 1)) (sint 0))) (defruled car-of-if (equal (car (if a b c)) (if a (car b) (car c)))) (defruled mv-nth-of-if (equal (mv-nth n (if a b c)) (if a (mv-nth n b) (mv-nth n c)))) (defruled len-of-if (equal (len (if a b c)) (if a (len b) (len c)))) (defruled value-result-fix-of-if (equal (value-result-fix (if a b c)) (if a (value-result-fix b) (value-result-fix c)))) (defruled errorp-of-if (equal (errorp (if a b c)) (if a (errorp b) (errorp c)))) (defruled valuep-of-if (equal (valuep (if a b c)) (if a (valuep b) (valuep c)))) (defruled scharp-of-if (equal (scharp (if a b c)) (if a (scharp b) (scharp c)))) (defruled ucharp-of-if (equal (ucharp (if a b c)) (if a (ucharp b) (ucharp c)))) (defruled sshortp-of-if (equal (sshortp (if a b c)) (if a (sshortp b) (sshortp c)))) (defruled ushortp-of-if (equal (ushortp (if a b c)) (if a (ushortp b) (ushortp c)))) (defruled sintp-of-if (equal (sintp (if a b c)) (if a (sintp b) (sintp c)))) (defruled uintp-of-if (equal (uintp (if a b c)) (if a (uintp b) (uintp c)))) (defruled slongp-of-if (equal (slongp (if a b c)) (if a (slongp b) (slongp c)))) (defruled ulongp-of-if (equal (ulongp (if a b c)) (if a (ulongp b) (ulongp c)))) (defruled sllongp-of-if (equal (sllongp (if a b c)) (if a (sllongp b) (sllongp c)))) (defruled ullongp-of-if (equal (ullongp (if a b c)) (if a (ullongp b) (ullongp c)))) (defruled pointerp-of-if (equal (pointerp (if a b c)) (if a (pointerp b) (pointerp c)))) (defruled compustate->frames-of-if (equal (compustate->frames (if a b c)) (if a (compustate->frames b) (compustate->frames c)))) (defruled 1+nat-greater-than-0 (implies (natp x) (< 0 (1+ x)))) (defruled natp-of-1+ (implies (natp x) (natp (1+ x)))) (defruled natp-of-len (natp (len x)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-return-names-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-return-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (argfixtype (atc-integer-type-fixtype type)) (restype (if (eq op 'lognot) (type-sint) (promote-type type))) (resfixtype (atc-integer-type-fixtype restype)) (respred (pack resfixtype 'p))) (cons (pack respred '-of- op '- argfixtype) (atc-integer-ops-1-return-names-loop-types op (cdr types))))))) (define atc-integer-ops-1-return-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-return-names-loop-types (car ops) types) (atc-integer-ops-1-return-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-return-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-return-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (fixtype (atc-integer-type-fixtype type)) (pred (pack fixtype 'p))) (cons (pack pred '-of- op '- lfixtype '- rfixtype) (atc-integer-ops-2-return-names-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-return-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-return-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-return-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-return-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-return-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-return-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-return-names-loop-src-types types types)) :prepwork ((define atc-integer-convs-return-names-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes))) (pred (pack dfixtype 'p))) (cons (pack pred '-of- dfixtype '-from- sfixtype) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-return-names-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-return-names-loop-dst-types (car stypes) dtypes) (atc-integer-convs-return-names-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-rewrite-rules* :short "List of rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These exlude the openers (see @(tsee *atc-opener-rules*)), and include not only the rules defined in @(see atc-rewrite-rules), but also other existing rewrite rules. Note that some of them serve to simplify fixtype deconstructors applied to constructors.") (xdoc::p "We take the opportunity here to discuss the general shape of the computation state terms during the symbolic execution. They have the form @('(compustate <frames>)'), where @('<frames>') is a @(tsee cons) nest of frames (possibly @('nil'), when there are no frames). Each frame has the form @('(frame <fun-id> <scopes>)'), where @('<fun-id>') is a quoted constant with the function identifier (the quoted constant being produced by the rules enabled in symbolic execution), and where @('<scopes>') is a @(tsee cons) nest of scopes, never @('nil') due to the invariant on the @(tsee scope) fixtype. Each scope is an @(tsee omap::update) nest, possibly @('nil'): note that @(tsee omap::update) is a constructor of non-empty omaps, @('nil') being the one for empty omaps. In this nest, the keys of the map are quoted constants for C variable identifiers, while the values are shallowly embedded C expressions, which depend on the ACL2 variables in the formulation of each functional correctness theorem, which are also the formal parameters of the ACL2 function that the functional correctness theorem pertains to.") (xdoc::p "Given the above, it should not be surprising to see rules like @('omap::in-of-update'), which serves to simplify, during symbolic execution, the finding of a variable in a scope.")) (append '(;; introduced in this file (see ATC-REWRITE-RULES): not-zp-of-limit-variable not-zp-of-limit-minus-const value-result-fix-when-valuep not-errorp-when-valuep not-errorp-when-value-listp not-errorp-when-scopep not-errorp-when-scope-listp not-errorp-when-uchar-arrayp not-errorp-when-booleanp len-of-cons 1+len-greater-than-0 boolean-from-sint-of-0 boolean-from-sint-of-1 lognot-sint-of-0 lognot-sint-of-1 car-of-if mv-nth-of-if len-of-if value-result-fix-of-if errorp-of-if valuep-of-if scharp-of-if ucharp-of-if sshortp-of-if ushortp-of-if sintp-of-if uintp-of-if slongp-of-if ulongp-of-if sllongp-of-if ullongp-of-if pointerp-of-if compustate->frames-of-if 1+nat-greater-than-0 natp-of-1+ natp-of-len ;; introduced elsewhere: booleanp-of-boolean-from-uchar booleanp-of-boolean-from-schar booleanp-of-boolean-from-ushort booleanp-of-boolean-from-sshort booleanp-of-boolean-from-uint booleanp-of-boolean-from-sint booleanp-of-boolean-from-ulong booleanp-of-boolean-from-slong booleanp-of-boolean-from-ullong booleanp-of-boolean-from-sllong car-cons cdr-cons compustate-of-fields compustate->frames-of-compustate compustate->heap-of-compustate compustate-fix-when-compustatep compustatep-of-compustate frame->function-of-frame frame->scopes-of-frame frame-fix-when-framep frame-list-fix-of-cons frame-list-fix-when-frame-listp frame-listp-of-compustate->frames framep-of-frame heap-fix-when-heapp heapp-of-compustate->heap not-errorp-when-compustatep omap::in-of-update pop-frame-of-push-frame scope-fix-when-scopep scope-list-fix-of-cons scope-listp-of-cons scopep-of-update schar-fix-when-scharp uchar-fix-when-ucharp sshort-fix-when-sshortp ushort-fix-when-ushortp sint-fix-when-sintp uint-fix-when-uintp slong-fix-when-slongp ulong-fix-when-ulongp sllong-fix-when-sllongp ullong-fix-when-ullongp scharp-of-schar ucharp-of-uchar sshortp-of-sshort ushortp-of-ushort sintp-of-sint uintp-of-uint slongp-of-slong ulongp-of-ulong sllongp-of-sllong ullongp-of-ullong ucharp-of-uchar-array-read-sint ucharp-of-uchar-array-read top-frame-of-push-frame valuep-when-pointerp valuep-when-scharp valuep-when-ucharp valuep-when-sshortp valuep-when-ushortp valuep-when-sintp valuep-when-uintp valuep-when-slongp valuep-when-ulongp valuep-when-sllongp valuep-when-ullongp value-fix-when-valuep value-listp-of-cons value-list-fix-of-cons value-optionp-when-valuep) ;; also introduced elsewhere: *value-disjoint-rules* *atc-integer-ops-1-return-rewrite-rules* *atc-integer-ops-2-return-rewrite-rules* *atc-integer-convs-return-rewrite-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-type-presc-rules-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-type-presc-rules-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rules true-list-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type))) (cons (list :t (pack op '- fixtype)) (atc-integer-ops-1-type-presc-rules-loop-types op (cdr types))))))) (define atc-integer-ops-1-type-presc-rules-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rule true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-type-presc-rules-loop-types (car ops) types) (atc-integer-ops-1-type-presc-rules-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-type-presc-rules-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-type-presc-rules-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype))) (cons (list :t (pack op '- lfixtype '- rfixtype)) (atc-integer-ops-2-type-presc-rules-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-type-presc-rules-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-type-presc-rules-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-type-presc-rules-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-type-presc-rules-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-type-prescription-rules* :short "List of type prescription rules for the models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-type-presc-rules-loop-src-types types types)) :prepwork ((define atc-integer-convs-type-presc-rules-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes)))) (cons (list :t (pack dfixtype '-from- sfixtype)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-type-presc-rules-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-type-presc-rules-loop-dst-types (car stypes) dtypes) (atc-integer-convs-type-presc-rules-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-type-prescription-rules* :short "List of type prescription rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "In the dynamic semantics, the execution of statements and other entities returns @(tsee mv) values, which logically satisfy @(tsee consp); the negated application of @(tsee consp) to those execution functions comes up in certain subgoals, so a simple way to discharge those subgoals is to use the type prescription rules for those execution functions.") (xdoc::p "We also need rules about the constructors of C integer values and the C functions that represent C operations and conversions, including array read operations.")) (append '((:t exec-expr-call-or-pure) (:t exec-fun) (:t exec-stmt) (:t exec-block-item) (:t exec-block-item-list) (:t schar) (:t uchar) (:t sshort) (:t ushort) (:t sint) (:t uint) (:t slong) (:t ulong) (:t sllong) (:t ullong) (:t uchar-array-read-sint) (:t uchar-array-read)) *atc-integer-ops-1-type-prescription-rules* *atc-integer-ops-2-type-prescription-rules* *atc-integer-convs-type-prescription-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-compound-recognizer-rules* :short "List of compound recognizer rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "The type prescription rules in @(tsee *atc-type-prescription-rules*) cover all the shallowly embedded C expressions except for variables. In the scenarios explained in @(tsee *atc-type-prescription-rules*), we may need to establish that a variable is not @('nil'), which must follow from the guard hypotheses. For this, we use the compound recognizer rule below. The fact that the type is @(tsee consp) is actually not important; what is important is that it does not include @('nil'), i.e. it is logically true.")) '(consp-when-scharp consp-when-ucharp consp-when-sshortp consp-when-ushortp consp-when-sintp consp-when-uintp consp-when-slongp consp-when-ulongp consp-when-sllongp consp-when-ullongp)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-all-rules* :short "List of all the (generic) rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ones used in all the generated proofs. In addition, each proof includes a few additional rules that depend on the specific C-representing ACL2 functions involved. See @(see atc-implementation).")) (append *atc-opener-rules* *atc-executable-counterpart-rules* *atc-definition-rules* *atc-rewrite-rules* *atc-type-prescription-rules* *atc-compound-recognizer-rules*))
8523
; C Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; Copyright (C) 2021 Kestrel Technology LLC (http://kestreltechnology.com) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "C") (include-book "dynamic-semantics") (include-book "kestrel/utilities/defopeners" :dir :system) (include-book "tools/rulesets" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc+ atc-proof-support :parents (atc-implementation) :short "Rules to support the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "Currently, the generated proofs of function correctness are carried out via symbolic execution of the C code. The C code is a constant value, because we are generating proofs over specific C functions.") (xdoc::p "In order to make these generated proofs more robust, we carry them out in a theory that consists exactly of (what we believe to be) all and only the needed rules. This file defines that theory, which consists of rules introduced elsewhere and rules introduced in this file. This set of rules has been defined by experimenting with several symbolic execution proofs, starting with the empty theory and adding rules as needed to advance the symbolic execution, and also by looking at the C dynamic semantics. There is no guarantee (meta proof) that these rules will suffice for every use of ATC; there is also no guarantee that the proof will not be defeated by some ACL2 heuristic in some cases. Nonetheless, the proof strategy seems sound and robust, and if a generated proof fails it should be possible to (prove and) use additional rules.")) :order-subtopics t :default-parent t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-opener-rules :short "Opener rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "To symbolically execute the generated C code, we need to unfold the recursive execution functions, as well as other recursive functions.") (xdoc::p "In general, just enabling recursive functions in ACL2 does not guarantee that their calls will be expanded when desired: ACL2 has heuristics to inhibit the unfolding sometimes, to avoid infinite loops. When the values over which a recursive function recurses are constant, as it happens in our symbolic execution, then we know that the expansion is always safe, but experiments suggest that ACL2's heuristics sometimes block those expansions. For this reason, it is better to have opener rules, i.e. rules that expand function calls, according to the function definitions, under suitable conditions.") (xdoc::p "We use the @('defopeners') utility from @('[books]/kestrel/utilities/defopeners'). Compared to the @(tsee defopener) utility, @('defopeners') generates multiple opener rules (note the plural vs. singular name), corresponding to the conditional structure of the function. In general, there will be some base cases and some step cases; the former have @('base') in the generated rule names, while the latter have @('unroll') in the generated rule names. The names of the generated rules are automatically obtained via the @('defopeners-names') companion tool of @('defopeners'). While @(tsee defopener) simplifies the expansion, @('defopeners') does not; since we use the rules in a symbolic execution, we expect that the simplification will take place there.") (xdoc::p "We generate opener rules for all the (singly and mutually) recursive @('exec-...') functions except @(tsee exec-fun) (more on this below), as well as for some other recursive functions. The opener rules have hypotheses saying that certain arguments are (quoted) constants, which is what we expect in the symbolic execution. For @(tsee read-var-aux) and @(tsee write-var-aux), we also add @(tsee syntaxp) hypotheses saying that the list of scopes has the form @('(cons ...)'), because this is what we expect to happen during symbolic execution. The latter is motivated by the fact that, during the symbolic execution, the list of scopes in a frame has the form of a nest of @(tsee cons)es, with some constant and some non-constant parts.") (xdoc::p "We avoid opener rules for @(tsee exec-fun) because we use the correctness theorems of callees in the correctness proofs of callers. Those correctness theorems are expressed in terms of @(tsee exec-fun), so we do not want to expand @(tsee exec-fun). See the proof generation code for more details.") (xdoc::p "We collect all the openers rules in a ruleset, to make it easier to collect them incrementally as they are introduced.")) (def-ruleset atc-openers nil) (progn (defopeners exec-expr-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure))) (progn (defopeners exec-expr-pure-list :hyps ((syntaxp (quotep es))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure-list))) (progn (defopeners exec-expr-call-or-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-call-or-pure))) (progn (defopeners exec-expr-asg :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-asg))) (progn (defopeners exec-stmt :hyps ((syntaxp (quotep s))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt))) (progn (defopeners exec-stmt-while :hyps ((syntaxp (quote test)) (syntaxp (quote body))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt-while))) (progn (defopeners exec-block-item :hyps ((syntaxp item)) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item))) (progn (defopeners exec-block-item-list :hyps ((syntaxp (quotep items))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item-list))) (progn (defopeners init-scope :hyps ((syntaxp formals)) :disable t) (add-to-ruleset atc-openers (defopeners-names init-scope))) (progn (defopeners read-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names read-var-aux))) (progn (defopeners write-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names write-var-aux)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (make-event `(defval *atc-opener-rules* :short "List of opener rules for the proofs generated by ATC." ',(get-ruleset 'atc-openers (w state)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-executable-counterpart-rules* :short "List of executable counterpart rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, some data is constant, especially the C abstract sytactic entities being executed. In the course of the symbolic execution, terms appear with functions applied to quoted constants. Those can be simplified via the executable counterparts of such functions. We collect all such rules here. Many of them are fixtype deconstructors; there are also some fixers and some constructors. The one for @(tsee zp) serves when testing the limit value, which is a (large) constant. This list may not be exhaustive; we may add more as needed.")) '((:e binop-fix) (:e binop-kind) (:e binop-purep) (:e binop-strictp) (:e block-item-declon->get) (:e block-item-kind) (:e block-item-stmt->get) (:e booleanp) (:e compustate) (:e compustate->frames) (:e compustate-fix) (:e const-int->get) (:e const-kind) (:e declon->init) (:e declon->declor) (:e declon->type) (:e declor->ident) (:e declor->pointerp) (:e expr-arrsub->arr) (:e expr-arrsub->sub) (:e expr-binary->arg1) (:e expr-binary->arg2) (:e expr-binary->op) (:e expr-call->args) (:e expr-call->fun) (:e expr-cast->type) (:e expr-cast->arg) (:e expr-cond->else) (:e expr-cond->test) (:e expr-cond->then) (:e expr-const->get) (:e expr-fix) (:e expr-ident->get) (:e expr-kind) (:e expr-unary->arg) (:e expr-unary->op) (:e exprp) (:e frame-list-fix) (:e fun-env-lookup) (:e fun-info->body) (:e fun-info->params) (:e fun-info->result) (:e iconst->base) (:e iconst->type) (:e iconst->unsignedp) (:e iconst->value) (:e iconst-fix) (:e iconst-tysuffix-kind) (:e ident) (:e ident-fix) (:e identp) (:e init-fun-env) (:e len) (:e natp) (:e omap::in) (:e param-declon->declor) (:e param-declon->type) (:e param-declon-list-fix) (:e scope-list-fix) (:e scope-listp) (:e scopep) (:e schar-integerp) (:e uchar-integerp) (:e sshort-integerp) (:e ushort-integerp) (:e sint-integerp) (:e uint-integerp) (:e slong-integerp) (:e ulong-integerp) (:e sllong-integerp) (:e ullong-integerp) (:e stmt-compound->items) (:e stmt-expr->get) (:e stmt-fix) (:e stmt-if->test) (:e stmt-if->then) (:e stmt-ifelse->else) (:e stmt-ifelse->test) (:e stmt-ifelse->then) (:e stmt-kind) (:e stmt-return->value) (:e stmt-while->test) (:e stmt-while->body) (:e tyname) (:e type-kind) (:e type-name-to-type) (:e type-pointer) (:e type-schar) (:e type-uchar) (:e type-sshort) (:e type-ushort) (:e type-sint) (:e type-uint) (:e type-slong) (:e type-ulong) (:e type-sllong) (:e type-ullong) (:e unop-fix) (:e unop-kind) (:e valuep) (:e value-list-fix) (:e value-listp) (:e zp))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-shift-definition-rules* :short "List of definition rules for shift operations for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ACL2 functions that model shift operations on C integers. They are expanded in proofs because they are defined in terms of the ACL2 functions that model shift operations on C integers (first argument) and ACL2 integers (second argument). We include in this list not only the function themselves, but also the ones expressing their guards.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-shl/shr-names-loop-left-types types types)) :prepwork ((define atc-shl/shr-names-loop-right-types ((ltype typep) (rtypes type-listp)) :guard (and (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype (car rtypes))) (shl (pack 'shl- lfixtype '- rfixtype)) (shr (pack 'shr- lfixtype '- rfixtype)) (shl-okp (pack shl '-okp)) (shr-okp (pack shr '-okp))) (list* shl shr shl-okp shr-okp (atc-shl/shr-names-loop-right-types ltype (cdr rtypes))))))) (define atc-shl/shr-names-loop-left-types ((ltypes type-listp) (rtypes type-listp)) :guard (and (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-shl/shr-names-loop-right-types (car ltypes) rtypes) (atc-shl/shr-names-loop-left-types (cdr ltypes) rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-conv-definition-rules* :short "List of definition rules for operations that involve one C integer type and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types of rank lower than @('int'): these involve conversions in the sense that the operand is promoted prior to being operated upon. We exclude logical negation from the operations here, because that operation does not promote the operand. We include the shift operations with ACL2 integers as second arguments.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort)))) (atc-integer-ops-1-conv-names-loop-ops '(plus minus bitnot shl shr) types)) :prepwork ((define atc-integer-ops-1-conv-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (name symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type)) (names (if (and (eq op 'minus) (type-signed-integerp type)) (list (pack op '- fixtype) (pack op '- fixtype '-okp)) (list (pack op '- fixtype)))) (more-names (atc-integer-ops-1-conv-names-loop-types op (cdr types)))) (append names more-names))))) (define atc-integer-ops-1-conv-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-conv-names-loop-types (car ops) types) (atc-integer-ops-1-conv-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-conv-definition-rules* :short "List of definition rules for operations that involve two C integer types and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types that differ or that have rank lower than @('int'): these involve conversions in the sense that the operands are subjected to the usual arithmetic conversions prior to being operated upon.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on equal types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-conv-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-conv-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) ((when (and (equal type ltype) (equal type rtype))) (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (names (if (or (member-eq op '(div rem)) (and (type-signed-integerp type) (member-eq op '(add sub mul)))) (list (pack op '- lfixtype '- rfixtype) (pack op '- lfixtype '- rfixtype '-okp)) (list (pack op '- lfixtype '- rfixtype)))) (more-names (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes)))) (append names more-names)))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-conv-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-conv-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-conv-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-conv-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-conv-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-conv-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-definition-rules* :short "List of definition rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, terms appear with certain non-recursive functions applied to terms that are not constant, but contain constant parts. These can be simplified by opening the function definition, which ACL2's heuristics (we believe) should never block, given that they are not recursive. Some are @('exec-...') functions, others are functions to manipulate the frame stack, etc.") (xdoc::p "We expand @(tsee condexpr) because it is just a wrapper that signifies a conditional expression instead of statement.") (xdoc::p "It may seem surprising that we expand functions like @(tsee sint-dec-const), since those correspond to C constructs; we certainly do not expand functions like @(tsee add-sint-sint). The reason is that functions like @(tsee sint-dec-const) are used to represent C constants in ACL2 functions, but in the dynamic semantics, @(tsee exec-iconst) (which we expand, obviously) produces terms of the form @('(sint <quoted-integer>)'). By expanding @(tsee sint-dec-const) in the ACL2 functions, we produce terms of the form @('(sint <quoted-integer>)'), which therefore match the ones from @(tsee exec-iconst).") (xdoc::p "We do not expand any fixtype constructors. This is because such expansions would expose the internal representational details of the fixtype's values. Instead, we want to operate on those as more abstract entities, and use deconstructors to obtain their components. In fact, as explained elsewhere, we enable rules that simplify applications of deconstructors to constructors.") (xdoc::p "We expand @(tsee sint-from-boolean), because it is really just an abbreviation. In fact, we want to expose its @(tsee if) structure in the symbolic execution.")) (append '(compustate-frames-number condexpr declar assign create-var endp enter-scope exit-scope exec-iconst exec-const exec-ident exec-plus exec-minus exec-bitnot exec-lognot exec-unary exec-mul exec-div exec-rem exec-add exec-sub exec-shl exec-shr exec-lt exec-gt exec-le exec-ge exec-eq exec-ne exec-bitand exec-bitxor exec-bitior exec-binary-strict-pure exec-test exec-integer exec-binary-logand exec-binary-logor exec-binary-pure exec-cast exec-arrsub promote-value mv-nth pop-frame push-frame read-var sint-from-boolean sint-dec-const sint-oct-const sint-hex-const uint-dec-const uint-oct-const uint-hex-const slong-dec-const slong-oct-const slong-hex-const ulong-dec-const ulong-oct-const ulong-hex-const sllong-dec-const sllong-oct-const sllong-hex-const ullong-dec-const ullong-oct-const ullong-hex-const top-frame type-of-value uaconvert-values uchar-array-sint-index-okp uchar-array-read-sint uchar-array-write-sint value-unsigned-integerp value-signed-integerp value-integerp value-realp value-arithmeticp value-scalarp write-var) *atc-shift-definition-rules* *atc-integer-ops-1-conv-definition-rules* *atc-integer-ops-2-conv-definition-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-rewrite-rules :short "Rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, certain term patterns appear, which are amenable to simplification via the following rewrite rules. These are non-opener rewrite rules; opener rules are considered separately (see @(tsee atc-opener-rules)).") (xdoc::p "The following rules are general and should be probably moved to a more general place. For now we put them here, disabled.") (xdoc::p "Some of the following rewrite rules, in combinations with external ones, may exhibit backchaining circularities. However, it looks like ACL2's ancestor checks should avoid actual circularities, in effect limiting the application of different partial ``arcs'' of the circles in different situations. Anyways, this is being flagged here as something to watch for.") (xdoc::p "The rule @('c::len-of-cons') below is a duplicate of @('acl2::len-of-cons') from at least two list libraries, but this way we avoid having this file depend on those list libraries; the theorem is very simple and small, so it is not a lot of duplication.") (xdoc::p "We also have two rules to simplify applications of @(tsee boolean-from-sint) to @('(sint 0)') and @('(sint 1)'). These applications appear during symbolic execution, because in C certain ``boolean'' expressions produce those @('int') values, and @(tsee boolean-from-sint) is used to turn those into ACL2 booleans, which are uses in @(tsee if)s, and thus we clearly want to simplify those application to @('t') and @('nil'), which further simplifies the @(tsee if)s.") (xdoc::p "We also have two rules to simplify applications of @(tsee lognot-sint) to @('(sint 0)') and @('(sint 1)'). Terms of this form may arise in the process of simplifying C non-strict expressions involving @('&&') and @('||').") (xdoc::p "We also found it necessary to include rules to distribute two specific functions over @(tsee if)s. It seems that, in the course of these symbolic execution proofs, we will always want to distribute functions over @(tsee if)s. This distribution happens at the goal level, but not in the rewriter by default.") (xdoc::p "The two @('not-zp-of-limit-...') rules serve to relieve the recurring hypothesis that the limit is never 0 during the symbolic execution. Initially the limit is a variable, and the first rule applies; the hypothesis of this rule is easily discharged by the inequality assumption over the initial limit in the symbolic execution theorem, via ACL2's linear arithmetic. The @(tsee syntaxp) hypothesis restricts the application of the rule to the case in which the limit is a variable (which is true initially). As the symbolic execution proceeds, 1 gets repeatedly subtracted from the initial limit variable, and it appears that ACL2 automatically combines multiple 1s into constants larger than 1, giving the pattern @('(binary-+ \'<negative-integer> <limit-variable>)'). This is the pattern in the second rule @('not-zp-of-limit-...'), whose hypothesis about the limit variable is easily discharged via linear arithmetic.")) (defruled not-zp-of-limit-variable (implies (and (syntaxp (symbolp limit)) (integerp limit) (> limit 0)) (not (zp limit)))) (defruled not-zp-of-limit-minus-const (implies (and (syntaxp (quotep -c)) (integerp -c) (< -c 0) (integerp limit) (> limit (- -c))) (not (zp (binary-+ -c limit))))) (defruled value-result-fix-when-valuep (implies (valuep x) (equal (value-result-fix x) x))) (defruled not-errorp-when-valuep (implies (valuep x) (not (errorp x))) :enable (errorp valuep ucharp scharp ushortp sshortp uintp sintp ulongp slongp ullongp sllongp pointerp)) (defruled not-errorp-when-value-listp (implies (value-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-scopep (implies (scopep x) (not (errorp x))) :enable (errorp scopep)) (defruled not-errorp-when-scope-listp (implies (scope-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-uchar-arrayp (implies (uchar-arrayp x) (not (errorp x))) :enable (errorp uchar-arrayp)) (defruled not-errorp-when-booleanp (implies (booleanp x) (not (errorp x))) :enable errorp) (defruled len-of-cons (equal (len (cons x y)) (1+ (len y))) :prep-books ((include-book "std/lists/len" :dir :system))) (defruled 1+len-greater-than-0 (> (1+ (len x)) 0)) (defruled boolean-from-sint-of-0 (equal (boolean-from-sint (sint 0)) nil)) (defruled boolean-from-sint-of-1 (equal (boolean-from-sint (sint 1)) t)) (defruled lognot-sint-of-0 (equal (lognot-sint (sint 0)) (sint 1))) (defruled lognot-sint-of-1 (equal (lognot-sint (sint 1)) (sint 0))) (defruled car-of-if (equal (car (if a b c)) (if a (car b) (car c)))) (defruled mv-nth-of-if (equal (mv-nth n (if a b c)) (if a (mv-nth n b) (mv-nth n c)))) (defruled len-of-if (equal (len (if a b c)) (if a (len b) (len c)))) (defruled value-result-fix-of-if (equal (value-result-fix (if a b c)) (if a (value-result-fix b) (value-result-fix c)))) (defruled errorp-of-if (equal (errorp (if a b c)) (if a (errorp b) (errorp c)))) (defruled valuep-of-if (equal (valuep (if a b c)) (if a (valuep b) (valuep c)))) (defruled scharp-of-if (equal (scharp (if a b c)) (if a (scharp b) (scharp c)))) (defruled ucharp-of-if (equal (ucharp (if a b c)) (if a (ucharp b) (ucharp c)))) (defruled sshortp-of-if (equal (sshortp (if a b c)) (if a (sshortp b) (sshortp c)))) (defruled ushortp-of-if (equal (ushortp (if a b c)) (if a (ushortp b) (ushortp c)))) (defruled sintp-of-if (equal (sintp (if a b c)) (if a (sintp b) (sintp c)))) (defruled uintp-of-if (equal (uintp (if a b c)) (if a (uintp b) (uintp c)))) (defruled slongp-of-if (equal (slongp (if a b c)) (if a (slongp b) (slongp c)))) (defruled ulongp-of-if (equal (ulongp (if a b c)) (if a (ulongp b) (ulongp c)))) (defruled sllongp-of-if (equal (sllongp (if a b c)) (if a (sllongp b) (sllongp c)))) (defruled ullongp-of-if (equal (ullongp (if a b c)) (if a (ullongp b) (ullongp c)))) (defruled pointerp-of-if (equal (pointerp (if a b c)) (if a (pointerp b) (pointerp c)))) (defruled compustate->frames-of-if (equal (compustate->frames (if a b c)) (if a (compustate->frames b) (compustate->frames c)))) (defruled 1+nat-greater-than-0 (implies (natp x) (< 0 (1+ x)))) (defruled natp-of-1+ (implies (natp x) (natp (1+ x)))) (defruled natp-of-len (natp (len x)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-return-names-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-return-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (argfixtype (atc-integer-type-fixtype type)) (restype (if (eq op 'lognot) (type-sint) (promote-type type))) (resfixtype (atc-integer-type-fixtype restype)) (respred (pack resfixtype 'p))) (cons (pack respred '-of- op '- argfixtype) (atc-integer-ops-1-return-names-loop-types op (cdr types))))))) (define atc-integer-ops-1-return-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-return-names-loop-types (car ops) types) (atc-integer-ops-1-return-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-return-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-return-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (fixtype (atc-integer-type-fixtype type)) (pred (pack fixtype 'p))) (cons (pack pred '-of- op '- lfixtype '- rfixtype) (atc-integer-ops-2-return-names-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-return-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-return-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-return-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-return-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-return-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-return-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-return-names-loop-src-types types types)) :prepwork ((define atc-integer-convs-return-names-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes))) (pred (pack dfixtype 'p))) (cons (pack pred '-of- dfixtype '-from- sfixtype) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-return-names-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-return-names-loop-dst-types (car stypes) dtypes) (atc-integer-convs-return-names-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-rewrite-rules* :short "List of rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These exlude the openers (see @(tsee *atc-opener-rules*)), and include not only the rules defined in @(see atc-rewrite-rules), but also other existing rewrite rules. Note that some of them serve to simplify fixtype deconstructors applied to constructors.") (xdoc::p "We take the opportunity here to discuss the general shape of the computation state terms during the symbolic execution. They have the form @('(compustate <frames>)'), where @('<frames>') is a @(tsee cons) nest of frames (possibly @('nil'), when there are no frames). Each frame has the form @('(frame <fun-id> <scopes>)'), where @('<fun-id>') is a quoted constant with the function identifier (the quoted constant being produced by the rules enabled in symbolic execution), and where @('<scopes>') is a @(tsee cons) nest of scopes, never @('nil') due to the invariant on the @(tsee scope) fixtype. Each scope is an @(tsee omap::update) nest, possibly @('nil'): note that @(tsee omap::update) is a constructor of non-empty omaps, @('nil') being the one for empty omaps. In this nest, the keys of the map are quoted constants for C variable identifiers, while the values are shallowly embedded C expressions, which depend on the ACL2 variables in the formulation of each functional correctness theorem, which are also the formal parameters of the ACL2 function that the functional correctness theorem pertains to.") (xdoc::p "Given the above, it should not be surprising to see rules like @('omap::in-of-update'), which serves to simplify, during symbolic execution, the finding of a variable in a scope.")) (append '(;; introduced in this file (see ATC-REWRITE-RULES): not-zp-of-limit-variable not-zp-of-limit-minus-const value-result-fix-when-valuep not-errorp-when-valuep not-errorp-when-value-listp not-errorp-when-scopep not-errorp-when-scope-listp not-errorp-when-uchar-arrayp not-errorp-when-booleanp len-of-cons 1+len-greater-than-0 boolean-from-sint-of-0 boolean-from-sint-of-1 lognot-sint-of-0 lognot-sint-of-1 car-of-if mv-nth-of-if len-of-if value-result-fix-of-if errorp-of-if valuep-of-if scharp-of-if ucharp-of-if sshortp-of-if ushortp-of-if sintp-of-if uintp-of-if slongp-of-if ulongp-of-if sllongp-of-if ullongp-of-if pointerp-of-if compustate->frames-of-if 1+nat-greater-than-0 natp-of-1+ natp-of-len ;; introduced elsewhere: booleanp-of-boolean-from-uchar booleanp-of-boolean-from-schar booleanp-of-boolean-from-ushort booleanp-of-boolean-from-sshort booleanp-of-boolean-from-uint booleanp-of-boolean-from-sint booleanp-of-boolean-from-ulong booleanp-of-boolean-from-slong booleanp-of-boolean-from-ullong booleanp-of-boolean-from-sllong car-cons cdr-cons compustate-of-fields compustate->frames-of-compustate compustate->heap-of-compustate compustate-fix-when-compustatep compustatep-of-compustate frame->function-of-frame frame->scopes-of-frame frame-fix-when-framep frame-list-fix-of-cons frame-list-fix-when-frame-listp frame-listp-of-compustate->frames framep-of-frame heap-fix-when-heapp heapp-of-compustate->heap not-errorp-when-compustatep omap::in-of-update pop-frame-of-push-frame scope-fix-when-scopep scope-list-fix-of-cons scope-listp-of-cons scopep-of-update schar-fix-when-scharp uchar-fix-when-ucharp sshort-fix-when-sshortp ushort-fix-when-ushortp sint-fix-when-sintp uint-fix-when-uintp slong-fix-when-slongp ulong-fix-when-ulongp sllong-fix-when-sllongp ullong-fix-when-ullongp scharp-of-schar ucharp-of-uchar sshortp-of-sshort ushortp-of-ushort sintp-of-sint uintp-of-uint slongp-of-slong ulongp-of-ulong sllongp-of-sllong ullongp-of-ullong ucharp-of-uchar-array-read-sint ucharp-of-uchar-array-read top-frame-of-push-frame valuep-when-pointerp valuep-when-scharp valuep-when-ucharp valuep-when-sshortp valuep-when-ushortp valuep-when-sintp valuep-when-uintp valuep-when-slongp valuep-when-ulongp valuep-when-sllongp valuep-when-ullongp value-fix-when-valuep value-listp-of-cons value-list-fix-of-cons value-optionp-when-valuep) ;; also introduced elsewhere: *value-disjoint-rules* *atc-integer-ops-1-return-rewrite-rules* *atc-integer-ops-2-return-rewrite-rules* *atc-integer-convs-return-rewrite-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-type-presc-rules-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-type-presc-rules-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rules true-list-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type))) (cons (list :t (pack op '- fixtype)) (atc-integer-ops-1-type-presc-rules-loop-types op (cdr types))))))) (define atc-integer-ops-1-type-presc-rules-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rule true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-type-presc-rules-loop-types (car ops) types) (atc-integer-ops-1-type-presc-rules-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-type-presc-rules-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-type-presc-rules-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype))) (cons (list :t (pack op '- lfixtype '- rfixtype)) (atc-integer-ops-2-type-presc-rules-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-type-presc-rules-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-type-presc-rules-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-type-presc-rules-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-type-presc-rules-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-type-prescription-rules* :short "List of type prescription rules for the models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-type-presc-rules-loop-src-types types types)) :prepwork ((define atc-integer-convs-type-presc-rules-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes)))) (cons (list :t (pack dfixtype '-from- sfixtype)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-type-presc-rules-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-type-presc-rules-loop-dst-types (car stypes) dtypes) (atc-integer-convs-type-presc-rules-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-type-prescription-rules* :short "List of type prescription rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "In the dynamic semantics, the execution of statements and other entities returns @(tsee mv) values, which logically satisfy @(tsee consp); the negated application of @(tsee consp) to those execution functions comes up in certain subgoals, so a simple way to discharge those subgoals is to use the type prescription rules for those execution functions.") (xdoc::p "We also need rules about the constructors of C integer values and the C functions that represent C operations and conversions, including array read operations.")) (append '((:t exec-expr-call-or-pure) (:t exec-fun) (:t exec-stmt) (:t exec-block-item) (:t exec-block-item-list) (:t schar) (:t uchar) (:t sshort) (:t ushort) (:t sint) (:t uint) (:t slong) (:t ulong) (:t sllong) (:t ullong) (:t uchar-array-read-sint) (:t uchar-array-read)) *atc-integer-ops-1-type-prescription-rules* *atc-integer-ops-2-type-prescription-rules* *atc-integer-convs-type-prescription-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-compound-recognizer-rules* :short "List of compound recognizer rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "The type prescription rules in @(tsee *atc-type-prescription-rules*) cover all the shallowly embedded C expressions except for variables. In the scenarios explained in @(tsee *atc-type-prescription-rules*), we may need to establish that a variable is not @('nil'), which must follow from the guard hypotheses. For this, we use the compound recognizer rule below. The fact that the type is @(tsee consp) is actually not important; what is important is that it does not include @('nil'), i.e. it is logically true.")) '(consp-when-scharp consp-when-ucharp consp-when-sshortp consp-when-ushortp consp-when-sintp consp-when-uintp consp-when-slongp consp-when-ulongp consp-when-sllongp consp-when-ullongp)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-all-rules* :short "List of all the (generic) rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ones used in all the generated proofs. In addition, each proof includes a few additional rules that depend on the specific C-representing ACL2 functions involved. See @(see atc-implementation).")) (append *atc-opener-rules* *atc-executable-counterpart-rules* *atc-definition-rules* *atc-rewrite-rules* *atc-type-prescription-rules* *atc-compound-recognizer-rules*))
true
; C Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; Copyright (C) 2021 Kestrel Technology LLC (http://kestreltechnology.com) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "C") (include-book "dynamic-semantics") (include-book "kestrel/utilities/defopeners" :dir :system) (include-book "tools/rulesets" :dir :system) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defxdoc+ atc-proof-support :parents (atc-implementation) :short "Rules to support the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "Currently, the generated proofs of function correctness are carried out via symbolic execution of the C code. The C code is a constant value, because we are generating proofs over specific C functions.") (xdoc::p "In order to make these generated proofs more robust, we carry them out in a theory that consists exactly of (what we believe to be) all and only the needed rules. This file defines that theory, which consists of rules introduced elsewhere and rules introduced in this file. This set of rules has been defined by experimenting with several symbolic execution proofs, starting with the empty theory and adding rules as needed to advance the symbolic execution, and also by looking at the C dynamic semantics. There is no guarantee (meta proof) that these rules will suffice for every use of ATC; there is also no guarantee that the proof will not be defeated by some ACL2 heuristic in some cases. Nonetheless, the proof strategy seems sound and robust, and if a generated proof fails it should be possible to (prove and) use additional rules.")) :order-subtopics t :default-parent t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-opener-rules :short "Opener rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "To symbolically execute the generated C code, we need to unfold the recursive execution functions, as well as other recursive functions.") (xdoc::p "In general, just enabling recursive functions in ACL2 does not guarantee that their calls will be expanded when desired: ACL2 has heuristics to inhibit the unfolding sometimes, to avoid infinite loops. When the values over which a recursive function recurses are constant, as it happens in our symbolic execution, then we know that the expansion is always safe, but experiments suggest that ACL2's heuristics sometimes block those expansions. For this reason, it is better to have opener rules, i.e. rules that expand function calls, according to the function definitions, under suitable conditions.") (xdoc::p "We use the @('defopeners') utility from @('[books]/kestrel/utilities/defopeners'). Compared to the @(tsee defopener) utility, @('defopeners') generates multiple opener rules (note the plural vs. singular name), corresponding to the conditional structure of the function. In general, there will be some base cases and some step cases; the former have @('base') in the generated rule names, while the latter have @('unroll') in the generated rule names. The names of the generated rules are automatically obtained via the @('defopeners-names') companion tool of @('defopeners'). While @(tsee defopener) simplifies the expansion, @('defopeners') does not; since we use the rules in a symbolic execution, we expect that the simplification will take place there.") (xdoc::p "We generate opener rules for all the (singly and mutually) recursive @('exec-...') functions except @(tsee exec-fun) (more on this below), as well as for some other recursive functions. The opener rules have hypotheses saying that certain arguments are (quoted) constants, which is what we expect in the symbolic execution. For @(tsee read-var-aux) and @(tsee write-var-aux), we also add @(tsee syntaxp) hypotheses saying that the list of scopes has the form @('(cons ...)'), because this is what we expect to happen during symbolic execution. The latter is motivated by the fact that, during the symbolic execution, the list of scopes in a frame has the form of a nest of @(tsee cons)es, with some constant and some non-constant parts.") (xdoc::p "We avoid opener rules for @(tsee exec-fun) because we use the correctness theorems of callees in the correctness proofs of callers. Those correctness theorems are expressed in terms of @(tsee exec-fun), so we do not want to expand @(tsee exec-fun). See the proof generation code for more details.") (xdoc::p "We collect all the openers rules in a ruleset, to make it easier to collect them incrementally as they are introduced.")) (def-ruleset atc-openers nil) (progn (defopeners exec-expr-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure))) (progn (defopeners exec-expr-pure-list :hyps ((syntaxp (quotep es))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-pure-list))) (progn (defopeners exec-expr-call-or-pure :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-call-or-pure))) (progn (defopeners exec-expr-asg :hyps ((syntaxp (quotep e))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-expr-asg))) (progn (defopeners exec-stmt :hyps ((syntaxp (quotep s))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt))) (progn (defopeners exec-stmt-while :hyps ((syntaxp (quote test)) (syntaxp (quote body))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-stmt-while))) (progn (defopeners exec-block-item :hyps ((syntaxp item)) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item))) (progn (defopeners exec-block-item-list :hyps ((syntaxp (quotep items))) :disable t) (add-to-ruleset atc-openers (defopeners-names exec-block-item-list))) (progn (defopeners init-scope :hyps ((syntaxp formals)) :disable t) (add-to-ruleset atc-openers (defopeners-names init-scope))) (progn (defopeners read-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names read-var-aux))) (progn (defopeners write-var-aux :hyps ((syntaxp (quotep var)) (syntaxp (and (consp scopes) (eq (car scopes) 'cons)))) :disable t) (add-to-ruleset atc-openers (defopeners-names write-var-aux)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (make-event `(defval *atc-opener-rules* :short "List of opener rules for the proofs generated by ATC." ',(get-ruleset 'atc-openers (w state)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-executable-counterpart-rules* :short "List of executable counterpart rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, some data is constant, especially the C abstract sytactic entities being executed. In the course of the symbolic execution, terms appear with functions applied to quoted constants. Those can be simplified via the executable counterparts of such functions. We collect all such rules here. Many of them are fixtype deconstructors; there are also some fixers and some constructors. The one for @(tsee zp) serves when testing the limit value, which is a (large) constant. This list may not be exhaustive; we may add more as needed.")) '((:e binop-fix) (:e binop-kind) (:e binop-purep) (:e binop-strictp) (:e block-item-declon->get) (:e block-item-kind) (:e block-item-stmt->get) (:e booleanp) (:e compustate) (:e compustate->frames) (:e compustate-fix) (:e const-int->get) (:e const-kind) (:e declon->init) (:e declon->declor) (:e declon->type) (:e declor->ident) (:e declor->pointerp) (:e expr-arrsub->arr) (:e expr-arrsub->sub) (:e expr-binary->arg1) (:e expr-binary->arg2) (:e expr-binary->op) (:e expr-call->args) (:e expr-call->fun) (:e expr-cast->type) (:e expr-cast->arg) (:e expr-cond->else) (:e expr-cond->test) (:e expr-cond->then) (:e expr-const->get) (:e expr-fix) (:e expr-ident->get) (:e expr-kind) (:e expr-unary->arg) (:e expr-unary->op) (:e exprp) (:e frame-list-fix) (:e fun-env-lookup) (:e fun-info->body) (:e fun-info->params) (:e fun-info->result) (:e iconst->base) (:e iconst->type) (:e iconst->unsignedp) (:e iconst->value) (:e iconst-fix) (:e iconst-tysuffix-kind) (:e ident) (:e ident-fix) (:e identp) (:e init-fun-env) (:e len) (:e natp) (:e omap::in) (:e param-declon->declor) (:e param-declon->type) (:e param-declon-list-fix) (:e scope-list-fix) (:e scope-listp) (:e scopep) (:e schar-integerp) (:e uchar-integerp) (:e sshort-integerp) (:e ushort-integerp) (:e sint-integerp) (:e uint-integerp) (:e slong-integerp) (:e ulong-integerp) (:e sllong-integerp) (:e ullong-integerp) (:e stmt-compound->items) (:e stmt-expr->get) (:e stmt-fix) (:e stmt-if->test) (:e stmt-if->then) (:e stmt-ifelse->else) (:e stmt-ifelse->test) (:e stmt-ifelse->then) (:e stmt-kind) (:e stmt-return->value) (:e stmt-while->test) (:e stmt-while->body) (:e tyname) (:e type-kind) (:e type-name-to-type) (:e type-pointer) (:e type-schar) (:e type-uchar) (:e type-sshort) (:e type-ushort) (:e type-sint) (:e type-uint) (:e type-slong) (:e type-ulong) (:e type-sllong) (:e type-ullong) (:e unop-fix) (:e unop-kind) (:e valuep) (:e value-list-fix) (:e value-listp) (:e zp))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-shift-definition-rules* :short "List of definition rules for shift operations for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ACL2 functions that model shift operations on C integers. They are expanded in proofs because they are defined in terms of the ACL2 functions that model shift operations on C integers (first argument) and ACL2 integers (second argument). We include in this list not only the function themselves, but also the ones expressing their guards.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-shl/shr-names-loop-left-types types types)) :prepwork ((define atc-shl/shr-names-loop-right-types ((ltype typep) (rtypes type-listp)) :guard (and (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype (car rtypes))) (shl (pack 'shl- lfixtype '- rfixtype)) (shr (pack 'shr- lfixtype '- rfixtype)) (shl-okp (pack shl '-okp)) (shr-okp (pack shr '-okp))) (list* shl shr shl-okp shr-okp (atc-shl/shr-names-loop-right-types ltype (cdr rtypes))))))) (define atc-shl/shr-names-loop-left-types ((ltypes type-listp) (rtypes type-listp)) :guard (and (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-shl/shr-names-loop-right-types (car ltypes) rtypes) (atc-shl/shr-names-loop-left-types (cdr ltypes) rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-conv-definition-rules* :short "List of definition rules for operations that involve one C integer type and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types of rank lower than @('int'): these involve conversions in the sense that the operand is promoted prior to being operated upon. We exclude logical negation from the operations here, because that operation does not promote the operand. We include the shift operations with ACL2 integers as second arguments.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort)))) (atc-integer-ops-1-conv-names-loop-ops '(plus minus bitnot shl shr) types)) :prepwork ((define atc-integer-ops-1-conv-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (name symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type)) (names (if (and (eq op 'minus) (type-signed-integerp type)) (list (pack op '- fixtype) (pack op '- fixtype '-okp)) (list (pack op '- fixtype)))) (more-names (atc-integer-ops-1-conv-names-loop-types op (cdr types)))) (append names more-names))))) (define atc-integer-ops-1-conv-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-conv-names-loop-types (car ops) types) (atc-integer-ops-1-conv-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-conv-definition-rules* :short "List of definition rules for operations that involve two C integer types and that involve conversions." :long (xdoc::topstring (xdoc::p "This is for operations on types that differ or that have rank lower than @('int'): these involve conversions in the sense that the operands are subjected to the usual arithmetic conversions prior to being operated upon.") (xdoc::p "These functions are all expanded in proofs because they are defined in terms of conversions and of operations on equal types of rank at least @('int'): this is what the dynamic semantics of C uses.")) (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-conv-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-conv-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) ((when (and (equal type ltype) (equal type rtype))) (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (names (if (or (member-eq op '(div rem)) (and (type-signed-integerp type) (member-eq op '(add sub mul)))) (list (pack op '- lfixtype '- rfixtype) (pack op '- lfixtype '- rfixtype '-okp)) (list (pack op '- lfixtype '- rfixtype)))) (more-names (atc-integer-ops-2-conv-names-loop-right-types op ltype (cdr rtypes)))) (append names more-names)))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-conv-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-conv-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-conv-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-conv-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-conv-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-conv-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-definition-rules* :short "List of definition rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, terms appear with certain non-recursive functions applied to terms that are not constant, but contain constant parts. These can be simplified by opening the function definition, which ACL2's heuristics (we believe) should never block, given that they are not recursive. Some are @('exec-...') functions, others are functions to manipulate the frame stack, etc.") (xdoc::p "We expand @(tsee condexpr) because it is just a wrapper that signifies a conditional expression instead of statement.") (xdoc::p "It may seem surprising that we expand functions like @(tsee sint-dec-const), since those correspond to C constructs; we certainly do not expand functions like @(tsee add-sint-sint). The reason is that functions like @(tsee sint-dec-const) are used to represent C constants in ACL2 functions, but in the dynamic semantics, @(tsee exec-iconst) (which we expand, obviously) produces terms of the form @('(sint <quoted-integer>)'). By expanding @(tsee sint-dec-const) in the ACL2 functions, we produce terms of the form @('(sint <quoted-integer>)'), which therefore match the ones from @(tsee exec-iconst).") (xdoc::p "We do not expand any fixtype constructors. This is because such expansions would expose the internal representational details of the fixtype's values. Instead, we want to operate on those as more abstract entities, and use deconstructors to obtain their components. In fact, as explained elsewhere, we enable rules that simplify applications of deconstructors to constructors.") (xdoc::p "We expand @(tsee sint-from-boolean), because it is really just an abbreviation. In fact, we want to expose its @(tsee if) structure in the symbolic execution.")) (append '(compustate-frames-number condexpr declar assign create-var endp enter-scope exit-scope exec-iconst exec-const exec-ident exec-plus exec-minus exec-bitnot exec-lognot exec-unary exec-mul exec-div exec-rem exec-add exec-sub exec-shl exec-shr exec-lt exec-gt exec-le exec-ge exec-eq exec-ne exec-bitand exec-bitxor exec-bitior exec-binary-strict-pure exec-test exec-integer exec-binary-logand exec-binary-logor exec-binary-pure exec-cast exec-arrsub promote-value mv-nth pop-frame push-frame read-var sint-from-boolean sint-dec-const sint-oct-const sint-hex-const uint-dec-const uint-oct-const uint-hex-const slong-dec-const slong-oct-const slong-hex-const ulong-dec-const ulong-oct-const ulong-hex-const sllong-dec-const sllong-oct-const sllong-hex-const ullong-dec-const ullong-oct-const ullong-hex-const top-frame type-of-value uaconvert-values uchar-array-sint-index-okp uchar-array-read-sint uchar-array-write-sint value-unsigned-integerp value-signed-integerp value-integerp value-realp value-arithmeticp value-scalarp write-var) *atc-shift-definition-rules* *atc-integer-ops-1-conv-definition-rules* *atc-integer-ops-2-conv-definition-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection atc-rewrite-rules :short "Rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "During symbolic execution, certain term patterns appear, which are amenable to simplification via the following rewrite rules. These are non-opener rewrite rules; opener rules are considered separately (see @(tsee atc-opener-rules)).") (xdoc::p "The following rules are general and should be probably moved to a more general place. For now we put them here, disabled.") (xdoc::p "Some of the following rewrite rules, in combinations with external ones, may exhibit backchaining circularities. However, it looks like ACL2's ancestor checks should avoid actual circularities, in effect limiting the application of different partial ``arcs'' of the circles in different situations. Anyways, this is being flagged here as something to watch for.") (xdoc::p "The rule @('c::len-of-cons') below is a duplicate of @('acl2::len-of-cons') from at least two list libraries, but this way we avoid having this file depend on those list libraries; the theorem is very simple and small, so it is not a lot of duplication.") (xdoc::p "We also have two rules to simplify applications of @(tsee boolean-from-sint) to @('(sint 0)') and @('(sint 1)'). These applications appear during symbolic execution, because in C certain ``boolean'' expressions produce those @('int') values, and @(tsee boolean-from-sint) is used to turn those into ACL2 booleans, which are uses in @(tsee if)s, and thus we clearly want to simplify those application to @('t') and @('nil'), which further simplifies the @(tsee if)s.") (xdoc::p "We also have two rules to simplify applications of @(tsee lognot-sint) to @('(sint 0)') and @('(sint 1)'). Terms of this form may arise in the process of simplifying C non-strict expressions involving @('&&') and @('||').") (xdoc::p "We also found it necessary to include rules to distribute two specific functions over @(tsee if)s. It seems that, in the course of these symbolic execution proofs, we will always want to distribute functions over @(tsee if)s. This distribution happens at the goal level, but not in the rewriter by default.") (xdoc::p "The two @('not-zp-of-limit-...') rules serve to relieve the recurring hypothesis that the limit is never 0 during the symbolic execution. Initially the limit is a variable, and the first rule applies; the hypothesis of this rule is easily discharged by the inequality assumption over the initial limit in the symbolic execution theorem, via ACL2's linear arithmetic. The @(tsee syntaxp) hypothesis restricts the application of the rule to the case in which the limit is a variable (which is true initially). As the symbolic execution proceeds, 1 gets repeatedly subtracted from the initial limit variable, and it appears that ACL2 automatically combines multiple 1s into constants larger than 1, giving the pattern @('(binary-+ \'<negative-integer> <limit-variable>)'). This is the pattern in the second rule @('not-zp-of-limit-...'), whose hypothesis about the limit variable is easily discharged via linear arithmetic.")) (defruled not-zp-of-limit-variable (implies (and (syntaxp (symbolp limit)) (integerp limit) (> limit 0)) (not (zp limit)))) (defruled not-zp-of-limit-minus-const (implies (and (syntaxp (quotep -c)) (integerp -c) (< -c 0) (integerp limit) (> limit (- -c))) (not (zp (binary-+ -c limit))))) (defruled value-result-fix-when-valuep (implies (valuep x) (equal (value-result-fix x) x))) (defruled not-errorp-when-valuep (implies (valuep x) (not (errorp x))) :enable (errorp valuep ucharp scharp ushortp sshortp uintp sintp ulongp slongp ullongp sllongp pointerp)) (defruled not-errorp-when-value-listp (implies (value-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-scopep (implies (scopep x) (not (errorp x))) :enable (errorp scopep)) (defruled not-errorp-when-scope-listp (implies (scope-listp x) (not (errorp x))) :enable errorp) (defruled not-errorp-when-uchar-arrayp (implies (uchar-arrayp x) (not (errorp x))) :enable (errorp uchar-arrayp)) (defruled not-errorp-when-booleanp (implies (booleanp x) (not (errorp x))) :enable errorp) (defruled len-of-cons (equal (len (cons x y)) (1+ (len y))) :prep-books ((include-book "std/lists/len" :dir :system))) (defruled 1+len-greater-than-0 (> (1+ (len x)) 0)) (defruled boolean-from-sint-of-0 (equal (boolean-from-sint (sint 0)) nil)) (defruled boolean-from-sint-of-1 (equal (boolean-from-sint (sint 1)) t)) (defruled lognot-sint-of-0 (equal (lognot-sint (sint 0)) (sint 1))) (defruled lognot-sint-of-1 (equal (lognot-sint (sint 1)) (sint 0))) (defruled car-of-if (equal (car (if a b c)) (if a (car b) (car c)))) (defruled mv-nth-of-if (equal (mv-nth n (if a b c)) (if a (mv-nth n b) (mv-nth n c)))) (defruled len-of-if (equal (len (if a b c)) (if a (len b) (len c)))) (defruled value-result-fix-of-if (equal (value-result-fix (if a b c)) (if a (value-result-fix b) (value-result-fix c)))) (defruled errorp-of-if (equal (errorp (if a b c)) (if a (errorp b) (errorp c)))) (defruled valuep-of-if (equal (valuep (if a b c)) (if a (valuep b) (valuep c)))) (defruled scharp-of-if (equal (scharp (if a b c)) (if a (scharp b) (scharp c)))) (defruled ucharp-of-if (equal (ucharp (if a b c)) (if a (ucharp b) (ucharp c)))) (defruled sshortp-of-if (equal (sshortp (if a b c)) (if a (sshortp b) (sshortp c)))) (defruled ushortp-of-if (equal (ushortp (if a b c)) (if a (ushortp b) (ushortp c)))) (defruled sintp-of-if (equal (sintp (if a b c)) (if a (sintp b) (sintp c)))) (defruled uintp-of-if (equal (uintp (if a b c)) (if a (uintp b) (uintp c)))) (defruled slongp-of-if (equal (slongp (if a b c)) (if a (slongp b) (slongp c)))) (defruled ulongp-of-if (equal (ulongp (if a b c)) (if a (ulongp b) (ulongp c)))) (defruled sllongp-of-if (equal (sllongp (if a b c)) (if a (sllongp b) (sllongp c)))) (defruled ullongp-of-if (equal (ullongp (if a b c)) (if a (ullongp b) (ullongp c)))) (defruled pointerp-of-if (equal (pointerp (if a b c)) (if a (pointerp b) (pointerp c)))) (defruled compustate->frames-of-if (equal (compustate->frames (if a b c)) (if a (compustate->frames b) (compustate->frames c)))) (defruled 1+nat-greater-than-0 (implies (natp x) (< 0 (1+ x)))) (defruled natp-of-1+ (implies (natp x) (natp (1+ x)))) (defruled natp-of-len (natp (len x)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-return-names-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-return-names-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (argfixtype (atc-integer-type-fixtype type)) (restype (if (eq op 'lognot) (type-sint) (promote-type type))) (resfixtype (atc-integer-type-fixtype restype)) (respred (pack resfixtype 'p))) (cons (pack respred '-of- op '- argfixtype) (atc-integer-ops-1-return-names-loop-types op (cdr types))))))) (define atc-integer-ops-1-return-names-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-return-names-loop-types (car ops) types) (atc-integer-ops-1-return-names-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-return-names-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-return-names-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (type (if (member-eq op '(lt gt le ge eq ne)) (type-sint) (uaconvert-types ltype rtype))) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype)) (fixtype (atc-integer-type-fixtype type)) (pred (pack fixtype 'p))) (cons (pack pred '-of- op '- lfixtype '- rfixtype) (atc-integer-ops-2-return-names-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-return-names-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-return-names-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-return-names-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-return-names-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (names symbol-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-return-names-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-return-names-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-return-rewrite-rules* :short "List of rewrite rules for the return types of models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-return-names-loop-src-types types types)) :prepwork ((define atc-integer-convs-return-names-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes))) (pred (pack dfixtype 'p))) (cons (pack pred '-of- dfixtype '-from- sfixtype) (atc-integer-convs-return-names-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-return-names-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (names symbol-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-return-names-loop-dst-types (car stypes) dtypes) (atc-integer-convs-return-names-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-rewrite-rules* :short "List of rewrite rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These exlude the openers (see @(tsee *atc-opener-rules*)), and include not only the rules defined in @(see atc-rewrite-rules), but also other existing rewrite rules. Note that some of them serve to simplify fixtype deconstructors applied to constructors.") (xdoc::p "We take the opportunity here to discuss the general shape of the computation state terms during the symbolic execution. They have the form @('(compustate <frames>)'), where @('<frames>') is a @(tsee cons) nest of frames (possibly @('nil'), when there are no frames). Each frame has the form @('(frame <fun-id> <scopes>)'), where @('<fun-id>') is a quoted constant with the function identifier (the quoted constant being produced by the rules enabled in symbolic execution), and where @('<scopes>') is a @(tsee cons) nest of scopes, never @('nil') due to the invariant on the @(tsee scope) fixtype. Each scope is an @(tsee omap::update) nest, possibly @('nil'): note that @(tsee omap::update) is a constructor of non-empty omaps, @('nil') being the one for empty omaps. In this nest, the keys of the map are quoted constants for C variable identifiers, while the values are shallowly embedded C expressions, which depend on the ACL2 variables in the formulation of each functional correctness theorem, which are also the formal parameters of the ACL2 function that the functional correctness theorem pertains to.") (xdoc::p "Given the above, it should not be surprising to see rules like @('omap::in-of-update'), which serves to simplify, during symbolic execution, the finding of a variable in a scope.")) (append '(;; introduced in this file (see ATC-REWRITE-RULES): not-zp-of-limit-variable not-zp-of-limit-minus-const value-result-fix-when-valuep not-errorp-when-valuep not-errorp-when-value-listp not-errorp-when-scopep not-errorp-when-scope-listp not-errorp-when-uchar-arrayp not-errorp-when-booleanp len-of-cons 1+len-greater-than-0 boolean-from-sint-of-0 boolean-from-sint-of-1 lognot-sint-of-0 lognot-sint-of-1 car-of-if mv-nth-of-if len-of-if value-result-fix-of-if errorp-of-if valuep-of-if scharp-of-if ucharp-of-if sshortp-of-if ushortp-of-if sintp-of-if uintp-of-if slongp-of-if ulongp-of-if sllongp-of-if ullongp-of-if pointerp-of-if compustate->frames-of-if 1+nat-greater-than-0 natp-of-1+ natp-of-len ;; introduced elsewhere: booleanp-of-boolean-from-uchar booleanp-of-boolean-from-schar booleanp-of-boolean-from-ushort booleanp-of-boolean-from-sshort booleanp-of-boolean-from-uint booleanp-of-boolean-from-sint booleanp-of-boolean-from-ulong booleanp-of-boolean-from-slong booleanp-of-boolean-from-ullong booleanp-of-boolean-from-sllong car-cons cdr-cons compustate-of-fields compustate->frames-of-compustate compustate->heap-of-compustate compustate-fix-when-compustatep compustatep-of-compustate frame->function-of-frame frame->scopes-of-frame frame-fix-when-framep frame-list-fix-of-cons frame-list-fix-when-frame-listp frame-listp-of-compustate->frames framep-of-frame heap-fix-when-heapp heapp-of-compustate->heap not-errorp-when-compustatep omap::in-of-update pop-frame-of-push-frame scope-fix-when-scopep scope-list-fix-of-cons scope-listp-of-cons scopep-of-update schar-fix-when-scharp uchar-fix-when-ucharp sshort-fix-when-sshortp ushort-fix-when-ushortp sint-fix-when-sintp uint-fix-when-uintp slong-fix-when-slongp ulong-fix-when-ulongp sllong-fix-when-sllongp ullong-fix-when-ullongp scharp-of-schar ucharp-of-uchar sshortp-of-sshort ushortp-of-ushort sintp-of-sint uintp-of-uint slongp-of-slong ulongp-of-ulong sllongp-of-sllong ullongp-of-ullong ucharp-of-uchar-array-read-sint ucharp-of-uchar-array-read top-frame-of-push-frame valuep-when-pointerp valuep-when-scharp valuep-when-ucharp valuep-when-sshortp valuep-when-ushortp valuep-when-sintp valuep-when-uintp valuep-when-slongp valuep-when-ulongp valuep-when-sllongp valuep-when-ullongp value-fix-when-valuep value-listp-of-cons value-list-fix-of-cons value-optionp-when-valuep) ;; also introduced elsewhere: *value-disjoint-rules* *atc-integer-ops-1-return-rewrite-rules* *atc-integer-ops-2-return-rewrite-rules* *atc-integer-convs-return-rewrite-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-1-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve one C integer type." (b* ((ops '(plus minus bitnot lognot shl shr)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-1-type-presc-rules-loop-ops ops types)) :prepwork ((define atc-integer-ops-1-type-presc-rules-loop-types ((op symbolp) (types type-listp)) :guard (and (member-eq op '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rules true-list-listp) (cond ((endp types) nil) (t (b* ((type (car types)) (fixtype (atc-integer-type-fixtype type))) (cons (list :t (pack op '- fixtype)) (atc-integer-ops-1-type-presc-rules-loop-types op (cdr types))))))) (define atc-integer-ops-1-type-presc-rules-loop-ops ((ops symbol-listp) (types type-listp)) :guard (and (subsetp-eq ops '(plus minus bitnot lognot shl shr)) (type-integer-listp types)) :returns (rule true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-1-type-presc-rules-loop-types (car ops) types) (atc-integer-ops-1-type-presc-rules-loop-ops (cdr ops) types))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-ops-2-type-prescription-rules* :short "List of type prescription rules for the models of C integer operations that involve two C integer types." (b* ((ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-ops-2-type-presc-rules-loop-ops ops types types)) :prepwork ((define atc-integer-ops-2-type-presc-rules-loop-right-types ((op symbolp) (ltype typep) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integerp ltype) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp rtypes) nil) (t (b* ((rtype (car rtypes)) (lfixtype (atc-integer-type-fixtype ltype)) (rfixtype (atc-integer-type-fixtype rtype))) (cons (list :t (pack op '- lfixtype '- rfixtype)) (atc-integer-ops-2-type-presc-rules-loop-right-types op ltype (cdr rtypes)))))) :guard-hints (("Goal" :in-theory (enable type-arithmeticp type-realp)))) (define atc-integer-ops-2-type-presc-rules-loop-left-types ((op symbolp) (ltypes type-listp) (rtypes type-listp)) :guard (and (member-eq op (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ltypes) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-right-types op (car ltypes) rtypes) (atc-integer-ops-2-type-presc-rules-loop-left-types op (cdr ltypes) rtypes))))) (define atc-integer-ops-2-type-presc-rules-loop-ops ((ops symbol-listp) (ltypes type-listp) (rtypes type-listp)) :guard (and (subsetp-eq ops (list 'add 'sub 'mul 'div 'rem 'lt 'gt 'le 'ge 'eq 'ne 'bitand 'bitxor 'bitior)) (type-integer-listp ltypes) (type-integer-listp rtypes)) :returns (rules true-list-listp) (cond ((endp ops) nil) (t (append (atc-integer-ops-2-type-presc-rules-loop-left-types (car ops) ltypes rtypes) (atc-integer-ops-2-type-presc-rules-loop-ops (cdr ops) ltypes rtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-integer-convs-type-prescription-rules* :short "List of type prescription rules for the models of C integer conversions." (b* ((types (list (type-schar) (type-uchar) (type-sshort) (type-ushort) (type-sint) (type-uint) (type-slong) (type-ulong) (type-sllong) (type-ullong)))) (atc-integer-convs-type-presc-rules-loop-src-types types types)) :prepwork ((define atc-integer-convs-type-presc-rules-loop-dst-types ((stype typep) (dtypes type-listp)) :guard (and (type-integerp stype) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp dtypes) nil) ((equal stype (car dtypes)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))) (t (b* ((sfixtype (atc-integer-type-fixtype stype)) (dfixtype (atc-integer-type-fixtype (car dtypes)))) (cons (list :t (pack dfixtype '-from- sfixtype)) (atc-integer-convs-type-presc-rules-loop-dst-types stype (cdr dtypes))))))) (define atc-integer-convs-type-presc-rules-loop-src-types ((stypes type-listp) (dtypes type-listp)) :guard (and (type-integer-listp stypes) (type-integer-listp dtypes)) :returns (rules true-list-listp) (cond ((endp stypes) nil) (t (append (atc-integer-convs-type-presc-rules-loop-dst-types (car stypes) dtypes) (atc-integer-convs-type-presc-rules-loop-src-types (cdr stypes) dtypes))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-type-prescription-rules* :short "List of type prescription rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "In the dynamic semantics, the execution of statements and other entities returns @(tsee mv) values, which logically satisfy @(tsee consp); the negated application of @(tsee consp) to those execution functions comes up in certain subgoals, so a simple way to discharge those subgoals is to use the type prescription rules for those execution functions.") (xdoc::p "We also need rules about the constructors of C integer values and the C functions that represent C operations and conversions, including array read operations.")) (append '((:t exec-expr-call-or-pure) (:t exec-fun) (:t exec-stmt) (:t exec-block-item) (:t exec-block-item-list) (:t schar) (:t uchar) (:t sshort) (:t ushort) (:t sint) (:t uint) (:t slong) (:t ulong) (:t sllong) (:t ullong) (:t uchar-array-read-sint) (:t uchar-array-read)) *atc-integer-ops-1-type-prescription-rules* *atc-integer-ops-2-type-prescription-rules* *atc-integer-convs-type-prescription-rules*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-compound-recognizer-rules* :short "List of compound recognizer rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "The type prescription rules in @(tsee *atc-type-prescription-rules*) cover all the shallowly embedded C expressions except for variables. In the scenarios explained in @(tsee *atc-type-prescription-rules*), we may need to establish that a variable is not @('nil'), which must follow from the guard hypotheses. For this, we use the compound recognizer rule below. The fact that the type is @(tsee consp) is actually not important; what is important is that it does not include @('nil'), i.e. it is logically true.")) '(consp-when-scharp consp-when-ucharp consp-when-sshortp consp-when-ushortp consp-when-sintp consp-when-uintp consp-when-slongp consp-when-ulongp consp-when-sllongp consp-when-ullongp)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defval *atc-all-rules* :short "List of all the (generic) rules for the proofs generated by ATC." :long (xdoc::topstring (xdoc::p "These are the ones used in all the generated proofs. In addition, each proof includes a few additional rules that depend on the specific C-representing ACL2 functions involved. See @(see atc-implementation).")) (append *atc-opener-rules* *atc-executable-counterpart-rules* *atc-definition-rules* *atc-rewrite-rules* *atc-type-prescription-rules* *atc-compound-recognizer-rules*))
[ { "context": "backend for CFFI.\n;;;\n;;; Copyright (C) 2005-2006, James Bielman <[email protected]>\n;;;\n;;; Permission is here", "end": 141, "score": 0.9997991323471069, "start": 128, "tag": "NAME", "value": "James Bielman" }, { "context": "\n;;;\n;;; Copyright (C) 2005-2006, James Bielman <[email protected]>\n;;;\n;;; Permission is hereby granted, free of ch", "end": 163, "score": 0.9999301433563232, "start": 144, "tag": "EMAIL", "value": "[email protected]" } ]
cusp/jasko.tim.lisp.libs/libs/cffi-080216/src/cffi-ecl.lisp
TeamSPoon/CYC_JRTL_with_CommonLisp_OLD
10
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-ecl.lisp --- ECL backend for CFFI. ;;; ;;; Copyright (C) 2005-2006, James Bielman <[email protected]> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:cffi-utils) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%mem-ref #:%mem-set #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:native-namestring #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%defcallback #:%callback #:%foreign-symbol-pointer)) (in-package #:cffi-sys) ;;;# Features (eval-when (:compile-toplevel :load-toplevel :execute) (mapc (lambda (feature) (pushnew feature *features*)) '(;; Backend mis-features. cffi-features:no-long-long cffi-features:flat-namespace ;; OS/CPU features. #+:darwin cffi-features:darwin #+:darwin cffi-features:unix #+:unix cffi-features:unix #+:win32 cffi-features:windows ;; XXX: figure out a way to get a X86 feature ;;#+:athlon cffi-features:x86 #+:powerpc7450 cffi-features:ppc32 ))) ;;; Symbol case. (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Allocation (defun %foreign-alloc (size) "Allocate SIZE bytes of foreign-addressable memory." (si:allocate-foreign-data :void size)) (defun foreign-free (ptr) "Free a pointer PTR allocated by FOREIGN-ALLOC." (si:free-foreign-data ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) `(let* ((,size-var ,size) (,var (%foreign-alloc ,size-var))) (unwind-protect (progn ,@body) (foreign-free ,var)))) ;;;# Misc. Pointer Operations (deftype foreign-pointer () 'si:foreign-data) (defun null-pointer () "Construct and return a null pointer." (si:allocate-foreign-data :void 0)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (si:null-pointer-p ptr)) (defun inc-pointer (ptr offset) "Return a pointer OFFSET bytes past PTR." (ffi:make-pointer (+ (ffi:pointer-address ptr) offset) :void)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (typep ptr 'si:foreign-data)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (= (ffi:pointer-address ptr1) (ffi:pointer-address ptr2))) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (ffi:make-pointer address :void)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (ffi:pointer-address ptr)) ;;;# Dereferencing (defun %mem-ref (ptr type &optional (offset 0)) "Dereference an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-ref-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type))) (defun %mem-set (value ptr type &optional (offset 0)) "Set an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-set-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type value))) ;;;# Type Operations (defconstant +translation-table+ '((:char :byte "char") (:unsigned-char :unsigned-byte "unsigned char") (:short :short "short") (:unsigned-short :unsigned-short "unsigned short") (:int :int "int") (:unsigned-int :unsigned-int "unsigned int") (:long :long "long") (:unsigned-long :unsigned-long "unsigned long") (:float :float "float") (:double :double "double") (:pointer :pointer-void "void*") (:void :void "void"))) (defun cffi-type->ecl-type (type-keyword) "Convert a CFFI type keyword to an ECL type keyword." (or (second (find type-keyword +translation-table+ :key #'first)) (error "~S is not a valid CFFI type" type-keyword))) (defun ecl-type->c-type (type-keyword) "Convert a CFFI type keyword to an valid C type keyword." (or (third (find type-keyword +translation-table+ :key #'second)) (error "~S is not a valid CFFI type" type-keyword))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (nth-value 0 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (nth-value 1 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) ;;;# Calling Foreign Functions (defconstant +ecl-inline-codes+ "#0,#1,#2,#3,#4,#5,#6,#7,#8,#9,#a,#b,#c,#d,#e,#f,#g,#h,#i,#j,#k,#l,#m,#n,#o,#p,#q,#r,#s,#t,#u,#v,#w,#x,#y,#z") (defun produce-function-pointer-call (pointer types values return-type) #-dffi (if (stringp pointer) ;; `(ffi:c-inline ,values ,types ,return-type ;; ,(format nil "~A(~A)" pointer ;; (subseq +ecl-inline-codes+ 0 (max 0 (1- (* (length values) 3))))) ;; :one-liner t :side-effects t) (produce-function-pointer-call `(foreign-symbol-pointer ,pointer) types values return-type) `(ffi:c-inline ,(list* pointer values) ,(list* :pointer-void types) ,return-type ,(with-output-to-string (s) (let ((types (mapcar #'ecl-type->c-type types))) ;; On AMD64, the following code only works with the extra argument ",..." ;; If this is not present, functions like sprintf do not work (format s "((~A (*)(~@[~{~A,~}...~]))(#0))(~A)" (ecl-type->c-type return-type) types (subseq +ecl-inline-codes+ 3 (max 3 (+ 2 (* (length values) 3))))))) :one-liner t :side-effects t)) #+dffi (progn (when (stringp pointer) (setf pointer `(foreign-symbol-pointer ,pointer))) `(si:call-cfun ,pointer ,return-type (list ,@types) (list ,@values)))) (defun foreign-funcall-parse-args (args) "Return three values, lists of arg types, values, and result type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect (cffi-type->ecl-type type) into types and collect arg into values else do (setf return-type (cffi-type->ecl-type type)) finally (return (values types values return-type))))) (defmacro %foreign-funcall (name args &key library calling-convention) "Call a foreign function." (declare (ignore library calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call name types values return-type))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call ptr types values return-type))) ;;;# Foreign Libraries (defun %load-foreign-library (name path) "Load a foreign library." (declare (ignore name)) #-dffi (error "LOAD-FOREIGN-LIBRARY requires ECL's DFFI support. Use ~ FFI:LOAD-FOREIGN-LIBRARY with a constant argument instead.") #+dffi (si:load-foreign-module path)) (defun %close-foreign-library (handle) (error "%CLOSE-FOREIGN-LIBRARY unimplemented.")) (defun native-namestring (pathname) (namestring pathname)) ;;;# Callbacks ;;; Create a package to contain the symbols for callback functions. ;;; We want to redefine callbacks with the same symbol so the internal ;;; data structures are reused. (defpackage #:cffi-callbacks (:use)) (defvar *callbacks* (make-hash-table)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the ;;; internal callback for NAME. (eval-when (:compile-toplevel :load-toplevel :execute) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) (let ((cb-name (intern-callback name))) `(progn (ffi:defcallback (,cb-name :cdecl) ,(cffi-type->ecl-type rettype) ,(mapcar #'list arg-names (mapcar #'cffi-type->ecl-type arg-types)) ,body) (setf (gethash ',name *callbacks*) ',cb-name)))) (defun %callback (name) (multiple-value-bind (symbol winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) (ffi:callback symbol))) ;;;# Foreign Globals (defun convert-external-name (name) "Add an underscore to NAME if necessary for the ABI." name) (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (si:find-foreign-symbol (convert-external-name name) :default :pointer-void 0))
188
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-ecl.lisp --- ECL backend for CFFI. ;;; ;;; Copyright (C) 2005-2006, <NAME> <<EMAIL>> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:cffi-utils) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%mem-ref #:%mem-set #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:native-namestring #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%defcallback #:%callback #:%foreign-symbol-pointer)) (in-package #:cffi-sys) ;;;# Features (eval-when (:compile-toplevel :load-toplevel :execute) (mapc (lambda (feature) (pushnew feature *features*)) '(;; Backend mis-features. cffi-features:no-long-long cffi-features:flat-namespace ;; OS/CPU features. #+:darwin cffi-features:darwin #+:darwin cffi-features:unix #+:unix cffi-features:unix #+:win32 cffi-features:windows ;; XXX: figure out a way to get a X86 feature ;;#+:athlon cffi-features:x86 #+:powerpc7450 cffi-features:ppc32 ))) ;;; Symbol case. (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Allocation (defun %foreign-alloc (size) "Allocate SIZE bytes of foreign-addressable memory." (si:allocate-foreign-data :void size)) (defun foreign-free (ptr) "Free a pointer PTR allocated by FOREIGN-ALLOC." (si:free-foreign-data ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) `(let* ((,size-var ,size) (,var (%foreign-alloc ,size-var))) (unwind-protect (progn ,@body) (foreign-free ,var)))) ;;;# Misc. Pointer Operations (deftype foreign-pointer () 'si:foreign-data) (defun null-pointer () "Construct and return a null pointer." (si:allocate-foreign-data :void 0)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (si:null-pointer-p ptr)) (defun inc-pointer (ptr offset) "Return a pointer OFFSET bytes past PTR." (ffi:make-pointer (+ (ffi:pointer-address ptr) offset) :void)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (typep ptr 'si:foreign-data)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (= (ffi:pointer-address ptr1) (ffi:pointer-address ptr2))) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (ffi:make-pointer address :void)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (ffi:pointer-address ptr)) ;;;# Dereferencing (defun %mem-ref (ptr type &optional (offset 0)) "Dereference an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-ref-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type))) (defun %mem-set (value ptr type &optional (offset 0)) "Set an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-set-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type value))) ;;;# Type Operations (defconstant +translation-table+ '((:char :byte "char") (:unsigned-char :unsigned-byte "unsigned char") (:short :short "short") (:unsigned-short :unsigned-short "unsigned short") (:int :int "int") (:unsigned-int :unsigned-int "unsigned int") (:long :long "long") (:unsigned-long :unsigned-long "unsigned long") (:float :float "float") (:double :double "double") (:pointer :pointer-void "void*") (:void :void "void"))) (defun cffi-type->ecl-type (type-keyword) "Convert a CFFI type keyword to an ECL type keyword." (or (second (find type-keyword +translation-table+ :key #'first)) (error "~S is not a valid CFFI type" type-keyword))) (defun ecl-type->c-type (type-keyword) "Convert a CFFI type keyword to an valid C type keyword." (or (third (find type-keyword +translation-table+ :key #'second)) (error "~S is not a valid CFFI type" type-keyword))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (nth-value 0 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (nth-value 1 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) ;;;# Calling Foreign Functions (defconstant +ecl-inline-codes+ "#0,#1,#2,#3,#4,#5,#6,#7,#8,#9,#a,#b,#c,#d,#e,#f,#g,#h,#i,#j,#k,#l,#m,#n,#o,#p,#q,#r,#s,#t,#u,#v,#w,#x,#y,#z") (defun produce-function-pointer-call (pointer types values return-type) #-dffi (if (stringp pointer) ;; `(ffi:c-inline ,values ,types ,return-type ;; ,(format nil "~A(~A)" pointer ;; (subseq +ecl-inline-codes+ 0 (max 0 (1- (* (length values) 3))))) ;; :one-liner t :side-effects t) (produce-function-pointer-call `(foreign-symbol-pointer ,pointer) types values return-type) `(ffi:c-inline ,(list* pointer values) ,(list* :pointer-void types) ,return-type ,(with-output-to-string (s) (let ((types (mapcar #'ecl-type->c-type types))) ;; On AMD64, the following code only works with the extra argument ",..." ;; If this is not present, functions like sprintf do not work (format s "((~A (*)(~@[~{~A,~}...~]))(#0))(~A)" (ecl-type->c-type return-type) types (subseq +ecl-inline-codes+ 3 (max 3 (+ 2 (* (length values) 3))))))) :one-liner t :side-effects t)) #+dffi (progn (when (stringp pointer) (setf pointer `(foreign-symbol-pointer ,pointer))) `(si:call-cfun ,pointer ,return-type (list ,@types) (list ,@values)))) (defun foreign-funcall-parse-args (args) "Return three values, lists of arg types, values, and result type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect (cffi-type->ecl-type type) into types and collect arg into values else do (setf return-type (cffi-type->ecl-type type)) finally (return (values types values return-type))))) (defmacro %foreign-funcall (name args &key library calling-convention) "Call a foreign function." (declare (ignore library calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call name types values return-type))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call ptr types values return-type))) ;;;# Foreign Libraries (defun %load-foreign-library (name path) "Load a foreign library." (declare (ignore name)) #-dffi (error "LOAD-FOREIGN-LIBRARY requires ECL's DFFI support. Use ~ FFI:LOAD-FOREIGN-LIBRARY with a constant argument instead.") #+dffi (si:load-foreign-module path)) (defun %close-foreign-library (handle) (error "%CLOSE-FOREIGN-LIBRARY unimplemented.")) (defun native-namestring (pathname) (namestring pathname)) ;;;# Callbacks ;;; Create a package to contain the symbols for callback functions. ;;; We want to redefine callbacks with the same symbol so the internal ;;; data structures are reused. (defpackage #:cffi-callbacks (:use)) (defvar *callbacks* (make-hash-table)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the ;;; internal callback for NAME. (eval-when (:compile-toplevel :load-toplevel :execute) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) (let ((cb-name (intern-callback name))) `(progn (ffi:defcallback (,cb-name :cdecl) ,(cffi-type->ecl-type rettype) ,(mapcar #'list arg-names (mapcar #'cffi-type->ecl-type arg-types)) ,body) (setf (gethash ',name *callbacks*) ',cb-name)))) (defun %callback (name) (multiple-value-bind (symbol winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) (ffi:callback symbol))) ;;;# Foreign Globals (defun convert-external-name (name) "Add an underscore to NAME if necessary for the ABI." name) (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (si:find-foreign-symbol (convert-external-name name) :default :pointer-void 0))
true
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*- ;;; ;;; cffi-ecl.lisp --- ECL backend for CFFI. ;;; ;;; Copyright (C) 2005-2006, PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;;# Administrivia (defpackage #:cffi-sys (:use #:common-lisp #:cffi-utils) (:export #:canonicalize-symbol-name-case #:foreign-pointer #:pointerp #:pointer-eq #:%foreign-alloc #:foreign-free #:with-foreign-pointer #:null-pointer #:null-pointer-p #:inc-pointer #:make-pointer #:pointer-address #:%mem-ref #:%mem-set #:%foreign-funcall #:%foreign-funcall-pointer #:%foreign-type-alignment #:%foreign-type-size #:%load-foreign-library #:native-namestring #:make-shareable-byte-vector #:with-pointer-to-vector-data #:%defcallback #:%callback #:%foreign-symbol-pointer)) (in-package #:cffi-sys) ;;;# Features (eval-when (:compile-toplevel :load-toplevel :execute) (mapc (lambda (feature) (pushnew feature *features*)) '(;; Backend mis-features. cffi-features:no-long-long cffi-features:flat-namespace ;; OS/CPU features. #+:darwin cffi-features:darwin #+:darwin cffi-features:unix #+:unix cffi-features:unix #+:win32 cffi-features:windows ;; XXX: figure out a way to get a X86 feature ;;#+:athlon cffi-features:x86 #+:powerpc7450 cffi-features:ppc32 ))) ;;; Symbol case. (defun canonicalize-symbol-name-case (name) (declare (string name)) (string-upcase name)) ;;;# Allocation (defun %foreign-alloc (size) "Allocate SIZE bytes of foreign-addressable memory." (si:allocate-foreign-data :void size)) (defun foreign-free (ptr) "Free a pointer PTR allocated by FOREIGN-ALLOC." (si:free-foreign-data ptr)) (defmacro with-foreign-pointer ((var size &optional size-var) &body body) "Bind VAR to SIZE bytes of foreign memory during BODY. The pointer in VAR is invalid beyond the dynamic extent of BODY, and may be stack-allocated if supported by the implementation. If SIZE-VAR is supplied, it will be bound to SIZE during BODY." (unless size-var (setf size-var (gensym "SIZE"))) `(let* ((,size-var ,size) (,var (%foreign-alloc ,size-var))) (unwind-protect (progn ,@body) (foreign-free ,var)))) ;;;# Misc. Pointer Operations (deftype foreign-pointer () 'si:foreign-data) (defun null-pointer () "Construct and return a null pointer." (si:allocate-foreign-data :void 0)) (defun null-pointer-p (ptr) "Return true if PTR is a null pointer." (si:null-pointer-p ptr)) (defun inc-pointer (ptr offset) "Return a pointer OFFSET bytes past PTR." (ffi:make-pointer (+ (ffi:pointer-address ptr) offset) :void)) (defun pointerp (ptr) "Return true if PTR is a foreign pointer." (typep ptr 'si:foreign-data)) (defun pointer-eq (ptr1 ptr2) "Return true if PTR1 and PTR2 point to the same address." (= (ffi:pointer-address ptr1) (ffi:pointer-address ptr2))) (defun make-pointer (address) "Return a pointer pointing to ADDRESS." (ffi:make-pointer address :void)) (defun pointer-address (ptr) "Return the address pointed to by PTR." (ffi:pointer-address ptr)) ;;;# Dereferencing (defun %mem-ref (ptr type &optional (offset 0)) "Dereference an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-ref-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type))) (defun %mem-set (value ptr type &optional (offset 0)) "Set an object of TYPE at OFFSET bytes from PTR." (let* ((type (cffi-type->ecl-type type)) (type-size (ffi:size-of-foreign-type type))) (si:foreign-data-set-elt (si:foreign-data-recast ptr (+ offset type-size) :void) offset type value))) ;;;# Type Operations (defconstant +translation-table+ '((:char :byte "char") (:unsigned-char :unsigned-byte "unsigned char") (:short :short "short") (:unsigned-short :unsigned-short "unsigned short") (:int :int "int") (:unsigned-int :unsigned-int "unsigned int") (:long :long "long") (:unsigned-long :unsigned-long "unsigned long") (:float :float "float") (:double :double "double") (:pointer :pointer-void "void*") (:void :void "void"))) (defun cffi-type->ecl-type (type-keyword) "Convert a CFFI type keyword to an ECL type keyword." (or (second (find type-keyword +translation-table+ :key #'first)) (error "~S is not a valid CFFI type" type-keyword))) (defun ecl-type->c-type (type-keyword) "Convert a CFFI type keyword to an valid C type keyword." (or (third (find type-keyword +translation-table+ :key #'second)) (error "~S is not a valid CFFI type" type-keyword))) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (nth-value 0 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." (nth-value 1 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) ;;;# Calling Foreign Functions (defconstant +ecl-inline-codes+ "#0,#1,#2,#3,#4,#5,#6,#7,#8,#9,#a,#b,#c,#d,#e,#f,#g,#h,#i,#j,#k,#l,#m,#n,#o,#p,#q,#r,#s,#t,#u,#v,#w,#x,#y,#z") (defun produce-function-pointer-call (pointer types values return-type) #-dffi (if (stringp pointer) ;; `(ffi:c-inline ,values ,types ,return-type ;; ,(format nil "~A(~A)" pointer ;; (subseq +ecl-inline-codes+ 0 (max 0 (1- (* (length values) 3))))) ;; :one-liner t :side-effects t) (produce-function-pointer-call `(foreign-symbol-pointer ,pointer) types values return-type) `(ffi:c-inline ,(list* pointer values) ,(list* :pointer-void types) ,return-type ,(with-output-to-string (s) (let ((types (mapcar #'ecl-type->c-type types))) ;; On AMD64, the following code only works with the extra argument ",..." ;; If this is not present, functions like sprintf do not work (format s "((~A (*)(~@[~{~A,~}...~]))(#0))(~A)" (ecl-type->c-type return-type) types (subseq +ecl-inline-codes+ 3 (max 3 (+ 2 (* (length values) 3))))))) :one-liner t :side-effects t)) #+dffi (progn (when (stringp pointer) (setf pointer `(foreign-symbol-pointer ,pointer))) `(si:call-cfun ,pointer ,return-type (list ,@types) (list ,@values)))) (defun foreign-funcall-parse-args (args) "Return three values, lists of arg types, values, and result type." (let ((return-type :void)) (loop for (type arg) on args by #'cddr if arg collect (cffi-type->ecl-type type) into types and collect arg into values else do (setf return-type (cffi-type->ecl-type type)) finally (return (values types values return-type))))) (defmacro %foreign-funcall (name args &key library calling-convention) "Call a foreign function." (declare (ignore library calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call name types values return-type))) (defmacro %foreign-funcall-pointer (ptr args &key calling-convention) "Funcall a pointer to a foreign function." (declare (ignore calling-convention)) (multiple-value-bind (types values return-type) (foreign-funcall-parse-args args) (produce-function-pointer-call ptr types values return-type))) ;;;# Foreign Libraries (defun %load-foreign-library (name path) "Load a foreign library." (declare (ignore name)) #-dffi (error "LOAD-FOREIGN-LIBRARY requires ECL's DFFI support. Use ~ FFI:LOAD-FOREIGN-LIBRARY with a constant argument instead.") #+dffi (si:load-foreign-module path)) (defun %close-foreign-library (handle) (error "%CLOSE-FOREIGN-LIBRARY unimplemented.")) (defun native-namestring (pathname) (namestring pathname)) ;;;# Callbacks ;;; Create a package to contain the symbols for callback functions. ;;; We want to redefine callbacks with the same symbol so the internal ;;; data structures are reused. (defpackage #:cffi-callbacks (:use)) (defvar *callbacks* (make-hash-table)) ;;; Intern a symbol in the CFFI-CALLBACKS package used to name the ;;; internal callback for NAME. (eval-when (:compile-toplevel :load-toplevel :execute) (defun intern-callback (name) (intern (format nil "~A::~A" (package-name (symbol-package name)) (symbol-name name)) '#:cffi-callbacks))) (defmacro %defcallback (name rettype arg-names arg-types body &key calling-convention) (declare (ignore calling-convention)) (let ((cb-name (intern-callback name))) `(progn (ffi:defcallback (,cb-name :cdecl) ,(cffi-type->ecl-type rettype) ,(mapcar #'list arg-names (mapcar #'cffi-type->ecl-type arg-types)) ,body) (setf (gethash ',name *callbacks*) ',cb-name)))) (defun %callback (name) (multiple-value-bind (symbol winp) (gethash name *callbacks*) (unless winp (error "Undefined callback: ~S" name)) (ffi:callback symbol))) ;;;# Foreign Globals (defun convert-external-name (name) "Add an underscore to NAME if necessary for the ABI." name) (defun %foreign-symbol-pointer (name library) "Returns a pointer to a foreign symbol NAME." (declare (ignore library)) (si:find-foreign-symbol (convert-external-name name) :default :pointer-void 0))
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n; 10/29/2013: Mods made by M", "end": 1415, "score": 0.9996817111968994, "start": 1404, "tag": "NAME", "value": "Jared Davis" }, { "context": "N THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n; 10/29/2013: Mods made by Matt Kaufmann to supp", "end": 1435, "score": 0.9999344944953918, "start": 1417, "tag": "EMAIL", "value": "[email protected]" }, { "context": "is <[email protected]>\n; 10/29/2013: Mods made by Matt Kaufmann to support Emacs-based ACL2-Doc browser\n\n(in-pack", "end": 1477, "score": 0.998805046081543, "start": 1464, "tag": "NAME", "value": "Matt Kaufmann" }, { "context": "y members\n; of the ACL2 community.\n\n; Written by: Matt Kaufmann and J Strother Moore\n; email: ", "end": 4121, "score": 0.9998881816864014, "start": 4108, "tag": "NAME", "value": "Matt Kaufmann" }, { "context": "y.\n\n; Written by: Matt Kaufmann and J Strother Moore\n; email: [email protected] and Mo", "end": 4156, "score": 0.9998908042907715, "start": 4140, "tag": "NAME", "value": "J Strother Moore" }, { "context": " and J Strother Moore\n; email: [email protected] and [email protected]\n; Department of Comp", "end": 4194, "score": 0.9999352097511292, "start": 4172, "tag": "EMAIL", "value": "[email protected]" }, { "context": "ore\n; email: [email protected] and [email protected]\n; Department of Computer Science\n; University of ", "end": 4223, "score": 0.9999350905418396, "start": 4204, "tag": "EMAIL", "value": "[email protected]" } ]
books/system/doc/render-doc.lisp
jaredcdavis/acl2
1
; Converter From ACL2 System Documentation to Text ; Copyright (C) 2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Jared Davis <[email protected]> ; 10/29/2013: Mods made by Matt Kaufmann to support Emacs-based ACL2-Doc browser (in-package "XDOC") (set-state-ok t) (include-book "render-doc-base") (program) ;; Load the ACL2 system documentation and throw away any other topics (which ;; might be GPL'd) to ensure that only pure BSD-licensed topics are included. (table xdoc 'doc acl2::*acl2-sources-xdoc-topics*) (value-triple (len (get-xdoc-table (w state)))) (defttag :open-output-channel!) (defun remove-acl2-parent (topics acc) (cond ((endp topics) (reverse acc)) (t (remove-acl2-parent (cdr topics) (cons (cond ((and (eq (cdr (assoc-eq :name (car topics))) 'acl2::acl2) (equal (cdr (assoc-eq :parents (car topics))) '(acl2::top))) (put-assoc-eq :parents nil (car topics))) (t (car topics))) acc))))) (acl2::defconsts (& & state) (state-global-let* ((current-package "ACL2" set-current-package-state)) (b* ((all-topics (remove-acl2-parent (get-xdoc-table (w state)) nil)) ((mv rendered state) (render-topics all-topics all-topics state)) (rendered (split-acl2-topics rendered nil nil nil)) (- (cw "Writing rendered-doc.lsp~%")) ((mv channel state) (open-output-channel! "rendered-doc.lsp" :character state)) ((unless channel) (cw "can't open rendered-doc.lsp for output.") (acl2::silent-error state)) (state (princ$ "; Documentation for the ACL2 Theorem Prover ; WARNING: GENERATED FILE, DO NOT HAND EDIT! ; The contents of this file are derived from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. ; ACL2 Version 7.1 -- A Computational Logic for Applicative Common Lisp ; Copyright (C) 2015, Regents of the University of Texas ; This version of ACL2 is a descendent of ACL2 Version 1.9, Copyright ; (C) 1997 Computational Logic, Inc. See the documentation topic NOTE-2-0. ; This program is free software; you can redistribute it and/or modify ; it under the terms of the LICENSE file distributed with ACL2. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; LICENSE for more details. ; Here are the original authors of books/system/doc/acl2-doc.lisp. ; Additional contributions may have been made to that file by members ; of the ACL2 community. ; Written by: Matt Kaufmann and J Strother Moore ; email: [email protected] and [email protected] ; Department of Computer Science ; University of Texas at Austin ; Austin, TX 78701 U.S.A. ; WARNING: This file is generated from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. To edit ACL2 documentation modify ; that file, not this one! Instructions are just above the in-package ; form in that book. (in-package \"ACL2\") (defconst *acl2-system-documentation* '" channel state)) (state (fms! "~x0" (list (cons #\0 rendered)) channel state nil)) (state (fms! ")" nil channel state nil)) (state (newline channel state)) (state (close-output-channel channel state))) (value nil))))
42345
; Converter From ACL2 System Documentation to Text ; Copyright (C) 2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> ; 10/29/2013: Mods made by <NAME> to support Emacs-based ACL2-Doc browser (in-package "XDOC") (set-state-ok t) (include-book "render-doc-base") (program) ;; Load the ACL2 system documentation and throw away any other topics (which ;; might be GPL'd) to ensure that only pure BSD-licensed topics are included. (table xdoc 'doc acl2::*acl2-sources-xdoc-topics*) (value-triple (len (get-xdoc-table (w state)))) (defttag :open-output-channel!) (defun remove-acl2-parent (topics acc) (cond ((endp topics) (reverse acc)) (t (remove-acl2-parent (cdr topics) (cons (cond ((and (eq (cdr (assoc-eq :name (car topics))) 'acl2::acl2) (equal (cdr (assoc-eq :parents (car topics))) '(acl2::top))) (put-assoc-eq :parents nil (car topics))) (t (car topics))) acc))))) (acl2::defconsts (& & state) (state-global-let* ((current-package "ACL2" set-current-package-state)) (b* ((all-topics (remove-acl2-parent (get-xdoc-table (w state)) nil)) ((mv rendered state) (render-topics all-topics all-topics state)) (rendered (split-acl2-topics rendered nil nil nil)) (- (cw "Writing rendered-doc.lsp~%")) ((mv channel state) (open-output-channel! "rendered-doc.lsp" :character state)) ((unless channel) (cw "can't open rendered-doc.lsp for output.") (acl2::silent-error state)) (state (princ$ "; Documentation for the ACL2 Theorem Prover ; WARNING: GENERATED FILE, DO NOT HAND EDIT! ; The contents of this file are derived from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. ; ACL2 Version 7.1 -- A Computational Logic for Applicative Common Lisp ; Copyright (C) 2015, Regents of the University of Texas ; This version of ACL2 is a descendent of ACL2 Version 1.9, Copyright ; (C) 1997 Computational Logic, Inc. See the documentation topic NOTE-2-0. ; This program is free software; you can redistribute it and/or modify ; it under the terms of the LICENSE file distributed with ACL2. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; LICENSE for more details. ; Here are the original authors of books/system/doc/acl2-doc.lisp. ; Additional contributions may have been made to that file by members ; of the ACL2 community. ; Written by: <NAME> and <NAME> ; email: <EMAIL> and <EMAIL> ; Department of Computer Science ; University of Texas at Austin ; Austin, TX 78701 U.S.A. ; WARNING: This file is generated from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. To edit ACL2 documentation modify ; that file, not this one! Instructions are just above the in-package ; form in that book. (in-package \"ACL2\") (defconst *acl2-system-documentation* '" channel state)) (state (fms! "~x0" (list (cons #\0 rendered)) channel state nil)) (state (fms! ")" nil channel state nil)) (state (newline channel state)) (state (close-output-channel channel state))) (value nil))))
true
; Converter From ACL2 System Documentation to Text ; Copyright (C) 2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ; 10/29/2013: Mods made by PI:NAME:<NAME>END_PI to support Emacs-based ACL2-Doc browser (in-package "XDOC") (set-state-ok t) (include-book "render-doc-base") (program) ;; Load the ACL2 system documentation and throw away any other topics (which ;; might be GPL'd) to ensure that only pure BSD-licensed topics are included. (table xdoc 'doc acl2::*acl2-sources-xdoc-topics*) (value-triple (len (get-xdoc-table (w state)))) (defttag :open-output-channel!) (defun remove-acl2-parent (topics acc) (cond ((endp topics) (reverse acc)) (t (remove-acl2-parent (cdr topics) (cons (cond ((and (eq (cdr (assoc-eq :name (car topics))) 'acl2::acl2) (equal (cdr (assoc-eq :parents (car topics))) '(acl2::top))) (put-assoc-eq :parents nil (car topics))) (t (car topics))) acc))))) (acl2::defconsts (& & state) (state-global-let* ((current-package "ACL2" set-current-package-state)) (b* ((all-topics (remove-acl2-parent (get-xdoc-table (w state)) nil)) ((mv rendered state) (render-topics all-topics all-topics state)) (rendered (split-acl2-topics rendered nil nil nil)) (- (cw "Writing rendered-doc.lsp~%")) ((mv channel state) (open-output-channel! "rendered-doc.lsp" :character state)) ((unless channel) (cw "can't open rendered-doc.lsp for output.") (acl2::silent-error state)) (state (princ$ "; Documentation for the ACL2 Theorem Prover ; WARNING: GENERATED FILE, DO NOT HAND EDIT! ; The contents of this file are derived from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. ; ACL2 Version 7.1 -- A Computational Logic for Applicative Common Lisp ; Copyright (C) 2015, Regents of the University of Texas ; This version of ACL2 is a descendent of ACL2 Version 1.9, Copyright ; (C) 1997 Computational Logic, Inc. See the documentation topic NOTE-2-0. ; This program is free software; you can redistribute it and/or modify ; it under the terms of the LICENSE file distributed with ACL2. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; LICENSE for more details. ; Here are the original authors of books/system/doc/acl2-doc.lisp. ; Additional contributions may have been made to that file by members ; of the ACL2 community. ; Written by: PI:NAME:<NAME>END_PI and PI:NAME:<NAME>END_PI ; email: PI:EMAIL:<EMAIL>END_PI and PI:EMAIL:<EMAIL>END_PI ; Department of Computer Science ; University of Texas at Austin ; Austin, TX 78701 U.S.A. ; WARNING: This file is generated from ACL2 Community Book ; books/system/doc/acl2-doc.lisp. To edit ACL2 documentation modify ; that file, not this one! Instructions are just above the in-package ; form in that book. (in-package \"ACL2\") (defconst *acl2-system-documentation* '" channel state)) (state (fms! "~x0" (list (cons #\0 rendered)) channel state nil)) (state (fms! ")" nil channel state nil)) (state (newline channel state)) (state (close-output-channel channel state))) (value nil))))
[ { "context": "ies if the input is a bit (0 or 1)\n;\n\n; Deleted by Matt K. on 6/10/2013 because bitp is defined in\n; ihs/bas", "end": 1848, "score": 0.9998730421066284, "start": 1842, "tag": "NAME", "value": "Matt K" }, { "context": " definition from ihs/basic-definitions.lisp:\n\n;; [Jared] changing this to just include the basic-definiti", "end": 2209, "score": 0.9915041923522949, "start": 2204, "tag": "NAME", "value": "Jared" }, { "context": " (prefix-nth bit-list n)))))\n\n;\n; David Rager's Lemma - this is required to admit the below the", "end": 13380, "score": 0.9410818219184875, "start": 13369, "tag": "NAME", "value": "David Rager" } ]
books/projects/security/util/byte-operations.lisp
mayankmanj/acl2
305
(in-package "ACL2") ; cert_param: (non-acl2r) (include-book "arithmetic-5/top" :dir :system) ; ; Converts a list of characters to bytes ; (defun charlist-to-bytes(charlist) (if (atom charlist) nil (cons (char-code (car charlist)) (charlist-to-bytes(cdr charlist))))) ; ; Converts an entire string into a list of bytes ; (defun string-to-bytes(S) (charlist-to-bytes(coerce S 'LIST))) ; ; Theorem asserting that the length of the string is essentially same as the ; length of the list of bytes representing it. ; (defthm coerce-produces-chars (implies (stringp S) (character-listp (coerce S 'LIST)))) (defthm num-chars-equals-num-bytes (implies (character-listp cl) (equal (len cl) (len (charlist-to-bytes cl))))) ; ; This does not go through unless I include (> (len S) 0) ; ;(defthm string-length-equals-num-bytes ; (implies (stringp S) ; (equal (len S) ; (len (string-to-bytes S))))) ; ; Converts a large integer into a list of bytes (little-endian) ; (defun make-bytes(number-int) (declare (xargs :guard (natp number-int))) (if (< number-int 256) (cons number-int nil) (cons (mod number-int 256) (make-bytes (ash number-int -8))))) (defun make-bytes-msb(number-int) (declare (xargs :guard (natp number-int))) (reverse (make-bytes number-int))) ; ; This method constructs a list consisting of length x and consisting of only ; the item n repeated x times. ; (defun make-list-n (n x) (if (or (zp x) (not (atom n))) nil (cons n (make-list-n n (- x 1))))) (defthm length-x-make-list-n (implies (and (natp x) (natp n)) (equal (len (make-list-n n x)) x))) ; ; Verifies if the input is a bit (0 or 1) ; ; Deleted by Matt K. on 6/10/2013 because bitp is defined in ; ihs/basic-definitions.lisp, which is now included under centaur/gl/gl.lisp, ; and both the latter book and this one are included in ../des/des.lisp ; (defun bitp(e) ; (if (consp e) ; nil ; (or (equal e 0) ; (equal e 1)))) ; So here is the definition from ihs/basic-definitions.lisp: ;; [Jared] changing this to just include the basic-definitions book from IHS. ;; It's very lightweight, and this way we don't duplicate the definition and ;; have to maintain it in two places. (include-book "ihs/basic-definitions" :dir :system) ; ; Computes the logical XOR of two single bits ; (defun xor-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) 0 1) nil)) ; ; Computes the logical AND of two single bits ; (defun and-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) x 0) nil)) ; ; Computes the complement of a single bit ; (defun not-bit(x) (if (and (atom x) (bitp x)) (if (equal x 1) 0 1) nil)) ; ; This method verifies if the input is a bit-list ; (defun bit-listp(x) (if (atom x) nil (if (null (cdr x)) (bitp (car x)) (and (bitp (car x)) (bit-listp (cdr x)))))) ; ; n-bitp is a generic method that verifies if a list has n bits ; The other methods are just wrappers that are used for better readability of ; the code, and therefore directly call n-bitp. ; (defun n-bitp(x-bits n) (and (bit-listp x-bits) (equal (len x-bits) n))) (defun 64-bitp(x-bits) (n-bitp x-bits 64)) (defun 56-bitp(x-bits) (n-bitp x-bits 56)) (defun 48-bitp(x-bits) (n-bitp x-bits 48)) (defun 32-bitp(x-bits) (n-bitp x-bits 32)) (defun 28-bitp(x-bits) (n-bitp x-bits 28)) (defun 8-bitp(x-bits) (n-bitp x-bits 8)) (defun 6-bitp(x-bits) (n-bitp x-bits 6)) ; ; This methods verifies if the bit-list being provided to it has a length that ; is a multiple of 64. ; (defun 64-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 64)))) (defun 8-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 8)))) ; ; This method computes a logical compliment of two bit lists ; (defun not-bit-list(x) (if (bit-listp x) (cons (not-bit (car x)) (not-bit-list (cdr x))) nil)) ; ; Correctness for not-bit ; (defthm not-not-bit (implies (bitp x) (equal (not-bit (not-bit x)) x))) ; ; Correctness theorem for not-bit-list ; (defthm not-not-bit-list (implies (bit-listp x) (equal (not-bit-list (not-bit-list x)) x))) ; ; This method computes a logical AND of two bit lists ; (defun and-bit-list(x y) (if (and (bit-listp x) (bit-listp y)) (cons (and-bit (car x) (car y)) (and-bit-list (cdr x) (cdr y))) nil)) ; ; Correctness theorem for and-bit ; (defthm and-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (and-bit x y) (and-bit y x)) (equal (and-bit x x) x) (equal (and-bit y y) y)))) ; ; Correctness theorem for and-bit-list ; (defthm and-bit-list-correct (implies (and (bit-listp x) (bit-listp y)) (and (equal (and-bit-list x y) (and-bit-list y x)) (equal (and-bit-list x x) x) (equal (and-bit-list y y) y)))) ; ; This method computes a logical XOR of two bit lists ; (defun xor-bit-list(x y) (if (atom x) (if (bit-listp y) y nil) (if (atom y) (if (bit-listp x) x nil) (cons (xor-bit (car x) (car y)) (xor-bit-list (cdr x) (cdr y)))))) ; ; Correctness theorem for xor-bit ; (defthm xor-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (xor-bit x y) (xor-bit y x)) (equal (xor-bit x x) 0) (equal (xor-bit y y) 0)))) ; ; Correctness theorem for xor-bit-list ; NOT YET PROVED ; ;(defthm xor-bit-list-correct ; (implies (and (bit-listp x) ; (bit-listp y)) ; (and (equal (xor-bit-list x y) ; (xor-bit-list y x)) ; (equal (bits-to-number (xor-bit-list x x)) ; 0) ; (equal (bits-to-number (xor-bit-list y y)) ; 0)))) ; ; This method is the reverse of bits-to-number and computes ; bit list out of a number. ; (defun number-to-bits(x) (if (not (natp x)) nil (if (< x 2) (cons x nil) (cons (mod x 2) (number-to-bits (floor x 2)))))) (defun number-to-32bits(x) (if (not (natp x)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 32 len-list)))))) (defun number-to-8bits(x) (if (or (not (natp x)) (> x 255)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 8 len-list)))))) (defun number-to-4bits(x) (if (or (not (natp x)) (> x 15)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 4 len-list)))))) (defun number-to-4bits-msb(x) (reverse (number-to-4bits x))) ; ; Method to convert a list of bytes to bits using the number-to-bits method ; (defun bytes-to-8bits-msb(bytes) (if (atom bytes) nil (append (reverse (number-to-8bits (car bytes))) (bytes-to-8bits-msb (cdr bytes))))) ; ; Method to convert a string to bits using the number-to-bits method ; (defun string-to-bits-msb(S) (if (not (stringp S)) nil (let ((bytes (string-to-bytes S))) (bytes-to-8bits-msb bytes)))) ; ; This method is the reverse of number-to-bits and computes ; the decimal equivalent of a bit list. ; (defun bits-to-number1(x exp) (if (not (bit-listp x)) nil (let ((val (* (car x) (expt 2 exp)))) (if (null (cdr x)) val (+ val (bits-to-number1 (cdr x) (+ 1 exp))))))) (defun bits-to-number(x) (bits-to-number1 x 0)) ; ; Theorem to prove correctness of number-to-bits and bits-to-number ; NOT PROVED YET ; ;(defthm bits-number-correct ; (implies (natp x) ; (equal (bits-to-number (number-to-bits x)) ; x))) ; ; A method that computes the logical-XOR of two numbers ; In our case these will be two 32-bit numbers ; (defun xor-number(x y) (bits-to-number (xor-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that computes the logical-AND of two numbers ; In our case these will be two 32-bit numbers ; (defun and-number(x y) (bits-to-number (and-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that converts a number into its bit complement ; In our case this will be a 32-bit number ; (defun not-number(x) (bits-to-number (not-bit-list (number-to-32bits x)))) ; ; Method for getting a list out of the remaining items ; after removing the first n items ; (defun get-nth(x n) (if (< n 0) nil (if (atom x) nil (if (= n 0) x (get-nth (cdr x) (- n 1)))))) ; ; Correctness of get-nth ; (defthm get-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (+ n (len (get-nth x n))) (len x)))) ; ; Method for getting a list out of the first n items from ; a list of items. ; (defun prefix-nth(x n) (if (<= n 0) nil (if (atom x) nil (cons (car x) (prefix-nth (cdr x) (- n 1)))))) ; ; Correctness of prefix-nth ; (defthm prefix-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (len (prefix-nth x n)) n))) ; ; Correctness of get-nth and prefix-nth ; (defthm get-nth-prefix-correct (implies (and (natp n) (consp x) (< n (len x))) (and (equal (append (prefix-nth x n) (get-nth x n)) x) (equal (len (append (prefix-nth x n) (get-nth x n))) (len x))))) ; ; Following methods deal with converting a list of large bits ; (with 8bit boundaries) into a string. ; ; ; This method takes in 8 bits and converts it into a byte ; (defun 8bits-to-byte (x) (if (not (8-bitp x)) nil (+ (* (Nth 0 x) 128) (* (Nth 1 x) 64) (* (Nth 2 x) 32) (* (Nth 3 x) 16) (* (Nth 4 x) 8) (* (Nth 5 x) 4) (* (Nth 6 x) 2) (* (Nth 7 x) 1)))) ; ; Lemma to help acl2 admit the following method ; and another method at the end of the file ; (defthm get-nth-posp-reduces-length (implies (and (consp message) (posp n)) (< (len (get-nth message n)) (len message)))) ; ; This method takes a list of bits and groups them into smaller ; inner lists of 8 bits each. ; (defun bits-to-8bits (x) (declare (xargs :measure (len x))) (if (atom x) nil (if (<= (len x) 8) (cons x nil) (cons (prefix-nth x 8) (bits-to-8bits (get-nth x 8)))))) ; ; This method takes a list of 8bit groups and converts this list into ; a list of bytes ; (defun 8bits-to-bytes (x) (if (atom x) nil (cons (8bits-to-byte (car x)) (8bits-to-bytes (cdr x))))) ; ; A method to convert a list of bits to bytes ; (defun bits-to-bytes (x) (if (atom x) nil (8bits-to-bytes (bits-to-8bits x)))) ; ; A method which converts each byte in a list into a character using the ; built in code-char function ; (defun bytes-to-charlist (x) (if (atom x) nil (cons (code-char (car x)) (bytes-to-charlist (cdr x))))) ; ; An uber level function that converts a bigendian list of bits (multiple ; of 8 bits) to a string by first converting them into groups of 8, converting ; these groups into bytes, converting these bytes into characters and then ; using coerce to force this character list to a string. ; (defun bigendian-bits-to-string (x) (if (not (8-bit-multiplep x)) nil (let* ((8bit-groups (bits-to-8bits x)) (bytes (8bits-to-bytes 8bit-groups)) (charlist (bytes-to-charlist bytes))) (coerce charlist 'string)))) ; ; This method rotates a list of bits to the right by n bits ; This is called by rightrotate, after converting a number to bits ; (defun rightrotate-bits (bit-list n) (if (< n 0) nil (if (atom bit-list) nil (append (get-nth bit-list n) (prefix-nth bit-list n))))) ; ; David Rager's Lemma - this is required to admit the below theorem. ; (defthm get-nth-lemma-rotate (implies (true-listp x) (equal (get-nth x (len x)) nil))) ; ; Correctness of rightrotate ; (defthm rightrotate-bits-correct (implies (true-listp x) (equal (rightrotate-bits x (len x)) x))) ; ; This method rotates a number to the right by n bits ; The number here is a decimal representation of a 32bit integer ; (defun rightrotate(number n) (let ((bit-list (number-to-32bits number))) (bits-to-number (rightrotate-bits bit-list n)))) ; ; Addition modulo (expt 2 32) ; (defun add-32bit (x y) (if (and (natp x) (natp y)) (mod (+ x y) (expt 2 32)) nil)) ; ; This method converts a list of bytes and converts it to 32bit numbers ; (defun bytes-to-32bit-blocks1(byte-list currval m) (if (atom byte-list) nil (let ((val (+ (* currval 256) (car byte-list)))) (if (null (cdr byte-list)) (cons val nil) (if (equal 1 m) (cons val (bytes-to-32bit-blocks1 (cdr byte-list) 0 4)) (bytes-to-32bit-blocks1 (cdr byte-list) val (- m 1))))))) (defun bytes-to-32bit-blocks(byte-list) (bytes-to-32bit-blocks1 byte-list 0 4)) ; ; This routine splits a list of bytes into a list of lists ; which contain 64 bytes each = 512 bits. ; (defun bytes-to-multiple-64-byte-blocks (message-bytes) (declare (xargs :measure (len message-bytes))) (if (atom message-bytes) nil (if (<= (len message-bytes) 64) (cons message-bytes nil) (cons (prefix-nth message-bytes 64) (bytes-to-multiple-64-byte-blocks (get-nth message-bytes 64))))))
89977
(in-package "ACL2") ; cert_param: (non-acl2r) (include-book "arithmetic-5/top" :dir :system) ; ; Converts a list of characters to bytes ; (defun charlist-to-bytes(charlist) (if (atom charlist) nil (cons (char-code (car charlist)) (charlist-to-bytes(cdr charlist))))) ; ; Converts an entire string into a list of bytes ; (defun string-to-bytes(S) (charlist-to-bytes(coerce S 'LIST))) ; ; Theorem asserting that the length of the string is essentially same as the ; length of the list of bytes representing it. ; (defthm coerce-produces-chars (implies (stringp S) (character-listp (coerce S 'LIST)))) (defthm num-chars-equals-num-bytes (implies (character-listp cl) (equal (len cl) (len (charlist-to-bytes cl))))) ; ; This does not go through unless I include (> (len S) 0) ; ;(defthm string-length-equals-num-bytes ; (implies (stringp S) ; (equal (len S) ; (len (string-to-bytes S))))) ; ; Converts a large integer into a list of bytes (little-endian) ; (defun make-bytes(number-int) (declare (xargs :guard (natp number-int))) (if (< number-int 256) (cons number-int nil) (cons (mod number-int 256) (make-bytes (ash number-int -8))))) (defun make-bytes-msb(number-int) (declare (xargs :guard (natp number-int))) (reverse (make-bytes number-int))) ; ; This method constructs a list consisting of length x and consisting of only ; the item n repeated x times. ; (defun make-list-n (n x) (if (or (zp x) (not (atom n))) nil (cons n (make-list-n n (- x 1))))) (defthm length-x-make-list-n (implies (and (natp x) (natp n)) (equal (len (make-list-n n x)) x))) ; ; Verifies if the input is a bit (0 or 1) ; ; Deleted by <NAME>. on 6/10/2013 because bitp is defined in ; ihs/basic-definitions.lisp, which is now included under centaur/gl/gl.lisp, ; and both the latter book and this one are included in ../des/des.lisp ; (defun bitp(e) ; (if (consp e) ; nil ; (or (equal e 0) ; (equal e 1)))) ; So here is the definition from ihs/basic-definitions.lisp: ;; [<NAME>] changing this to just include the basic-definitions book from IHS. ;; It's very lightweight, and this way we don't duplicate the definition and ;; have to maintain it in two places. (include-book "ihs/basic-definitions" :dir :system) ; ; Computes the logical XOR of two single bits ; (defun xor-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) 0 1) nil)) ; ; Computes the logical AND of two single bits ; (defun and-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) x 0) nil)) ; ; Computes the complement of a single bit ; (defun not-bit(x) (if (and (atom x) (bitp x)) (if (equal x 1) 0 1) nil)) ; ; This method verifies if the input is a bit-list ; (defun bit-listp(x) (if (atom x) nil (if (null (cdr x)) (bitp (car x)) (and (bitp (car x)) (bit-listp (cdr x)))))) ; ; n-bitp is a generic method that verifies if a list has n bits ; The other methods are just wrappers that are used for better readability of ; the code, and therefore directly call n-bitp. ; (defun n-bitp(x-bits n) (and (bit-listp x-bits) (equal (len x-bits) n))) (defun 64-bitp(x-bits) (n-bitp x-bits 64)) (defun 56-bitp(x-bits) (n-bitp x-bits 56)) (defun 48-bitp(x-bits) (n-bitp x-bits 48)) (defun 32-bitp(x-bits) (n-bitp x-bits 32)) (defun 28-bitp(x-bits) (n-bitp x-bits 28)) (defun 8-bitp(x-bits) (n-bitp x-bits 8)) (defun 6-bitp(x-bits) (n-bitp x-bits 6)) ; ; This methods verifies if the bit-list being provided to it has a length that ; is a multiple of 64. ; (defun 64-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 64)))) (defun 8-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 8)))) ; ; This method computes a logical compliment of two bit lists ; (defun not-bit-list(x) (if (bit-listp x) (cons (not-bit (car x)) (not-bit-list (cdr x))) nil)) ; ; Correctness for not-bit ; (defthm not-not-bit (implies (bitp x) (equal (not-bit (not-bit x)) x))) ; ; Correctness theorem for not-bit-list ; (defthm not-not-bit-list (implies (bit-listp x) (equal (not-bit-list (not-bit-list x)) x))) ; ; This method computes a logical AND of two bit lists ; (defun and-bit-list(x y) (if (and (bit-listp x) (bit-listp y)) (cons (and-bit (car x) (car y)) (and-bit-list (cdr x) (cdr y))) nil)) ; ; Correctness theorem for and-bit ; (defthm and-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (and-bit x y) (and-bit y x)) (equal (and-bit x x) x) (equal (and-bit y y) y)))) ; ; Correctness theorem for and-bit-list ; (defthm and-bit-list-correct (implies (and (bit-listp x) (bit-listp y)) (and (equal (and-bit-list x y) (and-bit-list y x)) (equal (and-bit-list x x) x) (equal (and-bit-list y y) y)))) ; ; This method computes a logical XOR of two bit lists ; (defun xor-bit-list(x y) (if (atom x) (if (bit-listp y) y nil) (if (atom y) (if (bit-listp x) x nil) (cons (xor-bit (car x) (car y)) (xor-bit-list (cdr x) (cdr y)))))) ; ; Correctness theorem for xor-bit ; (defthm xor-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (xor-bit x y) (xor-bit y x)) (equal (xor-bit x x) 0) (equal (xor-bit y y) 0)))) ; ; Correctness theorem for xor-bit-list ; NOT YET PROVED ; ;(defthm xor-bit-list-correct ; (implies (and (bit-listp x) ; (bit-listp y)) ; (and (equal (xor-bit-list x y) ; (xor-bit-list y x)) ; (equal (bits-to-number (xor-bit-list x x)) ; 0) ; (equal (bits-to-number (xor-bit-list y y)) ; 0)))) ; ; This method is the reverse of bits-to-number and computes ; bit list out of a number. ; (defun number-to-bits(x) (if (not (natp x)) nil (if (< x 2) (cons x nil) (cons (mod x 2) (number-to-bits (floor x 2)))))) (defun number-to-32bits(x) (if (not (natp x)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 32 len-list)))))) (defun number-to-8bits(x) (if (or (not (natp x)) (> x 255)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 8 len-list)))))) (defun number-to-4bits(x) (if (or (not (natp x)) (> x 15)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 4 len-list)))))) (defun number-to-4bits-msb(x) (reverse (number-to-4bits x))) ; ; Method to convert a list of bytes to bits using the number-to-bits method ; (defun bytes-to-8bits-msb(bytes) (if (atom bytes) nil (append (reverse (number-to-8bits (car bytes))) (bytes-to-8bits-msb (cdr bytes))))) ; ; Method to convert a string to bits using the number-to-bits method ; (defun string-to-bits-msb(S) (if (not (stringp S)) nil (let ((bytes (string-to-bytes S))) (bytes-to-8bits-msb bytes)))) ; ; This method is the reverse of number-to-bits and computes ; the decimal equivalent of a bit list. ; (defun bits-to-number1(x exp) (if (not (bit-listp x)) nil (let ((val (* (car x) (expt 2 exp)))) (if (null (cdr x)) val (+ val (bits-to-number1 (cdr x) (+ 1 exp))))))) (defun bits-to-number(x) (bits-to-number1 x 0)) ; ; Theorem to prove correctness of number-to-bits and bits-to-number ; NOT PROVED YET ; ;(defthm bits-number-correct ; (implies (natp x) ; (equal (bits-to-number (number-to-bits x)) ; x))) ; ; A method that computes the logical-XOR of two numbers ; In our case these will be two 32-bit numbers ; (defun xor-number(x y) (bits-to-number (xor-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that computes the logical-AND of two numbers ; In our case these will be two 32-bit numbers ; (defun and-number(x y) (bits-to-number (and-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that converts a number into its bit complement ; In our case this will be a 32-bit number ; (defun not-number(x) (bits-to-number (not-bit-list (number-to-32bits x)))) ; ; Method for getting a list out of the remaining items ; after removing the first n items ; (defun get-nth(x n) (if (< n 0) nil (if (atom x) nil (if (= n 0) x (get-nth (cdr x) (- n 1)))))) ; ; Correctness of get-nth ; (defthm get-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (+ n (len (get-nth x n))) (len x)))) ; ; Method for getting a list out of the first n items from ; a list of items. ; (defun prefix-nth(x n) (if (<= n 0) nil (if (atom x) nil (cons (car x) (prefix-nth (cdr x) (- n 1)))))) ; ; Correctness of prefix-nth ; (defthm prefix-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (len (prefix-nth x n)) n))) ; ; Correctness of get-nth and prefix-nth ; (defthm get-nth-prefix-correct (implies (and (natp n) (consp x) (< n (len x))) (and (equal (append (prefix-nth x n) (get-nth x n)) x) (equal (len (append (prefix-nth x n) (get-nth x n))) (len x))))) ; ; Following methods deal with converting a list of large bits ; (with 8bit boundaries) into a string. ; ; ; This method takes in 8 bits and converts it into a byte ; (defun 8bits-to-byte (x) (if (not (8-bitp x)) nil (+ (* (Nth 0 x) 128) (* (Nth 1 x) 64) (* (Nth 2 x) 32) (* (Nth 3 x) 16) (* (Nth 4 x) 8) (* (Nth 5 x) 4) (* (Nth 6 x) 2) (* (Nth 7 x) 1)))) ; ; Lemma to help acl2 admit the following method ; and another method at the end of the file ; (defthm get-nth-posp-reduces-length (implies (and (consp message) (posp n)) (< (len (get-nth message n)) (len message)))) ; ; This method takes a list of bits and groups them into smaller ; inner lists of 8 bits each. ; (defun bits-to-8bits (x) (declare (xargs :measure (len x))) (if (atom x) nil (if (<= (len x) 8) (cons x nil) (cons (prefix-nth x 8) (bits-to-8bits (get-nth x 8)))))) ; ; This method takes a list of 8bit groups and converts this list into ; a list of bytes ; (defun 8bits-to-bytes (x) (if (atom x) nil (cons (8bits-to-byte (car x)) (8bits-to-bytes (cdr x))))) ; ; A method to convert a list of bits to bytes ; (defun bits-to-bytes (x) (if (atom x) nil (8bits-to-bytes (bits-to-8bits x)))) ; ; A method which converts each byte in a list into a character using the ; built in code-char function ; (defun bytes-to-charlist (x) (if (atom x) nil (cons (code-char (car x)) (bytes-to-charlist (cdr x))))) ; ; An uber level function that converts a bigendian list of bits (multiple ; of 8 bits) to a string by first converting them into groups of 8, converting ; these groups into bytes, converting these bytes into characters and then ; using coerce to force this character list to a string. ; (defun bigendian-bits-to-string (x) (if (not (8-bit-multiplep x)) nil (let* ((8bit-groups (bits-to-8bits x)) (bytes (8bits-to-bytes 8bit-groups)) (charlist (bytes-to-charlist bytes))) (coerce charlist 'string)))) ; ; This method rotates a list of bits to the right by n bits ; This is called by rightrotate, after converting a number to bits ; (defun rightrotate-bits (bit-list n) (if (< n 0) nil (if (atom bit-list) nil (append (get-nth bit-list n) (prefix-nth bit-list n))))) ; ; <NAME>'s Lemma - this is required to admit the below theorem. ; (defthm get-nth-lemma-rotate (implies (true-listp x) (equal (get-nth x (len x)) nil))) ; ; Correctness of rightrotate ; (defthm rightrotate-bits-correct (implies (true-listp x) (equal (rightrotate-bits x (len x)) x))) ; ; This method rotates a number to the right by n bits ; The number here is a decimal representation of a 32bit integer ; (defun rightrotate(number n) (let ((bit-list (number-to-32bits number))) (bits-to-number (rightrotate-bits bit-list n)))) ; ; Addition modulo (expt 2 32) ; (defun add-32bit (x y) (if (and (natp x) (natp y)) (mod (+ x y) (expt 2 32)) nil)) ; ; This method converts a list of bytes and converts it to 32bit numbers ; (defun bytes-to-32bit-blocks1(byte-list currval m) (if (atom byte-list) nil (let ((val (+ (* currval 256) (car byte-list)))) (if (null (cdr byte-list)) (cons val nil) (if (equal 1 m) (cons val (bytes-to-32bit-blocks1 (cdr byte-list) 0 4)) (bytes-to-32bit-blocks1 (cdr byte-list) val (- m 1))))))) (defun bytes-to-32bit-blocks(byte-list) (bytes-to-32bit-blocks1 byte-list 0 4)) ; ; This routine splits a list of bytes into a list of lists ; which contain 64 bytes each = 512 bits. ; (defun bytes-to-multiple-64-byte-blocks (message-bytes) (declare (xargs :measure (len message-bytes))) (if (atom message-bytes) nil (if (<= (len message-bytes) 64) (cons message-bytes nil) (cons (prefix-nth message-bytes 64) (bytes-to-multiple-64-byte-blocks (get-nth message-bytes 64))))))
true
(in-package "ACL2") ; cert_param: (non-acl2r) (include-book "arithmetic-5/top" :dir :system) ; ; Converts a list of characters to bytes ; (defun charlist-to-bytes(charlist) (if (atom charlist) nil (cons (char-code (car charlist)) (charlist-to-bytes(cdr charlist))))) ; ; Converts an entire string into a list of bytes ; (defun string-to-bytes(S) (charlist-to-bytes(coerce S 'LIST))) ; ; Theorem asserting that the length of the string is essentially same as the ; length of the list of bytes representing it. ; (defthm coerce-produces-chars (implies (stringp S) (character-listp (coerce S 'LIST)))) (defthm num-chars-equals-num-bytes (implies (character-listp cl) (equal (len cl) (len (charlist-to-bytes cl))))) ; ; This does not go through unless I include (> (len S) 0) ; ;(defthm string-length-equals-num-bytes ; (implies (stringp S) ; (equal (len S) ; (len (string-to-bytes S))))) ; ; Converts a large integer into a list of bytes (little-endian) ; (defun make-bytes(number-int) (declare (xargs :guard (natp number-int))) (if (< number-int 256) (cons number-int nil) (cons (mod number-int 256) (make-bytes (ash number-int -8))))) (defun make-bytes-msb(number-int) (declare (xargs :guard (natp number-int))) (reverse (make-bytes number-int))) ; ; This method constructs a list consisting of length x and consisting of only ; the item n repeated x times. ; (defun make-list-n (n x) (if (or (zp x) (not (atom n))) nil (cons n (make-list-n n (- x 1))))) (defthm length-x-make-list-n (implies (and (natp x) (natp n)) (equal (len (make-list-n n x)) x))) ; ; Verifies if the input is a bit (0 or 1) ; ; Deleted by PI:NAME:<NAME>END_PI. on 6/10/2013 because bitp is defined in ; ihs/basic-definitions.lisp, which is now included under centaur/gl/gl.lisp, ; and both the latter book and this one are included in ../des/des.lisp ; (defun bitp(e) ; (if (consp e) ; nil ; (or (equal e 0) ; (equal e 1)))) ; So here is the definition from ihs/basic-definitions.lisp: ;; [PI:NAME:<NAME>END_PI] changing this to just include the basic-definitions book from IHS. ;; It's very lightweight, and this way we don't duplicate the definition and ;; have to maintain it in two places. (include-book "ihs/basic-definitions" :dir :system) ; ; Computes the logical XOR of two single bits ; (defun xor-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) 0 1) nil)) ; ; Computes the logical AND of two single bits ; (defun and-bit(x y) (if (and (atom x) (atom y) (bitp x) (bitp y)) (if (equal x y) x 0) nil)) ; ; Computes the complement of a single bit ; (defun not-bit(x) (if (and (atom x) (bitp x)) (if (equal x 1) 0 1) nil)) ; ; This method verifies if the input is a bit-list ; (defun bit-listp(x) (if (atom x) nil (if (null (cdr x)) (bitp (car x)) (and (bitp (car x)) (bit-listp (cdr x)))))) ; ; n-bitp is a generic method that verifies if a list has n bits ; The other methods are just wrappers that are used for better readability of ; the code, and therefore directly call n-bitp. ; (defun n-bitp(x-bits n) (and (bit-listp x-bits) (equal (len x-bits) n))) (defun 64-bitp(x-bits) (n-bitp x-bits 64)) (defun 56-bitp(x-bits) (n-bitp x-bits 56)) (defun 48-bitp(x-bits) (n-bitp x-bits 48)) (defun 32-bitp(x-bits) (n-bitp x-bits 32)) (defun 28-bitp(x-bits) (n-bitp x-bits 28)) (defun 8-bitp(x-bits) (n-bitp x-bits 8)) (defun 6-bitp(x-bits) (n-bitp x-bits 6)) ; ; This methods verifies if the bit-list being provided to it has a length that ; is a multiple of 64. ; (defun 64-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 64)))) (defun 8-bit-multiplep(x-bits) (and (bit-listp x-bits) (equal 0 (mod (len x-bits) 8)))) ; ; This method computes a logical compliment of two bit lists ; (defun not-bit-list(x) (if (bit-listp x) (cons (not-bit (car x)) (not-bit-list (cdr x))) nil)) ; ; Correctness for not-bit ; (defthm not-not-bit (implies (bitp x) (equal (not-bit (not-bit x)) x))) ; ; Correctness theorem for not-bit-list ; (defthm not-not-bit-list (implies (bit-listp x) (equal (not-bit-list (not-bit-list x)) x))) ; ; This method computes a logical AND of two bit lists ; (defun and-bit-list(x y) (if (and (bit-listp x) (bit-listp y)) (cons (and-bit (car x) (car y)) (and-bit-list (cdr x) (cdr y))) nil)) ; ; Correctness theorem for and-bit ; (defthm and-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (and-bit x y) (and-bit y x)) (equal (and-bit x x) x) (equal (and-bit y y) y)))) ; ; Correctness theorem for and-bit-list ; (defthm and-bit-list-correct (implies (and (bit-listp x) (bit-listp y)) (and (equal (and-bit-list x y) (and-bit-list y x)) (equal (and-bit-list x x) x) (equal (and-bit-list y y) y)))) ; ; This method computes a logical XOR of two bit lists ; (defun xor-bit-list(x y) (if (atom x) (if (bit-listp y) y nil) (if (atom y) (if (bit-listp x) x nil) (cons (xor-bit (car x) (car y)) (xor-bit-list (cdr x) (cdr y)))))) ; ; Correctness theorem for xor-bit ; (defthm xor-bit-correct (implies (and (bitp x) (bitp y)) (and (equal (xor-bit x y) (xor-bit y x)) (equal (xor-bit x x) 0) (equal (xor-bit y y) 0)))) ; ; Correctness theorem for xor-bit-list ; NOT YET PROVED ; ;(defthm xor-bit-list-correct ; (implies (and (bit-listp x) ; (bit-listp y)) ; (and (equal (xor-bit-list x y) ; (xor-bit-list y x)) ; (equal (bits-to-number (xor-bit-list x x)) ; 0) ; (equal (bits-to-number (xor-bit-list y y)) ; 0)))) ; ; This method is the reverse of bits-to-number and computes ; bit list out of a number. ; (defun number-to-bits(x) (if (not (natp x)) nil (if (< x 2) (cons x nil) (cons (mod x 2) (number-to-bits (floor x 2)))))) (defun number-to-32bits(x) (if (not (natp x)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 32 len-list)))))) (defun number-to-8bits(x) (if (or (not (natp x)) (> x 255)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 8 len-list)))))) (defun number-to-4bits(x) (if (or (not (natp x)) (> x 15)) nil (let* ((bit-list (number-to-bits x)) (len-list (len bit-list))) (append bit-list (make-list-n 0 (- 4 len-list)))))) (defun number-to-4bits-msb(x) (reverse (number-to-4bits x))) ; ; Method to convert a list of bytes to bits using the number-to-bits method ; (defun bytes-to-8bits-msb(bytes) (if (atom bytes) nil (append (reverse (number-to-8bits (car bytes))) (bytes-to-8bits-msb (cdr bytes))))) ; ; Method to convert a string to bits using the number-to-bits method ; (defun string-to-bits-msb(S) (if (not (stringp S)) nil (let ((bytes (string-to-bytes S))) (bytes-to-8bits-msb bytes)))) ; ; This method is the reverse of number-to-bits and computes ; the decimal equivalent of a bit list. ; (defun bits-to-number1(x exp) (if (not (bit-listp x)) nil (let ((val (* (car x) (expt 2 exp)))) (if (null (cdr x)) val (+ val (bits-to-number1 (cdr x) (+ 1 exp))))))) (defun bits-to-number(x) (bits-to-number1 x 0)) ; ; Theorem to prove correctness of number-to-bits and bits-to-number ; NOT PROVED YET ; ;(defthm bits-number-correct ; (implies (natp x) ; (equal (bits-to-number (number-to-bits x)) ; x))) ; ; A method that computes the logical-XOR of two numbers ; In our case these will be two 32-bit numbers ; (defun xor-number(x y) (bits-to-number (xor-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that computes the logical-AND of two numbers ; In our case these will be two 32-bit numbers ; (defun and-number(x y) (bits-to-number (and-bit-list (number-to-32bits x) (number-to-32bits y)))) ; ; A method that converts a number into its bit complement ; In our case this will be a 32-bit number ; (defun not-number(x) (bits-to-number (not-bit-list (number-to-32bits x)))) ; ; Method for getting a list out of the remaining items ; after removing the first n items ; (defun get-nth(x n) (if (< n 0) nil (if (atom x) nil (if (= n 0) x (get-nth (cdr x) (- n 1)))))) ; ; Correctness of get-nth ; (defthm get-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (+ n (len (get-nth x n))) (len x)))) ; ; Method for getting a list out of the first n items from ; a list of items. ; (defun prefix-nth(x n) (if (<= n 0) nil (if (atom x) nil (cons (car x) (prefix-nth (cdr x) (- n 1)))))) ; ; Correctness of prefix-nth ; (defthm prefix-nth-correct (implies (and (natp n) (consp x) (> (len x) n)) (equal (len (prefix-nth x n)) n))) ; ; Correctness of get-nth and prefix-nth ; (defthm get-nth-prefix-correct (implies (and (natp n) (consp x) (< n (len x))) (and (equal (append (prefix-nth x n) (get-nth x n)) x) (equal (len (append (prefix-nth x n) (get-nth x n))) (len x))))) ; ; Following methods deal with converting a list of large bits ; (with 8bit boundaries) into a string. ; ; ; This method takes in 8 bits and converts it into a byte ; (defun 8bits-to-byte (x) (if (not (8-bitp x)) nil (+ (* (Nth 0 x) 128) (* (Nth 1 x) 64) (* (Nth 2 x) 32) (* (Nth 3 x) 16) (* (Nth 4 x) 8) (* (Nth 5 x) 4) (* (Nth 6 x) 2) (* (Nth 7 x) 1)))) ; ; Lemma to help acl2 admit the following method ; and another method at the end of the file ; (defthm get-nth-posp-reduces-length (implies (and (consp message) (posp n)) (< (len (get-nth message n)) (len message)))) ; ; This method takes a list of bits and groups them into smaller ; inner lists of 8 bits each. ; (defun bits-to-8bits (x) (declare (xargs :measure (len x))) (if (atom x) nil (if (<= (len x) 8) (cons x nil) (cons (prefix-nth x 8) (bits-to-8bits (get-nth x 8)))))) ; ; This method takes a list of 8bit groups and converts this list into ; a list of bytes ; (defun 8bits-to-bytes (x) (if (atom x) nil (cons (8bits-to-byte (car x)) (8bits-to-bytes (cdr x))))) ; ; A method to convert a list of bits to bytes ; (defun bits-to-bytes (x) (if (atom x) nil (8bits-to-bytes (bits-to-8bits x)))) ; ; A method which converts each byte in a list into a character using the ; built in code-char function ; (defun bytes-to-charlist (x) (if (atom x) nil (cons (code-char (car x)) (bytes-to-charlist (cdr x))))) ; ; An uber level function that converts a bigendian list of bits (multiple ; of 8 bits) to a string by first converting them into groups of 8, converting ; these groups into bytes, converting these bytes into characters and then ; using coerce to force this character list to a string. ; (defun bigendian-bits-to-string (x) (if (not (8-bit-multiplep x)) nil (let* ((8bit-groups (bits-to-8bits x)) (bytes (8bits-to-bytes 8bit-groups)) (charlist (bytes-to-charlist bytes))) (coerce charlist 'string)))) ; ; This method rotates a list of bits to the right by n bits ; This is called by rightrotate, after converting a number to bits ; (defun rightrotate-bits (bit-list n) (if (< n 0) nil (if (atom bit-list) nil (append (get-nth bit-list n) (prefix-nth bit-list n))))) ; ; PI:NAME:<NAME>END_PI's Lemma - this is required to admit the below theorem. ; (defthm get-nth-lemma-rotate (implies (true-listp x) (equal (get-nth x (len x)) nil))) ; ; Correctness of rightrotate ; (defthm rightrotate-bits-correct (implies (true-listp x) (equal (rightrotate-bits x (len x)) x))) ; ; This method rotates a number to the right by n bits ; The number here is a decimal representation of a 32bit integer ; (defun rightrotate(number n) (let ((bit-list (number-to-32bits number))) (bits-to-number (rightrotate-bits bit-list n)))) ; ; Addition modulo (expt 2 32) ; (defun add-32bit (x y) (if (and (natp x) (natp y)) (mod (+ x y) (expt 2 32)) nil)) ; ; This method converts a list of bytes and converts it to 32bit numbers ; (defun bytes-to-32bit-blocks1(byte-list currval m) (if (atom byte-list) nil (let ((val (+ (* currval 256) (car byte-list)))) (if (null (cdr byte-list)) (cons val nil) (if (equal 1 m) (cons val (bytes-to-32bit-blocks1 (cdr byte-list) 0 4)) (bytes-to-32bit-blocks1 (cdr byte-list) val (- m 1))))))) (defun bytes-to-32bit-blocks(byte-list) (bytes-to-32bit-blocks1 byte-list 0 4)) ; ; This routine splits a list of bytes into a list of lists ; which contain 64 bytes each = 512 bits. ; (defun bytes-to-multiple-64-byte-blocks (message-bytes) (declare (xargs :measure (len message-bytes))) (if (atom message-bytes) nil (if (<= (len message-bytes) 64) (cons message-bytes nil) (cons (prefix-nth message-bytes 64) (bytes-to-multiple-64-byte-blocks (get-nth message-bytes 64))))))
[ { "context": "rd \"test\" hash))\n (is-false (check-password \"nope\" hash))))\n\n(defun run-tests ()\n (run! 'cl-pass))", "end": 301, "score": 0.6107571125030518, "start": 299, "tag": "PASSWORD", "value": "pe" } ]
t/cl-pass.lisp
samuel-jimenez/cl-pass
28
(in-package :cl-user) (defpackage cl-pass-test (:use :cl :cl-pass :fiveam) (:export :run-tests)) (in-package :cl-pass-test) (def-suite cl-pass) (in-suite cl-pass) (test passwords (let ((hash (cl-pass:hash "test"))) (is-true (check-password "test" hash)) (is-false (check-password "nope" hash)))) (defun run-tests () (run! 'cl-pass))
53010
(in-package :cl-user) (defpackage cl-pass-test (:use :cl :cl-pass :fiveam) (:export :run-tests)) (in-package :cl-pass-test) (def-suite cl-pass) (in-suite cl-pass) (test passwords (let ((hash (cl-pass:hash "test"))) (is-true (check-password "test" hash)) (is-false (check-password "no<PASSWORD>" hash)))) (defun run-tests () (run! 'cl-pass))
true
(in-package :cl-user) (defpackage cl-pass-test (:use :cl :cl-pass :fiveam) (:export :run-tests)) (in-package :cl-pass-test) (def-suite cl-pass) (in-suite cl-pass) (test passwords (let ((hash (cl-pass:hash "test"))) (is-true (check-password "test" hash)) (is-false (check-password "noPI:PASSWORD:<PASSWORD>END_PI" hash)))) (defun run-tests () (run! 'cl-pass))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 229, "score": 0.999878466129303, "start": 212, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 249, "score": 0.9999299645423889, "start": 231, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/soft/implementation.lisp
shigoel/acl2
1
; SOFT (Second-Order Functions and Theorems) Library ; ; Copyright (C) 2019 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "SOFT") (include-book "kestrel/utilities/system/defchoose-queries" :dir :system) (include-book "kestrel/utilities/system/defun-sk-queries" :dir :system) (include-book "kestrel/utilities/er-soft-plus" :dir :system) (include-book "kestrel/utilities/system/event-forms" :dir :system) (include-book "kestrel/utilities/keyword-value-lists" :dir :system) (include-book "kestrel/utilities/messages" :dir :system) (include-book "kestrel/utilities/symbol-symbol-alists" :dir :system) (include-book "kestrel/utilities/user-interface" :dir :system) (include-book "std/alists/alist-equiv" :dir :system) (include-book "std/util/defines" :dir :system) (local (xdoc::set-default-parents soft-implementation)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define *-listp (stars) :returns (yes/no booleanp) :short "Recognize true lists of @('*')s." :long "<p> These lists are used to indicate the number of arguments of function variables in @(tsee defunvar). </p> <p> Any @('*') symbol (i.e. in any package) is allowed. Normally, the @('*') in the current package should be used (without package qualifier), which is often the one from the main Lisp package, which other packages generally import. </p>" (if (atom stars) (null stars) (and (symbolp (car stars)) (equal (symbol-name (car stars)) "*") (*-listp (cdr stars))))) (defsection function-variables-table :short "Table of function variables." :long "<p> The names of declared function variables are stored as keys in a @(tsee table). No values are associated to these keys, so the table is essentially a set. Note that the arity of a function variable can be retrieved from the @(see world). </p>" (table function-variables nil nil :guard (and (symbolp acl2::key) (null acl2::val)))) (define funvarp (funvar (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of function variables." :long "<p> These are symbols that name declared function variables, i.e. that are in the table of function variables. </p>" (let ((table (table-alist 'function-variables wrld))) (and (symbolp funvar) (not (null (assoc-eq funvar table)))))) (define defunvar-fn ((inputs true-listp) (call pseudo-event-formp "Call to @(tsee defunvar).") (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate the inputs to @(tsee defunvar) and generate the event form to submit." :long "<p> Similary to @(tsee *-listp), any @('*') and @('=>') symbol (i.e. in any package) is allowed. </p>" (b* ((wrld (w state)) ((unless (>= (len inputs) 4)) (er-soft+ ctx t nil "At least four inputs must be supplied, not ~n0." (len inputs))) (funvar (first inputs)) (arguments (second inputs)) (arrow (third inputs)) (result (fourth inputs)) (options (nthcdr 4 inputs)) ((unless (symbolp funvar)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." funvar)) ((unless (*-listp arguments)) (er-soft+ ctx t nil "The second input must be a list (* ... *), but ~x0 is not." arguments)) ((unless (and (symbolp arrow) (equal (symbol-name arrow) "=>"))) (er-soft+ ctx t nil "The third input must be =>, but ~x0 is not." arrow)) ((unless (and (symbolp result) (equal (symbol-name result) "*"))) (er-soft+ ctx t nil "The fourth input must be *, but ~x0 is not." result)) ((unless (or (null options) (and (= (len options) 2) (eq (car options) :print)))) (er-soft+ ctx t nil "After the * input there may be at most one :PRINT option, ~ but instead ~x0 was supplied." options)) (print (if options (cadr options) nil)) ((unless (member-eq print '(nil :all))) (er-soft+ ctx t nil "The :PRINT input must be NIL or :ALL, but ~x0 is not." print)) ((when (funvarp funvar wrld)) (b* ((arity (arity funvar wrld))) (if (= arity (len arguments)) (prog2$ (cw "~%The call ~x0 is redundant.~%" call) (value `(value-triple :invisible))) (er-soft+ ctx t nil "A function variable ~x0 with arity ~x1 ~ already exists.~%" funvar arity)))) (event `(progn (defstub ,funvar ,arguments ,arrow ,result) (table function-variables ',funvar nil) (value-triple ',funvar))) (event (restore-output? (eq print :all) event))) (value event))) (defsection defunvar-implementation :short "Implementation of @(tsee defunvar)." :long "@(def defunvar) @(def acl2::defunvar)" (defmacro defunvar (&whole call &rest inputs) `(make-event-terse (defunvar-fn ',inputs ',call (cons 'defunvar ',(if (consp inputs) (car inputs) nil)) state))) (defmacro acl2::defunvar (&rest inputs) `(defunvar ,@inputs))) (defsection show-defunvar :short "Show the event form generated by @(tsee defunvar), without submitting them." :long "@(def show-defunvar) @(def acl2::show-defunvar)" (defmacro show-defunvar (&whole call funvar arguments arrow result &key print) `(defunvar-fn ',funvar ',arguments ',arrow ',result ',print ',call (cons 'defunvar ',funvar) state)) (defmacro acl2::show-defunvar (&rest args) `(show-defunvar ,@args))) (define funvar-listp (funvars (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recoegnize true lists of function variables." (if (atom funvars) (null funvars) (and (funvarp (car funvars) wrld) (funvar-listp (cdr funvars) wrld)))) (define sofun-kindp (kind) :returns (yes/no booleanp) :short "Recognize symbols that denote the kinds of second-order functions supported by SOFT." :long "<p> Following the terminology used in the Workshop paper, in the implementation we use: </p> <ul> <li> @('plain') for second-order functions introduced via @(tsee defun2). </li> <li> @('choice') for second-order functions introduced via @(tsee defchoose2). </li> <li> @('quant') for second-order functions introduced via @(tsee defun-sk2). </li> </ul>" (or (eq kind 'plain) (eq kind 'choice) (eq kind 'quant))) (define sofun-infop (info (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information associated to second-order function names in the table of second-order functions." :long "<p> This records the kind of the function and the function variables that the function depends on. </p>" (and (true-listp info) (= (len info) 2) (sofun-kindp (first info)) (funvar-listp (second info) wrld))) (defsection second-order-functions-table :short "Table of second-order functions." :long "<p> The names of declared second-order functions are stored as keys in a @(see table), associated with their kind and the function variables they depend on. </p>" (table second-order-functions nil nil :guard (and (symbolp acl2::key) (sofun-infop acl2::val world)))) (define sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of second-order functions." (let ((table (table-alist 'second-order-functions wrld))) (and (symbolp sofun) (not (null (assoc-eq sofun table)))))) (define sofun-kind ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (kind "A @(tsee sofun-kindp).") :verify-guards nil :short "Kind of a second-order function recorded in the table." (let ((table (table-alist 'second-order-functions wrld))) (first (cdr (assoc-eq sofun table))))) (define plain-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize plain second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'plain))) (define choice-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize choice second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'choice))) (define quant-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize quantifier second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'quant))) (define sofun-funvars ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :verify-guards nil :short "Function variables that a second-order function depends on." (let ((table (table-alist 'second-order-functions wrld))) (second (cdr (assoc-eq sofun table))))) (defines funvars-of-term/terms :verify-guards nil :short "Function variables that terms depend on." :long "<p> A term may depend on a function variable directly (when the function variable occurs in the term) or indirectly (when a the second-order function that occurs in the term depends on the function variable). </p> <p> Note that, in the following code, if @('(sofunp fn wrld)') is @('nil'), then @('fn') is a first-order function, which depends on no function variables. </p> <p> The returned list may contain duplicates. </p> @(def funvars-of-term) @(def funvars-of-terms)" (define funvars-of-term ((term pseudo-termp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (or (variablep term) (quotep term)) nil (let* ((fn (fn-symb term)) (fn-vars (if (flambdap fn) (funvars-of-term (lambda-body fn) wrld) (if (funvarp fn wrld) (list fn) (if (sofunp fn wrld) (sofun-funvars fn wrld) nil))))) (append fn-vars (funvars-of-terms (fargs term) wrld))))) (define funvars-of-terms ((terms pseudo-term-listp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (endp terms) nil (append (funvars-of-term (car terms) wrld) (funvars-of-terms (cdr terms) wrld))))) (define funvars-of-plain-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a plain second-order function or by an instance of it." :long "<p> Plain second-order functions and their instances may depend on function variables via their defining bodies, via their measures (absent in non-recursive functions), and via their guards. For now recursive second-order functions (which are all plain) and their instances are only allowed to use @(tsee o<) as their well-founded relation, and so plain second-order functions and their instances may not depend on function variables via their well-founded relations. </p> <p> Note that if the function is recursive, the variable @('measure') in the following code is @('nil'), and @(tsee funvars-of-term) applied to that yields @('nil'). </p> <p> The returned list may contain duplicates. </p>" (let* ((body (ubody fun wrld)) (measure (if (recursivep fun nil wrld) (measure fun wrld) nil)) (guard (uguard fun wrld)) (body-funvars (funvars-of-term body wrld)) (measure-funvars (funvars-of-term measure wrld)) (guard-funvars (funvars-of-term guard wrld))) (append body-funvars measure-funvars guard-funvars))) (define funvars-of-choice-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a choice second-order function or by an instance of it." :long "<p> Choice second-order functions and their instances may depend on function variables via their defining bodies. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (defchoose-body fun wrld) wrld)) (define funvars-of-quantifier-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a quantifier second-order function or by an instance of it." :long "<p> Quantifier second-order functions and their instances may depend on function variables via their matrices and via their guards (which are introduced via @(':witness-dcls')). </p> <p> The returned list may contain duplicates. </p>" (let* ((matrix (defun-sk-matrix fun wrld)) (guard (uguard fun wrld)) (matrix-funvars (funvars-of-term matrix wrld)) (guard-funvars (funvars-of-term guard wrld))) (append matrix-funvars guard-funvars))) (define funvars-of-thm ((thm symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a second-order theorem or by an instance of it." :long "<p> Second-order theorems and their instances may depend on function variables via their formulas. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (formula thm nil wrld) wrld)) (define check-wfrel-o< ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? maybe-msgp) :verify-guards nil :short "Check if a recursive second-order function, or an instance of it, uses @(tsee o<) as well-founded relation." :long "<p> When a recursive second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its well-founded relation is @(tsee o<). The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p>" (if (recursivep fun nil wrld) (let ((wfrel (well-founded-relation fun wrld))) (if (eq wfrel 'o<) nil (msg "~x0 must use O< as well-founded relation, not ~x1.~%" fun wfrel))) nil)) (define check-qrewrite-rule-funvars ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? "A @(tsee maybe-msgp).") :mode :program :short "Check if the rewrite rule of a quantifier second-order function, or of an instance of it, depends exactly on the same function variables that the matrix of the function depends on." :long "<p> When a quantifier second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its rewrite rule depends exactly on the same function variables that the matrix of the function depends on. The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p> <p> This check is relevant when the rewrite rule is a custom one. Otherwise, it is a redundant check. </p>" (let* ((rule-name (defun-sk-rewrite-name fun wrld)) (rule-body (formula rule-name nil wrld)) (fun-matrix (defun-sk-matrix fun wrld))) (if (set-equiv (funvars-of-term rule-body wrld) (funvars-of-term fun-matrix wrld)) nil (msg "The custom rewrite rule ~x0 must have ~ the same function variables as the function's matrix ~x1.~%" rule-body fun-matrix)))) (define print-funvar-dependency ((fun symbolp) (kind sofun-kindp) (wrld plist-worldp)) :returns (nothing "Always @(tsee null).") :mode :program :short "Print the function variables that a funcion depends on." :long "<p> When a second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then prints the function variables that the function depends on. The following code performs that printing. </p> <p> This function returns nothing. It is only used for side effects, namely printing. </p> <p> The @('kind') argument is the kind of @('fun') if second-order, otherwise it is the kind of the second-order function of which @('fun') is an instance. </p>" (let ((funvars (case kind (plain (funvars-of-plain-fn fun wrld)) (choice (funvars-of-choice-fn fun wrld)) (quant (funvars-of-quantifier-fn fun wrld))))) (if funvars (cw "The function ~x0 depends on the function variables ~x1.~%" fun (remove-duplicates-eq funvars)) (cw "The function ~x0 depends on no function variables.~%" fun)))) (define defun2-fn (sofun rest (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun) to check the rest of the form. The second-to-last element of a valid @(tsee defun) can never be the keyword @(':print') (it must be a declaration, a documentation string, or a list of formals), so if the second-to-last element of @(tsee defun2) is @(':print'), the last element of @(tsee defun2) must be the value of the @(':print') option. After submitting the @(tsee defun) form, we check that, if the function is recursive, the well-founded relation is @(tsee o<). </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) (len-rest (len rest)) (print-is-present (and (>= len-rest 2) (eq :print (nth (- len-rest 2) rest)))) (print (if print-is-present (nth (1- len-rest) rest) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (rest (if print-is-present (butlast rest 2) rest)) (defun-event `(defun ,sofun ,@rest)) (table-event `(table second-order-functions ',sofun (list 'plain (remove-duplicates (funvars-of-plain-fn ',sofun world))))) (check-event `(make-event-terse (b* ((err-msg? (check-wfrel-o< ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun2-implementation :short "Implementation of @(tsee defun2)." :long "@(def defun2) @(def acl2::defun2)" (defmacro defun2 (sofun &rest rest) `(make-event-terse (defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state))) (defmacro acl2::defun2 (&rest args) `(defun2 ,@args))) (defsection show-defun2 :short "Show the event form generated by @(tsee defun2), without submitting them." :long "@(def show-defun2) @(def acl2::show-defun2)" (defmacro show-defun2 (sofun &rest rest) `(defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state)) (defmacro acl2::show-defun2 (&rest args) `(show-defun2 ,@args))) (define defchoose2-fn (sofun bvars params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defchoose2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defchoose) to check the rest of the form. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the fourth input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defchoose-event `(defchoose ,sofun ,bvars ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'choice (remove-duplicates (funvars-of-choice-fn ',sofun world))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defchoose-event) ,table-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defchoose2-implementation :short "Implementation of @(tsee defchoose2)." :long "@(def defchoose2) @(def acl2::defchoose2)" (defmacro defchoose2 (sofun bvars vars body &rest options) `(make-event-terse (defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state))) (defmacro acl2::defchoose2 (&rest args) `(defchoose2 ,@args))) (defsection show-defchoose2 :short "Show the event form generated by @(tsee defchoose2), without submitting them." :long "@(def show-defchoose2) @(def acl2::show-defchoose2)" (defmacro show-defchoose2 (sofun bvars vars body &rest options) `(defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state)) (defmacro acl2::show-defchoose2 (&rest args) `(show-defchoose2 ,@args))) (define defun-sk2-fn (sofun params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun-sk2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun-sk) to check the rest of the form. After submitting the @(tsee defun-sk) form, we check that the body and the rewrite rule depend on the same function variables. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the third input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defun-sk-event `(defun-sk ,sofun ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'quant (funvars-of-quantifier-fn ',sofun world)))) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-sk-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-sk2-implementation :short "Implementation of @(tsee defun-sk2)." :long "@(def defun-sk2) @(def acl2::defun-sk2)" (defmacro defun-sk2 (sofun params body &rest options) `(make-event-terse (defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state))) (defmacro acl2::defun-sk2 (&rest args) `(defun-sk2 ,@args))) (defsection show-defun-sk2 :short "Show the event form generated by @(tsee defun-sk2), without submitting them." :long "@(def show-defun-sk2) @(def acl2::show-defun-sk2)" (defmacro show-defun-sk2 (sofun params body &rest options) `(defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state)) (defmacro acl2::show-defun-sk2 (&rest args) `(show-defun-sk2 ,@args))) (define sothmp ((sothm symbolp) (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize second-order theorems." :long "<p> A theorem is second-order iff it depends on one or more function variables. </p>" (not (null (funvars-of-thm sothm wrld)))) (define no-trivial-pairsp ((alist alistp)) :returns (yes/no booleanp) :short "Check if an alist has no pairs with equal key and value." :long "<p> This is a constraint satisfied by function substitutions; see @(tsee fun-substp). A pair that substitutes a function with itself would have no effect, so such pairs are useless. </p>" (if (endp alist) t (let ((pair (car alist))) (and (not (equal (car pair) (cdr pair))) (no-trivial-pairsp (cdr alist)))))) (define fun-substp (fsbs) :returns (yes/no booleanp) :short "Recognize function substitutions." :long "<p> A function substitution is an alist from function names to function names, with unique keys and with no trivial pairs. </p>" (and (symbol-symbol-alistp fsbs) (no-duplicatesp (alist-keys fsbs)) (no-trivial-pairsp fsbs)) :guard-hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) (define funvar-instp (inst (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize instantiations." :long "<p> These are non-empty function substitutions whose keys are function variables and whose values are function names. </p>" (and (fun-substp inst) (consp inst) (funvar-listp (alist-keys inst) wrld) (function-symbol-listp (alist-vals inst) wrld))) (define funvar-inst-listp (insts (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize true lists of instantiations." (if (atom insts) (null insts) (and (funvar-instp (car insts) wrld) (funvar-inst-listp (cdr insts) wrld)))) (define sof-instancesp (instmap (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information about the instances that is associated to second-order function names in the @(tsee sof-instances) table." :long "<p> This is an alist from instantiations to function names. Each pair in the alist maps an instantiation to the corresponding instance. </p>" (and (alistp instmap) (funvar-inst-listp (alist-keys instmap) wrld) (symbol-listp (alist-vals instmap)))) (define get-sof-instance ((inst (funvar-instp inst wrld)) (instmap (sof-instancesp instmap wrld)) (wrld plist-worldp)) :returns (instance symbolp :hyp (sof-instancesp instmap wrld) :hints (("Goal" :in-theory (enable sof-instancesp)))) :verify-guards nil :short "Retrieve the instance associated to a given instantiation, in the map of known instances of a second-order function." :long "<p> Instantiations are treated as equivalent according to @(tsee alist-equiv). If no instance for the instantiation is found, @('nil') is returned. </p>" (if (endp instmap) nil (let ((pair (car instmap))) (if (alist-equiv (car pair) inst) (cdr pair) (get-sof-instance inst (cdr instmap) wrld))))) (define put-sof-instance ((inst (funvar-instp inst wrld)) (fun symbolp) (instmap (and (sof-instancesp instmap wrld) (null (get-sof-instance inst instmap wrld)))) (wrld plist-worldp)) :returns (new-instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Associates an instantiation with an instance in an existing map of know instances of a second-order function." :long "<p> The guard requires the absence of an instance for the same instantiation (equivalent up to @(tsee alist-equiv)). </p>" (declare (ignore wrld)) ; only used in guard (acons inst fun instmap)) (defsection sof-instances-table :short "Table of instances of second-order functions." :long "<p> The known instances of second-order functions are stored in a @(see table). The keys are the names of second-order functions that have instances, and the values are alists from instantiations to instances. </p>" (table sof-instances nil nil :guard (and (symbolp acl2::key) (sof-instancesp acl2::val world)))) (define sof-instances ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Known instances of a second-order function." (let ((table (table-alist 'sof-instances wrld))) (cdr (assoc-eq sofun table)))) (define fun-subst-function ((fsbs fun-substp) (fun symbolp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") :verify-guards nil :short "Apply a function substitution to an individual function." :long "<p> Applying an instantiation to a term involves replacing not only the function variables that are keys of the instantiation and that occur explicitly in the term, but also the ones that occur implicitly in the term via occurrences of second-order functions that depend on those function variables. For example, if @('ff') is a second-order function with function parameter @('f'), and an instantiation @('I') replaces @('f') with @('g'), applying @('I') to the term @('(cons (f x) (ff y))') should yield the term @('(cons (g x) (gg y))'), where @('gg') is the instance that results form applying @('I') to @('ff'). The @(tsee sof-instances) table is used to find @('gg'): @('I') is restricted to the function parameters of @('ff') before searching the map of instances of @('ff'); if the restriction is empty, @('gg') is @('ff'), i.e. no replacement takes place. If @('gg') does not exist, the application of @('I') to @('(cons (f x) (ff y))') fails; the user must create @('gg') and try applying @('I') to @('(cons (f x) (ff y))') again. </p> <p> When an instantiation is applied to the body of a recursive second-order function @('sofun') to obtain an instance @('fun'), occurrences of @('sofun') in the body must be replaced with @('fun'), but at that time @('fun') does not exist yet, and thus the table of second-order function instances of @('sofun') has no entries for @('fun') yet. Thus, it is convenient to use function substitutions (not just instantiations) to instantiate terms. </p> <p> The following code applies a function substitution to an individual function, in the manner explained above. It is used by @(tsee fun-subst-term), which applies a function substitution to a term. If a needed second-order function instance does not exist, an error occurs. </p>" (let ((pair (assoc-eq fun fsbs))) (if pair (cdr pair) (if (sofunp fun wrld) (let* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs))) (if (null subfsbs) fun (let* ((instmap (sof-instances fun wrld)) (new-fun (get-sof-instance subfsbs instmap wrld))) (if new-fun new-fun (raise "~x0 has no instance for ~x1." fun fsbs))))) fun)))) (defines fun-subst-term/terms :verify-guards nil :short "Apply function substitutions to terms." :long "<p> See the discussion in @(tsee fun-subst-function). </p> @(def fun-subst-term) @(def fun-subst-terms)" (define fun-subst-term ((fsbs fun-substp) (term pseudo-termp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) term (let* ((fn (fn-symb term)) (new-fn (if (symbolp fn) (fun-subst-function fsbs fn wrld) (make-lambda (lambda-formals fn) (fun-subst-term fsbs (lambda-body fn) wrld)))) (new-args (fun-subst-terms fsbs (fargs term) wrld))) (cons new-fn new-args)))) (define fun-subst-terms ((fsbs fun-substp) (terms pseudo-term-listp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) nil (cons (fun-subst-term fsbs (car terms) wrld) (fun-subst-terms fsbs (cdr terms) wrld))))) (defines ext-fun-subst-term/terms/function :mode :program :short "Extend function substitutions for functional instantiation." :long "<p> An instance @('thm') of a second-order theorem @('sothm') is also a theorem, provable using a @(':functional-instance') of @('sothm'). The pairs of the @(':functional-instance') are not only the pairs of the instantiation that creates @('thm') from @('sothm'), but also all the pairs whose first components are second-order functions that @('sothm') depends on and whose second components are the corresponding instances. </p> <p> For example, if @('sothm') is @('(p (sofun x))'), @('sofun') is a second-order function, @('p') is a first-order predicate, and applying an instantiation @('I') to @('(p (sofun x))') yields @('(p (fun x))'), then @('thm') is proved using @('(:functional-instance sothm (... (sofun fun) ...))'), where the first @('...') are the pairs of @('I') and the second @('...') are further pairs of second-order functions and their instances, e.g. if @('sofun') calls a second-order function @('sofun1'), the pair @('(sofun1 fun1)') must be in the second @('...'), where @('fun1') is the instance of @('sofun1') corresponding to @('I'). All these pairs are needed to properly instantiate the constraints that arise from the @(':functional-instance'), which involve the second-order functions that @('sothm') depends on, directly or indirectly. </p> <p> The following code extends a function substitution (initially an instantiation) to contain all those extra pairs. The starting point is a term; the bodies of second-order functions referenced in the term are recursively processed. The table of instances of second-order functions is searched, similarly to @(tsee fun-subst-function). </p> @(def ext-fun-subst-term) @(def ext-fun-subst-terms) @(def ext-fun-subst-function)" (define ext-fun-subst-term ((term pseudo-termp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) fsbs (let* ((fn (fn-symb term)) (fsbs (if (symbolp fn) (ext-fun-subst-function fn fsbs wrld) (ext-fun-subst-term (lambda-body fn) fsbs wrld)))) (ext-fun-subst-terms (fargs term) fsbs wrld)))) (define ext-fun-subst-terms ((terms pseudo-term-listp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) fsbs (let ((fsbs (ext-fun-subst-term (car terms) fsbs wrld))) (ext-fun-subst-terms (cdr terms) fsbs wrld)))) (define ext-fun-subst-function ((fun symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") (cond ((assoc fun fsbs) fsbs) ((sofunp fun wrld) (b* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs)) ((if (null subfsbs)) fsbs) (instmap (sof-instances fun wrld)) (funinst (get-sof-instance subfsbs instmap wrld)) ((unless funinst) (raise "~x0 has no instance for ~x1." fun fsbs)) (fsbs (acons fun funinst fsbs))) (case (sofun-kind fun wrld) ((plain quant) (ext-fun-subst-term (ubody fun wrld) fsbs wrld)) (choice (ext-fun-subst-term (defchoose-body fun wrld) fsbs wrld))))) (t fsbs)))) (define sothm-inst-pairs ((fsbs fun-substp) (wrld plist-worldp)) :returns (pairs "A @('doublet-listp').") :mode :program :short "Create a list of doublets for functional instantiation." :long "<p> From a function substitution obtained by extending an instantiation via @(tsee ext-fun-subst-term/terms/function), the list of pairs to supply to @(':functional-instance') is obtained. Each dotted pair is turned into a doublet (a different representation of the pair). </p> <p> In addition, when a dotted pair is encountered whose @(tsee car) is the name of a quantifier second-order function, an extra pair for instantiating the associated witness is inserted. The witnesses of quantifier second-order functions must also be part of the @(':functional-instance'), because they are referenced by the quantifier second-order functions. However, these witnesses are not recorded as second-order functions in the table of second-order functions, and thus the code of @(tsee ext-fun-subst-term/terms/function) does not catch these witnesses. </p>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (if (quant-sofunp 1st wrld) (let ((1st-wit (defun-sk-witness 1st wrld)) (2nd-wit (defun-sk-witness 2nd wrld))) (cons (list 1st 2nd) (cons (list 1st-wit 2nd-wit) (sothm-inst-pairs (cdr fsbs) wrld)))) (cons (list 1st 2nd) (sothm-inst-pairs (cdr fsbs) wrld)))))) (define sothm-inst-facts ((fsbs fun-substp) (wrld plist-worldp)) :returns (fact-names "A @(tsee symbol-listp).") :mode :program :short "Create list of facts for functional instantiation." :long "<p> When a @(':functional-instance') is used in a proof, proof subgoals are created to ensure that the replacing functions satisfy all the constraints of the replaced functions. In a @(':functional-instance') with a function substitution @('S') as calculated by @(tsee ext-fun-subst-term/terms/function), each function variable (which comes from the instantiation) has no constraints and so no subgoals are generated for them. Each second-order function @('sofun') in @('S') has the following constraints: </p> <ul> <li> If @('sofun') is a plain second-order function, the constraint is that the application of @('S') to the definition of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the definition of @('fun'). </li> <li> If @('sofun') is a choice second-order function, the constraint is that the application of @('S') to the choice axiom of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the choice axiom of @('fun'). </li> <li> If @('sofun') is a quantifier second-order function, the constraints are that (1) the application of @('S') to the rewrite rule generated by the @(tsee defun-sk) of @('sofun'), and (2) the application of @('S') to the definition of @('sofun') (or to the defining theorem of @('sofun') if @('sofun') was introduced with @(':constrain t')), are both theorems, which both follow by the construction of the instance @('fun') of @('sofun'), i.e. they follow from (1) the rewrite rule generated by the @(tsee defun-sk) of @('fun') and (2) the definition of @('fun') (or the defining theorem of @('fun') if @('fun') was introduced with @(':constrain nil')). </li> </ul> <p> The list of facts needed to prove these constraints is determined by the function substitution @('S'). For each pair @('(fun1 . fun2)') of the function substitution: </p> <ul> <li> If @('fun1') is a plain second-order function, the fact used in the proof is the definition of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun).) </li> <li> If @('fun1') is a choice second-order function, the fact used in the proof is the @(tsee defchoose) axiom of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defchoose).) </li> <li> If @('fun1') is a quantifier second-order function, the facts used in the proof are (1) the @(tsee defun-sk) rewrite rule of @('fun2') and (2) either (i) the definition of @('fun2') (if @('fun2') was introduced with @(':constrain nil')), whose name is the name of @('fun2'), or (ii) the defining theorem of @('fun2') (if @('fun2') was introduced with @(':constrain t')), whose name is @('fun2') followed by @('-definition'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun-sk).) </li> <li> Otherwise, @('fun1') is a function variable, which has no constraints, so no fact is used in the proof. </li> </ul>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (cond ((or (plain-sofunp 1st wrld) (choice-sofunp 1st wrld)) (cons 2nd (sothm-inst-facts (cdr fsbs) wrld))) ((quant-sofunp 1st wrld) `(,(defun-sk-rewrite-name 2nd wrld) ,(if (definedp 2nd wrld) 2nd (defun-sk-definition-name 2nd wrld)) ,@(sothm-inst-facts (cdr fsbs) wrld))) (t (sothm-inst-facts (cdr fsbs) wrld)))))) (define sothm-inst-proof ((sothm symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (instructions "A @(tsee true-listp).") :mode :program :short "Proof builder instructions to prove instances of second-order theorems." :long "<p> Instances of second-order theorems are proved using the ACL2 proof builder. Each such instance is proved by first using the @(':functional-instance') determined by @(tsee sothm-inst-pairs), then using the facts computed by @(tsee sothm-inst-facts) on the subgoals. Each sugoal only needs a subset of those facts, but for simplicity all the facts are used for each subgoal, using the proof builder <see topic='@(url acl2-pc::repeat)'>@(':repeat')</see> command. Since sometimes the facts are not quite identical to the subgoals, the proof builder <see topic='@(url acl2-pc::prove)'>@(':prove')</see> command is used to iron out any such differences. </p>" `(:instructions ((:use (:functional-instance ,sothm ,@(sothm-inst-pairs fsbs wrld))) (:repeat (:then (:use ,@(sothm-inst-facts fsbs wrld)) :prove))))) (define check-sothm-inst (sothm-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize designations of instances of second-order theorems." :long "<p> A designation of an instance of a second-order theorem has the form @('(sothm (f1 . g1) ... (fM . gM))'), where @('sothm') is a second-order theorem and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defthm-inst). </p>" (and (true-listp sothm-inst) (>= (len sothm-inst) 2) (sothmp (car sothm-inst) wrld) (funvar-instp (cdr sothm-inst) wrld))) (define defthm-inst-fn (thm sothm-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defthm-inst) and generate the event form to submit." :long "<p> We directly check all the inputs except for the @(':rule-classes') option, relying on @(tsee defthm) to check it. </p>" (b* ((wrld (w state)) ((unless (symbolp thm)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." thm)) ((unless (check-sothm-inst sothm-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order theorem ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sothm-inst)) (sothm (car sothm-inst)) (inst (cdr sothm-inst)) ((unless (subsetp (alist-keys inst) (funvars-of-thm sothm wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among function variable that ~x1 depends on." inst sothm)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The inputs keywords must be unique.")) ((unless (subsetp keywords '(:rule-classes :print))) (er-soft+ ctx t nil "Only the input keywords ~ :RULE-CLASSES and :PRINT are allowed.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (sothm-formula (formula sothm nil wrld)) (thm-formula (fun-subst-term inst sothm-formula wrld)) (thm-formula (untranslate thm-formula t wrld)) (fsbs (ext-fun-subst-term sothm-formula inst wrld)) (thm-proof (sothm-inst-proof sothm fsbs wrld)) (defthm-event `(defthm ,thm ,thm-formula ,@thm-proof ,@options)) (defthm-event-without-proof `(defthm ,thm ,thm-formula ,@options)) (return-value-event `(value-triple ',thm)) (event (cond ((eq print nil) `(progn ,defthm-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defthm-event ,return-value-event))) ((eq print :result) `(progn ,defthm-event (cw-event "~x0~|" ',defthm-event-without-proof) ,return-value-event)) (t (impossible))))) (value event))) (defsection defthm-inst-implementation :short "Implementation of @(tsee defthm-inst)." :long "@(def defthm-inst) @(def acl2::defthm-inst)" (defmacro defthm-inst (thm sothminst &rest options) `(make-event-terse (defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state))) (defmacro acl2::defthm-inst (&rest args) `(defthm-inst ,@args))) (defsection show-defthm-inst :short "Show the event form generated by @(tsee defthm-inst), without submitting them." :long "@(def show-defthm-inst) @(def acl2::show-defthm-inst)" (defmacro show-defthm-inst (thm sothminst &rest options) `(defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state)) (defmacro acl2::show-defthm-inst (&rest args) `(show-defthm-inst ,@args))) (define check-sofun-inst (sofun-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :verify-guards nil :short "Recognize designations of instances of second-order functions." :long "<p> A designation of an instance of a second-order function has the form @('(sofun (f1 . g1) ... (fM . gM))'), where @('sofun') is a second-order function and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defun-inst). </p>" (and (true-listp sofun-inst) (>= (len sofun-inst) 2) (sofunp (car sofun-inst) wrld) (funvar-instp (cdr sofun-inst) wrld))) (define defun-inst-plain-events ((fun symbolp) (sofun (plain-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a plain second-order function." :long "<p> Also return the @(tsee defun2) or @(tsee defun) event form, without the termination hints. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':verify-guards') and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p> <p> If @('sofun') (and consequently @('fun')) is recursive, we extend the instantiation with @('(sofun . fun)'), to ensure that the recursive calls are properly transformed. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:verify-guards :print))) (er-soft+ ctx t nil "Only the input keywords ~ :VERIFY-GUARDS and :PRINT are allowed, ~ because ~x0 is a plain second-order function." sofun)) (verify-guards (let ((verify-guards-option (assoc-keyword :verify-guards options))) (if verify-guards-option (cadr verify-guards-option) (guard-verified-p sofun wrld)))) (sofun-body (ubody sofun wrld)) (sofun-measure (if (recursivep sofun nil wrld) (measure sofun wrld) nil)) (sofun-guard (uguard sofun wrld)) (fsbs (if sofun-measure (acons sofun fun inst) inst)) (fun-body (fun-subst-term fsbs sofun-body wrld)) (fun-body-funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (fun-measure (fun-subst-term inst sofun-measure wrld)) (fun-measure-funvars (funvars-of-term fun-measure wrld)) (fun-measure (untranslate fun-measure nil wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (sofun-tt-name `(:termination-theorem ,sofun)) (sofun-tt-formula (and (recursivep sofun nil wrld) (termination-theorem sofun wrld))) (fsbs (ext-fun-subst-term sofun-tt-formula inst wrld)) (fun-tt-proof (sothm-inst-proof sofun-tt-name fsbs wrld)) (hints (if fun-measure `(:hints (("Goal" ,@fun-tt-proof))) nil)) (measure (if fun-measure `(:measure ,fun-measure) nil)) (formals (formals sofun wrld)) (funvars (remove-duplicates (append fun-body-funvars fun-measure-funvars fun-guard-funvars))) (defun-event `(defun ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure ,@hints)) ,fun-body)) (result `(,(if funvars 'defun2 'defun) ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure)) ,fun-body)) (table-event? (if funvars `((table second-order-functions ',fun (list 'plain ',funvars))) nil))) (value (list `(,defun-event ,@table-event?) result funvars)))) (define defun-inst-choice-events ((fun symbolp) (sofun (choice-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a choice second-order function." :long "<p> Also return the @(tsee defchoose2) or @(tsee defchoose) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':print') option may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:print))) (er-soft+ ctx t nil "Only the input keyword :PRINT is allowed, ~ because ~x0 is a choice second-order function." sofun)) (bound-vars (defchoose-bound-vars sofun wrld)) (sofun-body (defchoose-body sofun wrld)) (fun-body (fun-subst-term inst sofun-body wrld)) (funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (formals (formals sofun wrld)) (strengthen (defchoose-strengthen sofun wrld)) (funvars (remove-duplicates funvars)) (defchoose-event `(defchoose ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (result `(,(if funvars 'defchoose2 'defchoose) ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (table-event? (if funvars `((table second-order-functions ',fun (list 'choice ',funvars))) nil))) (value (list `(,defchoose-event ,@table-event?) result funvars)))) (define defun-inst-quant-events ((fun symbolp) (sofun (quant-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a quantifier second-order function." :long "<p> Also return the @(tsee defun-sk2) or @(tsee defun-sk) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':skolem-name'), @(':thm-name'), @(':rewrite'), @(':constrain'), and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:skolem-name :thm-name :rewrite :constrain :print))) (er-soft+ ctx t nil "Only the input keywords ~ :SKOLEM-NAME, :THM-NAME, :REWRITE, :CONSTRAIN and :PRINT ~ are allowed, ~ because ~x0 is a quantifier second-order function." sofun)) (bound-vars (defun-sk-bound-vars sofun wrld)) (quant (defun-sk-quantifier sofun wrld)) (sofun-matrix (defun-sk-matrix sofun wrld)) (fun-matrix (fun-subst-term inst sofun-matrix wrld)) (fun-matrix-funvars (funvars-of-term fun-matrix wrld)) (fun-matrix (untranslate fun-matrix nil wrld)) (rewrite-option (assoc-keyword :rewrite options)) (rewrite (if rewrite-option (cadr rewrite-option) (let ((qrkind (defun-sk-rewrite-kind sofun wrld))) (case qrkind (:default :default) (:direct :direct) (:custom (let* ((fsbs (acons sofun fun inst)) (rule-name (defun-sk-rewrite-name sofun wrld)) (term (formula rule-name nil wrld))) (fun-subst-term fsbs term wrld))))))) (skolem-name (let ((skolem-name-option (assoc-keyword :skolem-name options))) (if skolem-name-option `(:skolem-name ,(cadr skolem-name-option)) nil))) (thm-name (let ((thm-name-option (assoc-keyword :thm-name options))) (if thm-name-option `(:thm-name ,(cadr thm-name-option)) nil))) (constrain (let ((constrain-option (assoc-keyword :constrain options))) (if constrain-option `(:constrain ,(cadr constrain-option)) nil))) (sofun-guard (uguard sofun wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (wit-dcl `(declare (xargs :guard ,fun-guard :verify-guards nil))) (formals (formals sofun wrld)) (strengthen (defun-sk-strengthen sofun wrld)) (body (list quant bound-vars fun-matrix)) (rest `(:strengthen ,strengthen :quant-ok t ,@(and (eq quant 'forall) (list :rewrite rewrite)) ,@skolem-name ,@thm-name ,@constrain :witness-dcls (,wit-dcl))) (funvars (remove-duplicates (append fun-matrix-funvars fun-guard-funvars))) (defun-sk-event `(defun-sk ,fun ,formals ,body ,@rest)) (result `(,(if funvars 'defun-sk2 'defun-sk) ,fun ,formals ,body ,@rest)) (table-event? (if funvars `((table second-order-functions ',fun (list 'quant ',funvars))) nil)) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ (cons 'defun-inst ',fun) t nil "~@0" err-msg?) (value '(value-triple :invisible))))))) (value (list `(,defun-sk-event ,@table-event? ,check-event) result funvars)))) (define defun-inst-fn (fun sofun-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defun-inst) and generate the event form to submit." :long "<p> We directly check the name and instance designation, we directly check the correct presence of keyed options (we do that in @(tsee defun-inst-plain-events), @(tsee defun-inst-choice-events), and @(tsee defun-inst-quant-events)), and we directly check the correct value of the @(':print') option (if present), but rely on @(tsee defun), @(tsee defchoose), and @(tsee defun-sk) to check the values of the other keyed options. </p> <p> Prior to introducing @('fun'), we generate local events to avoid errors due to ignored or irrelevant formals in @('fun') (which may happen if @('sofun') has ignored or irrelevant formals). We add @('fun') to the table of instances of second-order functions. </p>" (b* ((wrld (w state)) ((unless (symbolp fun)) (er-soft+ ctx t nil "The first input must be a name, but ~x0 is not." fun)) ((unless (check-sofun-inst sofun-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order function ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sofun-inst)) (sofun (car sofun-inst)) (inst (cdr sofun-inst)) ((unless (subsetp (alist-keys inst) (sofun-funvars sofun wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among the function variables ~x1 ~ that ~x2 depends on." inst (sofun-funvars sofun wrld) sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The input keywords must be unique.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) ((er (list fun-intro-events result funvars)) (case (sofun-kind sofun wrld) (plain (defun-inst-plain-events fun sofun inst options ctx state)) (choice (defun-inst-choice-events fun sofun inst options ctx state)) (quant (defun-inst-quant-events fun sofun inst options ctx state)) (t (prog2$ (impossible) (value (list nil nil)))))) (instmap (sof-instances sofun wrld)) (new-instmap (put-sof-instance inst fun instmap wrld)) (encapsulate `(encapsulate () (set-ignore-ok t) (set-irrelevant-formals-ok t) ,@fun-intro-events (table sof-instances ',sofun ',new-instmap))) (result-event `(cw-event "~x0~|" ',result)) (print-funvar-event (if funvars `(cw-event "The function ~x0 depends on the function variables ~x1.~%" ',fun ',funvars) `(cw-event "The function ~x0 depends on no function variables.~%" ',fun))) (return-value-event `(value-triple ',fun)) (event (cond ((eq print nil) `(progn ,encapsulate ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,encapsulate ,print-funvar-event ,return-value-event))) ((eq print :result) `(progn ,encapsulate ,result-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-inst-implementation :short "Implementation of @(tsee defun-inst)." :long "@(def defun-inst) @(def acl2::defun-inst)" (defmacro defun-inst (fun sofun-inst &rest rest) `(make-event-terse (defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state))) (defmacro acl2::defun-inst (&rest args) `(defun-inst ,@args))) (defsection show-defun-inst :short "Show the event form generated by @(tsee defun-inst), without submitting them." :long "@(def show-defun-inst) @(def acl2::show-defun-inst)" (defmacro show-defun-inst (fun sofun-inst &rest rest) `(defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state)) (defmacro acl2::show-defun-inst (&rest args) `(show-defun-inst ,@args)))
94417
; SOFT (Second-Order Functions and Theorems) Library ; ; Copyright (C) 2019 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "SOFT") (include-book "kestrel/utilities/system/defchoose-queries" :dir :system) (include-book "kestrel/utilities/system/defun-sk-queries" :dir :system) (include-book "kestrel/utilities/er-soft-plus" :dir :system) (include-book "kestrel/utilities/system/event-forms" :dir :system) (include-book "kestrel/utilities/keyword-value-lists" :dir :system) (include-book "kestrel/utilities/messages" :dir :system) (include-book "kestrel/utilities/symbol-symbol-alists" :dir :system) (include-book "kestrel/utilities/user-interface" :dir :system) (include-book "std/alists/alist-equiv" :dir :system) (include-book "std/util/defines" :dir :system) (local (xdoc::set-default-parents soft-implementation)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define *-listp (stars) :returns (yes/no booleanp) :short "Recognize true lists of @('*')s." :long "<p> These lists are used to indicate the number of arguments of function variables in @(tsee defunvar). </p> <p> Any @('*') symbol (i.e. in any package) is allowed. Normally, the @('*') in the current package should be used (without package qualifier), which is often the one from the main Lisp package, which other packages generally import. </p>" (if (atom stars) (null stars) (and (symbolp (car stars)) (equal (symbol-name (car stars)) "*") (*-listp (cdr stars))))) (defsection function-variables-table :short "Table of function variables." :long "<p> The names of declared function variables are stored as keys in a @(tsee table). No values are associated to these keys, so the table is essentially a set. Note that the arity of a function variable can be retrieved from the @(see world). </p>" (table function-variables nil nil :guard (and (symbolp acl2::key) (null acl2::val)))) (define funvarp (funvar (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of function variables." :long "<p> These are symbols that name declared function variables, i.e. that are in the table of function variables. </p>" (let ((table (table-alist 'function-variables wrld))) (and (symbolp funvar) (not (null (assoc-eq funvar table)))))) (define defunvar-fn ((inputs true-listp) (call pseudo-event-formp "Call to @(tsee defunvar).") (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate the inputs to @(tsee defunvar) and generate the event form to submit." :long "<p> Similary to @(tsee *-listp), any @('*') and @('=>') symbol (i.e. in any package) is allowed. </p>" (b* ((wrld (w state)) ((unless (>= (len inputs) 4)) (er-soft+ ctx t nil "At least four inputs must be supplied, not ~n0." (len inputs))) (funvar (first inputs)) (arguments (second inputs)) (arrow (third inputs)) (result (fourth inputs)) (options (nthcdr 4 inputs)) ((unless (symbolp funvar)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." funvar)) ((unless (*-listp arguments)) (er-soft+ ctx t nil "The second input must be a list (* ... *), but ~x0 is not." arguments)) ((unless (and (symbolp arrow) (equal (symbol-name arrow) "=>"))) (er-soft+ ctx t nil "The third input must be =>, but ~x0 is not." arrow)) ((unless (and (symbolp result) (equal (symbol-name result) "*"))) (er-soft+ ctx t nil "The fourth input must be *, but ~x0 is not." result)) ((unless (or (null options) (and (= (len options) 2) (eq (car options) :print)))) (er-soft+ ctx t nil "After the * input there may be at most one :PRINT option, ~ but instead ~x0 was supplied." options)) (print (if options (cadr options) nil)) ((unless (member-eq print '(nil :all))) (er-soft+ ctx t nil "The :PRINT input must be NIL or :ALL, but ~x0 is not." print)) ((when (funvarp funvar wrld)) (b* ((arity (arity funvar wrld))) (if (= arity (len arguments)) (prog2$ (cw "~%The call ~x0 is redundant.~%" call) (value `(value-triple :invisible))) (er-soft+ ctx t nil "A function variable ~x0 with arity ~x1 ~ already exists.~%" funvar arity)))) (event `(progn (defstub ,funvar ,arguments ,arrow ,result) (table function-variables ',funvar nil) (value-triple ',funvar))) (event (restore-output? (eq print :all) event))) (value event))) (defsection defunvar-implementation :short "Implementation of @(tsee defunvar)." :long "@(def defunvar) @(def acl2::defunvar)" (defmacro defunvar (&whole call &rest inputs) `(make-event-terse (defunvar-fn ',inputs ',call (cons 'defunvar ',(if (consp inputs) (car inputs) nil)) state))) (defmacro acl2::defunvar (&rest inputs) `(defunvar ,@inputs))) (defsection show-defunvar :short "Show the event form generated by @(tsee defunvar), without submitting them." :long "@(def show-defunvar) @(def acl2::show-defunvar)" (defmacro show-defunvar (&whole call funvar arguments arrow result &key print) `(defunvar-fn ',funvar ',arguments ',arrow ',result ',print ',call (cons 'defunvar ',funvar) state)) (defmacro acl2::show-defunvar (&rest args) `(show-defunvar ,@args))) (define funvar-listp (funvars (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recoegnize true lists of function variables." (if (atom funvars) (null funvars) (and (funvarp (car funvars) wrld) (funvar-listp (cdr funvars) wrld)))) (define sofun-kindp (kind) :returns (yes/no booleanp) :short "Recognize symbols that denote the kinds of second-order functions supported by SOFT." :long "<p> Following the terminology used in the Workshop paper, in the implementation we use: </p> <ul> <li> @('plain') for second-order functions introduced via @(tsee defun2). </li> <li> @('choice') for second-order functions introduced via @(tsee defchoose2). </li> <li> @('quant') for second-order functions introduced via @(tsee defun-sk2). </li> </ul>" (or (eq kind 'plain) (eq kind 'choice) (eq kind 'quant))) (define sofun-infop (info (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information associated to second-order function names in the table of second-order functions." :long "<p> This records the kind of the function and the function variables that the function depends on. </p>" (and (true-listp info) (= (len info) 2) (sofun-kindp (first info)) (funvar-listp (second info) wrld))) (defsection second-order-functions-table :short "Table of second-order functions." :long "<p> The names of declared second-order functions are stored as keys in a @(see table), associated with their kind and the function variables they depend on. </p>" (table second-order-functions nil nil :guard (and (symbolp acl2::key) (sofun-infop acl2::val world)))) (define sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of second-order functions." (let ((table (table-alist 'second-order-functions wrld))) (and (symbolp sofun) (not (null (assoc-eq sofun table)))))) (define sofun-kind ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (kind "A @(tsee sofun-kindp).") :verify-guards nil :short "Kind of a second-order function recorded in the table." (let ((table (table-alist 'second-order-functions wrld))) (first (cdr (assoc-eq sofun table))))) (define plain-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize plain second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'plain))) (define choice-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize choice second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'choice))) (define quant-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize quantifier second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'quant))) (define sofun-funvars ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :verify-guards nil :short "Function variables that a second-order function depends on." (let ((table (table-alist 'second-order-functions wrld))) (second (cdr (assoc-eq sofun table))))) (defines funvars-of-term/terms :verify-guards nil :short "Function variables that terms depend on." :long "<p> A term may depend on a function variable directly (when the function variable occurs in the term) or indirectly (when a the second-order function that occurs in the term depends on the function variable). </p> <p> Note that, in the following code, if @('(sofunp fn wrld)') is @('nil'), then @('fn') is a first-order function, which depends on no function variables. </p> <p> The returned list may contain duplicates. </p> @(def funvars-of-term) @(def funvars-of-terms)" (define funvars-of-term ((term pseudo-termp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (or (variablep term) (quotep term)) nil (let* ((fn (fn-symb term)) (fn-vars (if (flambdap fn) (funvars-of-term (lambda-body fn) wrld) (if (funvarp fn wrld) (list fn) (if (sofunp fn wrld) (sofun-funvars fn wrld) nil))))) (append fn-vars (funvars-of-terms (fargs term) wrld))))) (define funvars-of-terms ((terms pseudo-term-listp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (endp terms) nil (append (funvars-of-term (car terms) wrld) (funvars-of-terms (cdr terms) wrld))))) (define funvars-of-plain-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a plain second-order function or by an instance of it." :long "<p> Plain second-order functions and their instances may depend on function variables via their defining bodies, via their measures (absent in non-recursive functions), and via their guards. For now recursive second-order functions (which are all plain) and their instances are only allowed to use @(tsee o<) as their well-founded relation, and so plain second-order functions and their instances may not depend on function variables via their well-founded relations. </p> <p> Note that if the function is recursive, the variable @('measure') in the following code is @('nil'), and @(tsee funvars-of-term) applied to that yields @('nil'). </p> <p> The returned list may contain duplicates. </p>" (let* ((body (ubody fun wrld)) (measure (if (recursivep fun nil wrld) (measure fun wrld) nil)) (guard (uguard fun wrld)) (body-funvars (funvars-of-term body wrld)) (measure-funvars (funvars-of-term measure wrld)) (guard-funvars (funvars-of-term guard wrld))) (append body-funvars measure-funvars guard-funvars))) (define funvars-of-choice-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a choice second-order function or by an instance of it." :long "<p> Choice second-order functions and their instances may depend on function variables via their defining bodies. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (defchoose-body fun wrld) wrld)) (define funvars-of-quantifier-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a quantifier second-order function or by an instance of it." :long "<p> Quantifier second-order functions and their instances may depend on function variables via their matrices and via their guards (which are introduced via @(':witness-dcls')). </p> <p> The returned list may contain duplicates. </p>" (let* ((matrix (defun-sk-matrix fun wrld)) (guard (uguard fun wrld)) (matrix-funvars (funvars-of-term matrix wrld)) (guard-funvars (funvars-of-term guard wrld))) (append matrix-funvars guard-funvars))) (define funvars-of-thm ((thm symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a second-order theorem or by an instance of it." :long "<p> Second-order theorems and their instances may depend on function variables via their formulas. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (formula thm nil wrld) wrld)) (define check-wfrel-o< ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? maybe-msgp) :verify-guards nil :short "Check if a recursive second-order function, or an instance of it, uses @(tsee o<) as well-founded relation." :long "<p> When a recursive second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its well-founded relation is @(tsee o<). The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p>" (if (recursivep fun nil wrld) (let ((wfrel (well-founded-relation fun wrld))) (if (eq wfrel 'o<) nil (msg "~x0 must use O< as well-founded relation, not ~x1.~%" fun wfrel))) nil)) (define check-qrewrite-rule-funvars ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? "A @(tsee maybe-msgp).") :mode :program :short "Check if the rewrite rule of a quantifier second-order function, or of an instance of it, depends exactly on the same function variables that the matrix of the function depends on." :long "<p> When a quantifier second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its rewrite rule depends exactly on the same function variables that the matrix of the function depends on. The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p> <p> This check is relevant when the rewrite rule is a custom one. Otherwise, it is a redundant check. </p>" (let* ((rule-name (defun-sk-rewrite-name fun wrld)) (rule-body (formula rule-name nil wrld)) (fun-matrix (defun-sk-matrix fun wrld))) (if (set-equiv (funvars-of-term rule-body wrld) (funvars-of-term fun-matrix wrld)) nil (msg "The custom rewrite rule ~x0 must have ~ the same function variables as the function's matrix ~x1.~%" rule-body fun-matrix)))) (define print-funvar-dependency ((fun symbolp) (kind sofun-kindp) (wrld plist-worldp)) :returns (nothing "Always @(tsee null).") :mode :program :short "Print the function variables that a funcion depends on." :long "<p> When a second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then prints the function variables that the function depends on. The following code performs that printing. </p> <p> This function returns nothing. It is only used for side effects, namely printing. </p> <p> The @('kind') argument is the kind of @('fun') if second-order, otherwise it is the kind of the second-order function of which @('fun') is an instance. </p>" (let ((funvars (case kind (plain (funvars-of-plain-fn fun wrld)) (choice (funvars-of-choice-fn fun wrld)) (quant (funvars-of-quantifier-fn fun wrld))))) (if funvars (cw "The function ~x0 depends on the function variables ~x1.~%" fun (remove-duplicates-eq funvars)) (cw "The function ~x0 depends on no function variables.~%" fun)))) (define defun2-fn (sofun rest (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun) to check the rest of the form. The second-to-last element of a valid @(tsee defun) can never be the keyword @(':print') (it must be a declaration, a documentation string, or a list of formals), so if the second-to-last element of @(tsee defun2) is @(':print'), the last element of @(tsee defun2) must be the value of the @(':print') option. After submitting the @(tsee defun) form, we check that, if the function is recursive, the well-founded relation is @(tsee o<). </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) (len-rest (len rest)) (print-is-present (and (>= len-rest 2) (eq :print (nth (- len-rest 2) rest)))) (print (if print-is-present (nth (1- len-rest) rest) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (rest (if print-is-present (butlast rest 2) rest)) (defun-event `(defun ,sofun ,@rest)) (table-event `(table second-order-functions ',sofun (list 'plain (remove-duplicates (funvars-of-plain-fn ',sofun world))))) (check-event `(make-event-terse (b* ((err-msg? (check-wfrel-o< ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun2-implementation :short "Implementation of @(tsee defun2)." :long "@(def defun2) @(def acl2::defun2)" (defmacro defun2 (sofun &rest rest) `(make-event-terse (defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state))) (defmacro acl2::defun2 (&rest args) `(defun2 ,@args))) (defsection show-defun2 :short "Show the event form generated by @(tsee defun2), without submitting them." :long "@(def show-defun2) @(def acl2::show-defun2)" (defmacro show-defun2 (sofun &rest rest) `(defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state)) (defmacro acl2::show-defun2 (&rest args) `(show-defun2 ,@args))) (define defchoose2-fn (sofun bvars params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defchoose2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defchoose) to check the rest of the form. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the fourth input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defchoose-event `(defchoose ,sofun ,bvars ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'choice (remove-duplicates (funvars-of-choice-fn ',sofun world))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defchoose-event) ,table-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defchoose2-implementation :short "Implementation of @(tsee defchoose2)." :long "@(def defchoose2) @(def acl2::defchoose2)" (defmacro defchoose2 (sofun bvars vars body &rest options) `(make-event-terse (defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state))) (defmacro acl2::defchoose2 (&rest args) `(defchoose2 ,@args))) (defsection show-defchoose2 :short "Show the event form generated by @(tsee defchoose2), without submitting them." :long "@(def show-defchoose2) @(def acl2::show-defchoose2)" (defmacro show-defchoose2 (sofun bvars vars body &rest options) `(defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state)) (defmacro acl2::show-defchoose2 (&rest args) `(show-defchoose2 ,@args))) (define defun-sk2-fn (sofun params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun-sk2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun-sk) to check the rest of the form. After submitting the @(tsee defun-sk) form, we check that the body and the rewrite rule depend on the same function variables. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the third input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defun-sk-event `(defun-sk ,sofun ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'quant (funvars-of-quantifier-fn ',sofun world)))) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-sk-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-sk2-implementation :short "Implementation of @(tsee defun-sk2)." :long "@(def defun-sk2) @(def acl2::defun-sk2)" (defmacro defun-sk2 (sofun params body &rest options) `(make-event-terse (defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state))) (defmacro acl2::defun-sk2 (&rest args) `(defun-sk2 ,@args))) (defsection show-defun-sk2 :short "Show the event form generated by @(tsee defun-sk2), without submitting them." :long "@(def show-defun-sk2) @(def acl2::show-defun-sk2)" (defmacro show-defun-sk2 (sofun params body &rest options) `(defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state)) (defmacro acl2::show-defun-sk2 (&rest args) `(show-defun-sk2 ,@args))) (define sothmp ((sothm symbolp) (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize second-order theorems." :long "<p> A theorem is second-order iff it depends on one or more function variables. </p>" (not (null (funvars-of-thm sothm wrld)))) (define no-trivial-pairsp ((alist alistp)) :returns (yes/no booleanp) :short "Check if an alist has no pairs with equal key and value." :long "<p> This is a constraint satisfied by function substitutions; see @(tsee fun-substp). A pair that substitutes a function with itself would have no effect, so such pairs are useless. </p>" (if (endp alist) t (let ((pair (car alist))) (and (not (equal (car pair) (cdr pair))) (no-trivial-pairsp (cdr alist)))))) (define fun-substp (fsbs) :returns (yes/no booleanp) :short "Recognize function substitutions." :long "<p> A function substitution is an alist from function names to function names, with unique keys and with no trivial pairs. </p>" (and (symbol-symbol-alistp fsbs) (no-duplicatesp (alist-keys fsbs)) (no-trivial-pairsp fsbs)) :guard-hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) (define funvar-instp (inst (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize instantiations." :long "<p> These are non-empty function substitutions whose keys are function variables and whose values are function names. </p>" (and (fun-substp inst) (consp inst) (funvar-listp (alist-keys inst) wrld) (function-symbol-listp (alist-vals inst) wrld))) (define funvar-inst-listp (insts (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize true lists of instantiations." (if (atom insts) (null insts) (and (funvar-instp (car insts) wrld) (funvar-inst-listp (cdr insts) wrld)))) (define sof-instancesp (instmap (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information about the instances that is associated to second-order function names in the @(tsee sof-instances) table." :long "<p> This is an alist from instantiations to function names. Each pair in the alist maps an instantiation to the corresponding instance. </p>" (and (alistp instmap) (funvar-inst-listp (alist-keys instmap) wrld) (symbol-listp (alist-vals instmap)))) (define get-sof-instance ((inst (funvar-instp inst wrld)) (instmap (sof-instancesp instmap wrld)) (wrld plist-worldp)) :returns (instance symbolp :hyp (sof-instancesp instmap wrld) :hints (("Goal" :in-theory (enable sof-instancesp)))) :verify-guards nil :short "Retrieve the instance associated to a given instantiation, in the map of known instances of a second-order function." :long "<p> Instantiations are treated as equivalent according to @(tsee alist-equiv). If no instance for the instantiation is found, @('nil') is returned. </p>" (if (endp instmap) nil (let ((pair (car instmap))) (if (alist-equiv (car pair) inst) (cdr pair) (get-sof-instance inst (cdr instmap) wrld))))) (define put-sof-instance ((inst (funvar-instp inst wrld)) (fun symbolp) (instmap (and (sof-instancesp instmap wrld) (null (get-sof-instance inst instmap wrld)))) (wrld plist-worldp)) :returns (new-instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Associates an instantiation with an instance in an existing map of know instances of a second-order function." :long "<p> The guard requires the absence of an instance for the same instantiation (equivalent up to @(tsee alist-equiv)). </p>" (declare (ignore wrld)) ; only used in guard (acons inst fun instmap)) (defsection sof-instances-table :short "Table of instances of second-order functions." :long "<p> The known instances of second-order functions are stored in a @(see table). The keys are the names of second-order functions that have instances, and the values are alists from instantiations to instances. </p>" (table sof-instances nil nil :guard (and (symbolp acl2::key) (sof-instancesp acl2::val world)))) (define sof-instances ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Known instances of a second-order function." (let ((table (table-alist 'sof-instances wrld))) (cdr (assoc-eq sofun table)))) (define fun-subst-function ((fsbs fun-substp) (fun symbolp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") :verify-guards nil :short "Apply a function substitution to an individual function." :long "<p> Applying an instantiation to a term involves replacing not only the function variables that are keys of the instantiation and that occur explicitly in the term, but also the ones that occur implicitly in the term via occurrences of second-order functions that depend on those function variables. For example, if @('ff') is a second-order function with function parameter @('f'), and an instantiation @('I') replaces @('f') with @('g'), applying @('I') to the term @('(cons (f x) (ff y))') should yield the term @('(cons (g x) (gg y))'), where @('gg') is the instance that results form applying @('I') to @('ff'). The @(tsee sof-instances) table is used to find @('gg'): @('I') is restricted to the function parameters of @('ff') before searching the map of instances of @('ff'); if the restriction is empty, @('gg') is @('ff'), i.e. no replacement takes place. If @('gg') does not exist, the application of @('I') to @('(cons (f x) (ff y))') fails; the user must create @('gg') and try applying @('I') to @('(cons (f x) (ff y))') again. </p> <p> When an instantiation is applied to the body of a recursive second-order function @('sofun') to obtain an instance @('fun'), occurrences of @('sofun') in the body must be replaced with @('fun'), but at that time @('fun') does not exist yet, and thus the table of second-order function instances of @('sofun') has no entries for @('fun') yet. Thus, it is convenient to use function substitutions (not just instantiations) to instantiate terms. </p> <p> The following code applies a function substitution to an individual function, in the manner explained above. It is used by @(tsee fun-subst-term), which applies a function substitution to a term. If a needed second-order function instance does not exist, an error occurs. </p>" (let ((pair (assoc-eq fun fsbs))) (if pair (cdr pair) (if (sofunp fun wrld) (let* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs))) (if (null subfsbs) fun (let* ((instmap (sof-instances fun wrld)) (new-fun (get-sof-instance subfsbs instmap wrld))) (if new-fun new-fun (raise "~x0 has no instance for ~x1." fun fsbs))))) fun)))) (defines fun-subst-term/terms :verify-guards nil :short "Apply function substitutions to terms." :long "<p> See the discussion in @(tsee fun-subst-function). </p> @(def fun-subst-term) @(def fun-subst-terms)" (define fun-subst-term ((fsbs fun-substp) (term pseudo-termp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) term (let* ((fn (fn-symb term)) (new-fn (if (symbolp fn) (fun-subst-function fsbs fn wrld) (make-lambda (lambda-formals fn) (fun-subst-term fsbs (lambda-body fn) wrld)))) (new-args (fun-subst-terms fsbs (fargs term) wrld))) (cons new-fn new-args)))) (define fun-subst-terms ((fsbs fun-substp) (terms pseudo-term-listp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) nil (cons (fun-subst-term fsbs (car terms) wrld) (fun-subst-terms fsbs (cdr terms) wrld))))) (defines ext-fun-subst-term/terms/function :mode :program :short "Extend function substitutions for functional instantiation." :long "<p> An instance @('thm') of a second-order theorem @('sothm') is also a theorem, provable using a @(':functional-instance') of @('sothm'). The pairs of the @(':functional-instance') are not only the pairs of the instantiation that creates @('thm') from @('sothm'), but also all the pairs whose first components are second-order functions that @('sothm') depends on and whose second components are the corresponding instances. </p> <p> For example, if @('sothm') is @('(p (sofun x))'), @('sofun') is a second-order function, @('p') is a first-order predicate, and applying an instantiation @('I') to @('(p (sofun x))') yields @('(p (fun x))'), then @('thm') is proved using @('(:functional-instance sothm (... (sofun fun) ...))'), where the first @('...') are the pairs of @('I') and the second @('...') are further pairs of second-order functions and their instances, e.g. if @('sofun') calls a second-order function @('sofun1'), the pair @('(sofun1 fun1)') must be in the second @('...'), where @('fun1') is the instance of @('sofun1') corresponding to @('I'). All these pairs are needed to properly instantiate the constraints that arise from the @(':functional-instance'), which involve the second-order functions that @('sothm') depends on, directly or indirectly. </p> <p> The following code extends a function substitution (initially an instantiation) to contain all those extra pairs. The starting point is a term; the bodies of second-order functions referenced in the term are recursively processed. The table of instances of second-order functions is searched, similarly to @(tsee fun-subst-function). </p> @(def ext-fun-subst-term) @(def ext-fun-subst-terms) @(def ext-fun-subst-function)" (define ext-fun-subst-term ((term pseudo-termp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) fsbs (let* ((fn (fn-symb term)) (fsbs (if (symbolp fn) (ext-fun-subst-function fn fsbs wrld) (ext-fun-subst-term (lambda-body fn) fsbs wrld)))) (ext-fun-subst-terms (fargs term) fsbs wrld)))) (define ext-fun-subst-terms ((terms pseudo-term-listp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) fsbs (let ((fsbs (ext-fun-subst-term (car terms) fsbs wrld))) (ext-fun-subst-terms (cdr terms) fsbs wrld)))) (define ext-fun-subst-function ((fun symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") (cond ((assoc fun fsbs) fsbs) ((sofunp fun wrld) (b* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs)) ((if (null subfsbs)) fsbs) (instmap (sof-instances fun wrld)) (funinst (get-sof-instance subfsbs instmap wrld)) ((unless funinst) (raise "~x0 has no instance for ~x1." fun fsbs)) (fsbs (acons fun funinst fsbs))) (case (sofun-kind fun wrld) ((plain quant) (ext-fun-subst-term (ubody fun wrld) fsbs wrld)) (choice (ext-fun-subst-term (defchoose-body fun wrld) fsbs wrld))))) (t fsbs)))) (define sothm-inst-pairs ((fsbs fun-substp) (wrld plist-worldp)) :returns (pairs "A @('doublet-listp').") :mode :program :short "Create a list of doublets for functional instantiation." :long "<p> From a function substitution obtained by extending an instantiation via @(tsee ext-fun-subst-term/terms/function), the list of pairs to supply to @(':functional-instance') is obtained. Each dotted pair is turned into a doublet (a different representation of the pair). </p> <p> In addition, when a dotted pair is encountered whose @(tsee car) is the name of a quantifier second-order function, an extra pair for instantiating the associated witness is inserted. The witnesses of quantifier second-order functions must also be part of the @(':functional-instance'), because they are referenced by the quantifier second-order functions. However, these witnesses are not recorded as second-order functions in the table of second-order functions, and thus the code of @(tsee ext-fun-subst-term/terms/function) does not catch these witnesses. </p>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (if (quant-sofunp 1st wrld) (let ((1st-wit (defun-sk-witness 1st wrld)) (2nd-wit (defun-sk-witness 2nd wrld))) (cons (list 1st 2nd) (cons (list 1st-wit 2nd-wit) (sothm-inst-pairs (cdr fsbs) wrld)))) (cons (list 1st 2nd) (sothm-inst-pairs (cdr fsbs) wrld)))))) (define sothm-inst-facts ((fsbs fun-substp) (wrld plist-worldp)) :returns (fact-names "A @(tsee symbol-listp).") :mode :program :short "Create list of facts for functional instantiation." :long "<p> When a @(':functional-instance') is used in a proof, proof subgoals are created to ensure that the replacing functions satisfy all the constraints of the replaced functions. In a @(':functional-instance') with a function substitution @('S') as calculated by @(tsee ext-fun-subst-term/terms/function), each function variable (which comes from the instantiation) has no constraints and so no subgoals are generated for them. Each second-order function @('sofun') in @('S') has the following constraints: </p> <ul> <li> If @('sofun') is a plain second-order function, the constraint is that the application of @('S') to the definition of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the definition of @('fun'). </li> <li> If @('sofun') is a choice second-order function, the constraint is that the application of @('S') to the choice axiom of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the choice axiom of @('fun'). </li> <li> If @('sofun') is a quantifier second-order function, the constraints are that (1) the application of @('S') to the rewrite rule generated by the @(tsee defun-sk) of @('sofun'), and (2) the application of @('S') to the definition of @('sofun') (or to the defining theorem of @('sofun') if @('sofun') was introduced with @(':constrain t')), are both theorems, which both follow by the construction of the instance @('fun') of @('sofun'), i.e. they follow from (1) the rewrite rule generated by the @(tsee defun-sk) of @('fun') and (2) the definition of @('fun') (or the defining theorem of @('fun') if @('fun') was introduced with @(':constrain nil')). </li> </ul> <p> The list of facts needed to prove these constraints is determined by the function substitution @('S'). For each pair @('(fun1 . fun2)') of the function substitution: </p> <ul> <li> If @('fun1') is a plain second-order function, the fact used in the proof is the definition of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun).) </li> <li> If @('fun1') is a choice second-order function, the fact used in the proof is the @(tsee defchoose) axiom of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defchoose).) </li> <li> If @('fun1') is a quantifier second-order function, the facts used in the proof are (1) the @(tsee defun-sk) rewrite rule of @('fun2') and (2) either (i) the definition of @('fun2') (if @('fun2') was introduced with @(':constrain nil')), whose name is the name of @('fun2'), or (ii) the defining theorem of @('fun2') (if @('fun2') was introduced with @(':constrain t')), whose name is @('fun2') followed by @('-definition'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun-sk).) </li> <li> Otherwise, @('fun1') is a function variable, which has no constraints, so no fact is used in the proof. </li> </ul>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (cond ((or (plain-sofunp 1st wrld) (choice-sofunp 1st wrld)) (cons 2nd (sothm-inst-facts (cdr fsbs) wrld))) ((quant-sofunp 1st wrld) `(,(defun-sk-rewrite-name 2nd wrld) ,(if (definedp 2nd wrld) 2nd (defun-sk-definition-name 2nd wrld)) ,@(sothm-inst-facts (cdr fsbs) wrld))) (t (sothm-inst-facts (cdr fsbs) wrld)))))) (define sothm-inst-proof ((sothm symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (instructions "A @(tsee true-listp).") :mode :program :short "Proof builder instructions to prove instances of second-order theorems." :long "<p> Instances of second-order theorems are proved using the ACL2 proof builder. Each such instance is proved by first using the @(':functional-instance') determined by @(tsee sothm-inst-pairs), then using the facts computed by @(tsee sothm-inst-facts) on the subgoals. Each sugoal only needs a subset of those facts, but for simplicity all the facts are used for each subgoal, using the proof builder <see topic='@(url acl2-pc::repeat)'>@(':repeat')</see> command. Since sometimes the facts are not quite identical to the subgoals, the proof builder <see topic='@(url acl2-pc::prove)'>@(':prove')</see> command is used to iron out any such differences. </p>" `(:instructions ((:use (:functional-instance ,sothm ,@(sothm-inst-pairs fsbs wrld))) (:repeat (:then (:use ,@(sothm-inst-facts fsbs wrld)) :prove))))) (define check-sothm-inst (sothm-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize designations of instances of second-order theorems." :long "<p> A designation of an instance of a second-order theorem has the form @('(sothm (f1 . g1) ... (fM . gM))'), where @('sothm') is a second-order theorem and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defthm-inst). </p>" (and (true-listp sothm-inst) (>= (len sothm-inst) 2) (sothmp (car sothm-inst) wrld) (funvar-instp (cdr sothm-inst) wrld))) (define defthm-inst-fn (thm sothm-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defthm-inst) and generate the event form to submit." :long "<p> We directly check all the inputs except for the @(':rule-classes') option, relying on @(tsee defthm) to check it. </p>" (b* ((wrld (w state)) ((unless (symbolp thm)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." thm)) ((unless (check-sothm-inst sothm-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order theorem ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sothm-inst)) (sothm (car sothm-inst)) (inst (cdr sothm-inst)) ((unless (subsetp (alist-keys inst) (funvars-of-thm sothm wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among function variable that ~x1 depends on." inst sothm)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The inputs keywords must be unique.")) ((unless (subsetp keywords '(:rule-classes :print))) (er-soft+ ctx t nil "Only the input keywords ~ :RULE-CLASSES and :PRINT are allowed.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (sothm-formula (formula sothm nil wrld)) (thm-formula (fun-subst-term inst sothm-formula wrld)) (thm-formula (untranslate thm-formula t wrld)) (fsbs (ext-fun-subst-term sothm-formula inst wrld)) (thm-proof (sothm-inst-proof sothm fsbs wrld)) (defthm-event `(defthm ,thm ,thm-formula ,@thm-proof ,@options)) (defthm-event-without-proof `(defthm ,thm ,thm-formula ,@options)) (return-value-event `(value-triple ',thm)) (event (cond ((eq print nil) `(progn ,defthm-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defthm-event ,return-value-event))) ((eq print :result) `(progn ,defthm-event (cw-event "~x0~|" ',defthm-event-without-proof) ,return-value-event)) (t (impossible))))) (value event))) (defsection defthm-inst-implementation :short "Implementation of @(tsee defthm-inst)." :long "@(def defthm-inst) @(def acl2::defthm-inst)" (defmacro defthm-inst (thm sothminst &rest options) `(make-event-terse (defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state))) (defmacro acl2::defthm-inst (&rest args) `(defthm-inst ,@args))) (defsection show-defthm-inst :short "Show the event form generated by @(tsee defthm-inst), without submitting them." :long "@(def show-defthm-inst) @(def acl2::show-defthm-inst)" (defmacro show-defthm-inst (thm sothminst &rest options) `(defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state)) (defmacro acl2::show-defthm-inst (&rest args) `(show-defthm-inst ,@args))) (define check-sofun-inst (sofun-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :verify-guards nil :short "Recognize designations of instances of second-order functions." :long "<p> A designation of an instance of a second-order function has the form @('(sofun (f1 . g1) ... (fM . gM))'), where @('sofun') is a second-order function and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defun-inst). </p>" (and (true-listp sofun-inst) (>= (len sofun-inst) 2) (sofunp (car sofun-inst) wrld) (funvar-instp (cdr sofun-inst) wrld))) (define defun-inst-plain-events ((fun symbolp) (sofun (plain-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a plain second-order function." :long "<p> Also return the @(tsee defun2) or @(tsee defun) event form, without the termination hints. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':verify-guards') and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p> <p> If @('sofun') (and consequently @('fun')) is recursive, we extend the instantiation with @('(sofun . fun)'), to ensure that the recursive calls are properly transformed. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:verify-guards :print))) (er-soft+ ctx t nil "Only the input keywords ~ :VERIFY-GUARDS and :PRINT are allowed, ~ because ~x0 is a plain second-order function." sofun)) (verify-guards (let ((verify-guards-option (assoc-keyword :verify-guards options))) (if verify-guards-option (cadr verify-guards-option) (guard-verified-p sofun wrld)))) (sofun-body (ubody sofun wrld)) (sofun-measure (if (recursivep sofun nil wrld) (measure sofun wrld) nil)) (sofun-guard (uguard sofun wrld)) (fsbs (if sofun-measure (acons sofun fun inst) inst)) (fun-body (fun-subst-term fsbs sofun-body wrld)) (fun-body-funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (fun-measure (fun-subst-term inst sofun-measure wrld)) (fun-measure-funvars (funvars-of-term fun-measure wrld)) (fun-measure (untranslate fun-measure nil wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (sofun-tt-name `(:termination-theorem ,sofun)) (sofun-tt-formula (and (recursivep sofun nil wrld) (termination-theorem sofun wrld))) (fsbs (ext-fun-subst-term sofun-tt-formula inst wrld)) (fun-tt-proof (sothm-inst-proof sofun-tt-name fsbs wrld)) (hints (if fun-measure `(:hints (("Goal" ,@fun-tt-proof))) nil)) (measure (if fun-measure `(:measure ,fun-measure) nil)) (formals (formals sofun wrld)) (funvars (remove-duplicates (append fun-body-funvars fun-measure-funvars fun-guard-funvars))) (defun-event `(defun ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure ,@hints)) ,fun-body)) (result `(,(if funvars 'defun2 'defun) ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure)) ,fun-body)) (table-event? (if funvars `((table second-order-functions ',fun (list 'plain ',funvars))) nil))) (value (list `(,defun-event ,@table-event?) result funvars)))) (define defun-inst-choice-events ((fun symbolp) (sofun (choice-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a choice second-order function." :long "<p> Also return the @(tsee defchoose2) or @(tsee defchoose) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':print') option may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:print))) (er-soft+ ctx t nil "Only the input keyword :PRINT is allowed, ~ because ~x0 is a choice second-order function." sofun)) (bound-vars (defchoose-bound-vars sofun wrld)) (sofun-body (defchoose-body sofun wrld)) (fun-body (fun-subst-term inst sofun-body wrld)) (funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (formals (formals sofun wrld)) (strengthen (defchoose-strengthen sofun wrld)) (funvars (remove-duplicates funvars)) (defchoose-event `(defchoose ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (result `(,(if funvars 'defchoose2 'defchoose) ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (table-event? (if funvars `((table second-order-functions ',fun (list 'choice ',funvars))) nil))) (value (list `(,defchoose-event ,@table-event?) result funvars)))) (define defun-inst-quant-events ((fun symbolp) (sofun (quant-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a quantifier second-order function." :long "<p> Also return the @(tsee defun-sk2) or @(tsee defun-sk) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':skolem-name'), @(':thm-name'), @(':rewrite'), @(':constrain'), and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:skolem-name :thm-name :rewrite :constrain :print))) (er-soft+ ctx t nil "Only the input keywords ~ :SKOLEM-NAME, :THM-NAME, :REWRITE, :CONSTRAIN and :PRINT ~ are allowed, ~ because ~x0 is a quantifier second-order function." sofun)) (bound-vars (defun-sk-bound-vars sofun wrld)) (quant (defun-sk-quantifier sofun wrld)) (sofun-matrix (defun-sk-matrix sofun wrld)) (fun-matrix (fun-subst-term inst sofun-matrix wrld)) (fun-matrix-funvars (funvars-of-term fun-matrix wrld)) (fun-matrix (untranslate fun-matrix nil wrld)) (rewrite-option (assoc-keyword :rewrite options)) (rewrite (if rewrite-option (cadr rewrite-option) (let ((qrkind (defun-sk-rewrite-kind sofun wrld))) (case qrkind (:default :default) (:direct :direct) (:custom (let* ((fsbs (acons sofun fun inst)) (rule-name (defun-sk-rewrite-name sofun wrld)) (term (formula rule-name nil wrld))) (fun-subst-term fsbs term wrld))))))) (skolem-name (let ((skolem-name-option (assoc-keyword :skolem-name options))) (if skolem-name-option `(:skolem-name ,(cadr skolem-name-option)) nil))) (thm-name (let ((thm-name-option (assoc-keyword :thm-name options))) (if thm-name-option `(:thm-name ,(cadr thm-name-option)) nil))) (constrain (let ((constrain-option (assoc-keyword :constrain options))) (if constrain-option `(:constrain ,(cadr constrain-option)) nil))) (sofun-guard (uguard sofun wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (wit-dcl `(declare (xargs :guard ,fun-guard :verify-guards nil))) (formals (formals sofun wrld)) (strengthen (defun-sk-strengthen sofun wrld)) (body (list quant bound-vars fun-matrix)) (rest `(:strengthen ,strengthen :quant-ok t ,@(and (eq quant 'forall) (list :rewrite rewrite)) ,@skolem-name ,@thm-name ,@constrain :witness-dcls (,wit-dcl))) (funvars (remove-duplicates (append fun-matrix-funvars fun-guard-funvars))) (defun-sk-event `(defun-sk ,fun ,formals ,body ,@rest)) (result `(,(if funvars 'defun-sk2 'defun-sk) ,fun ,formals ,body ,@rest)) (table-event? (if funvars `((table second-order-functions ',fun (list 'quant ',funvars))) nil)) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ (cons 'defun-inst ',fun) t nil "~@0" err-msg?) (value '(value-triple :invisible))))))) (value (list `(,defun-sk-event ,@table-event? ,check-event) result funvars)))) (define defun-inst-fn (fun sofun-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defun-inst) and generate the event form to submit." :long "<p> We directly check the name and instance designation, we directly check the correct presence of keyed options (we do that in @(tsee defun-inst-plain-events), @(tsee defun-inst-choice-events), and @(tsee defun-inst-quant-events)), and we directly check the correct value of the @(':print') option (if present), but rely on @(tsee defun), @(tsee defchoose), and @(tsee defun-sk) to check the values of the other keyed options. </p> <p> Prior to introducing @('fun'), we generate local events to avoid errors due to ignored or irrelevant formals in @('fun') (which may happen if @('sofun') has ignored or irrelevant formals). We add @('fun') to the table of instances of second-order functions. </p>" (b* ((wrld (w state)) ((unless (symbolp fun)) (er-soft+ ctx t nil "The first input must be a name, but ~x0 is not." fun)) ((unless (check-sofun-inst sofun-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order function ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sofun-inst)) (sofun (car sofun-inst)) (inst (cdr sofun-inst)) ((unless (subsetp (alist-keys inst) (sofun-funvars sofun wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among the function variables ~x1 ~ that ~x2 depends on." inst (sofun-funvars sofun wrld) sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The input keywords must be unique.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) ((er (list fun-intro-events result funvars)) (case (sofun-kind sofun wrld) (plain (defun-inst-plain-events fun sofun inst options ctx state)) (choice (defun-inst-choice-events fun sofun inst options ctx state)) (quant (defun-inst-quant-events fun sofun inst options ctx state)) (t (prog2$ (impossible) (value (list nil nil)))))) (instmap (sof-instances sofun wrld)) (new-instmap (put-sof-instance inst fun instmap wrld)) (encapsulate `(encapsulate () (set-ignore-ok t) (set-irrelevant-formals-ok t) ,@fun-intro-events (table sof-instances ',sofun ',new-instmap))) (result-event `(cw-event "~x0~|" ',result)) (print-funvar-event (if funvars `(cw-event "The function ~x0 depends on the function variables ~x1.~%" ',fun ',funvars) `(cw-event "The function ~x0 depends on no function variables.~%" ',fun))) (return-value-event `(value-triple ',fun)) (event (cond ((eq print nil) `(progn ,encapsulate ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,encapsulate ,print-funvar-event ,return-value-event))) ((eq print :result) `(progn ,encapsulate ,result-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-inst-implementation :short "Implementation of @(tsee defun-inst)." :long "@(def defun-inst) @(def acl2::defun-inst)" (defmacro defun-inst (fun sofun-inst &rest rest) `(make-event-terse (defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state))) (defmacro acl2::defun-inst (&rest args) `(defun-inst ,@args))) (defsection show-defun-inst :short "Show the event form generated by @(tsee defun-inst), without submitting them." :long "@(def show-defun-inst) @(def acl2::show-defun-inst)" (defmacro show-defun-inst (fun sofun-inst &rest rest) `(defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state)) (defmacro acl2::show-defun-inst (&rest args) `(show-defun-inst ,@args)))
true
; SOFT (Second-Order Functions and Theorems) Library ; ; Copyright (C) 2019 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "SOFT") (include-book "kestrel/utilities/system/defchoose-queries" :dir :system) (include-book "kestrel/utilities/system/defun-sk-queries" :dir :system) (include-book "kestrel/utilities/er-soft-plus" :dir :system) (include-book "kestrel/utilities/system/event-forms" :dir :system) (include-book "kestrel/utilities/keyword-value-lists" :dir :system) (include-book "kestrel/utilities/messages" :dir :system) (include-book "kestrel/utilities/symbol-symbol-alists" :dir :system) (include-book "kestrel/utilities/user-interface" :dir :system) (include-book "std/alists/alist-equiv" :dir :system) (include-book "std/util/defines" :dir :system) (local (xdoc::set-default-parents soft-implementation)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define *-listp (stars) :returns (yes/no booleanp) :short "Recognize true lists of @('*')s." :long "<p> These lists are used to indicate the number of arguments of function variables in @(tsee defunvar). </p> <p> Any @('*') symbol (i.e. in any package) is allowed. Normally, the @('*') in the current package should be used (without package qualifier), which is often the one from the main Lisp package, which other packages generally import. </p>" (if (atom stars) (null stars) (and (symbolp (car stars)) (equal (symbol-name (car stars)) "*") (*-listp (cdr stars))))) (defsection function-variables-table :short "Table of function variables." :long "<p> The names of declared function variables are stored as keys in a @(tsee table). No values are associated to these keys, so the table is essentially a set. Note that the arity of a function variable can be retrieved from the @(see world). </p>" (table function-variables nil nil :guard (and (symbolp acl2::key) (null acl2::val)))) (define funvarp (funvar (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of function variables." :long "<p> These are symbols that name declared function variables, i.e. that are in the table of function variables. </p>" (let ((table (table-alist 'function-variables wrld))) (and (symbolp funvar) (not (null (assoc-eq funvar table)))))) (define defunvar-fn ((inputs true-listp) (call pseudo-event-formp "Call to @(tsee defunvar).") (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate the inputs to @(tsee defunvar) and generate the event form to submit." :long "<p> Similary to @(tsee *-listp), any @('*') and @('=>') symbol (i.e. in any package) is allowed. </p>" (b* ((wrld (w state)) ((unless (>= (len inputs) 4)) (er-soft+ ctx t nil "At least four inputs must be supplied, not ~n0." (len inputs))) (funvar (first inputs)) (arguments (second inputs)) (arrow (third inputs)) (result (fourth inputs)) (options (nthcdr 4 inputs)) ((unless (symbolp funvar)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." funvar)) ((unless (*-listp arguments)) (er-soft+ ctx t nil "The second input must be a list (* ... *), but ~x0 is not." arguments)) ((unless (and (symbolp arrow) (equal (symbol-name arrow) "=>"))) (er-soft+ ctx t nil "The third input must be =>, but ~x0 is not." arrow)) ((unless (and (symbolp result) (equal (symbol-name result) "*"))) (er-soft+ ctx t nil "The fourth input must be *, but ~x0 is not." result)) ((unless (or (null options) (and (= (len options) 2) (eq (car options) :print)))) (er-soft+ ctx t nil "After the * input there may be at most one :PRINT option, ~ but instead ~x0 was supplied." options)) (print (if options (cadr options) nil)) ((unless (member-eq print '(nil :all))) (er-soft+ ctx t nil "The :PRINT input must be NIL or :ALL, but ~x0 is not." print)) ((when (funvarp funvar wrld)) (b* ((arity (arity funvar wrld))) (if (= arity (len arguments)) (prog2$ (cw "~%The call ~x0 is redundant.~%" call) (value `(value-triple :invisible))) (er-soft+ ctx t nil "A function variable ~x0 with arity ~x1 ~ already exists.~%" funvar arity)))) (event `(progn (defstub ,funvar ,arguments ,arrow ,result) (table function-variables ',funvar nil) (value-triple ',funvar))) (event (restore-output? (eq print :all) event))) (value event))) (defsection defunvar-implementation :short "Implementation of @(tsee defunvar)." :long "@(def defunvar) @(def acl2::defunvar)" (defmacro defunvar (&whole call &rest inputs) `(make-event-terse (defunvar-fn ',inputs ',call (cons 'defunvar ',(if (consp inputs) (car inputs) nil)) state))) (defmacro acl2::defunvar (&rest inputs) `(defunvar ,@inputs))) (defsection show-defunvar :short "Show the event form generated by @(tsee defunvar), without submitting them." :long "@(def show-defunvar) @(def acl2::show-defunvar)" (defmacro show-defunvar (&whole call funvar arguments arrow result &key print) `(defunvar-fn ',funvar ',arguments ',arrow ',result ',print ',call (cons 'defunvar ',funvar) state)) (defmacro acl2::show-defunvar (&rest args) `(show-defunvar ,@args))) (define funvar-listp (funvars (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recoegnize true lists of function variables." (if (atom funvars) (null funvars) (and (funvarp (car funvars) wrld) (funvar-listp (cdr funvars) wrld)))) (define sofun-kindp (kind) :returns (yes/no booleanp) :short "Recognize symbols that denote the kinds of second-order functions supported by SOFT." :long "<p> Following the terminology used in the Workshop paper, in the implementation we use: </p> <ul> <li> @('plain') for second-order functions introduced via @(tsee defun2). </li> <li> @('choice') for second-order functions introduced via @(tsee defchoose2). </li> <li> @('quant') for second-order functions introduced via @(tsee defun-sk2). </li> </ul>" (or (eq kind 'plain) (eq kind 'choice) (eq kind 'quant))) (define sofun-infop (info (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information associated to second-order function names in the table of second-order functions." :long "<p> This records the kind of the function and the function variables that the function depends on. </p>" (and (true-listp info) (= (len info) 2) (sofun-kindp (first info)) (funvar-listp (second info) wrld))) (defsection second-order-functions-table :short "Table of second-order functions." :long "<p> The names of declared second-order functions are stored as keys in a @(see table), associated with their kind and the function variables they depend on. </p>" (table second-order-functions nil nil :guard (and (symbolp acl2::key) (sofun-infop acl2::val world)))) (define sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize names of second-order functions." (let ((table (table-alist 'second-order-functions wrld))) (and (symbolp sofun) (not (null (assoc-eq sofun table)))))) (define sofun-kind ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (kind "A @(tsee sofun-kindp).") :verify-guards nil :short "Kind of a second-order function recorded in the table." (let ((table (table-alist 'second-order-functions wrld))) (first (cdr (assoc-eq sofun table))))) (define plain-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize plain second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'plain))) (define choice-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize choice second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'choice))) (define quant-sofunp (sofun (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize quantifier second-order functions." (and (sofunp sofun wrld) (eq (sofun-kind sofun wrld) 'quant))) (define sofun-funvars ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :verify-guards nil :short "Function variables that a second-order function depends on." (let ((table (table-alist 'second-order-functions wrld))) (second (cdr (assoc-eq sofun table))))) (defines funvars-of-term/terms :verify-guards nil :short "Function variables that terms depend on." :long "<p> A term may depend on a function variable directly (when the function variable occurs in the term) or indirectly (when a the second-order function that occurs in the term depends on the function variable). </p> <p> Note that, in the following code, if @('(sofunp fn wrld)') is @('nil'), then @('fn') is a first-order function, which depends on no function variables. </p> <p> The returned list may contain duplicates. </p> @(def funvars-of-term) @(def funvars-of-terms)" (define funvars-of-term ((term pseudo-termp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (or (variablep term) (quotep term)) nil (let* ((fn (fn-symb term)) (fn-vars (if (flambdap fn) (funvars-of-term (lambda-body fn) wrld) (if (funvarp fn wrld) (list fn) (if (sofunp fn wrld) (sofun-funvars fn wrld) nil))))) (append fn-vars (funvars-of-terms (fargs term) wrld))))) (define funvars-of-terms ((terms pseudo-term-listp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") (if (endp terms) nil (append (funvars-of-term (car terms) wrld) (funvars-of-terms (cdr terms) wrld))))) (define funvars-of-plain-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a plain second-order function or by an instance of it." :long "<p> Plain second-order functions and their instances may depend on function variables via their defining bodies, via their measures (absent in non-recursive functions), and via their guards. For now recursive second-order functions (which are all plain) and their instances are only allowed to use @(tsee o<) as their well-founded relation, and so plain second-order functions and their instances may not depend on function variables via their well-founded relations. </p> <p> Note that if the function is recursive, the variable @('measure') in the following code is @('nil'), and @(tsee funvars-of-term) applied to that yields @('nil'). </p> <p> The returned list may contain duplicates. </p>" (let* ((body (ubody fun wrld)) (measure (if (recursivep fun nil wrld) (measure fun wrld) nil)) (guard (uguard fun wrld)) (body-funvars (funvars-of-term body wrld)) (measure-funvars (funvars-of-term measure wrld)) (guard-funvars (funvars-of-term guard wrld))) (append body-funvars measure-funvars guard-funvars))) (define funvars-of-choice-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a choice second-order function or by an instance of it." :long "<p> Choice second-order functions and their instances may depend on function variables via their defining bodies. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (defchoose-body fun wrld) wrld)) (define funvars-of-quantifier-fn ((fun symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a quantifier second-order function or by an instance of it." :long "<p> Quantifier second-order functions and their instances may depend on function variables via their matrices and via their guards (which are introduced via @(':witness-dcls')). </p> <p> The returned list may contain duplicates. </p>" (let* ((matrix (defun-sk-matrix fun wrld)) (guard (uguard fun wrld)) (matrix-funvars (funvars-of-term matrix wrld)) (guard-funvars (funvars-of-term guard wrld))) (append matrix-funvars guard-funvars))) (define funvars-of-thm ((thm symbolp) (wrld plist-worldp)) :returns (funvars "A @(tsee funvar-listp).") :mode :program :short "Function variables depended on by a second-order theorem or by an instance of it." :long "<p> Second-order theorems and their instances may depend on function variables via their formulas. </p> <p> The returned list may contain duplicates. </p>" (funvars-of-term (formula thm nil wrld) wrld)) (define check-wfrel-o< ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? maybe-msgp) :verify-guards nil :short "Check if a recursive second-order function, or an instance of it, uses @(tsee o<) as well-founded relation." :long "<p> When a recursive second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its well-founded relation is @(tsee o<). The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p>" (if (recursivep fun nil wrld) (let ((wfrel (well-founded-relation fun wrld))) (if (eq wfrel 'o<) nil (msg "~x0 must use O< as well-founded relation, not ~x1.~%" fun wfrel))) nil)) (define check-qrewrite-rule-funvars ((fun symbolp) (wrld plist-worldp)) :returns (err-msg? "A @(tsee maybe-msgp).") :mode :program :short "Check if the rewrite rule of a quantifier second-order function, or of an instance of it, depends exactly on the same function variables that the matrix of the function depends on." :long "<p> When a quantifier second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then checks whether its rewrite rule depends exactly on the same function variables that the matrix of the function depends on. The following code performs this check. </p> <p> If the check is satisfied, @('nil') is returned. Otherwise, an error message is returned. </p> <p> This check is relevant when the rewrite rule is a custom one. Otherwise, it is a redundant check. </p>" (let* ((rule-name (defun-sk-rewrite-name fun wrld)) (rule-body (formula rule-name nil wrld)) (fun-matrix (defun-sk-matrix fun wrld))) (if (set-equiv (funvars-of-term rule-body wrld) (funvars-of-term fun-matrix wrld)) nil (msg "The custom rewrite rule ~x0 must have ~ the same function variables as the function's matrix ~x1.~%" rule-body fun-matrix)))) (define print-funvar-dependency ((fun symbolp) (kind sofun-kindp) (wrld plist-worldp)) :returns (nothing "Always @(tsee null).") :mode :program :short "Print the function variables that a funcion depends on." :long "<p> When a second-order function, or an instance thereof, is introduced, the submitted event form first introduces the function, and then prints the function variables that the function depends on. The following code performs that printing. </p> <p> This function returns nothing. It is only used for side effects, namely printing. </p> <p> The @('kind') argument is the kind of @('fun') if second-order, otherwise it is the kind of the second-order function of which @('fun') is an instance. </p>" (let ((funvars (case kind (plain (funvars-of-plain-fn fun wrld)) (choice (funvars-of-choice-fn fun wrld)) (quant (funvars-of-quantifier-fn fun wrld))))) (if funvars (cw "The function ~x0 depends on the function variables ~x1.~%" fun (remove-duplicates-eq funvars)) (cw "The function ~x0 depends on no function variables.~%" fun)))) (define defun2-fn (sofun rest (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun) to check the rest of the form. The second-to-last element of a valid @(tsee defun) can never be the keyword @(':print') (it must be a declaration, a documentation string, or a list of formals), so if the second-to-last element of @(tsee defun2) is @(':print'), the last element of @(tsee defun2) must be the value of the @(':print') option. After submitting the @(tsee defun) form, we check that, if the function is recursive, the well-founded relation is @(tsee o<). </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) (len-rest (len rest)) (print-is-present (and (>= len-rest 2) (eq :print (nth (- len-rest 2) rest)))) (print (if print-is-present (nth (1- len-rest) rest) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (rest (if print-is-present (butlast rest 2) rest)) (defun-event `(defun ,sofun ,@rest)) (table-event `(table second-order-functions ',sofun (list 'plain (remove-duplicates (funvars-of-plain-fn ',sofun world))))) (check-event `(make-event-terse (b* ((err-msg? (check-wfrel-o< ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun2-implementation :short "Implementation of @(tsee defun2)." :long "@(def defun2) @(def acl2::defun2)" (defmacro defun2 (sofun &rest rest) `(make-event-terse (defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state))) (defmacro acl2::defun2 (&rest args) `(defun2 ,@args))) (defsection show-defun2 :short "Show the event form generated by @(tsee defun2), without submitting them." :long "@(def show-defun2) @(def acl2::show-defun2)" (defmacro show-defun2 (sofun &rest rest) `(defun2-fn ',sofun ',rest (cons 'defun2 ',sofun) state)) (defmacro acl2::show-defun2 (&rest args) `(show-defun2 ,@args))) (define defchoose2-fn (sofun bvars params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defchoose2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defchoose) to check the rest of the form. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the fourth input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defchoose-event `(defchoose ,sofun ,bvars ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'choice (remove-duplicates (funvars-of-choice-fn ',sofun world))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defchoose-event ,table-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defchoose-event) ,table-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defchoose2-implementation :short "Implementation of @(tsee defchoose2)." :long "@(def defchoose2) @(def acl2::defchoose2)" (defmacro defchoose2 (sofun bvars vars body &rest options) `(make-event-terse (defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state))) (defmacro acl2::defchoose2 (&rest args) `(defchoose2 ,@args))) (defsection show-defchoose2 :short "Show the event form generated by @(tsee defchoose2), without submitting them." :long "@(def show-defchoose2) @(def acl2::show-defchoose2)" (defmacro show-defchoose2 (sofun bvars vars body &rest options) `(defchoose2-fn ',sofun ',bvars ',vars ',body ',options (cons 'defchoose2 ',sofun) state)) (defmacro acl2::show-defchoose2 (&rest args) `(show-defchoose2 ,@args))) (define defun-sk2-fn (sofun params body options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event maybe-pseudo-event-formp) state) :verify-guards nil :short "Validate some of the inputs to @(tsee defun-sk2) and generate the event form to submit." :long "<p> We directly check the name and @(':print') option (if present), but rely on @(tsee defun-sk) to check the rest of the form. After submitting the @(tsee defun-sk) form, we check that the body and the rewrite rule depend on the same function variables. </p>" (b* (((unless (symbolp sofun)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the third input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :fn-output)) ((unless (member-eq print '(nil :all :fn-output))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :FN-OUTPUT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (defun-sk-event `(defun-sk ,sofun ,params ,body ,@options)) (table-event `(table second-order-functions ',sofun (list 'quant (funvars-of-quantifier-fn ',sofun world)))) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ ',ctx t nil "~@0" err-msg?) (value '(value-triple :invisible)))))) (print-funvar-event `(value-triple (print-funvar-dependency ',sofun 'plain (w state)))) (return-value-event `(value-triple ',sofun)) (event (cond ((eq print nil) `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defun-sk-event ,table-event ,check-event ,print-funvar-event ,return-value-event))) ((eq print :fn-output) `(progn ,(restore-output defun-sk-event) ,table-event ,check-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-sk2-implementation :short "Implementation of @(tsee defun-sk2)." :long "@(def defun-sk2) @(def acl2::defun-sk2)" (defmacro defun-sk2 (sofun params body &rest options) `(make-event-terse (defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state))) (defmacro acl2::defun-sk2 (&rest args) `(defun-sk2 ,@args))) (defsection show-defun-sk2 :short "Show the event form generated by @(tsee defun-sk2), without submitting them." :long "@(def show-defun-sk2) @(def acl2::show-defun-sk2)" (defmacro show-defun-sk2 (sofun params body &rest options) `(defun-sk2-fn ',sofun ',params ',body ',options (cons 'defun-sk2 ',sofun) state)) (defmacro acl2::show-defun-sk2 (&rest args) `(show-defun-sk2 ,@args))) (define sothmp ((sothm symbolp) (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize second-order theorems." :long "<p> A theorem is second-order iff it depends on one or more function variables. </p>" (not (null (funvars-of-thm sothm wrld)))) (define no-trivial-pairsp ((alist alistp)) :returns (yes/no booleanp) :short "Check if an alist has no pairs with equal key and value." :long "<p> This is a constraint satisfied by function substitutions; see @(tsee fun-substp). A pair that substitutes a function with itself would have no effect, so such pairs are useless. </p>" (if (endp alist) t (let ((pair (car alist))) (and (not (equal (car pair) (cdr pair))) (no-trivial-pairsp (cdr alist)))))) (define fun-substp (fsbs) :returns (yes/no booleanp) :short "Recognize function substitutions." :long "<p> A function substitution is an alist from function names to function names, with unique keys and with no trivial pairs. </p>" (and (symbol-symbol-alistp fsbs) (no-duplicatesp (alist-keys fsbs)) (no-trivial-pairsp fsbs)) :guard-hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) (define funvar-instp (inst (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize instantiations." :long "<p> These are non-empty function substitutions whose keys are function variables and whose values are function names. </p>" (and (fun-substp inst) (consp inst) (funvar-listp (alist-keys inst) wrld) (function-symbol-listp (alist-vals inst) wrld))) (define funvar-inst-listp (insts (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize true lists of instantiations." (if (atom insts) (null insts) (and (funvar-instp (car insts) wrld) (funvar-inst-listp (cdr insts) wrld)))) (define sof-instancesp (instmap (wrld plist-worldp)) :returns (yes/no booleanp) :verify-guards nil :short "Recognize the information about the instances that is associated to second-order function names in the @(tsee sof-instances) table." :long "<p> This is an alist from instantiations to function names. Each pair in the alist maps an instantiation to the corresponding instance. </p>" (and (alistp instmap) (funvar-inst-listp (alist-keys instmap) wrld) (symbol-listp (alist-vals instmap)))) (define get-sof-instance ((inst (funvar-instp inst wrld)) (instmap (sof-instancesp instmap wrld)) (wrld plist-worldp)) :returns (instance symbolp :hyp (sof-instancesp instmap wrld) :hints (("Goal" :in-theory (enable sof-instancesp)))) :verify-guards nil :short "Retrieve the instance associated to a given instantiation, in the map of known instances of a second-order function." :long "<p> Instantiations are treated as equivalent according to @(tsee alist-equiv). If no instance for the instantiation is found, @('nil') is returned. </p>" (if (endp instmap) nil (let ((pair (car instmap))) (if (alist-equiv (car pair) inst) (cdr pair) (get-sof-instance inst (cdr instmap) wrld))))) (define put-sof-instance ((inst (funvar-instp inst wrld)) (fun symbolp) (instmap (and (sof-instancesp instmap wrld) (null (get-sof-instance inst instmap wrld)))) (wrld plist-worldp)) :returns (new-instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Associates an instantiation with an instance in an existing map of know instances of a second-order function." :long "<p> The guard requires the absence of an instance for the same instantiation (equivalent up to @(tsee alist-equiv)). </p>" (declare (ignore wrld)) ; only used in guard (acons inst fun instmap)) (defsection sof-instances-table :short "Table of instances of second-order functions." :long "<p> The known instances of second-order functions are stored in a @(see table). The keys are the names of second-order functions that have instances, and the values are alists from instantiations to instances. </p>" (table sof-instances nil nil :guard (and (symbolp acl2::key) (sof-instancesp acl2::val world)))) (define sof-instances ((sofun (sofunp sofun wrld)) (wrld plist-worldp)) :returns (instmap "A @(tsee sof-instancesp).") :verify-guards nil :short "Known instances of a second-order function." (let ((table (table-alist 'sof-instances wrld))) (cdr (assoc-eq sofun table)))) (define fun-subst-function ((fsbs fun-substp) (fun symbolp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") :verify-guards nil :short "Apply a function substitution to an individual function." :long "<p> Applying an instantiation to a term involves replacing not only the function variables that are keys of the instantiation and that occur explicitly in the term, but also the ones that occur implicitly in the term via occurrences of second-order functions that depend on those function variables. For example, if @('ff') is a second-order function with function parameter @('f'), and an instantiation @('I') replaces @('f') with @('g'), applying @('I') to the term @('(cons (f x) (ff y))') should yield the term @('(cons (g x) (gg y))'), where @('gg') is the instance that results form applying @('I') to @('ff'). The @(tsee sof-instances) table is used to find @('gg'): @('I') is restricted to the function parameters of @('ff') before searching the map of instances of @('ff'); if the restriction is empty, @('gg') is @('ff'), i.e. no replacement takes place. If @('gg') does not exist, the application of @('I') to @('(cons (f x) (ff y))') fails; the user must create @('gg') and try applying @('I') to @('(cons (f x) (ff y))') again. </p> <p> When an instantiation is applied to the body of a recursive second-order function @('sofun') to obtain an instance @('fun'), occurrences of @('sofun') in the body must be replaced with @('fun'), but at that time @('fun') does not exist yet, and thus the table of second-order function instances of @('sofun') has no entries for @('fun') yet. Thus, it is convenient to use function substitutions (not just instantiations) to instantiate terms. </p> <p> The following code applies a function substitution to an individual function, in the manner explained above. It is used by @(tsee fun-subst-term), which applies a function substitution to a term. If a needed second-order function instance does not exist, an error occurs. </p>" (let ((pair (assoc-eq fun fsbs))) (if pair (cdr pair) (if (sofunp fun wrld) (let* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs))) (if (null subfsbs) fun (let* ((instmap (sof-instances fun wrld)) (new-fun (get-sof-instance subfsbs instmap wrld))) (if new-fun new-fun (raise "~x0 has no instance for ~x1." fun fsbs))))) fun)))) (defines fun-subst-term/terms :verify-guards nil :short "Apply function substitutions to terms." :long "<p> See the discussion in @(tsee fun-subst-function). </p> @(def fun-subst-term) @(def fun-subst-terms)" (define fun-subst-term ((fsbs fun-substp) (term pseudo-termp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) term (let* ((fn (fn-symb term)) (new-fn (if (symbolp fn) (fun-subst-function fsbs fn wrld) (make-lambda (lambda-formals fn) (fun-subst-term fsbs (lambda-body fn) wrld)))) (new-args (fun-subst-terms fsbs (fargs term) wrld))) (cons new-fn new-args)))) (define fun-subst-terms ((fsbs fun-substp) (terms pseudo-term-listp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) nil (cons (fun-subst-term fsbs (car terms) wrld) (fun-subst-terms fsbs (cdr terms) wrld))))) (defines ext-fun-subst-term/terms/function :mode :program :short "Extend function substitutions for functional instantiation." :long "<p> An instance @('thm') of a second-order theorem @('sothm') is also a theorem, provable using a @(':functional-instance') of @('sothm'). The pairs of the @(':functional-instance') are not only the pairs of the instantiation that creates @('thm') from @('sothm'), but also all the pairs whose first components are second-order functions that @('sothm') depends on and whose second components are the corresponding instances. </p> <p> For example, if @('sothm') is @('(p (sofun x))'), @('sofun') is a second-order function, @('p') is a first-order predicate, and applying an instantiation @('I') to @('(p (sofun x))') yields @('(p (fun x))'), then @('thm') is proved using @('(:functional-instance sothm (... (sofun fun) ...))'), where the first @('...') are the pairs of @('I') and the second @('...') are further pairs of second-order functions and their instances, e.g. if @('sofun') calls a second-order function @('sofun1'), the pair @('(sofun1 fun1)') must be in the second @('...'), where @('fun1') is the instance of @('sofun1') corresponding to @('I'). All these pairs are needed to properly instantiate the constraints that arise from the @(':functional-instance'), which involve the second-order functions that @('sothm') depends on, directly or indirectly. </p> <p> The following code extends a function substitution (initially an instantiation) to contain all those extra pairs. The starting point is a term; the bodies of second-order functions referenced in the term are recursively processed. The table of instances of second-order functions is searched, similarly to @(tsee fun-subst-function). </p> @(def ext-fun-subst-term) @(def ext-fun-subst-terms) @(def ext-fun-subst-function)" (define ext-fun-subst-term ((term pseudo-termp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-term "A @(tsee pseudo-termp).") (if (or (variablep term) (quotep term)) fsbs (let* ((fn (fn-symb term)) (fsbs (if (symbolp fn) (ext-fun-subst-function fn fsbs wrld) (ext-fun-subst-term (lambda-body fn) fsbs wrld)))) (ext-fun-subst-terms (fargs term) fsbs wrld)))) (define ext-fun-subst-terms ((terms pseudo-term-listp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-terms "A @(tsee pseudo-term-listp).") (if (endp terms) fsbs (let ((fsbs (ext-fun-subst-term (car terms) fsbs wrld))) (ext-fun-subst-terms (cdr terms) fsbs wrld)))) (define ext-fun-subst-function ((fun symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (new-fun "A @(tsee symbolp).") (cond ((assoc fun fsbs) fsbs) ((sofunp fun wrld) (b* ((funvars (sofun-funvars fun wrld)) (subfsbs (restrict-alist funvars fsbs)) ((if (null subfsbs)) fsbs) (instmap (sof-instances fun wrld)) (funinst (get-sof-instance subfsbs instmap wrld)) ((unless funinst) (raise "~x0 has no instance for ~x1." fun fsbs)) (fsbs (acons fun funinst fsbs))) (case (sofun-kind fun wrld) ((plain quant) (ext-fun-subst-term (ubody fun wrld) fsbs wrld)) (choice (ext-fun-subst-term (defchoose-body fun wrld) fsbs wrld))))) (t fsbs)))) (define sothm-inst-pairs ((fsbs fun-substp) (wrld plist-worldp)) :returns (pairs "A @('doublet-listp').") :mode :program :short "Create a list of doublets for functional instantiation." :long "<p> From a function substitution obtained by extending an instantiation via @(tsee ext-fun-subst-term/terms/function), the list of pairs to supply to @(':functional-instance') is obtained. Each dotted pair is turned into a doublet (a different representation of the pair). </p> <p> In addition, when a dotted pair is encountered whose @(tsee car) is the name of a quantifier second-order function, an extra pair for instantiating the associated witness is inserted. The witnesses of quantifier second-order functions must also be part of the @(':functional-instance'), because they are referenced by the quantifier second-order functions. However, these witnesses are not recorded as second-order functions in the table of second-order functions, and thus the code of @(tsee ext-fun-subst-term/terms/function) does not catch these witnesses. </p>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (if (quant-sofunp 1st wrld) (let ((1st-wit (defun-sk-witness 1st wrld)) (2nd-wit (defun-sk-witness 2nd wrld))) (cons (list 1st 2nd) (cons (list 1st-wit 2nd-wit) (sothm-inst-pairs (cdr fsbs) wrld)))) (cons (list 1st 2nd) (sothm-inst-pairs (cdr fsbs) wrld)))))) (define sothm-inst-facts ((fsbs fun-substp) (wrld plist-worldp)) :returns (fact-names "A @(tsee symbol-listp).") :mode :program :short "Create list of facts for functional instantiation." :long "<p> When a @(':functional-instance') is used in a proof, proof subgoals are created to ensure that the replacing functions satisfy all the constraints of the replaced functions. In a @(':functional-instance') with a function substitution @('S') as calculated by @(tsee ext-fun-subst-term/terms/function), each function variable (which comes from the instantiation) has no constraints and so no subgoals are generated for them. Each second-order function @('sofun') in @('S') has the following constraints: </p> <ul> <li> If @('sofun') is a plain second-order function, the constraint is that the application of @('S') to the definition of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the definition of @('fun'). </li> <li> If @('sofun') is a choice second-order function, the constraint is that the application of @('S') to the choice axiom of @('sofun') is a theorem, which follows by the construction of the instance @('fun') of @('sofun'), i.e. it follows from the choice axiom of @('fun'). </li> <li> If @('sofun') is a quantifier second-order function, the constraints are that (1) the application of @('S') to the rewrite rule generated by the @(tsee defun-sk) of @('sofun'), and (2) the application of @('S') to the definition of @('sofun') (or to the defining theorem of @('sofun') if @('sofun') was introduced with @(':constrain t')), are both theorems, which both follow by the construction of the instance @('fun') of @('sofun'), i.e. they follow from (1) the rewrite rule generated by the @(tsee defun-sk) of @('fun') and (2) the definition of @('fun') (or the defining theorem of @('fun') if @('fun') was introduced with @(':constrain nil')). </li> </ul> <p> The list of facts needed to prove these constraints is determined by the function substitution @('S'). For each pair @('(fun1 . fun2)') of the function substitution: </p> <ul> <li> If @('fun1') is a plain second-order function, the fact used in the proof is the definition of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun).) </li> <li> If @('fun1') is a choice second-order function, the fact used in the proof is the @(tsee defchoose) axiom of @('fun2'), whose name is the name of @('fun2'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defchoose).) </li> <li> If @('fun1') is a quantifier second-order function, the facts used in the proof are (1) the @(tsee defun-sk) rewrite rule of @('fun2') and (2) either (i) the definition of @('fun2') (if @('fun2') was introduced with @(':constrain nil')), whose name is the name of @('fun2'), or (ii) the defining theorem of @('fun2') (if @('fun2') was introduced with @(':constrain t')), whose name is @('fun2') followed by @('-definition'). (Note that by construction, since @('fun2') is an instance of @('fun1'), @('fun2') is introduced by a @(tsee defun-sk).) </li> <li> Otherwise, @('fun1') is a function variable, which has no constraints, so no fact is used in the proof. </li> </ul>" (if (endp fsbs) nil (let* ((pair (car fsbs)) (1st (car pair)) (2nd (cdr pair))) (cond ((or (plain-sofunp 1st wrld) (choice-sofunp 1st wrld)) (cons 2nd (sothm-inst-facts (cdr fsbs) wrld))) ((quant-sofunp 1st wrld) `(,(defun-sk-rewrite-name 2nd wrld) ,(if (definedp 2nd wrld) 2nd (defun-sk-definition-name 2nd wrld)) ,@(sothm-inst-facts (cdr fsbs) wrld))) (t (sothm-inst-facts (cdr fsbs) wrld)))))) (define sothm-inst-proof ((sothm symbolp) (fsbs fun-substp) (wrld plist-worldp)) :returns (instructions "A @(tsee true-listp).") :mode :program :short "Proof builder instructions to prove instances of second-order theorems." :long "<p> Instances of second-order theorems are proved using the ACL2 proof builder. Each such instance is proved by first using the @(':functional-instance') determined by @(tsee sothm-inst-pairs), then using the facts computed by @(tsee sothm-inst-facts) on the subgoals. Each sugoal only needs a subset of those facts, but for simplicity all the facts are used for each subgoal, using the proof builder <see topic='@(url acl2-pc::repeat)'>@(':repeat')</see> command. Since sometimes the facts are not quite identical to the subgoals, the proof builder <see topic='@(url acl2-pc::prove)'>@(':prove')</see> command is used to iron out any such differences. </p>" `(:instructions ((:use (:functional-instance ,sothm ,@(sothm-inst-pairs fsbs wrld))) (:repeat (:then (:use ,@(sothm-inst-facts fsbs wrld)) :prove))))) (define check-sothm-inst (sothm-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :mode :program :short "Recognize designations of instances of second-order theorems." :long "<p> A designation of an instance of a second-order theorem has the form @('(sothm (f1 . g1) ... (fM . gM))'), where @('sothm') is a second-order theorem and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defthm-inst). </p>" (and (true-listp sothm-inst) (>= (len sothm-inst) 2) (sothmp (car sothm-inst) wrld) (funvar-instp (cdr sothm-inst) wrld))) (define defthm-inst-fn (thm sothm-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defthm-inst) and generate the event form to submit." :long "<p> We directly check all the inputs except for the @(':rule-classes') option, relying on @(tsee defthm) to check it. </p>" (b* ((wrld (w state)) ((unless (symbolp thm)) (er-soft+ ctx t nil "The first input must be a symbol, but ~x0 is not." thm)) ((unless (check-sothm-inst sothm-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order theorem ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sothm-inst)) (sothm (car sothm-inst)) (inst (cdr sothm-inst)) ((unless (subsetp (alist-keys inst) (funvars-of-thm sothm wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among function variable that ~x1 depends on." inst sothm)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The inputs keywords must be unique.")) ((unless (subsetp keywords '(:rule-classes :print))) (er-soft+ ctx t nil "Only the input keywords ~ :RULE-CLASSES and :PRINT are allowed.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) (options (remove-keyword :print options)) (sothm-formula (formula sothm nil wrld)) (thm-formula (fun-subst-term inst sothm-formula wrld)) (thm-formula (untranslate thm-formula t wrld)) (fsbs (ext-fun-subst-term sothm-formula inst wrld)) (thm-proof (sothm-inst-proof sothm fsbs wrld)) (defthm-event `(defthm ,thm ,thm-formula ,@thm-proof ,@options)) (defthm-event-without-proof `(defthm ,thm ,thm-formula ,@options)) (return-value-event `(value-triple ',thm)) (event (cond ((eq print nil) `(progn ,defthm-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,defthm-event ,return-value-event))) ((eq print :result) `(progn ,defthm-event (cw-event "~x0~|" ',defthm-event-without-proof) ,return-value-event)) (t (impossible))))) (value event))) (defsection defthm-inst-implementation :short "Implementation of @(tsee defthm-inst)." :long "@(def defthm-inst) @(def acl2::defthm-inst)" (defmacro defthm-inst (thm sothminst &rest options) `(make-event-terse (defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state))) (defmacro acl2::defthm-inst (&rest args) `(defthm-inst ,@args))) (defsection show-defthm-inst :short "Show the event form generated by @(tsee defthm-inst), without submitting them." :long "@(def show-defthm-inst) @(def acl2::show-defthm-inst)" (defmacro show-defthm-inst (thm sothminst &rest options) `(defthm-inst-fn ',thm ',sothminst ',options (cons 'defthm-inst ',thm) state)) (defmacro acl2::show-defthm-inst (&rest args) `(show-defthm-inst ,@args))) (define check-sofun-inst (sofun-inst (wrld plist-worldp)) :returns (yes/no "A @(tsee booleanp).") :verify-guards nil :short "Recognize designations of instances of second-order functions." :long "<p> A designation of an instance of a second-order function has the form @('(sofun (f1 . g1) ... (fM . gM))'), where @('sofun') is a second-order function and @('((f1 . g1) ... (fM . gM))') is an instantiation. These designations are used in @(tsee defun-inst). </p>" (and (true-listp sofun-inst) (>= (len sofun-inst) 2) (sofunp (car sofun-inst) wrld) (funvar-instp (cdr sofun-inst) wrld))) (define defun-inst-plain-events ((fun symbolp) (sofun (plain-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a plain second-order function." :long "<p> Also return the @(tsee defun2) or @(tsee defun) event form, without the termination hints. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':verify-guards') and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p> <p> If @('sofun') (and consequently @('fun')) is recursive, we extend the instantiation with @('(sofun . fun)'), to ensure that the recursive calls are properly transformed. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:verify-guards :print))) (er-soft+ ctx t nil "Only the input keywords ~ :VERIFY-GUARDS and :PRINT are allowed, ~ because ~x0 is a plain second-order function." sofun)) (verify-guards (let ((verify-guards-option (assoc-keyword :verify-guards options))) (if verify-guards-option (cadr verify-guards-option) (guard-verified-p sofun wrld)))) (sofun-body (ubody sofun wrld)) (sofun-measure (if (recursivep sofun nil wrld) (measure sofun wrld) nil)) (sofun-guard (uguard sofun wrld)) (fsbs (if sofun-measure (acons sofun fun inst) inst)) (fun-body (fun-subst-term fsbs sofun-body wrld)) (fun-body-funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (fun-measure (fun-subst-term inst sofun-measure wrld)) (fun-measure-funvars (funvars-of-term fun-measure wrld)) (fun-measure (untranslate fun-measure nil wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (sofun-tt-name `(:termination-theorem ,sofun)) (sofun-tt-formula (and (recursivep sofun nil wrld) (termination-theorem sofun wrld))) (fsbs (ext-fun-subst-term sofun-tt-formula inst wrld)) (fun-tt-proof (sothm-inst-proof sofun-tt-name fsbs wrld)) (hints (if fun-measure `(:hints (("Goal" ,@fun-tt-proof))) nil)) (measure (if fun-measure `(:measure ,fun-measure) nil)) (formals (formals sofun wrld)) (funvars (remove-duplicates (append fun-body-funvars fun-measure-funvars fun-guard-funvars))) (defun-event `(defun ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure ,@hints)) ,fun-body)) (result `(,(if funvars 'defun2 'defun) ,fun ,formals (declare (xargs :guard ,fun-guard :verify-guards ,verify-guards ,@measure)) ,fun-body)) (table-event? (if funvars `((table second-order-functions ',fun (list 'plain ',funvars))) nil))) (value (list `(,defun-event ,@table-event?) result funvars)))) (define defun-inst-choice-events ((fun symbolp) (sofun (choice-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a choice second-order function." :long "<p> Also return the @(tsee defchoose2) or @(tsee defchoose) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':print') option may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:print))) (er-soft+ ctx t nil "Only the input keyword :PRINT is allowed, ~ because ~x0 is a choice second-order function." sofun)) (bound-vars (defchoose-bound-vars sofun wrld)) (sofun-body (defchoose-body sofun wrld)) (fun-body (fun-subst-term inst sofun-body wrld)) (funvars (funvars-of-term fun-body wrld)) (fun-body (untranslate fun-body nil wrld)) (formals (formals sofun wrld)) (strengthen (defchoose-strengthen sofun wrld)) (funvars (remove-duplicates funvars)) (defchoose-event `(defchoose ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (result `(,(if funvars 'defchoose2 'defchoose) ,fun ,bound-vars ,formals ,fun-body :strengthen ,strengthen)) (table-event? (if funvars `((table second-order-functions ',fun (list 'choice ',funvars))) nil))) (value (list `(,defchoose-event ,@table-event?) result funvars)))) (define defun-inst-quant-events ((fun symbolp) (sofun (quant-sofunp sofun (w state))) inst (options keyword-value-listp) (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (events+result+funvars "A tuple @('(events result funvars)') where @('events') is a @(tsee pseudo-event-form-listp), @('result') is a @(tsee maybe-pseudo-event-formp), and @('funvars') is a @(tsee funvar-listp).") state) :mode :program :short "Generate a list of events to submit, when instantiating a quantifier second-order function." :long "<p> Also return the @(tsee defun-sk2) or @(tsee defun-sk) event form. This is printed when @(':print') is @(':result'). </p> <p> Also return the function variables that the new function depends on. </p> <p> Only the @(':skolem-name'), @(':thm-name'), @(':rewrite'), @(':constrain'), and @(':print') options may be present. </p> <p> We add @('fun') to the table of second-order functions iff it is second-order. </p>" (b* ((wrld (w state)) ((unless (subsetp (evens options) '(:skolem-name :thm-name :rewrite :constrain :print))) (er-soft+ ctx t nil "Only the input keywords ~ :SKOLEM-NAME, :THM-NAME, :REWRITE, :CONSTRAIN and :PRINT ~ are allowed, ~ because ~x0 is a quantifier second-order function." sofun)) (bound-vars (defun-sk-bound-vars sofun wrld)) (quant (defun-sk-quantifier sofun wrld)) (sofun-matrix (defun-sk-matrix sofun wrld)) (fun-matrix (fun-subst-term inst sofun-matrix wrld)) (fun-matrix-funvars (funvars-of-term fun-matrix wrld)) (fun-matrix (untranslate fun-matrix nil wrld)) (rewrite-option (assoc-keyword :rewrite options)) (rewrite (if rewrite-option (cadr rewrite-option) (let ((qrkind (defun-sk-rewrite-kind sofun wrld))) (case qrkind (:default :default) (:direct :direct) (:custom (let* ((fsbs (acons sofun fun inst)) (rule-name (defun-sk-rewrite-name sofun wrld)) (term (formula rule-name nil wrld))) (fun-subst-term fsbs term wrld))))))) (skolem-name (let ((skolem-name-option (assoc-keyword :skolem-name options))) (if skolem-name-option `(:skolem-name ,(cadr skolem-name-option)) nil))) (thm-name (let ((thm-name-option (assoc-keyword :thm-name options))) (if thm-name-option `(:thm-name ,(cadr thm-name-option)) nil))) (constrain (let ((constrain-option (assoc-keyword :constrain options))) (if constrain-option `(:constrain ,(cadr constrain-option)) nil))) (sofun-guard (uguard sofun wrld)) (fun-guard (fun-subst-term inst sofun-guard wrld)) (fun-guard-funvars (funvars-of-term fun-guard wrld)) (fun-guard (untranslate fun-guard t wrld)) (wit-dcl `(declare (xargs :guard ,fun-guard :verify-guards nil))) (formals (formals sofun wrld)) (strengthen (defun-sk-strengthen sofun wrld)) (body (list quant bound-vars fun-matrix)) (rest `(:strengthen ,strengthen :quant-ok t ,@(and (eq quant 'forall) (list :rewrite rewrite)) ,@skolem-name ,@thm-name ,@constrain :witness-dcls (,wit-dcl))) (funvars (remove-duplicates (append fun-matrix-funvars fun-guard-funvars))) (defun-sk-event `(defun-sk ,fun ,formals ,body ,@rest)) (result `(,(if funvars 'defun-sk2 'defun-sk) ,fun ,formals ,body ,@rest)) (table-event? (if funvars `((table second-order-functions ',fun (list 'quant ',funvars))) nil)) (check-event `(make-event-terse (b* ((err-msg? (check-qrewrite-rule-funvars ',sofun (w state)))) (if err-msg? (er-soft+ (cons 'defun-inst ',fun) t nil "~@0" err-msg?) (value '(value-triple :invisible))))))) (value (list `(,defun-sk-event ,@table-event? ,check-event) result funvars)))) (define defun-inst-fn (fun sofun-inst options (ctx "Context for errors.") state) :returns (mv (erp "@(tsee booleanp) flag of the <see topic='@(url acl2::error-triple)'>error triple</see>.") (event "A @(tsee maybe-pseudo-event-formp).") state) :mode :program :short "Validate some of the inputs to @(tsee defun-inst) and generate the event form to submit." :long "<p> We directly check the name and instance designation, we directly check the correct presence of keyed options (we do that in @(tsee defun-inst-plain-events), @(tsee defun-inst-choice-events), and @(tsee defun-inst-quant-events)), and we directly check the correct value of the @(':print') option (if present), but rely on @(tsee defun), @(tsee defchoose), and @(tsee defun-sk) to check the values of the other keyed options. </p> <p> Prior to introducing @('fun'), we generate local events to avoid errors due to ignored or irrelevant formals in @('fun') (which may happen if @('sofun') has ignored or irrelevant formals). We add @('fun') to the table of instances of second-order functions. </p>" (b* ((wrld (w state)) ((unless (symbolp fun)) (er-soft+ ctx t nil "The first input must be a name, but ~x0 is not." fun)) ((unless (check-sofun-inst sofun-inst wrld)) (er-soft+ ctx t nil "The second input must be ~ the name of a second-order function ~ followed by the pairs of an instantiation, ~ but ~x0 is not." sofun-inst)) (sofun (car sofun-inst)) (inst (cdr sofun-inst)) ((unless (subsetp (alist-keys inst) (sofun-funvars sofun wrld))) (er-soft+ ctx t nil "Each function variable key of ~x0 must be ~ among the function variables ~x1 ~ that ~x2 depends on." inst (sofun-funvars sofun wrld) sofun)) ((unless (keyword-value-listp options)) (er-soft+ ctx t nil "The inputs after the second input ~ must be a keyword-value list, ~ but ~x0 is not." options)) (keywords (evens options)) ((unless (no-duplicatesp keywords)) (er-soft+ ctx t nil "The input keywords must be unique.")) (print-pair (assoc-keyword :print options)) (print (if print-pair (cadr print-pair) :result)) ((unless (member-eq print '(nil :all :result))) (er-soft+ ctx t nil "The :PRINT input must be NIL, :ALL, or :RESULT, ~ but ~x0 is not." print)) ((er (list fun-intro-events result funvars)) (case (sofun-kind sofun wrld) (plain (defun-inst-plain-events fun sofun inst options ctx state)) (choice (defun-inst-choice-events fun sofun inst options ctx state)) (quant (defun-inst-quant-events fun sofun inst options ctx state)) (t (prog2$ (impossible) (value (list nil nil)))))) (instmap (sof-instances sofun wrld)) (new-instmap (put-sof-instance inst fun instmap wrld)) (encapsulate `(encapsulate () (set-ignore-ok t) (set-irrelevant-formals-ok t) ,@fun-intro-events (table sof-instances ',sofun ',new-instmap))) (result-event `(cw-event "~x0~|" ',result)) (print-funvar-event (if funvars `(cw-event "The function ~x0 depends on the function variables ~x1.~%" ',fun ',funvars) `(cw-event "The function ~x0 depends on no function variables.~%" ',fun))) (return-value-event `(value-triple ',fun)) (event (cond ((eq print nil) `(progn ,encapsulate ,print-funvar-event ,return-value-event)) ((eq print :all) (restore-output `(progn ,encapsulate ,print-funvar-event ,return-value-event))) ((eq print :result) `(progn ,encapsulate ,result-event ,print-funvar-event ,return-value-event)) (t (impossible))))) (value event))) (defsection defun-inst-implementation :short "Implementation of @(tsee defun-inst)." :long "@(def defun-inst) @(def acl2::defun-inst)" (defmacro defun-inst (fun sofun-inst &rest rest) `(make-event-terse (defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state))) (defmacro acl2::defun-inst (&rest args) `(defun-inst ,@args))) (defsection show-defun-inst :short "Show the event form generated by @(tsee defun-inst), without submitting them." :long "@(def show-defun-inst) @(def acl2::show-defun-inst)" (defmacro show-defun-inst (fun sofun-inst &rest rest) `(defun-inst-fn ',fun ',sofun-inst ',rest (cons 'defun-inst ',fun) state)) (defmacro acl2::show-defun-inst (&rest args) `(show-defun-inst ,@args)))
[ { "context": " DEALINGS IN THE SOFTWARE.\n;\n; Original authors: Sol Swords <[email protected]>\n; Jared ", "end": 1392, "score": 0.999866783618927, "start": 1382, "tag": "NAME", "value": "Sol Swords" }, { "context": "N THE SOFTWARE.\n;\n; Original authors: Sol Swords <[email protected]>\n; Jared Davis <jared@centtech.", "end": 1414, "score": 0.9999352097511292, "start": 1394, "tag": "EMAIL", "value": "[email protected]" }, { "context": " Swords <[email protected]>\n; Jared Davis <[email protected]>\n;\n; NOTE: This file is not p", "end": 1447, "score": 0.9998617172241211, "start": 1436, "tag": "NAME", "value": "Jared Davis" }, { "context": "[email protected]>\n; Jared Davis <[email protected]>\n;\n; NOTE: This file is not part of the standard ", "end": 1467, "score": 0.9999348521232605, "start": 1449, "tag": "EMAIL", "value": "[email protected]" } ]
books/build/cert_features.lsp
MattKaufmann/acl2
1
; cert.pl build system ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original authors: Sol Swords <[email protected]> ; Jared Davis <[email protected]> ; ; NOTE: This file is not part of the standard ACL2 books build process; it is ; part of an experimental build system. The ACL2 developers do not maintain ; this file. (in-package "ACL2") (mv-let (channel state) (open-output-channel "Makefile-features" :character state) (if (not channel) (progn$ (er hard? '|Makefile-features| "Error opening Makefile-features?") state) (let* ((state (princ$ "export ACL2_FEATURES_DETECTED := 1" channel state)) (state (newline channel state)) (state (princ$ #+hons "export ACL2_HAS_HONS := 1" #-hons "export ACL2_HAS_HONS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_HONS" channel state)) (state (newline channel state)) (state (princ$ #-(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := 1" #+(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_ANSI" channel state)) (state (newline channel state)) (state (princ$ #+acl2-par "export ACL2_HAS_PARALLEL := 1" #-acl2-par "export ACL2_HAS_PARALLEL := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_PARALLEL" channel state)) (state (newline channel state)) (state (princ$ #+non-standard-analysis "export ACL2_HAS_REALS := 1" #-non-standard-analysis "export ACL2_HAS_REALS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_REALS" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_COMP_EXT := " channel state)) (state (princ$ (@ compiled-file-extension) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_COMP_EXT" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_HOST_LISP := " channel state)) (host-lisp (symbol-name (@ host-lisp))) (state (princ$ host-lisp channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HOST_LISP" channel state)) (state (newline channel state)) (state (princ$ "export USE_QUICKLISP ?= " channel state)) (state (princ$ (if (equal host-lisp "GCL") "0" "1") channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += USE_QUICKLISP" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_THINKS_BOOK_DIR_IS := " channel state)) (state (princ$ (f-get-global 'system-books-dir state) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_THINKS_BOOK_DIR_IS" channel state)) (state (newline channel state)) (state (close-output-channel channel state))) state))) (defun write-file-if-obj-differs (filename object state) ;; Reads the given file and checks whether the first object it contains ;; equals the given object. If not, overwrites that file with the given ;; object. (declare (xargs :mode :program :stobjs state)) (mv-let (channel state) (open-input-channel filename :object state) (mv-let (need-to-write-file-p state) (if channel (mv-let (eof val state) (read-object channel state) (let ((state (close-input-channel channel state))) (if (and (not eof) (equal val object)) ;; File was read and object matches. (mv nil state) ;; No object in the file or didn't match. (mv t state)))) ;; File didn't exist. (mv t state)) (if need-to-write-file-p (mv-let (channel state) (open-output-channel filename :object state) (if channel (let* ((state (print-object$ object channel state))) (prog2$ (cw "Wrote ~s0~%" filename) (close-output-channel channel state))) (prog2$ (cw "Error writing to ~s0~%" filename) state))) (prog2$ (cw "No need to write ~s0~%" filename) state))))) (write-file-if-obj-differs "first-order-like-terms-and-out-arities.certdep" *first-order-like-terms-and-out-arities* state) (write-file-if-obj-differs "acl2-exports.certdep" *acl2-exports* state) (write-file-if-obj-differs "acl2-version.certdep" (f-get-global 'acl2-version state) state) (write-file-if-obj-differs "ground-zero-theory.certdep" (let ((world (w state))) (current-theory 'acl2::ground-zero)) state) (good-bye 0)
86623
; cert.pl build system ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original authors: <NAME> <<EMAIL>> ; <NAME> <<EMAIL>> ; ; NOTE: This file is not part of the standard ACL2 books build process; it is ; part of an experimental build system. The ACL2 developers do not maintain ; this file. (in-package "ACL2") (mv-let (channel state) (open-output-channel "Makefile-features" :character state) (if (not channel) (progn$ (er hard? '|Makefile-features| "Error opening Makefile-features?") state) (let* ((state (princ$ "export ACL2_FEATURES_DETECTED := 1" channel state)) (state (newline channel state)) (state (princ$ #+hons "export ACL2_HAS_HONS := 1" #-hons "export ACL2_HAS_HONS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_HONS" channel state)) (state (newline channel state)) (state (princ$ #-(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := 1" #+(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_ANSI" channel state)) (state (newline channel state)) (state (princ$ #+acl2-par "export ACL2_HAS_PARALLEL := 1" #-acl2-par "export ACL2_HAS_PARALLEL := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_PARALLEL" channel state)) (state (newline channel state)) (state (princ$ #+non-standard-analysis "export ACL2_HAS_REALS := 1" #-non-standard-analysis "export ACL2_HAS_REALS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_REALS" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_COMP_EXT := " channel state)) (state (princ$ (@ compiled-file-extension) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_COMP_EXT" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_HOST_LISP := " channel state)) (host-lisp (symbol-name (@ host-lisp))) (state (princ$ host-lisp channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HOST_LISP" channel state)) (state (newline channel state)) (state (princ$ "export USE_QUICKLISP ?= " channel state)) (state (princ$ (if (equal host-lisp "GCL") "0" "1") channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += USE_QUICKLISP" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_THINKS_BOOK_DIR_IS := " channel state)) (state (princ$ (f-get-global 'system-books-dir state) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_THINKS_BOOK_DIR_IS" channel state)) (state (newline channel state)) (state (close-output-channel channel state))) state))) (defun write-file-if-obj-differs (filename object state) ;; Reads the given file and checks whether the first object it contains ;; equals the given object. If not, overwrites that file with the given ;; object. (declare (xargs :mode :program :stobjs state)) (mv-let (channel state) (open-input-channel filename :object state) (mv-let (need-to-write-file-p state) (if channel (mv-let (eof val state) (read-object channel state) (let ((state (close-input-channel channel state))) (if (and (not eof) (equal val object)) ;; File was read and object matches. (mv nil state) ;; No object in the file or didn't match. (mv t state)))) ;; File didn't exist. (mv t state)) (if need-to-write-file-p (mv-let (channel state) (open-output-channel filename :object state) (if channel (let* ((state (print-object$ object channel state))) (prog2$ (cw "Wrote ~s0~%" filename) (close-output-channel channel state))) (prog2$ (cw "Error writing to ~s0~%" filename) state))) (prog2$ (cw "No need to write ~s0~%" filename) state))))) (write-file-if-obj-differs "first-order-like-terms-and-out-arities.certdep" *first-order-like-terms-and-out-arities* state) (write-file-if-obj-differs "acl2-exports.certdep" *acl2-exports* state) (write-file-if-obj-differs "acl2-version.certdep" (f-get-global 'acl2-version state) state) (write-file-if-obj-differs "ground-zero-theory.certdep" (let ((world (w state))) (current-theory 'acl2::ground-zero)) state) (good-bye 0)
true
; cert.pl build system ; Copyright (C) 2008-2014 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original authors: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ; PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ; ; NOTE: This file is not part of the standard ACL2 books build process; it is ; part of an experimental build system. The ACL2 developers do not maintain ; this file. (in-package "ACL2") (mv-let (channel state) (open-output-channel "Makefile-features" :character state) (if (not channel) (progn$ (er hard? '|Makefile-features| "Error opening Makefile-features?") state) (let* ((state (princ$ "export ACL2_FEATURES_DETECTED := 1" channel state)) (state (newline channel state)) (state (princ$ #+hons "export ACL2_HAS_HONS := 1" #-hons "export ACL2_HAS_HONS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_HONS" channel state)) (state (newline channel state)) (state (princ$ #-(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := 1" #+(and gcl (not ansi-cl)) "export ACL2_HAS_ANSI := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_ANSI" channel state)) (state (newline channel state)) (state (princ$ #+acl2-par "export ACL2_HAS_PARALLEL := 1" #-acl2-par "export ACL2_HAS_PARALLEL := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_PARALLEL" channel state)) (state (newline channel state)) (state (princ$ #+non-standard-analysis "export ACL2_HAS_REALS := 1" #-non-standard-analysis "export ACL2_HAS_REALS := " channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HAS_REALS" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_COMP_EXT := " channel state)) (state (princ$ (@ compiled-file-extension) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_COMP_EXT" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_HOST_LISP := " channel state)) (host-lisp (symbol-name (@ host-lisp))) (state (princ$ host-lisp channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_HOST_LISP" channel state)) (state (newline channel state)) (state (princ$ "export USE_QUICKLISP ?= " channel state)) (state (princ$ (if (equal host-lisp "GCL") "0" "1") channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += USE_QUICKLISP" channel state)) (state (newline channel state)) (state (princ$ "export ACL2_THINKS_BOOK_DIR_IS := " channel state)) (state (princ$ (f-get-global 'system-books-dir state) channel state)) (state (newline channel state)) (state (princ$ "EXPORTED_VARS += ACL2_THINKS_BOOK_DIR_IS" channel state)) (state (newline channel state)) (state (close-output-channel channel state))) state))) (defun write-file-if-obj-differs (filename object state) ;; Reads the given file and checks whether the first object it contains ;; equals the given object. If not, overwrites that file with the given ;; object. (declare (xargs :mode :program :stobjs state)) (mv-let (channel state) (open-input-channel filename :object state) (mv-let (need-to-write-file-p state) (if channel (mv-let (eof val state) (read-object channel state) (let ((state (close-input-channel channel state))) (if (and (not eof) (equal val object)) ;; File was read and object matches. (mv nil state) ;; No object in the file or didn't match. (mv t state)))) ;; File didn't exist. (mv t state)) (if need-to-write-file-p (mv-let (channel state) (open-output-channel filename :object state) (if channel (let* ((state (print-object$ object channel state))) (prog2$ (cw "Wrote ~s0~%" filename) (close-output-channel channel state))) (prog2$ (cw "Error writing to ~s0~%" filename) state))) (prog2$ (cw "No need to write ~s0~%" filename) state))))) (write-file-if-obj-differs "first-order-like-terms-and-out-arities.certdep" *first-order-like-terms-and-out-arities* state) (write-file-if-obj-differs "acl2-exports.certdep" *acl2-exports* state) (write-file-if-obj-differs "acl2-version.certdep" (f-get-global 'acl2-version state) state) (write-file-if-obj-differs "ground-zero-theory.certdep" (let ((world (w state))) (current-theory 'acl2::ground-zero)) state) (good-bye 0)
[ { "context": ";-*- Mode: Lisp -*-\n;;;; Author: Paul Dietz\n;;;; Created: Thu Jan 22 21:34:04 2004\n;;;; Cont", "end": 49, "score": 0.9998499155044556, "start": 39, "tag": "NAME", "value": "Paul Dietz" } ]
programs/ansi-test/streams/file-string-length.lsp
TeamSPoon/wam_common_lisp_devel_workspace
8
;-*- Mode: Lisp -*- ;;;; Author: Paul Dietz ;;;; Created: Thu Jan 22 21:34:04 2004 ;;;; Contains: Tests of FILE-STRING-LENGTH (in-package :cl-test) (deftest file-string-length.1 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s x) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-char x s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.2 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s (string x)) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-sequence (string x) s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.3 (with-open-file (stream "tmp.dat" :direction :output :if-exists :supersede) (let* ((s1 "abcde") (n (file-string-length stream s1))) (do-special-strings (s2 s1 nil) (assert (= (file-string-length stream s2) n))))) nil) ;;; Error tests (deftest file-string-length.error.1 (signals-error (file-string-length) program-error) t) (deftest file-string-length.error.2 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s)) program-error) t) (deftest file-string-length.error.3 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s #\x nil)) program-error) t)
14637
;-*- Mode: Lisp -*- ;;;; Author: <NAME> ;;;; Created: Thu Jan 22 21:34:04 2004 ;;;; Contains: Tests of FILE-STRING-LENGTH (in-package :cl-test) (deftest file-string-length.1 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s x) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-char x s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.2 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s (string x)) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-sequence (string x) s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.3 (with-open-file (stream "tmp.dat" :direction :output :if-exists :supersede) (let* ((s1 "abcde") (n (file-string-length stream s1))) (do-special-strings (s2 s1 nil) (assert (= (file-string-length stream s2) n))))) nil) ;;; Error tests (deftest file-string-length.error.1 (signals-error (file-string-length) program-error) t) (deftest file-string-length.error.2 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s)) program-error) t) (deftest file-string-length.error.3 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s #\x nil)) program-error) t)
true
;-*- Mode: Lisp -*- ;;;; Author: PI:NAME:<NAME>END_PI ;;;; Created: Thu Jan 22 21:34:04 2004 ;;;; Contains: Tests of FILE-STRING-LENGTH (in-package :cl-test) (deftest file-string-length.1 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s x) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-char x s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.2 (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (loop for x across +standard-chars+ for len = (file-string-length s (string x)) do (assert (typep len '(or null (integer 0)))) do (let ((pos1 (file-position s))) (write-sequence (string x) s) (let ((pos2 (file-position s))) (when (and pos1 pos2 len) (assert (= (+ pos1 len) pos2))))))) nil) (deftest file-string-length.3 (with-open-file (stream "tmp.dat" :direction :output :if-exists :supersede) (let* ((s1 "abcde") (n (file-string-length stream s1))) (do-special-strings (s2 s1 nil) (assert (= (file-string-length stream s2) n))))) nil) ;;; Error tests (deftest file-string-length.error.1 (signals-error (file-string-length) program-error) t) (deftest file-string-length.error.2 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s)) program-error) t) (deftest file-string-length.error.3 (signals-error (with-open-file (s "tmp.dat" :direction :output :if-exists :supersede) (file-string-length s #\x nil)) program-error) t)
[ { "context": "; Base: 10 -*-\n;;;;\n;;;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>\n;;;;\n;;;; cletris u", "end": 113, "score": 0.9998908042907715, "start": 96, "tag": "NAME", "value": "Nicolas Lamirault" }, { "context": ";;;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]>\n;;;;\n;;;; cletris users are granted the rights t", "end": 142, "score": 0.9999286532402039, "start": 115, "tag": "EMAIL", "value": "[email protected]" } ]
src/specials.lisp
nlamirault/cletris
14
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ;;;; Copyright (C) 2014, 2015 Nicolas Lamirault <[email protected]> ;;;; ;;;; cletris users are granted the rights to distribute and use this software ;;;; as governed by the terms of the MIT License : ;;;; http://www.opensource.org/licenses/mit-license.php ;;;; ;;;; ************************************************************************* (in-package :cletris) (defparameter *version* (asdf:component-version (asdf:find-system "cletris"))) (defparameter *debug* nil "When T, active some logs for debugging.") (defparameter *cletris-directory* (namestring (asdf:component-relative-pathname (asdf:find-system :cletris))) "Directory with contains CLETRIS source files.") (defparameter *speed* 10) (defparameter *scores* '() "The best scores.") ;; screen (unless (boundp '+width+) (defconstant +width+ 640 "The default width.")) (unless (boundp '+height+) (defconstant +height+ 480 "The default height.")) (unless (boundp '+game-left-corner-x+) (defconstant +game-left-corner-x+ 250)) (unless (boundp '+game-left-corner-y+) (defconstant +game-left-corner-y+ 50)) (unless (boundp '+blocks+) (defconstant +blocks+ '((((0 . -1) (0 . 0) (0 . 1) (1 . 1)) 255 255 255) ;; J (((0 . -1) (0 . 0) (0 . 1) (-1 . 1)) 255 0 255) ;; L (((0 . -1) (0 . 0) (-1 . 0) (1 . 0)) 178 109 57) ;; T (((0 . -2) (0 . -1) (0 . 0) (0 . 1)) 255 0 0) ;; I (((0 . -1) (1 . -1) (1 . 0) (0 . 0)) 0 0 255) ;; O (((-1 . -1) (-1 . 0) (0 . 0) (0 . 1)) 0 255 0) ;; S (((1 . -1) (1 . 0) (0 . 0) (0 . 1)) 0 255 255)))) ;; Z (unless (boundp '+matrix-background+) (defconstant +matrix-background+ '(50 50 50))) ;; multimedia files (unless (boundp '+background+) (defconstant +background+ "img/background.png")) ;; red : 255 0 0 ;; gren : 0 255 0 ;; cyan : 0 255 255 ;; white : 255 255 255 ;; brown : 178 109 57 ;; blue : 0 0 255 ;; magenta : 255 0 255
12977
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ;;;; Copyright (C) 2014, 2015 <NAME> <<EMAIL>> ;;;; ;;;; cletris users are granted the rights to distribute and use this software ;;;; as governed by the terms of the MIT License : ;;;; http://www.opensource.org/licenses/mit-license.php ;;;; ;;;; ************************************************************************* (in-package :cletris) (defparameter *version* (asdf:component-version (asdf:find-system "cletris"))) (defparameter *debug* nil "When T, active some logs for debugging.") (defparameter *cletris-directory* (namestring (asdf:component-relative-pathname (asdf:find-system :cletris))) "Directory with contains CLETRIS source files.") (defparameter *speed* 10) (defparameter *scores* '() "The best scores.") ;; screen (unless (boundp '+width+) (defconstant +width+ 640 "The default width.")) (unless (boundp '+height+) (defconstant +height+ 480 "The default height.")) (unless (boundp '+game-left-corner-x+) (defconstant +game-left-corner-x+ 250)) (unless (boundp '+game-left-corner-y+) (defconstant +game-left-corner-y+ 50)) (unless (boundp '+blocks+) (defconstant +blocks+ '((((0 . -1) (0 . 0) (0 . 1) (1 . 1)) 255 255 255) ;; J (((0 . -1) (0 . 0) (0 . 1) (-1 . 1)) 255 0 255) ;; L (((0 . -1) (0 . 0) (-1 . 0) (1 . 0)) 178 109 57) ;; T (((0 . -2) (0 . -1) (0 . 0) (0 . 1)) 255 0 0) ;; I (((0 . -1) (1 . -1) (1 . 0) (0 . 0)) 0 0 255) ;; O (((-1 . -1) (-1 . 0) (0 . 0) (0 . 1)) 0 255 0) ;; S (((1 . -1) (1 . 0) (0 . 0) (0 . 1)) 0 255 255)))) ;; Z (unless (boundp '+matrix-background+) (defconstant +matrix-background+ '(50 50 50))) ;; multimedia files (unless (boundp '+background+) (defconstant +background+ "img/background.png")) ;; red : 255 0 0 ;; gren : 0 255 0 ;; cyan : 0 255 255 ;; white : 255 255 255 ;; brown : 178 109 57 ;; blue : 0 0 255 ;; magenta : 255 0 255
true
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ;;;; Copyright (C) 2014, 2015 PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;;;; ;;;; cletris users are granted the rights to distribute and use this software ;;;; as governed by the terms of the MIT License : ;;;; http://www.opensource.org/licenses/mit-license.php ;;;; ;;;; ************************************************************************* (in-package :cletris) (defparameter *version* (asdf:component-version (asdf:find-system "cletris"))) (defparameter *debug* nil "When T, active some logs for debugging.") (defparameter *cletris-directory* (namestring (asdf:component-relative-pathname (asdf:find-system :cletris))) "Directory with contains CLETRIS source files.") (defparameter *speed* 10) (defparameter *scores* '() "The best scores.") ;; screen (unless (boundp '+width+) (defconstant +width+ 640 "The default width.")) (unless (boundp '+height+) (defconstant +height+ 480 "The default height.")) (unless (boundp '+game-left-corner-x+) (defconstant +game-left-corner-x+ 250)) (unless (boundp '+game-left-corner-y+) (defconstant +game-left-corner-y+ 50)) (unless (boundp '+blocks+) (defconstant +blocks+ '((((0 . -1) (0 . 0) (0 . 1) (1 . 1)) 255 255 255) ;; J (((0 . -1) (0 . 0) (0 . 1) (-1 . 1)) 255 0 255) ;; L (((0 . -1) (0 . 0) (-1 . 0) (1 . 0)) 178 109 57) ;; T (((0 . -2) (0 . -1) (0 . 0) (0 . 1)) 255 0 0) ;; I (((0 . -1) (1 . -1) (1 . 0) (0 . 0)) 0 0 255) ;; O (((-1 . -1) (-1 . 0) (0 . 0) (0 . 1)) 0 255 0) ;; S (((1 . -1) (1 . 0) (0 . 0) (0 . 1)) 0 255 255)))) ;; Z (unless (boundp '+matrix-background+) (defconstant +matrix-background+ '(50 50 50))) ;; multimedia files (unless (boundp '+background+) (defconstant +background+ "img/background.png")) ;; red : 255 0 0 ;; gren : 0 255 0 ;; cyan : 0 255 255 ;; white : 255 255 255 ;; brown : 178 109 57 ;; blue : 0 0 255 ;; magenta : 255 0 255
[ { "context": ";; Copyright (C) 2014 Nicolas Lamirault\n\n;; Permission is hereby granted, free of charge,", "end": 40, "score": 0.9998849034309387, "start": 23, "tag": "NAME", "value": "Nicolas Lamirault" } ]
src/lastfm.lisp
nlamirault/cl-lastfm
2
;; Copyright (C) 2014 Nicolas Lamirault ;; Permission is hereby granted, free of charge, to any person obtaining a copy ;; of this software and associated documentation files (the "Software"), to deal ;; in the Software without restriction, including without limitation the rights ;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;; copies of the Software, and to permit persons to whom the Software is ;; furnished to do so, subject to the following conditions: ;; The above copyright notice and this permission notice shall be included in ;; all copies or substantial portions of the Software. ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;; THE SOFTWARE. (in-package :cl-lastfm) ;; Macro for LastFM requests. (defmacro with-lastfm-stream (stream &body body) "Macro which creates an HTTP url, add parameters executing body, and performs the HTTP request defined by uri." `(let (uri) (with-output-to-string (,stream) ,@body (setf uri (get-output-stream-string ,stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Albums ;; (defun album-get-info (api-key &key artist-name album-name mbid lang) "@short{Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See @fun{playlist-fetch} on how to get the album playlist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[album-name]{The album name in question} @arg[mbid]{The musicbrainz id for the album} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun album-search (api-key album-name &key (limit 30) (page 1)) "@short{Search for an album by name. Returns album matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[album-name]{The album name in question} @arg[limit]{Limit the number of albums returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-search+ api-key) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Artists ;; (defun artist-get-events (api-key artist-name) "@short{Get a list of upcoming events for this artist. Easily integratable into calendars, using the ical standard. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-events+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-info (api-key &key artist-name mbid lang) "@short{Get the metadata for an artist on Last.fm. Includes biography. . This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[mbid]{The musicbrainz id for the artist} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-similar (api-key artist-name &optional limit) "@short{Get all the artists similar to this artist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of similar artists returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-similar+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-albums (api-key artist-name) "@short{Get the top albums for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-albums+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-fans (api-key artist-name) "@short{Get the top fans for an artist on Last.fm, based on listening data. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-fans+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tags (api-key artist-name) "@short{Get the top tags for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tags+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tracks (api-key artist-name) "@short{Get the top tracks by an artist on Last.fm, ordered by popularity This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tracks+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-search (api-key artist-name &key (limit 30) (page 1)) "@short{Search for an artist by name. Returns artist matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of artists returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-search+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Geo ;; (defun geo-get-events (api-key &key location lat long page distance) "@short{Get all events in a specific location by country or city name. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[location]{Specifies a location to retrieve events for (service returns nearby events by default} @arg[lat]{Specifies a latitude value to retrieve events for (service returns nearby events by default} @arg[long]{Specifies a longitude value to retrieve events for (service returns nearby events by default)} @arg[page]{Display more results by pagination} @arg[distance]{Find events within a specified distance} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-get-events+ api-key) (when location (format stream "&location=~A" (url-encode-utf8 location))) (when lat (format stream "&lat=~A" (url-encode-utf8 lat))) (when long (format stream "&long=~A" (url-encode-utf8 long))) (when distance (format stream "&distance=~A" (url-encode-utf8 distance))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-artists (api-key country-name) "@short{Get the most popular artists on Last.fm by country. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-artists+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-tracks (api-key country-name &optional location) "@short{Get the most popular tracks on Last.fm by country . This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @arg[location]{A metro name, to fetch the charts for (must be within the country specified)} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-tracks+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (when location (format stream "&location=~A" (url-encode-utf8 location))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; User ;; (defun user-get-events (api-key user) "@short{Get a list of upcoming events that this user is attending. Easily integratable into calendars, using the ical standard. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user to fetch the events for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-events api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-friends (api-key user &key limit page recenttracks) "@short{Get a list of the user's friends on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the friends of} @arg[limit]{An integer used to limit the number of friends returned} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @arg[recenttracks]{Whether or not to include information about friends' recent listening in the response} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-friends+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (when recenttracks (format stream "&recenttracks=~A" (url-encode-utf8 (format nil "~A" recenttracks)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-loved-tracks (api-key user &key limit page) "@short{Get the last 50 tracks loved by a user. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the loved tracks for} @arg[limit]{An integer representing the number of results to fetch per page. Defaults to 50} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-loved-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-neighbours (api-key user &key limit) "@short{Get a list of a user's neighbours on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the neighbours of} @arg[limit]{An integer used to limit the number of neighbours returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-neighbours+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-albums (api-key user &key period limit page) "@short{Get the top albums listened to by a user. You can stipulate a time period. Sends the overall chart by default} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top albums for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-albums+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-artists (api-key user &key period limit page) "@short{Get the top artists listened to by a user. You can stipulate a time period. Sends the overall chart by default.} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top artists for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-artists+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tags (api-key user &key limit) "@short{Get the top tags used by this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name} @arg[limit]{The number of tags returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tags+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tracks (api-key user &key period limit page) "@short{Get the top tracks listened to by a user. You can stipulate a time period. Sends the overall chart by default. } @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top tracks for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top tracks for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-recent-tracks (api-key user &key limit) "@short{Get a list of the recent tracks listened to by this user. Indicates now playing track if the user is currently listening} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the recent tracks of} @arg[limit]{An integer used to limit the number of tracks returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-recent-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-shouts (api-key user) "@short{Get shouts for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch shouts for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-shouts+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-album-chart (api-key user &key from to) "@short{Get an album chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent album chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-album-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-artist-chart (api-key user &key from to) "@short{Get an artist chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent artist chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-artist-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-chart-list (api-key user) "@short{Get a list of available charts for this user, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-chart-list+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-track-chart (api-key user &key from to) "@short{Get a track chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent track chart for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-track-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Groups ;; (defun group-get-members (api-key group) "@short{Get a list of members for this group. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[group]{The group name to fetch the members of} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-members+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-album-chart (api-key group &key from to) "@short{Get an album chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group.} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-album-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-artist-chart (api-key group &key from to) "@short{Get an artist chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-artist-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-chart-list (api-key group) "@short{Get a list of available charts for this group, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-chart-list+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-track-chart (api-key group &key from to) "@short{Get a track chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-track-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tasteometer ;; (defun tasteometer-compare (api-key first-type second-type first-value second-value &key (limit 5)) "@short{Get a Tasteometer score from two inputs, along with a list of shared artists. If the input is a User or a Myspace URL, some additional information is returned.} @arg[api_key]{A Last.fm API key} @arg[fisrt-type]{Must be user, artists or myspace} @arg[second-type]{Must be user, artists or myspace} @arg[first-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[second-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[limit]{How many shared artists to display} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tasteometer-compare+ api-key first-type second-type first-value second-value limit))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Events ;; (defun event-get-info (api-key eventid) "@short{Get the metadata for an event on Last.fm. Includes attendance and lineup information} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-info+ api-key eventid))) (defun event-get-shouts (api-key eventid) "@short{Get shouts for this event} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-shouts+ api-key eventid))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Library ;; (defun library-get-albums (api-key user &key page (limit 49)) "@short{A paginated list of all the albums in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of albums returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-albums+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-artists (api-key user &key page (limit 49)) "@short{A paginated list of all the artists in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of artists returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-artists+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-tracks (api-key user &key page (limit 49)) "@short{A paginated list of all the tracks in a user's library, with play counts and tag counts. } @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of tracks returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-tracks+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tag ;; (defun tag-get-similar (api-key tag) "@short{Search for tags similar to this one. Returns tags ranked by similarity, based on listening data} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-similar+ api-key tag))) (defun tag-get-top-albums (api-key tag) "@short{Get the top albums tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-albums+ api-key tag))) (defun tag-get-top-artists (api-key tag) "@short{Get the top artists tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-artists+ api-key tag))) (defun tag-get-top-tracks (api-key tag) "@short{Get the top tracks tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tracks+ api-key tag))) (defun tag-get-top-tags (api-key) "@short{Fetches the top global tags on Last.fm, sorted by popularity (number of times used).} @arg[api_key]{A Last.fm API key} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tags+ api-key))) (defun tag-get-weekly-artist-chart (api-key tag &key from to limit) "@short{Get an artist chart for a tag, for a given date range. If no date range is supplied, it will return the most recent artist chart for this tag} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @arg[limit]{The number of chart items to return} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-artist-chart+ api-key tag) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (when limit (format stream "&limit=~A" limit)))) (defun tag-get-weekly-chart-list (api-key tag) "@short{Get a list of available charts for this tag, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-chart-list+ api-key tag))) (defun tag-search (api-key tag &key (page 1) (limit 29)) "@short{Search for a tag by name. Returns matches sorted by relevance} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[limit]{Limit the number of tags returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-search+ api-key tag) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tracks ;; (defun track-get-info (api-key &key artist track mbid) "@short{Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-info+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-similar (api-key &key artist track mbid) "@short{Get the similar tracks for this track on Last.fm, based on listening data} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-similar+ api-key) (if mbid (format stream "&mbid=~A" (url-encode-utf8 (format nil "~A" mbid))) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-fans (api-key &key artist track mbid) "@short{Get the top fans for this track on Last.fm, based on listening data. Supply either track & artist name or musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-fans+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-tags (api-key &key artist track mbid) "@short{Get the top tags for this track on Last.fm, ordered by tag count. Supply either track & artist name or mbid} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-tags+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-search (api-key track &key artist (page 1) (limit 29)) "@short{Search for a track by track name. Returns track matches sorted by relevance} @arg[api-key]{A Last.fm API key} @arg[track]{The track name in question} @arg[limit]{The number of tracks returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-search+ api-key track) (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit))))
46594
;; Copyright (C) 2014 <NAME> ;; Permission is hereby granted, free of charge, to any person obtaining a copy ;; of this software and associated documentation files (the "Software"), to deal ;; in the Software without restriction, including without limitation the rights ;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;; copies of the Software, and to permit persons to whom the Software is ;; furnished to do so, subject to the following conditions: ;; The above copyright notice and this permission notice shall be included in ;; all copies or substantial portions of the Software. ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;; THE SOFTWARE. (in-package :cl-lastfm) ;; Macro for LastFM requests. (defmacro with-lastfm-stream (stream &body body) "Macro which creates an HTTP url, add parameters executing body, and performs the HTTP request defined by uri." `(let (uri) (with-output-to-string (,stream) ,@body (setf uri (get-output-stream-string ,stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Albums ;; (defun album-get-info (api-key &key artist-name album-name mbid lang) "@short{Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See @fun{playlist-fetch} on how to get the album playlist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[album-name]{The album name in question} @arg[mbid]{The musicbrainz id for the album} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun album-search (api-key album-name &key (limit 30) (page 1)) "@short{Search for an album by name. Returns album matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[album-name]{The album name in question} @arg[limit]{Limit the number of albums returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-search+ api-key) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Artists ;; (defun artist-get-events (api-key artist-name) "@short{Get a list of upcoming events for this artist. Easily integratable into calendars, using the ical standard. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-events+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-info (api-key &key artist-name mbid lang) "@short{Get the metadata for an artist on Last.fm. Includes biography. . This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[mbid]{The musicbrainz id for the artist} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-similar (api-key artist-name &optional limit) "@short{Get all the artists similar to this artist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of similar artists returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-similar+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-albums (api-key artist-name) "@short{Get the top albums for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-albums+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-fans (api-key artist-name) "@short{Get the top fans for an artist on Last.fm, based on listening data. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-fans+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tags (api-key artist-name) "@short{Get the top tags for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tags+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tracks (api-key artist-name) "@short{Get the top tracks by an artist on Last.fm, ordered by popularity This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tracks+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-search (api-key artist-name &key (limit 30) (page 1)) "@short{Search for an artist by name. Returns artist matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of artists returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-search+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Geo ;; (defun geo-get-events (api-key &key location lat long page distance) "@short{Get all events in a specific location by country or city name. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[location]{Specifies a location to retrieve events for (service returns nearby events by default} @arg[lat]{Specifies a latitude value to retrieve events for (service returns nearby events by default} @arg[long]{Specifies a longitude value to retrieve events for (service returns nearby events by default)} @arg[page]{Display more results by pagination} @arg[distance]{Find events within a specified distance} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-get-events+ api-key) (when location (format stream "&location=~A" (url-encode-utf8 location))) (when lat (format stream "&lat=~A" (url-encode-utf8 lat))) (when long (format stream "&long=~A" (url-encode-utf8 long))) (when distance (format stream "&distance=~A" (url-encode-utf8 distance))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-artists (api-key country-name) "@short{Get the most popular artists on Last.fm by country. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-artists+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-tracks (api-key country-name &optional location) "@short{Get the most popular tracks on Last.fm by country . This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @arg[location]{A metro name, to fetch the charts for (must be within the country specified)} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-tracks+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (when location (format stream "&location=~A" (url-encode-utf8 location))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; User ;; (defun user-get-events (api-key user) "@short{Get a list of upcoming events that this user is attending. Easily integratable into calendars, using the ical standard. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user to fetch the events for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-events api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-friends (api-key user &key limit page recenttracks) "@short{Get a list of the user's friends on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the friends of} @arg[limit]{An integer used to limit the number of friends returned} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @arg[recenttracks]{Whether or not to include information about friends' recent listening in the response} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-friends+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (when recenttracks (format stream "&recenttracks=~A" (url-encode-utf8 (format nil "~A" recenttracks)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-loved-tracks (api-key user &key limit page) "@short{Get the last 50 tracks loved by a user. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the loved tracks for} @arg[limit]{An integer representing the number of results to fetch per page. Defaults to 50} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-loved-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-neighbours (api-key user &key limit) "@short{Get a list of a user's neighbours on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the neighbours of} @arg[limit]{An integer used to limit the number of neighbours returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-neighbours+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-albums (api-key user &key period limit page) "@short{Get the top albums listened to by a user. You can stipulate a time period. Sends the overall chart by default} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top albums for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-albums+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-artists (api-key user &key period limit page) "@short{Get the top artists listened to by a user. You can stipulate a time period. Sends the overall chart by default.} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top artists for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-artists+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tags (api-key user &key limit) "@short{Get the top tags used by this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name} @arg[limit]{The number of tags returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tags+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tracks (api-key user &key period limit page) "@short{Get the top tracks listened to by a user. You can stipulate a time period. Sends the overall chart by default. } @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top tracks for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top tracks for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-recent-tracks (api-key user &key limit) "@short{Get a list of the recent tracks listened to by this user. Indicates now playing track if the user is currently listening} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the recent tracks of} @arg[limit]{An integer used to limit the number of tracks returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-recent-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-shouts (api-key user) "@short{Get shouts for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch shouts for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-shouts+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-album-chart (api-key user &key from to) "@short{Get an album chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent album chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-album-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-artist-chart (api-key user &key from to) "@short{Get an artist chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent artist chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-artist-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-chart-list (api-key user) "@short{Get a list of available charts for this user, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-chart-list+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-track-chart (api-key user &key from to) "@short{Get a track chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent track chart for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-track-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Groups ;; (defun group-get-members (api-key group) "@short{Get a list of members for this group. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[group]{The group name to fetch the members of} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-members+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-album-chart (api-key group &key from to) "@short{Get an album chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group.} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-album-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-artist-chart (api-key group &key from to) "@short{Get an artist chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-artist-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-chart-list (api-key group) "@short{Get a list of available charts for this group, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-chart-list+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-track-chart (api-key group &key from to) "@short{Get a track chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-track-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tasteometer ;; (defun tasteometer-compare (api-key first-type second-type first-value second-value &key (limit 5)) "@short{Get a Tasteometer score from two inputs, along with a list of shared artists. If the input is a User or a Myspace URL, some additional information is returned.} @arg[api_key]{A Last.fm API key} @arg[fisrt-type]{Must be user, artists or myspace} @arg[second-type]{Must be user, artists or myspace} @arg[first-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[second-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[limit]{How many shared artists to display} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tasteometer-compare+ api-key first-type second-type first-value second-value limit))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Events ;; (defun event-get-info (api-key eventid) "@short{Get the metadata for an event on Last.fm. Includes attendance and lineup information} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-info+ api-key eventid))) (defun event-get-shouts (api-key eventid) "@short{Get shouts for this event} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-shouts+ api-key eventid))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Library ;; (defun library-get-albums (api-key user &key page (limit 49)) "@short{A paginated list of all the albums in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of albums returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-albums+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-artists (api-key user &key page (limit 49)) "@short{A paginated list of all the artists in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of artists returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-artists+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-tracks (api-key user &key page (limit 49)) "@short{A paginated list of all the tracks in a user's library, with play counts and tag counts. } @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of tracks returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-tracks+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tag ;; (defun tag-get-similar (api-key tag) "@short{Search for tags similar to this one. Returns tags ranked by similarity, based on listening data} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-similar+ api-key tag))) (defun tag-get-top-albums (api-key tag) "@short{Get the top albums tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-albums+ api-key tag))) (defun tag-get-top-artists (api-key tag) "@short{Get the top artists tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-artists+ api-key tag))) (defun tag-get-top-tracks (api-key tag) "@short{Get the top tracks tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tracks+ api-key tag))) (defun tag-get-top-tags (api-key) "@short{Fetches the top global tags on Last.fm, sorted by popularity (number of times used).} @arg[api_key]{A Last.fm API key} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tags+ api-key))) (defun tag-get-weekly-artist-chart (api-key tag &key from to limit) "@short{Get an artist chart for a tag, for a given date range. If no date range is supplied, it will return the most recent artist chart for this tag} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @arg[limit]{The number of chart items to return} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-artist-chart+ api-key tag) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (when limit (format stream "&limit=~A" limit)))) (defun tag-get-weekly-chart-list (api-key tag) "@short{Get a list of available charts for this tag, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-chart-list+ api-key tag))) (defun tag-search (api-key tag &key (page 1) (limit 29)) "@short{Search for a tag by name. Returns matches sorted by relevance} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[limit]{Limit the number of tags returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-search+ api-key tag) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tracks ;; (defun track-get-info (api-key &key artist track mbid) "@short{Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-info+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-similar (api-key &key artist track mbid) "@short{Get the similar tracks for this track on Last.fm, based on listening data} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-similar+ api-key) (if mbid (format stream "&mbid=~A" (url-encode-utf8 (format nil "~A" mbid))) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-fans (api-key &key artist track mbid) "@short{Get the top fans for this track on Last.fm, based on listening data. Supply either track & artist name or musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-fans+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-tags (api-key &key artist track mbid) "@short{Get the top tags for this track on Last.fm, ordered by tag count. Supply either track & artist name or mbid} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-tags+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-search (api-key track &key artist (page 1) (limit 29)) "@short{Search for a track by track name. Returns track matches sorted by relevance} @arg[api-key]{A Last.fm API key} @arg[track]{The track name in question} @arg[limit]{The number of tracks returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-search+ api-key track) (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit))))
true
;; Copyright (C) 2014 PI:NAME:<NAME>END_PI ;; Permission is hereby granted, free of charge, to any person obtaining a copy ;; of this software and associated documentation files (the "Software"), to deal ;; in the Software without restriction, including without limitation the rights ;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ;; copies of the Software, and to permit persons to whom the Software is ;; furnished to do so, subject to the following conditions: ;; The above copyright notice and this permission notice shall be included in ;; all copies or substantial portions of the Software. ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ;; THE SOFTWARE. (in-package :cl-lastfm) ;; Macro for LastFM requests. (defmacro with-lastfm-stream (stream &body body) "Macro which creates an HTTP url, add parameters executing body, and performs the HTTP request defined by uri." `(let (uri) (with-output-to-string (,stream) ,@body (setf uri (get-output-stream-string ,stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Albums ;; (defun album-get-info (api-key &key artist-name album-name mbid lang) "@short{Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See @fun{playlist-fetch} on how to get the album playlist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[album-name]{The album name in question} @arg[mbid]{The musicbrainz id for the album} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun album-search (api-key album-name &key (limit 30) (page 1)) "@short{Search for an album by name. Returns album matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[album-name]{The album name in question} @arg[limit]{Limit the number of albums returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +album-search+ api-key) (when album-name (format stream "&album=~A" (url-encode-utf8 album-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Artists ;; (defun artist-get-events (api-key artist-name) "@short{Get a list of upcoming events for this artist. Easily integratable into calendars, using the ical standard. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-events+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-info (api-key &key artist-name mbid lang) "@short{Get the metadata for an artist on Last.fm. Includes biography. . This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[mbid]{The musicbrainz id for the artist} @arg[lang]{The language to return the biography in, expressed as an ISO 639 alpha-2 code} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-info+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when mbid (format stream "&mbid=~A" (url-encode-utf8 mbid))) (when lang (format stream "&lang=~A" (url-encode-utf8 lang))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-similar (api-key artist-name &optional limit) "@short{Get all the artists similar to this artist. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of similar artists returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-similar+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-albums (api-key artist-name) "@short{Get the top albums for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-albums+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-fans (api-key artist-name) "@short{Get the top fans for an artist on Last.fm, based on listening data. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-fans+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tags (api-key artist-name) "@short{Get the top tags for an artist on Last.fm, ordered by popularity. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tags+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-get-top-tracks (api-key artist-name) "@short{Get the top tracks by an artist on Last.fm, ordered by popularity This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-get-top-tracks+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun artist-search (api-key artist-name &key (limit 30) (page 1)) "@short{Search for an artist by name. Returns artist matches sorted by relevance. This service does not require authentication.} @arg[api-key]{A Last.fm API key} @arg[artist-name]{The artist name in question} @arg[limit]{Limit the number of artists returned at one time. Default (maximum) is 30} @arg[page]{Scan into the results by specifying a page number. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +artist-search+ api-key) (when artist-name (format stream "&artist=~A" (url-encode-utf8 artist-name))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Geo ;; (defun geo-get-events (api-key &key location lat long page distance) "@short{Get all events in a specific location by country or city name. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[location]{Specifies a location to retrieve events for (service returns nearby events by default} @arg[lat]{Specifies a latitude value to retrieve events for (service returns nearby events by default} @arg[long]{Specifies a longitude value to retrieve events for (service returns nearby events by default)} @arg[page]{Display more results by pagination} @arg[distance]{Find events within a specified distance} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-get-events+ api-key) (when location (format stream "&location=~A" (url-encode-utf8 location))) (when lat (format stream "&lat=~A" (url-encode-utf8 lat))) (when long (format stream "&long=~A" (url-encode-utf8 long))) (when distance (format stream "&distance=~A" (url-encode-utf8 distance))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-artists (api-key country-name) "@short{Get the most popular artists on Last.fm by country. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-artists+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun geo-top-tracks (api-key country-name &optional location) "@short{Get the most popular tracks on Last.fm by country . This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[country-name]{A country name, as defined by the ISO 3166-1 country names standard} @arg[location]{A metro name, to fetch the charts for (must be within the country specified)} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +geo-top-tracks+ api-key) (format stream "&country=~A" (url-encode-utf8 country-name)) (when location (format stream "&location=~A" (url-encode-utf8 location))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; User ;; (defun user-get-events (api-key user) "@short{Get a list of upcoming events that this user is attending. Easily integratable into calendars, using the ical standard. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user to fetch the events for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-events api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-friends (api-key user &key limit page recenttracks) "@short{Get a list of the user's friends on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the friends of} @arg[limit]{An integer used to limit the number of friends returned} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @arg[recenttracks]{Whether or not to include information about friends' recent listening in the response} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-friends+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (when recenttracks (format stream "&recenttracks=~A" (url-encode-utf8 (format nil "~A" recenttracks)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-loved-tracks (api-key user &key limit page) "@short{Get the last 50 tracks loved by a user. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the loved tracks for} @arg[limit]{An integer representing the number of results to fetch per page. Defaults to 50} @arg[page]{An integer representing the page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-loved-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-neighbours (api-key user &key limit) "@short{Get a list of a user's neighbours on Last.fm This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the neighbours of} @arg[limit]{An integer used to limit the number of neighbours returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-neighbours+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-albums (api-key user &key period limit page) "@short{Get the top albums listened to by a user. You can stipulate a time period. Sends the overall chart by default} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top albums for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-albums+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-artists (api-key user &key period limit page) "@short{Get the top artists listened to by a user. You can stipulate a time period. Sends the overall chart by default.} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top artists for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top albums for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-artists+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tags (api-key user &key limit) "@short{Get the top tags used by this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name} @arg[limit]{The number of tags returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tags+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-top-tracks (api-key user &key period limit page) "@short{Get the top tracks listened to by a user. You can stipulate a time period. Sends the overall chart by default. } @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch top tracks for} @arg[period]{overall | 3month | 6month | 12month - The time period over which to retrieve top tracks for.} @arg[limit]{The number of results to fetch per page. Defaults to 50} @arg[page]{The page number to fetch. Defaults to first page} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-top-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when period (format stream "&period=~A" (url-encode-utf8 (format nil "~A" period)))) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (when page (format stream "&page=~A" (url-encode-utf8 (format nil "~A" page)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-recent-tracks (api-key user &key limit) "@short{Get a list of the recent tracks listened to by this user. Indicates now playing track if the user is currently listening} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch the recent tracks of} @arg[limit]{An integer used to limit the number of tracks returned} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-recent-tracks+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when limit (format stream "&limit=~A" (url-encode-utf8 (format nil "~A" limit)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-shouts (api-key user) "@short{Get shouts for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The user name to fetch shouts for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-shouts+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-album-chart (api-key user &key from to) "@short{Get an album chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent album chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-album-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-artist-chart (api-key user &key from to) "@short{Get an artist chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent artist chart for this user.} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-artist-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-chart-list (api-key user) "@short{Get a list of available charts for this user, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-chart-list+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun user-get-weekly-track-chart (api-key user &key from to) "@short{Get a track chart for a user profile, for a given date range. If no date range is supplied, it will return the most recent track chart for this user} @arg[api_key]{A Last.fm API key} @arg[user]{The last.fm username to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +user-get-weekly-track-chart+ api-key) (format stream "&user=~A" (url-encode-utf8 user)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Groups ;; (defun group-get-members (api-key group) "@short{Get a list of members for this group. This service does not require authentication} @arg[api_key]{A Last.fm API key} @arg[group]{The group name to fetch the members of} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-members+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-album-chart (api-key group &key from to) "@short{Get an album chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group.} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-album-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-artist-chart (api-key group &key from to) "@short{Get an artist chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-artist-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-chart-list (api-key group) "@short{Get a list of available charts for this group, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts list for} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-chart-list+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) (defun group-get-weekly-track-chart (api-key group &key from to) "@short{Get a track chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group} @arg[api_key]{A Last.fm API key} @arg[group]{The last.fm group name to fetch the charts of} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @see-condition{lastfm-request-error} @return{An XML stream}" (let (uri) (with-output-to-string (stream) (format stream +group-get-weekly-track-chart+ api-key) (format stream "&group=~A" (url-encode-utf8 group)) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (setf uri (get-output-stream-string stream))) (perform-lastfm-query uri))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tasteometer ;; (defun tasteometer-compare (api-key first-type second-type first-value second-value &key (limit 5)) "@short{Get a Tasteometer score from two inputs, along with a list of shared artists. If the input is a User or a Myspace URL, some additional information is returned.} @arg[api_key]{A Last.fm API key} @arg[fisrt-type]{Must be user, artists or myspace} @arg[second-type]{Must be user, artists or myspace} @arg[first-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[second-value]{Must be : Last.fm username or comma-separated artist names or a MySpace profile URL} @arg[limit]{How many shared artists to display} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tasteometer-compare+ api-key first-type second-type first-value second-value limit))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Events ;; (defun event-get-info (api-key eventid) "@short{Get the metadata for an event on Last.fm. Includes attendance and lineup information} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-info+ api-key eventid))) (defun event-get-shouts (api-key eventid) "@short{Get shouts for this event} @arg[api_key]{A Last.fm API key} @arg[eventid]{The numeric Last.fm event id} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +event-get-shouts+ api-key eventid))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Library ;; (defun library-get-albums (api-key user &key page (limit 49)) "@short{A paginated list of all the albums in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of albums returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-albums+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-artists (api-key user &key page (limit 49)) "@short{A paginated list of all the artists in a user's library, with play counts and tag counts} @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of artists returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-artists+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) (defun library-get-tracks (api-key user &key page (limit 49)) "@short{A paginated list of all the tracks in a user's library, with play counts and tag counts. } @arg[api_key]{A Last.fm API key} @arg[user]{The user whose library you want to fetch} @arg[limit]{Limit the amount of tracks returned} @arg[page]{The page number you wish to scan to} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +library-get-tracks+ api-key user) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tag ;; (defun tag-get-similar (api-key tag) "@short{Search for tags similar to this one. Returns tags ranked by similarity, based on listening data} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-similar+ api-key tag))) (defun tag-get-top-albums (api-key tag) "@short{Get the top albums tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-albums+ api-key tag))) (defun tag-get-top-artists (api-key tag) "@short{Get the top artists tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-artists+ api-key tag))) (defun tag-get-top-tracks (api-key tag) "@short{Get the top tracks tagged by this tag, ordered by tag count} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tracks+ api-key tag))) (defun tag-get-top-tags (api-key) "@short{Fetches the top global tags on Last.fm, sorted by popularity (number of times used).} @arg[api_key]{A Last.fm API key} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-top-tags+ api-key))) (defun tag-get-weekly-artist-chart (api-key tag &key from to limit) "@short{Get an artist chart for a tag, for a given date range. If no date range is supplied, it will return the most recent artist chart for this tag} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[from]{The date at which the chart should start from} @arg[to]{The date at which the chart should end on} @arg[limit]{The number of chart items to return} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-artist-chart+ api-key tag) (when from (format stream "&from=~A" (url-encode-utf8 (format nil "~A" from)))) (when to (format stream "&to=~A" (url-encode-utf8 (format nil "~A" to)))) (when limit (format stream "&limit=~A" limit)))) (defun tag-get-weekly-chart-list (api-key tag) "@short{Get a list of available charts for this tag, expressed as date ranges which can be sent to the chart services} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-get-weekly-chart-list+ api-key tag))) (defun tag-search (api-key tag &key (page 1) (limit 29)) "@short{Search for a tag by name. Returns matches sorted by relevance} @arg[api_key]{A Last.fm API key} @arg[tag]{The tag name in question} @arg[limit]{Limit the number of tags returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +tag-search+ api-key tag) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Tracks ;; (defun track-get-info (api-key &key artist track mbid) "@short{Get the metadata for a track on Last.fm using the artist/track name or a musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-info+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-similar (api-key &key artist track mbid) "@short{Get the similar tracks for this track on Last.fm, based on listening data} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-similar+ api-key) (if mbid (format stream "&mbid=~A" (url-encode-utf8 (format nil "~A" mbid))) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-fans (api-key &key artist track mbid) "@short{Get the top fans for this track on Last.fm, based on listening data. Supply either track & artist name or musicbrainz id} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-fans+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-get-top-tags (api-key &key artist track mbid) "@short{Get the top tags for this track on Last.fm, ordered by tag count. Supply either track & artist name or mbid} @arg[api-key]{A Last.fm API key} @arg[artist]{The artist name in question} @arg[track]{The track name in question} @arg[mbid]{The musicbrainz id for the track} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-get-top-tags+ api-key) (if mbid (format stream "&mbid=~A" mbid) (progn (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when track (format stream "&track=~A" (url-encode-utf8 (format nil "~A" track)))))))) (defun track-search (api-key track &key artist (page 1) (limit 29)) "@short{Search for a track by track name. Returns track matches sorted by relevance} @arg[api-key]{A Last.fm API key} @arg[track]{The track name in question} @arg[limit]{The number of tracks returned at one time} @arg[page]{Scan into the results by specifying a page number} @see-condition{lastfm-request-error} @return{An XML stream}" (with-lastfm-stream stream (format stream +track-search+ api-key track) (when artist (format stream "&artist=~A" (url-encode-utf8 (format nil "~A" artist)))) (when page (format stream "&page=~A" page)) (when limit (format stream "&limit=~A" limit))))
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n\n; Added by Matt K., 12/8/20", "end": 1399, "score": 0.9996864795684814, "start": 1388, "tag": "NAME", "value": "Jared Davis" }, { "context": "N THE SOFTWARE.\n;\n; Original author: Jared Davis <[email protected]>\n\n; Added by Matt K., 12/8/2017: Some of the code", "end": 1419, "score": 0.9999324083328247, "start": 1401, "tag": "EMAIL", "value": "[email protected]" }, { "context": "thor: Jared Davis <[email protected]>\n\n; Added by Matt K., 12/8/2017: Some of the code to be executed only w", "end": 1439, "score": 0.9049851894378662, "start": 1433, "tag": "NAME", "value": "Matt K" }, { "context": "-summary)\n (hons-analyze-memory nil)\n ;; Jared changed this to force-output, since finish-output", "end": 3382, "score": 0.7390929460525513, "start": 3377, "tag": "NAME", "value": "Jared" }, { "context": "; thing in bytes,\" and was originally developed by Gary Byers in response to a\n; question on the CCL mailing li", "end": 4594, "score": 0.9998383522033691, "start": 4584, "tag": "NAME", "value": "Gary Byers" }, { "context": "response to a\n; question on the CCL mailing list. Jared only changed the names so it can be\n; in the ", "end": 4650, "score": 0.5366666913032532, "start": 4649, "tag": "NAME", "value": "J" }, { "context": " this field!\n;\n; The following comment was left by Gary:\n\n ;; All memory-allocated objects in CCL are ei", "end": 5076, "score": 0.9970411062240601, "start": 5072, "tag": "NAME", "value": "Gary" }, { "context": "lozure)\n(defun hl-hash-table-bytes (ht)\n\n; This is Jared's approximation of the actual memory being used b", "end": 6928, "score": 0.9231389760971069, "start": 6923, "tag": "NAME", "value": "Jared" }, { "context": "re)\n(defun hl-hash-table-key-bytes (ht)\n\n; This is Jared's approximation of the actual memory being used f", "end": 7493, "score": 0.9631263017654419, "start": 7488, "tag": "NAME", "value": "Jared" }, { "context": "re)\n(defun hl-hash-table-val-bytes (ht)\n\n; This is Jared's approximation of the actual memory being used f", "end": 7946, "score": 0.9726558923721313, "start": 7941, "tag": "NAME", "value": "Jared" } ]
books/centaur/misc/hons-memory-mgmt.lsp
mayankmanj/acl2
305
; Centaur Miscellaneous Books ; Copyright (C) 2008-2011 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Jared Davis <[email protected]> ; Added by Matt K., 12/8/2017: Some of the code to be executed only when ; #+static-hons has symbols ccl::xxx. I'm thus replacing the static-hons ; readtime conditional with (and static-hons Clozure). A more fine-grained fix ; might be possible by tracking down dependencies on functions with bodies that ; contain ccl::xxx symbols. (in-package "ACL2") (defvar *last-chance-threshold* ;; We'll automatically wash if we get within 1/400 of the max memory usage. ;; Examples: ;; If *max-mem-usage* is 8 GB, the cushion is ~21 MB. ;; If *max-mem-usage* is 16 GB, the cushion is ~42 MB. ;; If *max-mem-usage* is 32 GB, the cushion is ~85 MB. ;; If *max-mem-usage* is 64 GB, the cushion is ~171 MB. ;; If *max-mem-usage* is 96 GB, the cushion is ~257 MB. ;; If *max-mem-usage* is 128 GB, the cushion is ~343 MB. (ceiling *max-mem-usage* 400)) (defun set-max-mem-usage (max) (setf *max-mem-usage* max) (setf *last-chance-threshold* (ceiling *max-mem-usage* 400)) (setf *gc-min-threshold* (floor *max-mem-usage* 5)) #+Clozure (set-and-reset-gc-thresholds) nil) (defun print-quick-memory-summary () #+Clozure (multiple-value-bind (dynamic-used static-used library-used frozen-size) (ccl::%usedbytes) (let ((free (ccl::%freebytes)) (used (+ dynamic-used static-used library-used frozen-size)) (max *max-mem-usage*)) (format t "Max: ~15:D bytes~%" max) (format t "Free: ~15:D bytes~%" free) (format t "Used: ~15:D bytes~%" used) (format t " - Dynamic: ~15:D bytes~%" dynamic-used) (format t " - Static: ~15:D bytes~%" static-used) (format t " - Library: ~15:D bytes~%" library-used) (format t " - Frozen: ~15:D bytes~%" frozen-size) (format t "Dynamic+Frozen: ~15:D bytes~%" (+ dynamic-used frozen-size)) (hons-summary) (hons-analyze-memory nil) ;; Jared changed this to force-output, since finish-output is slow ;; on an NFS. (force-output))) nil) (defun maybe-wash-memory-fn (n clear) (declare (ignorable clear)) #+Clozure (when (or (eq n t) (< (ccl::%freebytes) (nfix n))) (format t "********** maybe-wash-memory started ***********~%~%") (format t "Pre-wash memory usage.~%") (print-quick-memory-summary) (hons-wash) (format t "Post-wash memory usage:~%") (print-quick-memory-summary) (format t "********** maybe-wash-memory finished **********~%")) nil) (defun last-chance-wash-memory-fn () #+Clozure (when (< (ccl::%freebytes) *last-chance-threshold*) (format t "*********** last-chance-wash-memory ************~%") (format t "~:D free bytes < ~:D last chance threshold~%" (ccl::%freebytes) *last-chance-threshold*) (maybe-wash-memory-fn t nil)) nil) (defun set-max-mem (max) (set-max-mem-usage max) nil) ; Raw lisp definition of hons-analyze-memory. #+(and static-hons Clozure) (defun hl-sizeof (thing) ; Highly CCL-specific. This function computes something like "the size of ; thing in bytes," and was originally developed by Gary Byers in response to a ; question on the CCL mailing list. Jared only changed the names so it can be ; in the ACL2 package and added this comment. ; ; Note: determining memory usage is subtle and this function does NOT ; necessarily give you the whole story. For instance, in CCL each hash table ; has a uvector inside of it that holds the data elements. So, the (hl-sizeof ; ht) for some hash table doesn't actually descend into this field! ; ; The following comment was left by Gary: ;; All memory-allocated objects in CCL are either CONSes or ;; "UVECTOR"s; a UVECTOR contains a header which describes the ;; object's primitive type (represented as an (UNSIGNED-BYTE 8) and ;; accessible via the function CCL::TYPECODE) and element-count ;; (accessible via the function CCL::UVSIZE.) A function defined in ;; the compiler backend knows how to map from a typecode and ;; element-count to a size in octets. UVECTORs are aligned on ;; doubleword boundaries and contain this extra header word, so the ;; "physical size" of the uvector is a bit bigger. On x86-64, ;; SYMBOLs and FUNCTIONs have their own tag, but there's an ;; underlying UVECTOR. (cond ((null thing) 0) ((consp thing) #+64-bit-target 16 #+32-bit-target 8) #+x8664-target ((symbolp thing) (hl-sizeof (ccl::%symptr->symvector thing))) #+x8664-target ((functionp thing) (hl-sizeof (ccl::function-to-function-vector thing))) ((ccl::uvectorp thing) (let* ((typecode (ccl::typecode thing)) (element-count (ccl::uvsize thing)) (sizeof-content-in-octets ;; Call the architecture-specific backend function. (funcall (arch::target-array-data-size-function (ccl::backend-target-arch ccl::*host-backend*)) typecode element-count))) (logandc2 (+ sizeof-content-in-octets #+64-bit-target (+ 8 15) #+32-bit-target (+ 4 7)) #+64-bit-target 15 #+32-bit-target 7))) (t 0))) #+(and static-hons Clozure) (defconstant hl-size-of-cons (hl-sizeof (cons nil nil))) #+(and static-hons Clozure) (defun hl-hash-table-bytes (ht) ; This is Jared's approximation of the actual memory being used by the hash ; table itself. Note that this does NOT include the memory used by any of the ; keys or values that are currently stored in the hash table; the only things ; we count are the hash table's vector and its header size. This may be an ; under-approximation if we are missing other uvectors in the hash table ; structure itself. (declaim (type hash-table ht)) (+ (hl-sizeof ht) (hl-sizeof (ccl::nhash.vector ht)))) #+(and static-hons Clozure) (defun hl-hash-table-key-bytes (ht) ; This is Jared's approximation of the actual memory being used for the keys of ; a hash table. This doesn't follow any pointers in the keys, but should work ; for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore val)) (unless (typep key 'fixnum) (incf size (hl-sizeof key)))) ht) size)) #+(and static-hons Clozure) (defun hl-hash-table-val-bytes (ht) ; This is Jared's approximation of the actual memory being used for the values ; of a hash table. This doesn't follow any pointers in the values, but should ; work for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore key)) (unless (typep val 'fixnum) (incf size (hl-sizeof val)))) ht) size)) #+(and static-hons Clozure) (defun hl-hspace-analyze-memory (slowp hs) ; Print a brief report about the memory being used by the hons space. When ; slowp is set, we generate better information but may require a lot more time ; to do it. (declaim (type hl-hspace hs)) (format t "Analyzing hons-space memory usage.~%~%") (format t "SBITS total memory: ~15:D bytes~%~%" (hl-sizeof (hl-hspace-sbits hs))) (let* ((addr-ht (hl-hspace-addr-ht hs)) (addr-key-bytes (if slowp (hl-hash-table-key-bytes addr-ht) 0)) (addr-tbl-bytes (hl-hash-table-bytes addr-ht)) (addr-overhead-bytes (+ addr-key-bytes addr-tbl-bytes)) (addr-data-bytes (* (hl-sizeof '(1 . 2)) ;; 16 (hash-table-count addr-ht))) (addr-total-mem (+ addr-overhead-bytes addr-data-bytes))) (format t "ADDR-HT total memory: ~15:D bytes~%" addr-total-mem) (format t " - Actual cons data: ~15:D bytes (~5,2f%)~%" addr-data-bytes (/ (* addr-data-bytes 100.0) addr-total-mem)) (if slowp (progn (format t " - Total overhead: ~15:D bytes (~5,2f%)~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)) (format t " from the table itself: ~15:D bytes~%" addr-tbl-bytes) (format t " from bignum indicies: ~15:D bytes~%~%" addr-key-bytes)) (format t " - Overhead (approx): ~15:D bytes (~5,2f%)~%~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)))) (let* ((str-ht (hl-hspace-str-ht hs)) (str-tbl-bytes (hl-hash-table-bytes str-ht)) (str-key-bytes (hl-hash-table-key-bytes str-ht)) (str-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count str-ht))) (str-total-bytes (+ str-tbl-bytes str-key-bytes str-addr-bytes))) (format t "STR-HT total memory: ~15:D bytes~%" str-total-bytes) (format t " - Actual string data: ~15:D bytes~%" str-key-bytes) (format t " - Total overhead: ~15:D bytes~%" (+ str-tbl-bytes str-addr-bytes)) (format t " from the table itself: ~15:D bytes~%" str-tbl-bytes) (format t " from address conses: ~15:D bytes~%~%" str-addr-bytes)) (let* ((other-ht (hl-hspace-other-ht hs)) (other-tbl-bytes (hl-hash-table-bytes other-ht)) (other-key-bytes (hl-hash-table-key-bytes other-ht)) (other-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count other-ht))) (other-total-bytes (+ other-tbl-bytes other-key-bytes other-addr-bytes))) (format t "OTHER-HT total memory: ~15:D bytes~%" other-total-bytes) (format t " - Data for the atoms: ~15:D bytes~%" other-key-bytes) (format t " - Table overhead: ~15:D bytes~%" other-tbl-bytes) (format t " - Address overhead: ~15:D bytes~%~%" other-addr-bytes)) ) #+(and static-hons Clozure) (defun hl-ponstable-bytes-aux (elem) ;; Suppose a pons-table contains (Y . ELEM). I think that ELEM is either ;; (1) an list of XYC = (X . Y) pairs, where each XYC represents the ;; unique cons for (X . Y) in this pons table, or ;; (2) is a hash table that binds X to XYC. ;; ;; We'd really like to know something like, "how much space could be freed up ;; if we cleared this memo table." But that's extraordinarily hard to ;; measure, because we'd have to know what subtrees of these XYC pairs are ;; reachable from other places in the program. So, this function is really ;; only explaining how much space is definitely due to a pons table entry. ;; ;; In case (1) we charge for each cons in the alist, and for the conses that ;; connect the alist together. For example, if the alist has the form: ;; ;; ((A . Y) . (B . Y) . (C . Y) . NIL) ;; ;; Then we estimate the cost as 6 conses. This could be a severe ;; underapproximation of the actual overhead if A, B, C, or Y was a large ;; cons-tree that isn't reachable from anywhere else in the program. ;; ;; In case (2), we charge for the size of the table itself, and also for the ;; each XYC cons. (if (listp elem) (* (length elem) (* 2 hl-size-of-cons)) (+ (hl-hash-table-bytes elem) (hl-hash-table-val-bytes elem)))) #+(and static-hons Clozure) (defun hl-ponstable-bytes (pt) (if (not pt) 0 (+ (hl-hash-table-bytes pt) (let ((sum 0)) (maphash (lambda (key val) (declare (ignore key)) (incf sum (hl-ponstable-bytes-aux val))) pt) sum)))) #+(and static-hons Clozure) (defun memo-table-size-debug1 (fn info) ;; (FN -> INFO) is an entry in the *memo-info-ht*. (when (natp fn) ;; Skip back-pointers from numbers to functions. (return-from memo-table-size-debug1 nil)) (let* ((table-name (access memoize-info-ht-entry info :tablename)) (table (symbol-value table-name)) (table-size (if table (hash-table-size table) 0)) (table-bytes (if table (hl-hash-table-bytes table) 0)) (ponstable-name (access memoize-info-ht-entry info :ponstablename)) (ponstable (symbol-value ponstable-name)) (ponstable-size (if ponstable (hash-table-size ponstable) 0)) (ponstable-bytes (hl-ponstable-bytes ponstable)) (total-bytes (+ ponstable-bytes table-bytes))) (when (or (> ponstable-size 0) (> table-size 0) (> table-bytes 0) (> total-bytes 0)) (list fn ponstable-size table-size total-bytes)))) #+(and static-hons Clozure) (defun memo-table-size-debug () (cw "Memoize table sizes. Note: the reported \"overhead\" does NOT include ~ the sizes of the actual argument/result data stored in the memo ~ table.~%~%") (let ((report nil) (indent 0) (indent-str nil)) (maphash (lambda (fn info) (let ((entry (memo-table-size-debug1 fn info))) (when entry (push entry report) (setq indent (max indent (length (symbol-name fn))))))) *memoize-info-ht*) (setq indent-str (format nil "~a" (+ 2 indent))) (format t (concatenate 'string "~" indent-str ":@a ~12:@a ~12:@a ~26:@a~%") "Function" "PT-Size" "MT-Size" "Approx. Overhead") (loop for entry in report do (format t (concatenate 'string "~" indent-str ":@a ~12:D ~12:D ~20:D bytes~%") (first entry) (second entry) (third entry) (fourth entry))) (format t "~%"))) (defun hons-analyze-memory (slowp) (hl-maybe-initialize-default-hs) #+(and static-hons Clozure) (progn (hl-hspace-analyze-memory slowp *default-hs*) (memo-table-size-debug) (print-memo-max-sizes)) #-(and static-hons Clozure) (cw "Hons-analyze-memory is only available for static honsing.~%")) #|| (lp) (defun my-function (a b c d) (declare (xargs :guard t)) (list a b c d)) (memoize 'my-function) :q (loop for i from 1 to 10000 do (my-function 1 2 (+ i (ash 1 62)) (+ i (ash 1 100)))) (memoize-table-size-debug) ||#
27436
; Centaur Miscellaneous Books ; Copyright (C) 2008-2011 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> ; Added by <NAME>., 12/8/2017: Some of the code to be executed only when ; #+static-hons has symbols ccl::xxx. I'm thus replacing the static-hons ; readtime conditional with (and static-hons Clozure). A more fine-grained fix ; might be possible by tracking down dependencies on functions with bodies that ; contain ccl::xxx symbols. (in-package "ACL2") (defvar *last-chance-threshold* ;; We'll automatically wash if we get within 1/400 of the max memory usage. ;; Examples: ;; If *max-mem-usage* is 8 GB, the cushion is ~21 MB. ;; If *max-mem-usage* is 16 GB, the cushion is ~42 MB. ;; If *max-mem-usage* is 32 GB, the cushion is ~85 MB. ;; If *max-mem-usage* is 64 GB, the cushion is ~171 MB. ;; If *max-mem-usage* is 96 GB, the cushion is ~257 MB. ;; If *max-mem-usage* is 128 GB, the cushion is ~343 MB. (ceiling *max-mem-usage* 400)) (defun set-max-mem-usage (max) (setf *max-mem-usage* max) (setf *last-chance-threshold* (ceiling *max-mem-usage* 400)) (setf *gc-min-threshold* (floor *max-mem-usage* 5)) #+Clozure (set-and-reset-gc-thresholds) nil) (defun print-quick-memory-summary () #+Clozure (multiple-value-bind (dynamic-used static-used library-used frozen-size) (ccl::%usedbytes) (let ((free (ccl::%freebytes)) (used (+ dynamic-used static-used library-used frozen-size)) (max *max-mem-usage*)) (format t "Max: ~15:D bytes~%" max) (format t "Free: ~15:D bytes~%" free) (format t "Used: ~15:D bytes~%" used) (format t " - Dynamic: ~15:D bytes~%" dynamic-used) (format t " - Static: ~15:D bytes~%" static-used) (format t " - Library: ~15:D bytes~%" library-used) (format t " - Frozen: ~15:D bytes~%" frozen-size) (format t "Dynamic+Frozen: ~15:D bytes~%" (+ dynamic-used frozen-size)) (hons-summary) (hons-analyze-memory nil) ;; <NAME> changed this to force-output, since finish-output is slow ;; on an NFS. (force-output))) nil) (defun maybe-wash-memory-fn (n clear) (declare (ignorable clear)) #+Clozure (when (or (eq n t) (< (ccl::%freebytes) (nfix n))) (format t "********** maybe-wash-memory started ***********~%~%") (format t "Pre-wash memory usage.~%") (print-quick-memory-summary) (hons-wash) (format t "Post-wash memory usage:~%") (print-quick-memory-summary) (format t "********** maybe-wash-memory finished **********~%")) nil) (defun last-chance-wash-memory-fn () #+Clozure (when (< (ccl::%freebytes) *last-chance-threshold*) (format t "*********** last-chance-wash-memory ************~%") (format t "~:D free bytes < ~:D last chance threshold~%" (ccl::%freebytes) *last-chance-threshold*) (maybe-wash-memory-fn t nil)) nil) (defun set-max-mem (max) (set-max-mem-usage max) nil) ; Raw lisp definition of hons-analyze-memory. #+(and static-hons Clozure) (defun hl-sizeof (thing) ; Highly CCL-specific. This function computes something like "the size of ; thing in bytes," and was originally developed by <NAME> in response to a ; question on the CCL mailing list. <NAME>ared only changed the names so it can be ; in the ACL2 package and added this comment. ; ; Note: determining memory usage is subtle and this function does NOT ; necessarily give you the whole story. For instance, in CCL each hash table ; has a uvector inside of it that holds the data elements. So, the (hl-sizeof ; ht) for some hash table doesn't actually descend into this field! ; ; The following comment was left by <NAME>: ;; All memory-allocated objects in CCL are either CONSes or ;; "UVECTOR"s; a UVECTOR contains a header which describes the ;; object's primitive type (represented as an (UNSIGNED-BYTE 8) and ;; accessible via the function CCL::TYPECODE) and element-count ;; (accessible via the function CCL::UVSIZE.) A function defined in ;; the compiler backend knows how to map from a typecode and ;; element-count to a size in octets. UVECTORs are aligned on ;; doubleword boundaries and contain this extra header word, so the ;; "physical size" of the uvector is a bit bigger. On x86-64, ;; SYMBOLs and FUNCTIONs have their own tag, but there's an ;; underlying UVECTOR. (cond ((null thing) 0) ((consp thing) #+64-bit-target 16 #+32-bit-target 8) #+x8664-target ((symbolp thing) (hl-sizeof (ccl::%symptr->symvector thing))) #+x8664-target ((functionp thing) (hl-sizeof (ccl::function-to-function-vector thing))) ((ccl::uvectorp thing) (let* ((typecode (ccl::typecode thing)) (element-count (ccl::uvsize thing)) (sizeof-content-in-octets ;; Call the architecture-specific backend function. (funcall (arch::target-array-data-size-function (ccl::backend-target-arch ccl::*host-backend*)) typecode element-count))) (logandc2 (+ sizeof-content-in-octets #+64-bit-target (+ 8 15) #+32-bit-target (+ 4 7)) #+64-bit-target 15 #+32-bit-target 7))) (t 0))) #+(and static-hons Clozure) (defconstant hl-size-of-cons (hl-sizeof (cons nil nil))) #+(and static-hons Clozure) (defun hl-hash-table-bytes (ht) ; This is <NAME>'s approximation of the actual memory being used by the hash ; table itself. Note that this does NOT include the memory used by any of the ; keys or values that are currently stored in the hash table; the only things ; we count are the hash table's vector and its header size. This may be an ; under-approximation if we are missing other uvectors in the hash table ; structure itself. (declaim (type hash-table ht)) (+ (hl-sizeof ht) (hl-sizeof (ccl::nhash.vector ht)))) #+(and static-hons Clozure) (defun hl-hash-table-key-bytes (ht) ; This is <NAME>'s approximation of the actual memory being used for the keys of ; a hash table. This doesn't follow any pointers in the keys, but should work ; for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore val)) (unless (typep key 'fixnum) (incf size (hl-sizeof key)))) ht) size)) #+(and static-hons Clozure) (defun hl-hash-table-val-bytes (ht) ; This is <NAME>'s approximation of the actual memory being used for the values ; of a hash table. This doesn't follow any pointers in the values, but should ; work for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore key)) (unless (typep val 'fixnum) (incf size (hl-sizeof val)))) ht) size)) #+(and static-hons Clozure) (defun hl-hspace-analyze-memory (slowp hs) ; Print a brief report about the memory being used by the hons space. When ; slowp is set, we generate better information but may require a lot more time ; to do it. (declaim (type hl-hspace hs)) (format t "Analyzing hons-space memory usage.~%~%") (format t "SBITS total memory: ~15:D bytes~%~%" (hl-sizeof (hl-hspace-sbits hs))) (let* ((addr-ht (hl-hspace-addr-ht hs)) (addr-key-bytes (if slowp (hl-hash-table-key-bytes addr-ht) 0)) (addr-tbl-bytes (hl-hash-table-bytes addr-ht)) (addr-overhead-bytes (+ addr-key-bytes addr-tbl-bytes)) (addr-data-bytes (* (hl-sizeof '(1 . 2)) ;; 16 (hash-table-count addr-ht))) (addr-total-mem (+ addr-overhead-bytes addr-data-bytes))) (format t "ADDR-HT total memory: ~15:D bytes~%" addr-total-mem) (format t " - Actual cons data: ~15:D bytes (~5,2f%)~%" addr-data-bytes (/ (* addr-data-bytes 100.0) addr-total-mem)) (if slowp (progn (format t " - Total overhead: ~15:D bytes (~5,2f%)~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)) (format t " from the table itself: ~15:D bytes~%" addr-tbl-bytes) (format t " from bignum indicies: ~15:D bytes~%~%" addr-key-bytes)) (format t " - Overhead (approx): ~15:D bytes (~5,2f%)~%~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)))) (let* ((str-ht (hl-hspace-str-ht hs)) (str-tbl-bytes (hl-hash-table-bytes str-ht)) (str-key-bytes (hl-hash-table-key-bytes str-ht)) (str-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count str-ht))) (str-total-bytes (+ str-tbl-bytes str-key-bytes str-addr-bytes))) (format t "STR-HT total memory: ~15:D bytes~%" str-total-bytes) (format t " - Actual string data: ~15:D bytes~%" str-key-bytes) (format t " - Total overhead: ~15:D bytes~%" (+ str-tbl-bytes str-addr-bytes)) (format t " from the table itself: ~15:D bytes~%" str-tbl-bytes) (format t " from address conses: ~15:D bytes~%~%" str-addr-bytes)) (let* ((other-ht (hl-hspace-other-ht hs)) (other-tbl-bytes (hl-hash-table-bytes other-ht)) (other-key-bytes (hl-hash-table-key-bytes other-ht)) (other-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count other-ht))) (other-total-bytes (+ other-tbl-bytes other-key-bytes other-addr-bytes))) (format t "OTHER-HT total memory: ~15:D bytes~%" other-total-bytes) (format t " - Data for the atoms: ~15:D bytes~%" other-key-bytes) (format t " - Table overhead: ~15:D bytes~%" other-tbl-bytes) (format t " - Address overhead: ~15:D bytes~%~%" other-addr-bytes)) ) #+(and static-hons Clozure) (defun hl-ponstable-bytes-aux (elem) ;; Suppose a pons-table contains (Y . ELEM). I think that ELEM is either ;; (1) an list of XYC = (X . Y) pairs, where each XYC represents the ;; unique cons for (X . Y) in this pons table, or ;; (2) is a hash table that binds X to XYC. ;; ;; We'd really like to know something like, "how much space could be freed up ;; if we cleared this memo table." But that's extraordinarily hard to ;; measure, because we'd have to know what subtrees of these XYC pairs are ;; reachable from other places in the program. So, this function is really ;; only explaining how much space is definitely due to a pons table entry. ;; ;; In case (1) we charge for each cons in the alist, and for the conses that ;; connect the alist together. For example, if the alist has the form: ;; ;; ((A . Y) . (B . Y) . (C . Y) . NIL) ;; ;; Then we estimate the cost as 6 conses. This could be a severe ;; underapproximation of the actual overhead if A, B, C, or Y was a large ;; cons-tree that isn't reachable from anywhere else in the program. ;; ;; In case (2), we charge for the size of the table itself, and also for the ;; each XYC cons. (if (listp elem) (* (length elem) (* 2 hl-size-of-cons)) (+ (hl-hash-table-bytes elem) (hl-hash-table-val-bytes elem)))) #+(and static-hons Clozure) (defun hl-ponstable-bytes (pt) (if (not pt) 0 (+ (hl-hash-table-bytes pt) (let ((sum 0)) (maphash (lambda (key val) (declare (ignore key)) (incf sum (hl-ponstable-bytes-aux val))) pt) sum)))) #+(and static-hons Clozure) (defun memo-table-size-debug1 (fn info) ;; (FN -> INFO) is an entry in the *memo-info-ht*. (when (natp fn) ;; Skip back-pointers from numbers to functions. (return-from memo-table-size-debug1 nil)) (let* ((table-name (access memoize-info-ht-entry info :tablename)) (table (symbol-value table-name)) (table-size (if table (hash-table-size table) 0)) (table-bytes (if table (hl-hash-table-bytes table) 0)) (ponstable-name (access memoize-info-ht-entry info :ponstablename)) (ponstable (symbol-value ponstable-name)) (ponstable-size (if ponstable (hash-table-size ponstable) 0)) (ponstable-bytes (hl-ponstable-bytes ponstable)) (total-bytes (+ ponstable-bytes table-bytes))) (when (or (> ponstable-size 0) (> table-size 0) (> table-bytes 0) (> total-bytes 0)) (list fn ponstable-size table-size total-bytes)))) #+(and static-hons Clozure) (defun memo-table-size-debug () (cw "Memoize table sizes. Note: the reported \"overhead\" does NOT include ~ the sizes of the actual argument/result data stored in the memo ~ table.~%~%") (let ((report nil) (indent 0) (indent-str nil)) (maphash (lambda (fn info) (let ((entry (memo-table-size-debug1 fn info))) (when entry (push entry report) (setq indent (max indent (length (symbol-name fn))))))) *memoize-info-ht*) (setq indent-str (format nil "~a" (+ 2 indent))) (format t (concatenate 'string "~" indent-str ":@a ~12:@a ~12:@a ~26:@a~%") "Function" "PT-Size" "MT-Size" "Approx. Overhead") (loop for entry in report do (format t (concatenate 'string "~" indent-str ":@a ~12:D ~12:D ~20:D bytes~%") (first entry) (second entry) (third entry) (fourth entry))) (format t "~%"))) (defun hons-analyze-memory (slowp) (hl-maybe-initialize-default-hs) #+(and static-hons Clozure) (progn (hl-hspace-analyze-memory slowp *default-hs*) (memo-table-size-debug) (print-memo-max-sizes)) #-(and static-hons Clozure) (cw "Hons-analyze-memory is only available for static honsing.~%")) #|| (lp) (defun my-function (a b c d) (declare (xargs :guard t)) (list a b c d)) (memoize 'my-function) :q (loop for i from 1 to 10000 do (my-function 1 2 (+ i (ash 1 62)) (+ i (ash 1 100)))) (memoize-table-size-debug) ||#
true
; Centaur Miscellaneous Books ; Copyright (C) 2008-2011 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ; Added by PI:NAME:<NAME>END_PI., 12/8/2017: Some of the code to be executed only when ; #+static-hons has symbols ccl::xxx. I'm thus replacing the static-hons ; readtime conditional with (and static-hons Clozure). A more fine-grained fix ; might be possible by tracking down dependencies on functions with bodies that ; contain ccl::xxx symbols. (in-package "ACL2") (defvar *last-chance-threshold* ;; We'll automatically wash if we get within 1/400 of the max memory usage. ;; Examples: ;; If *max-mem-usage* is 8 GB, the cushion is ~21 MB. ;; If *max-mem-usage* is 16 GB, the cushion is ~42 MB. ;; If *max-mem-usage* is 32 GB, the cushion is ~85 MB. ;; If *max-mem-usage* is 64 GB, the cushion is ~171 MB. ;; If *max-mem-usage* is 96 GB, the cushion is ~257 MB. ;; If *max-mem-usage* is 128 GB, the cushion is ~343 MB. (ceiling *max-mem-usage* 400)) (defun set-max-mem-usage (max) (setf *max-mem-usage* max) (setf *last-chance-threshold* (ceiling *max-mem-usage* 400)) (setf *gc-min-threshold* (floor *max-mem-usage* 5)) #+Clozure (set-and-reset-gc-thresholds) nil) (defun print-quick-memory-summary () #+Clozure (multiple-value-bind (dynamic-used static-used library-used frozen-size) (ccl::%usedbytes) (let ((free (ccl::%freebytes)) (used (+ dynamic-used static-used library-used frozen-size)) (max *max-mem-usage*)) (format t "Max: ~15:D bytes~%" max) (format t "Free: ~15:D bytes~%" free) (format t "Used: ~15:D bytes~%" used) (format t " - Dynamic: ~15:D bytes~%" dynamic-used) (format t " - Static: ~15:D bytes~%" static-used) (format t " - Library: ~15:D bytes~%" library-used) (format t " - Frozen: ~15:D bytes~%" frozen-size) (format t "Dynamic+Frozen: ~15:D bytes~%" (+ dynamic-used frozen-size)) (hons-summary) (hons-analyze-memory nil) ;; PI:NAME:<NAME>END_PI changed this to force-output, since finish-output is slow ;; on an NFS. (force-output))) nil) (defun maybe-wash-memory-fn (n clear) (declare (ignorable clear)) #+Clozure (when (or (eq n t) (< (ccl::%freebytes) (nfix n))) (format t "********** maybe-wash-memory started ***********~%~%") (format t "Pre-wash memory usage.~%") (print-quick-memory-summary) (hons-wash) (format t "Post-wash memory usage:~%") (print-quick-memory-summary) (format t "********** maybe-wash-memory finished **********~%")) nil) (defun last-chance-wash-memory-fn () #+Clozure (when (< (ccl::%freebytes) *last-chance-threshold*) (format t "*********** last-chance-wash-memory ************~%") (format t "~:D free bytes < ~:D last chance threshold~%" (ccl::%freebytes) *last-chance-threshold*) (maybe-wash-memory-fn t nil)) nil) (defun set-max-mem (max) (set-max-mem-usage max) nil) ; Raw lisp definition of hons-analyze-memory. #+(and static-hons Clozure) (defun hl-sizeof (thing) ; Highly CCL-specific. This function computes something like "the size of ; thing in bytes," and was originally developed by PI:NAME:<NAME>END_PI in response to a ; question on the CCL mailing list. PI:NAME:<NAME>END_PIared only changed the names so it can be ; in the ACL2 package and added this comment. ; ; Note: determining memory usage is subtle and this function does NOT ; necessarily give you the whole story. For instance, in CCL each hash table ; has a uvector inside of it that holds the data elements. So, the (hl-sizeof ; ht) for some hash table doesn't actually descend into this field! ; ; The following comment was left by PI:NAME:<NAME>END_PI: ;; All memory-allocated objects in CCL are either CONSes or ;; "UVECTOR"s; a UVECTOR contains a header which describes the ;; object's primitive type (represented as an (UNSIGNED-BYTE 8) and ;; accessible via the function CCL::TYPECODE) and element-count ;; (accessible via the function CCL::UVSIZE.) A function defined in ;; the compiler backend knows how to map from a typecode and ;; element-count to a size in octets. UVECTORs are aligned on ;; doubleword boundaries and contain this extra header word, so the ;; "physical size" of the uvector is a bit bigger. On x86-64, ;; SYMBOLs and FUNCTIONs have their own tag, but there's an ;; underlying UVECTOR. (cond ((null thing) 0) ((consp thing) #+64-bit-target 16 #+32-bit-target 8) #+x8664-target ((symbolp thing) (hl-sizeof (ccl::%symptr->symvector thing))) #+x8664-target ((functionp thing) (hl-sizeof (ccl::function-to-function-vector thing))) ((ccl::uvectorp thing) (let* ((typecode (ccl::typecode thing)) (element-count (ccl::uvsize thing)) (sizeof-content-in-octets ;; Call the architecture-specific backend function. (funcall (arch::target-array-data-size-function (ccl::backend-target-arch ccl::*host-backend*)) typecode element-count))) (logandc2 (+ sizeof-content-in-octets #+64-bit-target (+ 8 15) #+32-bit-target (+ 4 7)) #+64-bit-target 15 #+32-bit-target 7))) (t 0))) #+(and static-hons Clozure) (defconstant hl-size-of-cons (hl-sizeof (cons nil nil))) #+(and static-hons Clozure) (defun hl-hash-table-bytes (ht) ; This is PI:NAME:<NAME>END_PI's approximation of the actual memory being used by the hash ; table itself. Note that this does NOT include the memory used by any of the ; keys or values that are currently stored in the hash table; the only things ; we count are the hash table's vector and its header size. This may be an ; under-approximation if we are missing other uvectors in the hash table ; structure itself. (declaim (type hash-table ht)) (+ (hl-sizeof ht) (hl-sizeof (ccl::nhash.vector ht)))) #+(and static-hons Clozure) (defun hl-hash-table-key-bytes (ht) ; This is PI:NAME:<NAME>END_PI's approximation of the actual memory being used for the keys of ; a hash table. This doesn't follow any pointers in the keys, but should work ; for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore val)) (unless (typep key 'fixnum) (incf size (hl-sizeof key)))) ht) size)) #+(and static-hons Clozure) (defun hl-hash-table-val-bytes (ht) ; This is PI:NAME:<NAME>END_PI's approximation of the actual memory being used for the values ; of a hash table. This doesn't follow any pointers in the values, but should ; work for counting up strings, bignums, that sort of thing. (let ((size 0)) (maphash (lambda (key val) (declare (ignore key)) (unless (typep val 'fixnum) (incf size (hl-sizeof val)))) ht) size)) #+(and static-hons Clozure) (defun hl-hspace-analyze-memory (slowp hs) ; Print a brief report about the memory being used by the hons space. When ; slowp is set, we generate better information but may require a lot more time ; to do it. (declaim (type hl-hspace hs)) (format t "Analyzing hons-space memory usage.~%~%") (format t "SBITS total memory: ~15:D bytes~%~%" (hl-sizeof (hl-hspace-sbits hs))) (let* ((addr-ht (hl-hspace-addr-ht hs)) (addr-key-bytes (if slowp (hl-hash-table-key-bytes addr-ht) 0)) (addr-tbl-bytes (hl-hash-table-bytes addr-ht)) (addr-overhead-bytes (+ addr-key-bytes addr-tbl-bytes)) (addr-data-bytes (* (hl-sizeof '(1 . 2)) ;; 16 (hash-table-count addr-ht))) (addr-total-mem (+ addr-overhead-bytes addr-data-bytes))) (format t "ADDR-HT total memory: ~15:D bytes~%" addr-total-mem) (format t " - Actual cons data: ~15:D bytes (~5,2f%)~%" addr-data-bytes (/ (* addr-data-bytes 100.0) addr-total-mem)) (if slowp (progn (format t " - Total overhead: ~15:D bytes (~5,2f%)~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)) (format t " from the table itself: ~15:D bytes~%" addr-tbl-bytes) (format t " from bignum indicies: ~15:D bytes~%~%" addr-key-bytes)) (format t " - Overhead (approx): ~15:D bytes (~5,2f%)~%~%" addr-overhead-bytes (/ (* addr-overhead-bytes 100.0) addr-total-mem)))) (let* ((str-ht (hl-hspace-str-ht hs)) (str-tbl-bytes (hl-hash-table-bytes str-ht)) (str-key-bytes (hl-hash-table-key-bytes str-ht)) (str-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count str-ht))) (str-total-bytes (+ str-tbl-bytes str-key-bytes str-addr-bytes))) (format t "STR-HT total memory: ~15:D bytes~%" str-total-bytes) (format t " - Actual string data: ~15:D bytes~%" str-key-bytes) (format t " - Total overhead: ~15:D bytes~%" (+ str-tbl-bytes str-addr-bytes)) (format t " from the table itself: ~15:D bytes~%" str-tbl-bytes) (format t " from address conses: ~15:D bytes~%~%" str-addr-bytes)) (let* ((other-ht (hl-hspace-other-ht hs)) (other-tbl-bytes (hl-hash-table-bytes other-ht)) (other-key-bytes (hl-hash-table-key-bytes other-ht)) (other-addr-bytes (* (hl-sizeof '(1 . 2)) (hash-table-count other-ht))) (other-total-bytes (+ other-tbl-bytes other-key-bytes other-addr-bytes))) (format t "OTHER-HT total memory: ~15:D bytes~%" other-total-bytes) (format t " - Data for the atoms: ~15:D bytes~%" other-key-bytes) (format t " - Table overhead: ~15:D bytes~%" other-tbl-bytes) (format t " - Address overhead: ~15:D bytes~%~%" other-addr-bytes)) ) #+(and static-hons Clozure) (defun hl-ponstable-bytes-aux (elem) ;; Suppose a pons-table contains (Y . ELEM). I think that ELEM is either ;; (1) an list of XYC = (X . Y) pairs, where each XYC represents the ;; unique cons for (X . Y) in this pons table, or ;; (2) is a hash table that binds X to XYC. ;; ;; We'd really like to know something like, "how much space could be freed up ;; if we cleared this memo table." But that's extraordinarily hard to ;; measure, because we'd have to know what subtrees of these XYC pairs are ;; reachable from other places in the program. So, this function is really ;; only explaining how much space is definitely due to a pons table entry. ;; ;; In case (1) we charge for each cons in the alist, and for the conses that ;; connect the alist together. For example, if the alist has the form: ;; ;; ((A . Y) . (B . Y) . (C . Y) . NIL) ;; ;; Then we estimate the cost as 6 conses. This could be a severe ;; underapproximation of the actual overhead if A, B, C, or Y was a large ;; cons-tree that isn't reachable from anywhere else in the program. ;; ;; In case (2), we charge for the size of the table itself, and also for the ;; each XYC cons. (if (listp elem) (* (length elem) (* 2 hl-size-of-cons)) (+ (hl-hash-table-bytes elem) (hl-hash-table-val-bytes elem)))) #+(and static-hons Clozure) (defun hl-ponstable-bytes (pt) (if (not pt) 0 (+ (hl-hash-table-bytes pt) (let ((sum 0)) (maphash (lambda (key val) (declare (ignore key)) (incf sum (hl-ponstable-bytes-aux val))) pt) sum)))) #+(and static-hons Clozure) (defun memo-table-size-debug1 (fn info) ;; (FN -> INFO) is an entry in the *memo-info-ht*. (when (natp fn) ;; Skip back-pointers from numbers to functions. (return-from memo-table-size-debug1 nil)) (let* ((table-name (access memoize-info-ht-entry info :tablename)) (table (symbol-value table-name)) (table-size (if table (hash-table-size table) 0)) (table-bytes (if table (hl-hash-table-bytes table) 0)) (ponstable-name (access memoize-info-ht-entry info :ponstablename)) (ponstable (symbol-value ponstable-name)) (ponstable-size (if ponstable (hash-table-size ponstable) 0)) (ponstable-bytes (hl-ponstable-bytes ponstable)) (total-bytes (+ ponstable-bytes table-bytes))) (when (or (> ponstable-size 0) (> table-size 0) (> table-bytes 0) (> total-bytes 0)) (list fn ponstable-size table-size total-bytes)))) #+(and static-hons Clozure) (defun memo-table-size-debug () (cw "Memoize table sizes. Note: the reported \"overhead\" does NOT include ~ the sizes of the actual argument/result data stored in the memo ~ table.~%~%") (let ((report nil) (indent 0) (indent-str nil)) (maphash (lambda (fn info) (let ((entry (memo-table-size-debug1 fn info))) (when entry (push entry report) (setq indent (max indent (length (symbol-name fn))))))) *memoize-info-ht*) (setq indent-str (format nil "~a" (+ 2 indent))) (format t (concatenate 'string "~" indent-str ":@a ~12:@a ~12:@a ~26:@a~%") "Function" "PT-Size" "MT-Size" "Approx. Overhead") (loop for entry in report do (format t (concatenate 'string "~" indent-str ":@a ~12:D ~12:D ~20:D bytes~%") (first entry) (second entry) (third entry) (fourth entry))) (format t "~%"))) (defun hons-analyze-memory (slowp) (hl-maybe-initialize-default-hs) #+(and static-hons Clozure) (progn (hl-hspace-analyze-memory slowp *default-hs*) (memo-table-size-debug) (print-memo-max-sizes)) #-(and static-hons Clozure) (cw "Hons-analyze-memory is only available for static honsing.~%")) #|| (lp) (defun my-function (a b c d) (declare (xargs :guard t)) (list a b c d)) (memoize 'my-function) :q (loop for i from 1 to 10000 do (my-function 1 2 (+ i (ash 1 62)) (+ i (ash 1 100)))) (memoize-table-size-debug) ||#
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 190, "score": 0.9998791217803955, "start": 173, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 210, "score": 0.9999303817749023, "start": 192, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/yul/transformations/dead-code-eliminator-nofun.lisp
mayankmanj/acl2
0
; Yul Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "YUL") (include-book "dead-code-eliminator") (include-book "no-function-definitions") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection dead-code-eliminator-no-function-definitions :parents (transformations) :short "Proof that the @('DeadCodeEliminator') transformation preserves the condition in which functions are defined elsewhere." (defthm-statements/blocks/cases/fundefs-dead-flag (defthm statement-nofunp-of-statement-dead (implies (statement-nofunp stmt) (statement-nofunp (statement-dead stmt))) :flag statement-dead) (defthm statement-list-nofunp-of-statement-list-dead (implies (statement-list-nofunp stmts) (statement-list-nofunp (statement-list-dead stmts))) :flag statement-list-dead) (defthm block-nofunp-of-block-dead (implies (block-nofunp block) (block-nofunp (block-dead block))) :flag block-dead) (defthm block-option-nofunp-of-block-option-dead (implies (block-option-nofunp block?) (block-option-nofunp (block-option-dead block?))) :flag block-option-dead) (defthm swcase-nofunp-of-swcase-dead (implies (swcase-nofunp case) (swcase-nofunp (swcase-dead case))) :flag swcase-dead) (defthm swcase-list-nofunp-of-swcase-list-dead (implies (swcase-list-nofunp cases) (swcase-list-nofunp (swcase-list-dead cases))) :flag swcase-list-dead) (defthm fundef-nofunp-of-fundef-dead (implies (fundef-nofunp fundef) (fundef-nofunp (fundef-dead fundef))) :flag fundef-dead) :hints (("Goal" :in-theory (enable statement-dead statement-list-dead block-dead block-option-dead swcase-dead swcase-list-dead fundef-dead statement-nofunp statement-list-nofunp block-nofunp block-option-nofunp swcase-nofunp swcase-list-nofunp fundef-nofunp)))))
20292
; Yul Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "YUL") (include-book "dead-code-eliminator") (include-book "no-function-definitions") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection dead-code-eliminator-no-function-definitions :parents (transformations) :short "Proof that the @('DeadCodeEliminator') transformation preserves the condition in which functions are defined elsewhere." (defthm-statements/blocks/cases/fundefs-dead-flag (defthm statement-nofunp-of-statement-dead (implies (statement-nofunp stmt) (statement-nofunp (statement-dead stmt))) :flag statement-dead) (defthm statement-list-nofunp-of-statement-list-dead (implies (statement-list-nofunp stmts) (statement-list-nofunp (statement-list-dead stmts))) :flag statement-list-dead) (defthm block-nofunp-of-block-dead (implies (block-nofunp block) (block-nofunp (block-dead block))) :flag block-dead) (defthm block-option-nofunp-of-block-option-dead (implies (block-option-nofunp block?) (block-option-nofunp (block-option-dead block?))) :flag block-option-dead) (defthm swcase-nofunp-of-swcase-dead (implies (swcase-nofunp case) (swcase-nofunp (swcase-dead case))) :flag swcase-dead) (defthm swcase-list-nofunp-of-swcase-list-dead (implies (swcase-list-nofunp cases) (swcase-list-nofunp (swcase-list-dead cases))) :flag swcase-list-dead) (defthm fundef-nofunp-of-fundef-dead (implies (fundef-nofunp fundef) (fundef-nofunp (fundef-dead fundef))) :flag fundef-dead) :hints (("Goal" :in-theory (enable statement-dead statement-list-dead block-dead block-option-dead swcase-dead swcase-list-dead fundef-dead statement-nofunp statement-list-nofunp block-nofunp block-option-nofunp swcase-nofunp swcase-list-nofunp fundef-nofunp)))))
true
; Yul Library ; ; Copyright (C) 2021 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "YUL") (include-book "dead-code-eliminator") (include-book "no-function-definitions") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsection dead-code-eliminator-no-function-definitions :parents (transformations) :short "Proof that the @('DeadCodeEliminator') transformation preserves the condition in which functions are defined elsewhere." (defthm-statements/blocks/cases/fundefs-dead-flag (defthm statement-nofunp-of-statement-dead (implies (statement-nofunp stmt) (statement-nofunp (statement-dead stmt))) :flag statement-dead) (defthm statement-list-nofunp-of-statement-list-dead (implies (statement-list-nofunp stmts) (statement-list-nofunp (statement-list-dead stmts))) :flag statement-list-dead) (defthm block-nofunp-of-block-dead (implies (block-nofunp block) (block-nofunp (block-dead block))) :flag block-dead) (defthm block-option-nofunp-of-block-option-dead (implies (block-option-nofunp block?) (block-option-nofunp (block-option-dead block?))) :flag block-option-dead) (defthm swcase-nofunp-of-swcase-dead (implies (swcase-nofunp case) (swcase-nofunp (swcase-dead case))) :flag swcase-dead) (defthm swcase-list-nofunp-of-swcase-list-dead (implies (swcase-list-nofunp cases) (swcase-list-nofunp (swcase-list-dead cases))) :flag swcase-list-dead) (defthm fundef-nofunp-of-fundef-dead (implies (fundef-nofunp fundef) (fundef-nofunp (fundef-dead fundef))) :flag fundef-dead) :hints (("Goal" :in-theory (enable statement-dead statement-list-dead block-dead block-option-dead swcase-dead swcase-list-dead fundef-dead statement-nofunp statement-list-nofunp block-nofunp block-option-nofunp swcase-nofunp swcase-list-nofunp fundef-nofunp)))))
[ { "context": ";; This file is part of cardiogram\n;; (c) 2018 - Abraham Aguilar <[email protected]>\n\n(uiop:define-packag", "end": 64, "score": 0.9998880624771118, "start": 49, "tag": "NAME", "value": "Abraham Aguilar" }, { "context": "part of cardiogram\n;; (c) 2018 - Abraham Aguilar <[email protected]>\n\n(uiop:define-package :cardiogram/annotations\n ", "end": 92, "score": 0.9999347925186157, "start": 66, "tag": "EMAIL", "value": "[email protected]" } ]
src/annotations.lisp
fullandfaithful/cardiogram
0
;; This file is part of cardiogram ;; (c) 2018 - Abraham Aguilar <[email protected]> (uiop:define-package :cardiogram/annotations (:use :cl :cl-annot :cardiogram/toolkit) (:export :in)) (in-package :cardiogram/annotations) (labels ((e!symbolp (s) (and (symbolp s) (< 2 (length (symbol-name s))) (string= (symbol-name s) "E!" :end1 1 :end2 1)))) (defannotation in (x def) (:arity 2) (let* ((pname (if (e!symbolp x) (intern (subseq (symbol-name x) 2) :keyword) x)) (fname (intern (symbol-name (cadr def)) pname))) `(progn ,(when (e!symbolp x) `(export ',fname ,pname)) ,(l! (car def) fname (cddr def))))))
54256
;; This file is part of cardiogram ;; (c) 2018 - <NAME> <<EMAIL>> (uiop:define-package :cardiogram/annotations (:use :cl :cl-annot :cardiogram/toolkit) (:export :in)) (in-package :cardiogram/annotations) (labels ((e!symbolp (s) (and (symbolp s) (< 2 (length (symbol-name s))) (string= (symbol-name s) "E!" :end1 1 :end2 1)))) (defannotation in (x def) (:arity 2) (let* ((pname (if (e!symbolp x) (intern (subseq (symbol-name x) 2) :keyword) x)) (fname (intern (symbol-name (cadr def)) pname))) `(progn ,(when (e!symbolp x) `(export ',fname ,pname)) ,(l! (car def) fname (cddr def))))))
true
;; This file is part of cardiogram ;; (c) 2018 - PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (uiop:define-package :cardiogram/annotations (:use :cl :cl-annot :cardiogram/toolkit) (:export :in)) (in-package :cardiogram/annotations) (labels ((e!symbolp (s) (and (symbolp s) (< 2 (length (symbol-name s))) (string= (symbol-name s) "E!" :end1 1 :end2 1)))) (defannotation in (x def) (:arity 2) (let* ((pname (if (e!symbolp x) (intern (subseq (symbol-name x) 2) :keyword) x)) (fname (intern (symbol-name (cadr def)) pname))) `(progn ,(when (e!symbolp x) `(export ',fname ,pname)) ,(l! (car def) fname (cddr def))))))
[ { "context": "=======================\n;; \n;; Copyright (C) 2018, David Greve\n;; All rights reserved.\n;; \n;; This software may ", "end": 109, "score": 0.9998601078987122, "start": 98, "tag": "NAME", "value": "David Greve" } ]
books/coi/util/linearize-complex-polys.lisp
mayankmanj/acl2
305
;; =================================================================== ;; ;; Copyright (C) 2018, David Greve ;; All rights reserved. ;; ;; This software may be modified and distributed under the terms of ;; the 3-clause BSD license. See the LICENSE file distributed with ;; ACL2. ;; ;; =================================================================== (in-package "ACL2") ;; =================================================================== ;; This book was inspired by the following comment in linear-a.lisp ;; from the ACL2 source code: ;; =================================================================== ; Note that in Multiplication by Positive Preserves Inequality we require the ; positive to be rational. Multiplication by a "positive" complex rational ; does not preserve the inequality. For example, the following evaluates ; to nil: ; (let ((c #c(1 -10)) ; (x #c(1 1)) ; (y #c(2 -2))) ; (implies (and ; (rationalp c) ; omit the rationalp hyp ; (< 0 c)) ; (iff (< x y) ; t ; (< (* c x) (* c y))))) ; nil ; Thus, the coefficients in our polys must be rational. ;; =================================================================== ;; And if we trace the linear functions in ACL2 we see that terms of ;; the form (* #c(a b) x) are treated as atomic terms .. the complex ;; number is *not* treated as a coefficient. ;; ;; Note, however, that ;; ;; (* #(c a b) x) ;; ;; is the same as ;; ;; (+ (* a x) (* b #(c 0 1) x)) ;; ;; In other words, we can always decompose complex constants into ;; real and imaginary components (each with rational coefficients) ;; and perform linear reasoning on the fragments. ;; ;; Of course, complex numbers are sufficiently uncommon in ACL2 that ;; it is not worth the additional complexity and effort to extend the ;; linear procedure to do this natively. ;; ;; So that is what this library is for. It introduces the function ;; (imaginary) as a stand-in for the complex number #c(0 1) and then ;; reduces complex coefficients into their rational and imaginary ;; components. ;; ;; =================================================================== (encapsulate () (local (include-book "workshops/2006/cowles-gamboa-euclid/Euclid/ed5aa" :dir :system)) ;; These facts were hard to find in the books .. (defthm realpart-* (equal (realpart (* x y)) (- (* (realpart x) (realpart y)) (* (imagpart x) (imagpart y))))) (defthm imagpart-* (equal (imagpart (* x y)) (+ (* (realpart x) (imagpart y)) (* (imagpart x) (realpart y))))) ) (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (local (defthm imagpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (imagpart (complex x y)) y)))) (local (defthm realpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (realpart (complex x y)) x)))) (defthm equal-complex-to-equal-parts (iff (equal (complex real imag) z) (and (acl2-numberp z) (equal (rfix real) (realpart z)) (equal (rfix imag) (imagpart z))))) (defthmd equal-complex-to-equal-parts-z (implies (complex-rationalp c) (iff (equal c z) (and (acl2-numberp z) (equal (realpart c) (realpart z)) (equal (imagpart c) (imagpart z))))) :hints (("Goal" :use (:instance equal-complex-to-equal-parts (real (realpart c)) (imag (imagpart c)))))) )) (defun imaginary () (complex 0 1)) (in-theory (disable (:type-prescription imaginary))) (defthm imaginary-type (acl2-numberp (imaginary)) :rule-classes (:type-prescription)) (defthm realpart-imaginary (equal (realpart (imaginary)) 0)) (defthm imagpart-imaginary (equal (imagpart (imaginary)) 1)) (defthm imaginary-product-2 (equal (* (imaginary) (imaginary)) -1)) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm imaginary-product-3 (equal (* (imaginary) (* (imaginary) x)) (* -1 x))) ) (encapsulate () (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthmd open-mod-4 (implies (and (syntaxp (symbolp x)) (natp x)) (equal (mod x 4) (if (<= 4 x) (mod (- x 4) 4) x)))) (defthm move-constants (implies (syntaxp (and (not (quotep x)) (quotep y))) (equal (* x (* y z)) (* y (* x z))))) )) (local (encapsulate () (defun mod4 (n) (let ((n (nfix n))) (cond ((equal n 0) 0) ((equal n 1) 1) ((equal n 2) 2) ((equal n 3) 3) (t (mod4 (- n 4)))))) (defthm equal-mod4-mod4 (implies (natp x) (equal (mod x 4) (mod4 x))) :hints (("Goal" :induct (mod4 x) :in-theory (e/d (open-mod-4) (mod))))) (defthm alt-expt-definition (implies (and (syntaxp (symbolp n)) (natp n)) (equal (expt x n) (let ((x (fix x))) (cond ((equal n 0) 1) ((equal n 1) x) ((equal n 2) (* x x)) ((equal n 3) (* x x x)) (t (* x x x x (expt x (- n 4)))))))) :rule-classes (:definition) :hints (("Goal" :do-not-induct t :expand ((expt x 3) (expt x 2) (expt x 1))) (and stable-under-simplificationp `(:expand (expt x n))) (and stable-under-simplificationp `(:expand (expt x (+ -1 n)))) (and stable-under-simplificationp `(:expand (expt x (+ -2 n)))) )) (defthm collect-constants (implies (syntaxp (and (quotep x) (quotep y))) (equal (* x (* y z)) (* (* x y) z)))) )) (defthm expt-imaginary (implies (natp n) (equal (expt (imaginary) n) (let ((n (mod n 4))) (cond ((equal n 0) 1) ((equal n 1) (imaginary)) ((equal n 2) -1) (t (- (imaginary))))))) :hints (("Goal" :induct (mod4 n) :in-theory (disable mod expt (imaginary) imaginary)) (and stable-under-simplificationp '(:expand ( (:free (x) (expt x 0)) (:free (x) (expt x 1)) (:free (x) (expt x 2)) (:free (x) (expt x 3)) ))))) ) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm complex-to-imaginary (equal (complex real imag) (+ (rfix real) (* (rfix imag) (imaginary))))) (defthm reduce-complex-coefficient (implies (and (syntaxp (quotep c)) (complex-rationalp c)) (equal (* c x) (+ (* (realpart c) x) (* (imagpart c) (imaginary) x)))) :hints (("Goal" :in-theory (enable equal-complex-to-equal-parts-z)))) ) (in-theory (disable imaginary (imaginary))) (local ;; Note: this theorem was not provable (by linear) prior to loading this book (defthm complex-poly-test (implies (and (acl2-numberp x) (acl2-numberp y) (< 0 (+ (* #C( 1 2) x) (* #C(4 3) y))) (< 0 (+ (* #C(-1 -2) x) (* #C(0 -3) y))) (< 0 (+ (- y) -2)) ) nil) :rule-classes nil) )
71292
;; =================================================================== ;; ;; Copyright (C) 2018, <NAME> ;; All rights reserved. ;; ;; This software may be modified and distributed under the terms of ;; the 3-clause BSD license. See the LICENSE file distributed with ;; ACL2. ;; ;; =================================================================== (in-package "ACL2") ;; =================================================================== ;; This book was inspired by the following comment in linear-a.lisp ;; from the ACL2 source code: ;; =================================================================== ; Note that in Multiplication by Positive Preserves Inequality we require the ; positive to be rational. Multiplication by a "positive" complex rational ; does not preserve the inequality. For example, the following evaluates ; to nil: ; (let ((c #c(1 -10)) ; (x #c(1 1)) ; (y #c(2 -2))) ; (implies (and ; (rationalp c) ; omit the rationalp hyp ; (< 0 c)) ; (iff (< x y) ; t ; (< (* c x) (* c y))))) ; nil ; Thus, the coefficients in our polys must be rational. ;; =================================================================== ;; And if we trace the linear functions in ACL2 we see that terms of ;; the form (* #c(a b) x) are treated as atomic terms .. the complex ;; number is *not* treated as a coefficient. ;; ;; Note, however, that ;; ;; (* #(c a b) x) ;; ;; is the same as ;; ;; (+ (* a x) (* b #(c 0 1) x)) ;; ;; In other words, we can always decompose complex constants into ;; real and imaginary components (each with rational coefficients) ;; and perform linear reasoning on the fragments. ;; ;; Of course, complex numbers are sufficiently uncommon in ACL2 that ;; it is not worth the additional complexity and effort to extend the ;; linear procedure to do this natively. ;; ;; So that is what this library is for. It introduces the function ;; (imaginary) as a stand-in for the complex number #c(0 1) and then ;; reduces complex coefficients into their rational and imaginary ;; components. ;; ;; =================================================================== (encapsulate () (local (include-book "workshops/2006/cowles-gamboa-euclid/Euclid/ed5aa" :dir :system)) ;; These facts were hard to find in the books .. (defthm realpart-* (equal (realpart (* x y)) (- (* (realpart x) (realpart y)) (* (imagpart x) (imagpart y))))) (defthm imagpart-* (equal (imagpart (* x y)) (+ (* (realpart x) (imagpart y)) (* (imagpart x) (realpart y))))) ) (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (local (defthm imagpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (imagpart (complex x y)) y)))) (local (defthm realpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (realpart (complex x y)) x)))) (defthm equal-complex-to-equal-parts (iff (equal (complex real imag) z) (and (acl2-numberp z) (equal (rfix real) (realpart z)) (equal (rfix imag) (imagpart z))))) (defthmd equal-complex-to-equal-parts-z (implies (complex-rationalp c) (iff (equal c z) (and (acl2-numberp z) (equal (realpart c) (realpart z)) (equal (imagpart c) (imagpart z))))) :hints (("Goal" :use (:instance equal-complex-to-equal-parts (real (realpart c)) (imag (imagpart c)))))) )) (defun imaginary () (complex 0 1)) (in-theory (disable (:type-prescription imaginary))) (defthm imaginary-type (acl2-numberp (imaginary)) :rule-classes (:type-prescription)) (defthm realpart-imaginary (equal (realpart (imaginary)) 0)) (defthm imagpart-imaginary (equal (imagpart (imaginary)) 1)) (defthm imaginary-product-2 (equal (* (imaginary) (imaginary)) -1)) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm imaginary-product-3 (equal (* (imaginary) (* (imaginary) x)) (* -1 x))) ) (encapsulate () (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthmd open-mod-4 (implies (and (syntaxp (symbolp x)) (natp x)) (equal (mod x 4) (if (<= 4 x) (mod (- x 4) 4) x)))) (defthm move-constants (implies (syntaxp (and (not (quotep x)) (quotep y))) (equal (* x (* y z)) (* y (* x z))))) )) (local (encapsulate () (defun mod4 (n) (let ((n (nfix n))) (cond ((equal n 0) 0) ((equal n 1) 1) ((equal n 2) 2) ((equal n 3) 3) (t (mod4 (- n 4)))))) (defthm equal-mod4-mod4 (implies (natp x) (equal (mod x 4) (mod4 x))) :hints (("Goal" :induct (mod4 x) :in-theory (e/d (open-mod-4) (mod))))) (defthm alt-expt-definition (implies (and (syntaxp (symbolp n)) (natp n)) (equal (expt x n) (let ((x (fix x))) (cond ((equal n 0) 1) ((equal n 1) x) ((equal n 2) (* x x)) ((equal n 3) (* x x x)) (t (* x x x x (expt x (- n 4)))))))) :rule-classes (:definition) :hints (("Goal" :do-not-induct t :expand ((expt x 3) (expt x 2) (expt x 1))) (and stable-under-simplificationp `(:expand (expt x n))) (and stable-under-simplificationp `(:expand (expt x (+ -1 n)))) (and stable-under-simplificationp `(:expand (expt x (+ -2 n)))) )) (defthm collect-constants (implies (syntaxp (and (quotep x) (quotep y))) (equal (* x (* y z)) (* (* x y) z)))) )) (defthm expt-imaginary (implies (natp n) (equal (expt (imaginary) n) (let ((n (mod n 4))) (cond ((equal n 0) 1) ((equal n 1) (imaginary)) ((equal n 2) -1) (t (- (imaginary))))))) :hints (("Goal" :induct (mod4 n) :in-theory (disable mod expt (imaginary) imaginary)) (and stable-under-simplificationp '(:expand ( (:free (x) (expt x 0)) (:free (x) (expt x 1)) (:free (x) (expt x 2)) (:free (x) (expt x 3)) ))))) ) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm complex-to-imaginary (equal (complex real imag) (+ (rfix real) (* (rfix imag) (imaginary))))) (defthm reduce-complex-coefficient (implies (and (syntaxp (quotep c)) (complex-rationalp c)) (equal (* c x) (+ (* (realpart c) x) (* (imagpart c) (imaginary) x)))) :hints (("Goal" :in-theory (enable equal-complex-to-equal-parts-z)))) ) (in-theory (disable imaginary (imaginary))) (local ;; Note: this theorem was not provable (by linear) prior to loading this book (defthm complex-poly-test (implies (and (acl2-numberp x) (acl2-numberp y) (< 0 (+ (* #C( 1 2) x) (* #C(4 3) y))) (< 0 (+ (* #C(-1 -2) x) (* #C(0 -3) y))) (< 0 (+ (- y) -2)) ) nil) :rule-classes nil) )
true
;; =================================================================== ;; ;; Copyright (C) 2018, PI:NAME:<NAME>END_PI ;; All rights reserved. ;; ;; This software may be modified and distributed under the terms of ;; the 3-clause BSD license. See the LICENSE file distributed with ;; ACL2. ;; ;; =================================================================== (in-package "ACL2") ;; =================================================================== ;; This book was inspired by the following comment in linear-a.lisp ;; from the ACL2 source code: ;; =================================================================== ; Note that in Multiplication by Positive Preserves Inequality we require the ; positive to be rational. Multiplication by a "positive" complex rational ; does not preserve the inequality. For example, the following evaluates ; to nil: ; (let ((c #c(1 -10)) ; (x #c(1 1)) ; (y #c(2 -2))) ; (implies (and ; (rationalp c) ; omit the rationalp hyp ; (< 0 c)) ; (iff (< x y) ; t ; (< (* c x) (* c y))))) ; nil ; Thus, the coefficients in our polys must be rational. ;; =================================================================== ;; And if we trace the linear functions in ACL2 we see that terms of ;; the form (* #c(a b) x) are treated as atomic terms .. the complex ;; number is *not* treated as a coefficient. ;; ;; Note, however, that ;; ;; (* #(c a b) x) ;; ;; is the same as ;; ;; (+ (* a x) (* b #(c 0 1) x)) ;; ;; In other words, we can always decompose complex constants into ;; real and imaginary components (each with rational coefficients) ;; and perform linear reasoning on the fragments. ;; ;; Of course, complex numbers are sufficiently uncommon in ACL2 that ;; it is not worth the additional complexity and effort to extend the ;; linear procedure to do this natively. ;; ;; So that is what this library is for. It introduces the function ;; (imaginary) as a stand-in for the complex number #c(0 1) and then ;; reduces complex coefficients into their rational and imaginary ;; components. ;; ;; =================================================================== (encapsulate () (local (include-book "workshops/2006/cowles-gamboa-euclid/Euclid/ed5aa" :dir :system)) ;; These facts were hard to find in the books .. (defthm realpart-* (equal (realpart (* x y)) (- (* (realpart x) (realpart y)) (* (imagpart x) (imagpart y))))) (defthm imagpart-* (equal (imagpart (* x y)) (+ (* (realpart x) (imagpart y)) (* (imagpart x) (realpart y))))) ) (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (local (defthm imagpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (imagpart (complex x y)) y)))) (local (defthm realpart-complex-force (implies (case-split (and (rationalp x) (rationalp y))) (equal (realpart (complex x y)) x)))) (defthm equal-complex-to-equal-parts (iff (equal (complex real imag) z) (and (acl2-numberp z) (equal (rfix real) (realpart z)) (equal (rfix imag) (imagpart z))))) (defthmd equal-complex-to-equal-parts-z (implies (complex-rationalp c) (iff (equal c z) (and (acl2-numberp z) (equal (realpart c) (realpart z)) (equal (imagpart c) (imagpart z))))) :hints (("Goal" :use (:instance equal-complex-to-equal-parts (real (realpart c)) (imag (imagpart c)))))) )) (defun imaginary () (complex 0 1)) (in-theory (disable (:type-prescription imaginary))) (defthm imaginary-type (acl2-numberp (imaginary)) :rule-classes (:type-prescription)) (defthm realpart-imaginary (equal (realpart (imaginary)) 0)) (defthm imagpart-imaginary (equal (imagpart (imaginary)) 1)) (defthm imaginary-product-2 (equal (* (imaginary) (imaginary)) -1)) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm imaginary-product-3 (equal (* (imaginary) (* (imaginary) x)) (* -1 x))) ) (encapsulate () (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthmd open-mod-4 (implies (and (syntaxp (symbolp x)) (natp x)) (equal (mod x 4) (if (<= 4 x) (mod (- x 4) 4) x)))) (defthm move-constants (implies (syntaxp (and (not (quotep x)) (quotep y))) (equal (* x (* y z)) (* y (* x z))))) )) (local (encapsulate () (defun mod4 (n) (let ((n (nfix n))) (cond ((equal n 0) 0) ((equal n 1) 1) ((equal n 2) 2) ((equal n 3) 3) (t (mod4 (- n 4)))))) (defthm equal-mod4-mod4 (implies (natp x) (equal (mod x 4) (mod4 x))) :hints (("Goal" :induct (mod4 x) :in-theory (e/d (open-mod-4) (mod))))) (defthm alt-expt-definition (implies (and (syntaxp (symbolp n)) (natp n)) (equal (expt x n) (let ((x (fix x))) (cond ((equal n 0) 1) ((equal n 1) x) ((equal n 2) (* x x)) ((equal n 3) (* x x x)) (t (* x x x x (expt x (- n 4)))))))) :rule-classes (:definition) :hints (("Goal" :do-not-induct t :expand ((expt x 3) (expt x 2) (expt x 1))) (and stable-under-simplificationp `(:expand (expt x n))) (and stable-under-simplificationp `(:expand (expt x (+ -1 n)))) (and stable-under-simplificationp `(:expand (expt x (+ -2 n)))) )) (defthm collect-constants (implies (syntaxp (and (quotep x) (quotep y))) (equal (* x (* y z)) (* (* x y) z)))) )) (defthm expt-imaginary (implies (natp n) (equal (expt (imaginary) n) (let ((n (mod n 4))) (cond ((equal n 0) 1) ((equal n 1) (imaginary)) ((equal n 2) -1) (t (- (imaginary))))))) :hints (("Goal" :induct (mod4 n) :in-theory (disable mod expt (imaginary) imaginary)) (and stable-under-simplificationp '(:expand ( (:free (x) (expt x 0)) (:free (x) (expt x 1)) (:free (x) (expt x 2)) (:free (x) (expt x 3)) ))))) ) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm complex-to-imaginary (equal (complex real imag) (+ (rfix real) (* (rfix imag) (imaginary))))) (defthm reduce-complex-coefficient (implies (and (syntaxp (quotep c)) (complex-rationalp c)) (equal (* c x) (+ (* (realpart c) x) (* (imagpart c) (imaginary) x)))) :hints (("Goal" :in-theory (enable equal-complex-to-equal-parts-z)))) ) (in-theory (disable imaginary (imaginary))) (local ;; Note: this theorem was not provable (by linear) prior to loading this book (defthm complex-poly-test (implies (and (acl2-numberp x) (acl2-numberp y) (< 0 (+ (* #C( 1 2) x) (* #C(4 3) y))) (< 0 (+ (* #C(-1 -2) x) (* #C(0 -3) y))) (< 0 (+ (- y) -2)) ) nil) :rule-classes nil) )
[ { "context": ";;; Copyright (c) 2013, James M. Lawrence. All rights reserved.\n;;;\n;;; Redistribution and ", "end": 41, "score": 0.9998252987861633, "start": 24, "tag": "NAME", "value": "James M. Lawrence" }, { "context": " (*auth* (make-instance 'password-auth :password \"hello\")))\n (with-server (host port)\n (with-kern", "end": 3213, "score": 0.9993125200271606, "start": 3208, "tag": "PASSWORD", "value": "hello" }, { "context": "t ((pass (make-instance 'password-auth :password \"world\")))\n (let ((*auth* pass))\n (signa", "end": 3636, "score": 0.9994892477989197, "start": 3631, "tag": "PASSWORD", "value": "world" } ]
lfarm-test/auth-test.lisp
nixz/lfarm
0
;;; Copyright (c) 2013, James M. Lawrence. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials provided ;;; with the distribution. ;;; ;;; * Neither the name of the project nor the names of its ;;; contributors may be used to endorse or promote products derived ;;; from this software without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:lfarm-test) (defclass password-auth () ((password :reader password :initarg :password))) (define-condition password-auth-error (lfarm-common.data-transport:auth-error) () (:report "bad password")) (defmethod lfarm-common.data-transport:initialize-client-stream ((auth password-auth) stream server-name) (declare (ignore server-name)) (info "initializing client stream for auth password") (send-object (password auth) stream) (info "client sent password") (handler-case (ecase (receive-object stream) (:ok (info "client notified that password accepted"))) (end-of-file () (info "client detected that server rejected password") (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:initialize-server-stream ((auth password-auth) stream) (info "initializing server stream for auth password") (cond ((equal (password auth) (receive-object stream)) (info "server accepted password") (send-object :ok stream)) (t (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:send-buffer ((auth password-auth) buffer stream) (call-next-method auth (case (deserialize-buffer buffer) (7 (serialize-to-buffer 8)) (11 (error "11 is not allowed")) (otherwise buffer)) stream)) (base-test auth-test (let ((host *local-host*) (port (next-port)) (*auth* (make-instance 'password-auth :password "hello"))) (with-server (host port) (with-kernel (*kernel* `((,host ,port))) (let ((channel (make-channel))) (submit-task channel #'+ 3 4) ;; 3 + 4 = 8, hooray! (is (= 8 (receive-result channel))) (submit-task channel #'+ 5 6) (signals task-execution-error (receive-result channel)))) (let ((pass (make-instance 'password-auth :password "world"))) (let ((*auth* pass)) (signals kernel-creation-error (make-kernel `((,host ,port))))) (signals kernel-creation-error (make-kernel `((,host ,port)) :auth pass))))))
50494
;;; Copyright (c) 2013, <NAME>. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials provided ;;; with the distribution. ;;; ;;; * Neither the name of the project nor the names of its ;;; contributors may be used to endorse or promote products derived ;;; from this software without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:lfarm-test) (defclass password-auth () ((password :reader password :initarg :password))) (define-condition password-auth-error (lfarm-common.data-transport:auth-error) () (:report "bad password")) (defmethod lfarm-common.data-transport:initialize-client-stream ((auth password-auth) stream server-name) (declare (ignore server-name)) (info "initializing client stream for auth password") (send-object (password auth) stream) (info "client sent password") (handler-case (ecase (receive-object stream) (:ok (info "client notified that password accepted"))) (end-of-file () (info "client detected that server rejected password") (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:initialize-server-stream ((auth password-auth) stream) (info "initializing server stream for auth password") (cond ((equal (password auth) (receive-object stream)) (info "server accepted password") (send-object :ok stream)) (t (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:send-buffer ((auth password-auth) buffer stream) (call-next-method auth (case (deserialize-buffer buffer) (7 (serialize-to-buffer 8)) (11 (error "11 is not allowed")) (otherwise buffer)) stream)) (base-test auth-test (let ((host *local-host*) (port (next-port)) (*auth* (make-instance 'password-auth :password "<PASSWORD>"))) (with-server (host port) (with-kernel (*kernel* `((,host ,port))) (let ((channel (make-channel))) (submit-task channel #'+ 3 4) ;; 3 + 4 = 8, hooray! (is (= 8 (receive-result channel))) (submit-task channel #'+ 5 6) (signals task-execution-error (receive-result channel)))) (let ((pass (make-instance 'password-auth :password "<PASSWORD>"))) (let ((*auth* pass)) (signals kernel-creation-error (make-kernel `((,host ,port))))) (signals kernel-creation-error (make-kernel `((,host ,port)) :auth pass))))))
true
;;; Copyright (c) 2013, PI:NAME:<NAME>END_PI. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials provided ;;; with the distribution. ;;; ;;; * Neither the name of the project nor the names of its ;;; contributors may be used to endorse or promote products derived ;;; from this software without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package #:lfarm-test) (defclass password-auth () ((password :reader password :initarg :password))) (define-condition password-auth-error (lfarm-common.data-transport:auth-error) () (:report "bad password")) (defmethod lfarm-common.data-transport:initialize-client-stream ((auth password-auth) stream server-name) (declare (ignore server-name)) (info "initializing client stream for auth password") (send-object (password auth) stream) (info "client sent password") (handler-case (ecase (receive-object stream) (:ok (info "client notified that password accepted"))) (end-of-file () (info "client detected that server rejected password") (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:initialize-server-stream ((auth password-auth) stream) (info "initializing server stream for auth password") (cond ((equal (password auth) (receive-object stream)) (info "server accepted password") (send-object :ok stream)) (t (error 'password-auth-error))) stream) (defmethod lfarm-common.data-transport:send-buffer ((auth password-auth) buffer stream) (call-next-method auth (case (deserialize-buffer buffer) (7 (serialize-to-buffer 8)) (11 (error "11 is not allowed")) (otherwise buffer)) stream)) (base-test auth-test (let ((host *local-host*) (port (next-port)) (*auth* (make-instance 'password-auth :password "PI:PASSWORD:<PASSWORD>END_PI"))) (with-server (host port) (with-kernel (*kernel* `((,host ,port))) (let ((channel (make-channel))) (submit-task channel #'+ 3 4) ;; 3 + 4 = 8, hooray! (is (= 8 (receive-result channel))) (submit-task channel #'+ 5 6) (signals task-execution-error (receive-result channel)))) (let ((pass (make-instance 'password-auth :password "PI:PASSWORD:<PASSWORD>END_PI"))) (let ((*auth* pass)) (signals kernel-creation-error (make-kernel `((,host ,port))))) (signals kernel-creation-error (make-kernel `((,host ,port)) :auth pass))))))
[ { "context": "e\" \"keysyms\" \"manager\" \"image\" \"resource\"))\n\n\f\n;;; Franz\n\n;;\n;; The following is a suggestion. If you ", "end": 4558, "score": 0.7335304617881775, "start": 4556, "tag": "NAME", "value": "Fr" } ]
prolog/wam_cl/src/clx/defsystem.lsp
nzioki/wam_common_lisp
77
;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; Lowercase: T; -*- ;;; ;;; TEXAS INSTRUMENTS INCORPORATED ;;; P.O. BOX 2909 ;;; AUSTIN, TEXAS 78769 ;;; ;;; Portions Copyright (C) 1987 Texas Instruments Incorporated. ;;; Portions Copyright (C) 1988, 1989 Franz Inc, Berkeley, Ca. ;;; ;;; Permission is granted to any individual or institution to use, copy, modify, ;;; and distribute this software, provided that this complete copyright and ;;; permission notice is maintained, intact, in all copies and supporting ;;; documentation. ;;; ;;; Texas Instruments Incorporated provides this software "as is" without ;;; express or implied warranty. ;;; ;;; Franz Incorporated provides this software "as is" without express or ;;; implied warranty. ;;; #+ features used in this file ;;; clx-ansi-common-lisp ;;; lispm ;;; genera ;;; minima ;;; lucid ;;; lcl3.0 ;;; apollo ;;; kcl ;;; ibcl ;;; excl #+(or Genera Minima) (eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:pushnew :clx-ansi-common-lisp common-lisp:*features*)) #+(and Genera clx-ansi-common-lisp) (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* si:*ansi-common-lisp-readtable*)) #-clx-ansi-common-lisp (lisp:in-package :user) #+clx-ansi-common-lisp (common-lisp:in-package :common-lisp-user) ;;;; Lisp Machines #+(and lispm (not genera)) (global:defsystem CLX (:pathname-default "clx:clx;") (:patchable "clx:patch;" clx-ti) (:initial-status :experimental) (:module package "package") (:module depdefs "depdefs") (:module clx "clx") (:module dependent "dependent") (:module macros "macros") (:module bufmac "bufmac") (:module buffer "buffer") (:module display "display") (:module gcontext "gcontext") (:module requests "requests") (:module input "input") (:module fonts "fonts") (:module graphics "graphics") (:module text "text") (:module attributes "attributes") (:module translate "translate") (:module keysyms "keysyms") (:module manager "manager") (:module image "image") (:module resource "resource") (:module doc "doc") (:compile-load package) (:compile-load depdefs (:fasload package)) (:compile-load clx (:fasload package depdefs)) (:compile-load dependent (:fasload package depdefs clx)) ;; Macros only needed for compilation (:skip :compile-load macros (:fasload package depdefs clx dependent)) ;; Bufmac only needed for compilation (:skip :compile-load bufmac (:fasload package depdefs clx dependent macros)) (:compile-load buffer (:fasload package depdefs clx dependent macros bufmac)) (:compile-load display (:fasload package depdefs clx dependent macros bufmac buffer)) (:compile-load gcontext (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load input (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load requests (:fasload package depdefs clx dependent macros bufmac buffer display input)) (:compile-load fonts (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load graphics (:fasload package depdefs clx dependent macros fonts bufmac buffer display fonts)) (:compile-load text (:fasload package depdefs clx dependent macros fonts bufmac buffer display gcontext fonts)) (:compile-load-init attributes (dependent) (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load translate (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load keysyms (:fasload package depdefs clx dependent macros bufmac buffer display translate)) (:compile-load manager (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load image (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load resource (:fasload package depdefs clx dependent macros bufmac buffer display)) (:auxiliary doc) ) ;;; Symbolics Lisp Machines #+Genera (scl:defsystem CLX (:default-pathname "SYS:X11;CLX;" :pretty-name "CLX" :maintaining-sites (:scrc) :distribute-sources t :distribute-binaries t :source-category :basic) (:module doc ("doc") (:type :lisp-example)) (:serial "package" "depdefs" "generalock" "clx" "dependent" "macros" "bufmac" "buffer" "display" "gcontext" "input" "requests" "fonts" "graphics" "text" "attributes" "translate" "keysyms" "manager" "image" "resource")) ;;; Franz ;; ;; The following is a suggestion. If you comment out this form be ;; prepared for possible deadlock, since no interrupts will be recognized ;; while reading from the X socket if the scheduler is not running. ;; #+excl (setq compiler::generate-interrupt-checks-switch (compile nil '(lambda (safety size speed &optional debug) (declare (ignore size debug)) (or (< speed 3) (> safety 0))))) ;;; Allegro #+allegro (excl:defsystem :clx () |package| (|excldep| :load-before-compile (|package|) :recompile-on (|package|)) (|depdefs| :load-before-compile (|package| |excldep|) :recompile-on (|excldep|)) (|clx| :load-before-compile (|package| |excldep| |depdefs|) :recompile-on (|package| |excldep| |depdefs|)) (|dependent| :load-before-compile (|package| |excldep| |depdefs| |clx|) :recompile-on (|clx|)) (|exclcmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent|) :recompile-on (|dependent|)) (|macros| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac|) :recompile-on (|exclcmac|)) (|bufmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros|) :recompile-on (|macros|)) (|buffer| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac|) :recompile-on (|bufmac|)) (|display| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer|) :recompile-on (|buffer|)) (|gcontext| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|input| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|requests| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |input|) :recompile-on (|display|)) (|fonts| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|graphics| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |fonts|) :recompile-on (|fonts|)) (|text| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |gcontext| |fonts|) :recompile-on (|gcontext| |fonts|) :load-after (|translate|)) ;; The above line gets around a compiler macro expansion bug. (|attributes| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|translate| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |text|) :recompile-on (|display|)) (|keysyms| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |translate|) :recompile-on (|translate|)) (|manager| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|image| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ;; Don't know if l-b-c list is correct. XX (|resource| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ) #+allegro (excl:defsystem :clx-debug (:default-pathname "debug/" :needed-systems (:clx) :load-before-compile (:clx)) |describe| |keytrans| |trace| |util|) ;;;; Compile CLX ;;; COMPILE-CLX compiles the lisp source files and loads the binaries. ;;; It goes to some trouble to let the source files be in one directory ;;; and the binary files in another. Thus the same set of sources can ;;; be used for different machines and/or lisp systems. It also allows ;;; you to supply explicit extensions, so source files do not have to ;;; be renamed to fit into the naming conventions of an implementation. ;;; For example, ;;; (compile-clx "*.lisp" "machine/") ;;; compiles source files from the connected directory and puts them ;;; into the "machine" subdirectory. You can then load CLX out of the ;;; machine directory. ;;; The code has no knowledge of the source file types (eg, ".l" or ;;; ".lisp") or of the binary file types (eg, ".b" or ".sbin"). Calling ;;; compile-file and load with a file type of NIL usually sorts things ;;; out correctly, but you may have to explicitly give the source and ;;; binary file types. ;;; An attempt at compiling the C language sources is also made, ;;; but you may have to set different compiler switches ;;; should be. If it doesn't do the right thing, then do ;;; (compile-clx "" "" :compile-c NIL) ;;; to prevent the compilation. ;;; compilation notes ;;; lucid2.0/hp9000s300 ;;; must uudecode the file make-sequence-patch.uu #+(or lucid kcl ibcl) (defun clx-foreign-files (binary-path) #+(and lucid (not lcl3.0) (or mc68000 mc68020)) (load (merge-pathnames "make-sequence-patch" binary-path)) #+(and lucid apollo) (lucid::load-foreign-file (namestring (merge-pathnames "socket" binary-path)) :preserve-pathname t) #+(and lucid (not apollo)) (lucid::load-foreign-files (list (namestring (merge-pathnames "socket.o" binary-path))) '("-lc")) #+(or kcl ibcl) (progn (let ((pathname (merge-pathnames "sockcl.o" binary-path)) (options (concatenate 'string (namestring (merge-pathnames "socket.o" binary-path)) " -lc"))) (format t "~&Faslinking ~A with ~A.~%" pathname options) (si:faslink (namestring pathname) options) (format t "~&Finished faslinking ~A.~%" pathname))) ) #-(or lispm allegro) (defun compile-clx (&optional (source-pathname-defaults "") (binary-pathname-defaults "") &key (compile-c t)) ;; The pathname-defaults above might only be strings, so coerce them ;; to pathnames. Build a default binary path with every component ;; of the source except the file type. This should prevent ;; (compile-clx "*.lisp") from destroying source files. (let* ((source-path (pathname source-pathname-defaults)) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) #+clx-ansi-common-lisp (*compile-verbose* t) (*load-verbose* t)) ;; Make sure source-path and binary-path file types are distinct so ;; we don't accidently overwrite the source files. NIL should be an ;; ok type, but anything else spells trouble. (if (and (equal (pathname-type source-path) (pathname-type binary-path)) (not (null (pathname-type binary-path)))) (error "Source and binary pathname defaults have same type ~s ~s" source-path binary-path)) (format t "~&;;; Default paths: ~s ~s~%" source-path binary-path) ;; In lucid make sure we're using the compiler in production mode. #+lcl3.0 (progn (unless (member :pqc *features*) (cerror "Go ahead anyway." "Lucid's production mode compiler must be loaded to compile CLX.")) (proclaim '(optimize (speed 3) (safety 1) (space 0) (compilation-speed 0)))) (labels ((compile-lisp (filename) (let ((source (merge-pathnames filename source-path)) (binary (merge-pathnames filename binary-path))) ;; If the source and binary pathnames are the same, ;; then don't supply an output file just to be sure ;; compile-file defaults correctly. #+(or kcl ibcl) (load source) (if (equal source binary) (compile-file source) (compile-file source :output-file binary)) binary)) (compile-and-load (filename) (load (compile-lisp filename))) #+(or lucid kcl ibcl) (compile-c (filename) (let* ((c-filename (concatenate 'string filename ".c")) (o-filename (concatenate 'string filename ".o")) (src (merge-pathnames c-filename source-path)) (obj (merge-pathnames o-filename binary-path)) (args (list "-c" (namestring src) "-o" (namestring obj) #+mips "-G 0" #+(or hp sysv) "-DSYSV" #+(and mips (not dec)) "-I/usr/include/bsd" #-(and mips (not dec)) "-DUNIXCONN" #+(and lucid pa) "-DHPUX -DHPUX7.0" ))) (format t ";;; cc~{ ~A~}~%" args) (unless (zerop #+lucid (multiple-value-bind (iostream estream exitstatus pid) ;; in 2.0, run-program is exported from system: ;; in 3.0, run-program is exported from lcl: ;; system inheirits lcl (system::run-program "cc" :arguments args) (declare (ignore iostream estream pid)) exitstatus) #+(or kcl ibcl) (system (format nil "cc~{ ~A~}" args))) (error "Compile of ~A failed." src))))) ;; Now compile and load all the files. ;; Defer compiler warnings until everything's compiled, if possible. (#+clx-ansi-common-lisp with-compilation-unit #+lcl3.0 lucid::with-deferred-warnings #-(or lcl3.0 clx-ansi-common-lisp) progn () (compile-and-load "package") #+(or lucid kcl ibcl) (when compile-c (compile-c "socket")) #+(or kcl ibcl) (compile-lisp "sockcl") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (compile-and-load "excldep") (compile-and-load "depdefs") (compile-and-load "clx") (compile-and-load "dependent") #+excl (compile-and-load "exclcmac") ; these are just macros (compile-and-load "macros") ; these are just macros (compile-and-load "bufmac") ; these are just macros (compile-and-load "buffer") (compile-and-load "display") (compile-and-load "gcontext") (compile-and-load "input") (compile-and-load "requests") (compile-and-load "fonts") (compile-and-load "graphics") (compile-and-load "text") (compile-and-load "attributes") (compile-and-load "translate") (compile-and-load "keysyms") (compile-and-load "manager") (compile-and-load "image") (compile-and-load "resource") )))) ;;;; Load CLX ;;; This procedure loads the binaries for CLX. All of the binaries ;;; should be in the same directory, so setting the default pathname ;;; should point load to the right place. ;;; You should have a module definition somewhere so the require/provide ;;; mechanism can avoid reloading CLX. In an ideal world, somebody would ;;; just put ;;; (REQUIRE 'CLX) ;;; in their file (some implementations don't have a central registry for ;;; modules, so a pathname needs to be supplied). ;;; The REQUIRE should find a file that does ;;; (IN-PACKAGE 'XLIB :USE '(LISP)) ;;; (PROVIDE 'CLX) ;;; (LOAD <clx-defsystem-file>) ;;; (LOAD-CLX <binary-specific-clx-directory>) #-(or lispm allegro) (defun load-clx (&optional (binary-pathname-defaults "") &key (macrosp nil)) (let* ((source-path (pathname "")) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) (*load-verbose* t)) (flet ((load-binary (filename) (let ((binary (merge-pathnames filename binary-path))) (load binary)))) (load-binary "package") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (load-binary "excldep") (load-binary "depdefs") (load-binary "clx") (load-binary "dependent") (when macrosp #+excl (load-binary "exclcmac") (load-binary "macros") (load-binary "bufmac")) (load-binary "buffer") (load-binary "display") (load-binary "gcontext") (load-binary "input") (load-binary "requests") (load-binary "fonts") (load-binary "graphics") (load-binary "text") (load-binary "attributes") (load-binary "translate") (load-binary "keysyms") (load-binary "manager") (load-binary "image") (load-binary "resource") )))
39681
;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; Lowercase: T; -*- ;;; ;;; TEXAS INSTRUMENTS INCORPORATED ;;; P.O. BOX 2909 ;;; AUSTIN, TEXAS 78769 ;;; ;;; Portions Copyright (C) 1987 Texas Instruments Incorporated. ;;; Portions Copyright (C) 1988, 1989 Franz Inc, Berkeley, Ca. ;;; ;;; Permission is granted to any individual or institution to use, copy, modify, ;;; and distribute this software, provided that this complete copyright and ;;; permission notice is maintained, intact, in all copies and supporting ;;; documentation. ;;; ;;; Texas Instruments Incorporated provides this software "as is" without ;;; express or implied warranty. ;;; ;;; Franz Incorporated provides this software "as is" without express or ;;; implied warranty. ;;; #+ features used in this file ;;; clx-ansi-common-lisp ;;; lispm ;;; genera ;;; minima ;;; lucid ;;; lcl3.0 ;;; apollo ;;; kcl ;;; ibcl ;;; excl #+(or Genera Minima) (eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:pushnew :clx-ansi-common-lisp common-lisp:*features*)) #+(and Genera clx-ansi-common-lisp) (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* si:*ansi-common-lisp-readtable*)) #-clx-ansi-common-lisp (lisp:in-package :user) #+clx-ansi-common-lisp (common-lisp:in-package :common-lisp-user) ;;;; Lisp Machines #+(and lispm (not genera)) (global:defsystem CLX (:pathname-default "clx:clx;") (:patchable "clx:patch;" clx-ti) (:initial-status :experimental) (:module package "package") (:module depdefs "depdefs") (:module clx "clx") (:module dependent "dependent") (:module macros "macros") (:module bufmac "bufmac") (:module buffer "buffer") (:module display "display") (:module gcontext "gcontext") (:module requests "requests") (:module input "input") (:module fonts "fonts") (:module graphics "graphics") (:module text "text") (:module attributes "attributes") (:module translate "translate") (:module keysyms "keysyms") (:module manager "manager") (:module image "image") (:module resource "resource") (:module doc "doc") (:compile-load package) (:compile-load depdefs (:fasload package)) (:compile-load clx (:fasload package depdefs)) (:compile-load dependent (:fasload package depdefs clx)) ;; Macros only needed for compilation (:skip :compile-load macros (:fasload package depdefs clx dependent)) ;; Bufmac only needed for compilation (:skip :compile-load bufmac (:fasload package depdefs clx dependent macros)) (:compile-load buffer (:fasload package depdefs clx dependent macros bufmac)) (:compile-load display (:fasload package depdefs clx dependent macros bufmac buffer)) (:compile-load gcontext (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load input (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load requests (:fasload package depdefs clx dependent macros bufmac buffer display input)) (:compile-load fonts (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load graphics (:fasload package depdefs clx dependent macros fonts bufmac buffer display fonts)) (:compile-load text (:fasload package depdefs clx dependent macros fonts bufmac buffer display gcontext fonts)) (:compile-load-init attributes (dependent) (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load translate (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load keysyms (:fasload package depdefs clx dependent macros bufmac buffer display translate)) (:compile-load manager (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load image (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load resource (:fasload package depdefs clx dependent macros bufmac buffer display)) (:auxiliary doc) ) ;;; Symbolics Lisp Machines #+Genera (scl:defsystem CLX (:default-pathname "SYS:X11;CLX;" :pretty-name "CLX" :maintaining-sites (:scrc) :distribute-sources t :distribute-binaries t :source-category :basic) (:module doc ("doc") (:type :lisp-example)) (:serial "package" "depdefs" "generalock" "clx" "dependent" "macros" "bufmac" "buffer" "display" "gcontext" "input" "requests" "fonts" "graphics" "text" "attributes" "translate" "keysyms" "manager" "image" "resource")) ;;; <NAME>anz ;; ;; The following is a suggestion. If you comment out this form be ;; prepared for possible deadlock, since no interrupts will be recognized ;; while reading from the X socket if the scheduler is not running. ;; #+excl (setq compiler::generate-interrupt-checks-switch (compile nil '(lambda (safety size speed &optional debug) (declare (ignore size debug)) (or (< speed 3) (> safety 0))))) ;;; Allegro #+allegro (excl:defsystem :clx () |package| (|excldep| :load-before-compile (|package|) :recompile-on (|package|)) (|depdefs| :load-before-compile (|package| |excldep|) :recompile-on (|excldep|)) (|clx| :load-before-compile (|package| |excldep| |depdefs|) :recompile-on (|package| |excldep| |depdefs|)) (|dependent| :load-before-compile (|package| |excldep| |depdefs| |clx|) :recompile-on (|clx|)) (|exclcmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent|) :recompile-on (|dependent|)) (|macros| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac|) :recompile-on (|exclcmac|)) (|bufmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros|) :recompile-on (|macros|)) (|buffer| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac|) :recompile-on (|bufmac|)) (|display| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer|) :recompile-on (|buffer|)) (|gcontext| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|input| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|requests| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |input|) :recompile-on (|display|)) (|fonts| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|graphics| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |fonts|) :recompile-on (|fonts|)) (|text| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |gcontext| |fonts|) :recompile-on (|gcontext| |fonts|) :load-after (|translate|)) ;; The above line gets around a compiler macro expansion bug. (|attributes| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|translate| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |text|) :recompile-on (|display|)) (|keysyms| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |translate|) :recompile-on (|translate|)) (|manager| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|image| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ;; Don't know if l-b-c list is correct. XX (|resource| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ) #+allegro (excl:defsystem :clx-debug (:default-pathname "debug/" :needed-systems (:clx) :load-before-compile (:clx)) |describe| |keytrans| |trace| |util|) ;;;; Compile CLX ;;; COMPILE-CLX compiles the lisp source files and loads the binaries. ;;; It goes to some trouble to let the source files be in one directory ;;; and the binary files in another. Thus the same set of sources can ;;; be used for different machines and/or lisp systems. It also allows ;;; you to supply explicit extensions, so source files do not have to ;;; be renamed to fit into the naming conventions of an implementation. ;;; For example, ;;; (compile-clx "*.lisp" "machine/") ;;; compiles source files from the connected directory and puts them ;;; into the "machine" subdirectory. You can then load CLX out of the ;;; machine directory. ;;; The code has no knowledge of the source file types (eg, ".l" or ;;; ".lisp") or of the binary file types (eg, ".b" or ".sbin"). Calling ;;; compile-file and load with a file type of NIL usually sorts things ;;; out correctly, but you may have to explicitly give the source and ;;; binary file types. ;;; An attempt at compiling the C language sources is also made, ;;; but you may have to set different compiler switches ;;; should be. If it doesn't do the right thing, then do ;;; (compile-clx "" "" :compile-c NIL) ;;; to prevent the compilation. ;;; compilation notes ;;; lucid2.0/hp9000s300 ;;; must uudecode the file make-sequence-patch.uu #+(or lucid kcl ibcl) (defun clx-foreign-files (binary-path) #+(and lucid (not lcl3.0) (or mc68000 mc68020)) (load (merge-pathnames "make-sequence-patch" binary-path)) #+(and lucid apollo) (lucid::load-foreign-file (namestring (merge-pathnames "socket" binary-path)) :preserve-pathname t) #+(and lucid (not apollo)) (lucid::load-foreign-files (list (namestring (merge-pathnames "socket.o" binary-path))) '("-lc")) #+(or kcl ibcl) (progn (let ((pathname (merge-pathnames "sockcl.o" binary-path)) (options (concatenate 'string (namestring (merge-pathnames "socket.o" binary-path)) " -lc"))) (format t "~&Faslinking ~A with ~A.~%" pathname options) (si:faslink (namestring pathname) options) (format t "~&Finished faslinking ~A.~%" pathname))) ) #-(or lispm allegro) (defun compile-clx (&optional (source-pathname-defaults "") (binary-pathname-defaults "") &key (compile-c t)) ;; The pathname-defaults above might only be strings, so coerce them ;; to pathnames. Build a default binary path with every component ;; of the source except the file type. This should prevent ;; (compile-clx "*.lisp") from destroying source files. (let* ((source-path (pathname source-pathname-defaults)) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) #+clx-ansi-common-lisp (*compile-verbose* t) (*load-verbose* t)) ;; Make sure source-path and binary-path file types are distinct so ;; we don't accidently overwrite the source files. NIL should be an ;; ok type, but anything else spells trouble. (if (and (equal (pathname-type source-path) (pathname-type binary-path)) (not (null (pathname-type binary-path)))) (error "Source and binary pathname defaults have same type ~s ~s" source-path binary-path)) (format t "~&;;; Default paths: ~s ~s~%" source-path binary-path) ;; In lucid make sure we're using the compiler in production mode. #+lcl3.0 (progn (unless (member :pqc *features*) (cerror "Go ahead anyway." "Lucid's production mode compiler must be loaded to compile CLX.")) (proclaim '(optimize (speed 3) (safety 1) (space 0) (compilation-speed 0)))) (labels ((compile-lisp (filename) (let ((source (merge-pathnames filename source-path)) (binary (merge-pathnames filename binary-path))) ;; If the source and binary pathnames are the same, ;; then don't supply an output file just to be sure ;; compile-file defaults correctly. #+(or kcl ibcl) (load source) (if (equal source binary) (compile-file source) (compile-file source :output-file binary)) binary)) (compile-and-load (filename) (load (compile-lisp filename))) #+(or lucid kcl ibcl) (compile-c (filename) (let* ((c-filename (concatenate 'string filename ".c")) (o-filename (concatenate 'string filename ".o")) (src (merge-pathnames c-filename source-path)) (obj (merge-pathnames o-filename binary-path)) (args (list "-c" (namestring src) "-o" (namestring obj) #+mips "-G 0" #+(or hp sysv) "-DSYSV" #+(and mips (not dec)) "-I/usr/include/bsd" #-(and mips (not dec)) "-DUNIXCONN" #+(and lucid pa) "-DHPUX -DHPUX7.0" ))) (format t ";;; cc~{ ~A~}~%" args) (unless (zerop #+lucid (multiple-value-bind (iostream estream exitstatus pid) ;; in 2.0, run-program is exported from system: ;; in 3.0, run-program is exported from lcl: ;; system inheirits lcl (system::run-program "cc" :arguments args) (declare (ignore iostream estream pid)) exitstatus) #+(or kcl ibcl) (system (format nil "cc~{ ~A~}" args))) (error "Compile of ~A failed." src))))) ;; Now compile and load all the files. ;; Defer compiler warnings until everything's compiled, if possible. (#+clx-ansi-common-lisp with-compilation-unit #+lcl3.0 lucid::with-deferred-warnings #-(or lcl3.0 clx-ansi-common-lisp) progn () (compile-and-load "package") #+(or lucid kcl ibcl) (when compile-c (compile-c "socket")) #+(or kcl ibcl) (compile-lisp "sockcl") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (compile-and-load "excldep") (compile-and-load "depdefs") (compile-and-load "clx") (compile-and-load "dependent") #+excl (compile-and-load "exclcmac") ; these are just macros (compile-and-load "macros") ; these are just macros (compile-and-load "bufmac") ; these are just macros (compile-and-load "buffer") (compile-and-load "display") (compile-and-load "gcontext") (compile-and-load "input") (compile-and-load "requests") (compile-and-load "fonts") (compile-and-load "graphics") (compile-and-load "text") (compile-and-load "attributes") (compile-and-load "translate") (compile-and-load "keysyms") (compile-and-load "manager") (compile-and-load "image") (compile-and-load "resource") )))) ;;;; Load CLX ;;; This procedure loads the binaries for CLX. All of the binaries ;;; should be in the same directory, so setting the default pathname ;;; should point load to the right place. ;;; You should have a module definition somewhere so the require/provide ;;; mechanism can avoid reloading CLX. In an ideal world, somebody would ;;; just put ;;; (REQUIRE 'CLX) ;;; in their file (some implementations don't have a central registry for ;;; modules, so a pathname needs to be supplied). ;;; The REQUIRE should find a file that does ;;; (IN-PACKAGE 'XLIB :USE '(LISP)) ;;; (PROVIDE 'CLX) ;;; (LOAD <clx-defsystem-file>) ;;; (LOAD-CLX <binary-specific-clx-directory>) #-(or lispm allegro) (defun load-clx (&optional (binary-pathname-defaults "") &key (macrosp nil)) (let* ((source-path (pathname "")) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) (*load-verbose* t)) (flet ((load-binary (filename) (let ((binary (merge-pathnames filename binary-path))) (load binary)))) (load-binary "package") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (load-binary "excldep") (load-binary "depdefs") (load-binary "clx") (load-binary "dependent") (when macrosp #+excl (load-binary "exclcmac") (load-binary "macros") (load-binary "bufmac")) (load-binary "buffer") (load-binary "display") (load-binary "gcontext") (load-binary "input") (load-binary "requests") (load-binary "fonts") (load-binary "graphics") (load-binary "text") (load-binary "attributes") (load-binary "translate") (load-binary "keysyms") (load-binary "manager") (load-binary "image") (load-binary "resource") )))
true
;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; Lowercase: T; -*- ;;; ;;; TEXAS INSTRUMENTS INCORPORATED ;;; P.O. BOX 2909 ;;; AUSTIN, TEXAS 78769 ;;; ;;; Portions Copyright (C) 1987 Texas Instruments Incorporated. ;;; Portions Copyright (C) 1988, 1989 Franz Inc, Berkeley, Ca. ;;; ;;; Permission is granted to any individual or institution to use, copy, modify, ;;; and distribute this software, provided that this complete copyright and ;;; permission notice is maintained, intact, in all copies and supporting ;;; documentation. ;;; ;;; Texas Instruments Incorporated provides this software "as is" without ;;; express or implied warranty. ;;; ;;; Franz Incorporated provides this software "as is" without express or ;;; implied warranty. ;;; #+ features used in this file ;;; clx-ansi-common-lisp ;;; lispm ;;; genera ;;; minima ;;; lucid ;;; lcl3.0 ;;; apollo ;;; kcl ;;; ibcl ;;; excl #+(or Genera Minima) (eval-when (:compile-toplevel :load-toplevel :execute) (common-lisp:pushnew :clx-ansi-common-lisp common-lisp:*features*)) #+(and Genera clx-ansi-common-lisp) (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* si:*ansi-common-lisp-readtable*)) #-clx-ansi-common-lisp (lisp:in-package :user) #+clx-ansi-common-lisp (common-lisp:in-package :common-lisp-user) ;;;; Lisp Machines #+(and lispm (not genera)) (global:defsystem CLX (:pathname-default "clx:clx;") (:patchable "clx:patch;" clx-ti) (:initial-status :experimental) (:module package "package") (:module depdefs "depdefs") (:module clx "clx") (:module dependent "dependent") (:module macros "macros") (:module bufmac "bufmac") (:module buffer "buffer") (:module display "display") (:module gcontext "gcontext") (:module requests "requests") (:module input "input") (:module fonts "fonts") (:module graphics "graphics") (:module text "text") (:module attributes "attributes") (:module translate "translate") (:module keysyms "keysyms") (:module manager "manager") (:module image "image") (:module resource "resource") (:module doc "doc") (:compile-load package) (:compile-load depdefs (:fasload package)) (:compile-load clx (:fasload package depdefs)) (:compile-load dependent (:fasload package depdefs clx)) ;; Macros only needed for compilation (:skip :compile-load macros (:fasload package depdefs clx dependent)) ;; Bufmac only needed for compilation (:skip :compile-load bufmac (:fasload package depdefs clx dependent macros)) (:compile-load buffer (:fasload package depdefs clx dependent macros bufmac)) (:compile-load display (:fasload package depdefs clx dependent macros bufmac buffer)) (:compile-load gcontext (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load input (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load requests (:fasload package depdefs clx dependent macros bufmac buffer display input)) (:compile-load fonts (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load graphics (:fasload package depdefs clx dependent macros fonts bufmac buffer display fonts)) (:compile-load text (:fasload package depdefs clx dependent macros fonts bufmac buffer display gcontext fonts)) (:compile-load-init attributes (dependent) (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load translate (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load keysyms (:fasload package depdefs clx dependent macros bufmac buffer display translate)) (:compile-load manager (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load image (:fasload package depdefs clx dependent macros bufmac buffer display)) (:compile-load resource (:fasload package depdefs clx dependent macros bufmac buffer display)) (:auxiliary doc) ) ;;; Symbolics Lisp Machines #+Genera (scl:defsystem CLX (:default-pathname "SYS:X11;CLX;" :pretty-name "CLX" :maintaining-sites (:scrc) :distribute-sources t :distribute-binaries t :source-category :basic) (:module doc ("doc") (:type :lisp-example)) (:serial "package" "depdefs" "generalock" "clx" "dependent" "macros" "bufmac" "buffer" "display" "gcontext" "input" "requests" "fonts" "graphics" "text" "attributes" "translate" "keysyms" "manager" "image" "resource")) ;;; PI:NAME:<NAME>END_PIanz ;; ;; The following is a suggestion. If you comment out this form be ;; prepared for possible deadlock, since no interrupts will be recognized ;; while reading from the X socket if the scheduler is not running. ;; #+excl (setq compiler::generate-interrupt-checks-switch (compile nil '(lambda (safety size speed &optional debug) (declare (ignore size debug)) (or (< speed 3) (> safety 0))))) ;;; Allegro #+allegro (excl:defsystem :clx () |package| (|excldep| :load-before-compile (|package|) :recompile-on (|package|)) (|depdefs| :load-before-compile (|package| |excldep|) :recompile-on (|excldep|)) (|clx| :load-before-compile (|package| |excldep| |depdefs|) :recompile-on (|package| |excldep| |depdefs|)) (|dependent| :load-before-compile (|package| |excldep| |depdefs| |clx|) :recompile-on (|clx|)) (|exclcmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent|) :recompile-on (|dependent|)) (|macros| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac|) :recompile-on (|exclcmac|)) (|bufmac| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros|) :recompile-on (|macros|)) (|buffer| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac|) :recompile-on (|bufmac|)) (|display| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer|) :recompile-on (|buffer|)) (|gcontext| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|input| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|requests| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |input|) :recompile-on (|display|)) (|fonts| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|graphics| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |fonts|) :recompile-on (|fonts|)) (|text| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |gcontext| |fonts|) :recompile-on (|gcontext| |fonts|) :load-after (|translate|)) ;; The above line gets around a compiler macro expansion bug. (|attributes| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|translate| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |text|) :recompile-on (|display|)) (|keysyms| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display| |translate|) :recompile-on (|translate|)) (|manager| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) (|image| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ;; Don't know if l-b-c list is correct. XX (|resource| :load-before-compile (|package| |excldep| |depdefs| |clx| |dependent| |exclcmac| |macros| |bufmac| |buffer| |display|) :recompile-on (|display|)) ) #+allegro (excl:defsystem :clx-debug (:default-pathname "debug/" :needed-systems (:clx) :load-before-compile (:clx)) |describe| |keytrans| |trace| |util|) ;;;; Compile CLX ;;; COMPILE-CLX compiles the lisp source files and loads the binaries. ;;; It goes to some trouble to let the source files be in one directory ;;; and the binary files in another. Thus the same set of sources can ;;; be used for different machines and/or lisp systems. It also allows ;;; you to supply explicit extensions, so source files do not have to ;;; be renamed to fit into the naming conventions of an implementation. ;;; For example, ;;; (compile-clx "*.lisp" "machine/") ;;; compiles source files from the connected directory and puts them ;;; into the "machine" subdirectory. You can then load CLX out of the ;;; machine directory. ;;; The code has no knowledge of the source file types (eg, ".l" or ;;; ".lisp") or of the binary file types (eg, ".b" or ".sbin"). Calling ;;; compile-file and load with a file type of NIL usually sorts things ;;; out correctly, but you may have to explicitly give the source and ;;; binary file types. ;;; An attempt at compiling the C language sources is also made, ;;; but you may have to set different compiler switches ;;; should be. If it doesn't do the right thing, then do ;;; (compile-clx "" "" :compile-c NIL) ;;; to prevent the compilation. ;;; compilation notes ;;; lucid2.0/hp9000s300 ;;; must uudecode the file make-sequence-patch.uu #+(or lucid kcl ibcl) (defun clx-foreign-files (binary-path) #+(and lucid (not lcl3.0) (or mc68000 mc68020)) (load (merge-pathnames "make-sequence-patch" binary-path)) #+(and lucid apollo) (lucid::load-foreign-file (namestring (merge-pathnames "socket" binary-path)) :preserve-pathname t) #+(and lucid (not apollo)) (lucid::load-foreign-files (list (namestring (merge-pathnames "socket.o" binary-path))) '("-lc")) #+(or kcl ibcl) (progn (let ((pathname (merge-pathnames "sockcl.o" binary-path)) (options (concatenate 'string (namestring (merge-pathnames "socket.o" binary-path)) " -lc"))) (format t "~&Faslinking ~A with ~A.~%" pathname options) (si:faslink (namestring pathname) options) (format t "~&Finished faslinking ~A.~%" pathname))) ) #-(or lispm allegro) (defun compile-clx (&optional (source-pathname-defaults "") (binary-pathname-defaults "") &key (compile-c t)) ;; The pathname-defaults above might only be strings, so coerce them ;; to pathnames. Build a default binary path with every component ;; of the source except the file type. This should prevent ;; (compile-clx "*.lisp") from destroying source files. (let* ((source-path (pathname source-pathname-defaults)) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) #+clx-ansi-common-lisp (*compile-verbose* t) (*load-verbose* t)) ;; Make sure source-path and binary-path file types are distinct so ;; we don't accidently overwrite the source files. NIL should be an ;; ok type, but anything else spells trouble. (if (and (equal (pathname-type source-path) (pathname-type binary-path)) (not (null (pathname-type binary-path)))) (error "Source and binary pathname defaults have same type ~s ~s" source-path binary-path)) (format t "~&;;; Default paths: ~s ~s~%" source-path binary-path) ;; In lucid make sure we're using the compiler in production mode. #+lcl3.0 (progn (unless (member :pqc *features*) (cerror "Go ahead anyway." "Lucid's production mode compiler must be loaded to compile CLX.")) (proclaim '(optimize (speed 3) (safety 1) (space 0) (compilation-speed 0)))) (labels ((compile-lisp (filename) (let ((source (merge-pathnames filename source-path)) (binary (merge-pathnames filename binary-path))) ;; If the source and binary pathnames are the same, ;; then don't supply an output file just to be sure ;; compile-file defaults correctly. #+(or kcl ibcl) (load source) (if (equal source binary) (compile-file source) (compile-file source :output-file binary)) binary)) (compile-and-load (filename) (load (compile-lisp filename))) #+(or lucid kcl ibcl) (compile-c (filename) (let* ((c-filename (concatenate 'string filename ".c")) (o-filename (concatenate 'string filename ".o")) (src (merge-pathnames c-filename source-path)) (obj (merge-pathnames o-filename binary-path)) (args (list "-c" (namestring src) "-o" (namestring obj) #+mips "-G 0" #+(or hp sysv) "-DSYSV" #+(and mips (not dec)) "-I/usr/include/bsd" #-(and mips (not dec)) "-DUNIXCONN" #+(and lucid pa) "-DHPUX -DHPUX7.0" ))) (format t ";;; cc~{ ~A~}~%" args) (unless (zerop #+lucid (multiple-value-bind (iostream estream exitstatus pid) ;; in 2.0, run-program is exported from system: ;; in 3.0, run-program is exported from lcl: ;; system inheirits lcl (system::run-program "cc" :arguments args) (declare (ignore iostream estream pid)) exitstatus) #+(or kcl ibcl) (system (format nil "cc~{ ~A~}" args))) (error "Compile of ~A failed." src))))) ;; Now compile and load all the files. ;; Defer compiler warnings until everything's compiled, if possible. (#+clx-ansi-common-lisp with-compilation-unit #+lcl3.0 lucid::with-deferred-warnings #-(or lcl3.0 clx-ansi-common-lisp) progn () (compile-and-load "package") #+(or lucid kcl ibcl) (when compile-c (compile-c "socket")) #+(or kcl ibcl) (compile-lisp "sockcl") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (compile-and-load "excldep") (compile-and-load "depdefs") (compile-and-load "clx") (compile-and-load "dependent") #+excl (compile-and-load "exclcmac") ; these are just macros (compile-and-load "macros") ; these are just macros (compile-and-load "bufmac") ; these are just macros (compile-and-load "buffer") (compile-and-load "display") (compile-and-load "gcontext") (compile-and-load "input") (compile-and-load "requests") (compile-and-load "fonts") (compile-and-load "graphics") (compile-and-load "text") (compile-and-load "attributes") (compile-and-load "translate") (compile-and-load "keysyms") (compile-and-load "manager") (compile-and-load "image") (compile-and-load "resource") )))) ;;;; Load CLX ;;; This procedure loads the binaries for CLX. All of the binaries ;;; should be in the same directory, so setting the default pathname ;;; should point load to the right place. ;;; You should have a module definition somewhere so the require/provide ;;; mechanism can avoid reloading CLX. In an ideal world, somebody would ;;; just put ;;; (REQUIRE 'CLX) ;;; in their file (some implementations don't have a central registry for ;;; modules, so a pathname needs to be supplied). ;;; The REQUIRE should find a file that does ;;; (IN-PACKAGE 'XLIB :USE '(LISP)) ;;; (PROVIDE 'CLX) ;;; (LOAD <clx-defsystem-file>) ;;; (LOAD-CLX <binary-specific-clx-directory>) #-(or lispm allegro) (defun load-clx (&optional (binary-pathname-defaults "") &key (macrosp nil)) (let* ((source-path (pathname "")) (path (make-pathname :host (pathname-host source-path) :device (pathname-device source-path) :directory (pathname-directory source-path) :name (pathname-name source-path) :type nil :version (pathname-version source-path))) (binary-path (merge-pathnames binary-pathname-defaults path)) (*load-verbose* t)) (flet ((load-binary (filename) (let ((binary (merge-pathnames filename binary-path))) (load binary)))) (load-binary "package") #+(or lucid kcl ibcl) (clx-foreign-files binary-path) #+excl (load-binary "excldep") (load-binary "depdefs") (load-binary "clx") (load-binary "dependent") (when macrosp #+excl (load-binary "exclcmac") (load-binary "macros") (load-binary "bufmac")) (load-binary "buffer") (load-binary "display") (load-binary "gcontext") (load-binary "input") (load-binary "requests") (load-binary "fonts") (load-binary "graphics") (load-binary "text") (load-binary "attributes") (load-binary "translate") (load-binary "keysyms") (load-binary "manager") (load-binary "image") (load-binary "resource") )))
[ { "context": "il address to:\n;;; CommonLoops Coordinator\n;;; Xerox PARC\n;;; 3333 Coyote Hill Rd.\n;;; Palo Alto, CA 94", "end": 859, "score": 0.9593791961669922, "start": 849, "tag": "NAME", "value": "Xerox PARC" }, { "context": " Palo Alto, CA 94304\n;;; (or send Arpanet mail to [email protected])\n;;;\n;;; Suggestions, comments and requests for i", "end": 979, "score": 0.999211847782135, "start": 942, "tag": "EMAIL", "value": "[email protected]" } ]
prolog/wam_cl/src/pcl/dlap.lisp
nzioki/wam_common_lisp
77
;;;-*-Mode:LISP; Package:(PCL LISP 1000); Base:10; Syntax:Common-lisp -*- ;;; ;;; ************************************************************************* ;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation. ;;; All rights reserved. ;;; ;;; Use and copying of this software and preparation of derivative works ;;; based upon this software are permitted. Any distribution of this ;;; software or derivative works must comply with all applicable United ;;; States export control laws. ;;; ;;; This software is made available AS IS, and Xerox Corporation makes no ;;; warranty about the software, its performance or its conformity to any ;;; specification. ;;; ;;; Any person obtaining a copy of this software is requested to send their ;;; name and post office or electronic mail address to: ;;; CommonLoops Coordinator ;;; Xerox PARC ;;; 3333 Coyote Hill Rd. ;;; Palo Alto, CA 94304 ;;; (or send Arpanet mail to [email protected]) ;;; ;;; Suggestions, comments and requests for improvements are also welcome. ;;; ************************************************************************* ;;; (in-package 'pcl) (defun emit-one-class-reader (class-slot-p) (emit-reader/writer :reader 1 class-slot-p)) (defun emit-one-class-writer (class-slot-p) (emit-reader/writer :writer 1 class-slot-p)) (defun emit-two-class-reader (class-slot-p) (emit-reader/writer :reader 2 class-slot-p)) (defun emit-two-class-writer (class-slot-p) (emit-reader/writer :writer 2 class-slot-p)) (defun emit-reader/writer (reader/writer 1-or-2-class class-slot-p) (declare (type index 1-or-2-class) (type boolean class-slot-p)) (let ((instance nil) (arglist ()) (closure-variables ()) (field (first-wrapper-cache-number-index))) ;we need some field to do ;the fast obsolete check (ecase reader/writer (:reader (setq instance (dfun-arg-symbol 0) arglist (list instance))) (:writer (setq instance (dfun-arg-symbol 1) arglist (list (dfun-arg-symbol 0) instance)))) (ecase 1-or-2-class (1 (setq closure-variables '(wrapper-0 index miss-fn))) (2 (setq closure-variables '(wrapper-0 wrapper-1 index miss-fn)))) (generating-lap closure-variables arglist (with-lap-registers ((inst t) ;reg for the instance (wrapper #-structure-wrapper vector ;reg for the wrapper #+structure-wrapper t) #+structure-wrapper (cnv fixnum-vector) (cache-no index)) ;reg for the cache no (let ((index cache-no) ;This register is used ;for different values at ;different times. (slots (and (null class-slot-p) (allocate-register 'vector))) (csv (and class-slot-p (allocate-register t)))) (prog1 (flatten-lap (opcode :move (operand :arg instance) inst) ;get the instance (opcode :std-instance-p inst 'std-instance) ;if not either std-inst (opcode :fsc-instance-p inst 'fsc-instance) ;or fsc-instance then #+pcl-user-instances (opcode :user-instance-p inst 'user-instance) ;if not either std-inst (opcode :go 'trap) ;we lose #+pcl-user-instances (opcode :label 'user-instance) #+pcl-user-instances (opcode :move (operand :user-wrapper inst) wrapper) #+pcl-user-instances (and slots (opcode :move (operand :user-slots inst) slots)) #+pcl-user-instances (opcode :go 'have-wrapper) (opcode :label 'fsc-instance) (opcode :move (operand :fsc-wrapper inst) wrapper) (and slots (opcode :move (operand :fsc-slots inst) slots)) (opcode :go 'have-wrapper) (opcode :label 'std-instance) (opcode :move (operand :std-wrapper inst) wrapper) (and slots (opcode :move (operand :std-slots inst) slots)) (opcode :label 'have-wrapper) #-structure-wrapper (opcode :move (operand :cref wrapper field) cache-no) #+structure-wrapper (opcode :move (emit-wrapper-cache-number-vector wrapper) cnv) #+structure-wrapper (opcode :move (operand :cref cnv field) cache-no) (opcode :izerop cache-no 'trap) ;obsolete wrapper? (ecase 1-or-2-class (1 (emit-check-1-class-wrapper wrapper 'wrapper-0 'trap)) (2 (emit-check-2-class-wrapper wrapper 'wrapper-0 'wrapper-1 'trap))) (if class-slot-p (flatten-lap (opcode :move (operand :cvar 'index) csv) (ecase reader/writer (:reader (emit-get-class-slot csv 'trap inst)) (:writer (emit-set-class-slot csv (car arglist) inst)))) (flatten-lap (opcode :move (operand :cvar 'index) index) (ecase reader/writer (:reader (emit-get-slot slots index 'trap inst)) (:writer (emit-set-slot slots index (car arglist) inst))))) (opcode :label 'trap) (emit-miss 'miss-fn)) (when slots (deallocate-register slots)) (when csv (deallocate-register csv)))))))) (defun emit-one-index-readers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-get-class-slot index 'trap slots) (emit-get-slot slots index 'trap)))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list slots))))))) (defun emit-one-index-writers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(t standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-set-class-slot index (dfun-arg-symbol 0) slots) (emit-set-slot slots index (dfun-arg-symbol 0))))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list nil slots))))))) (defun emit-n-n-readers () (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (emit-dlap arglist '(standard-instance) 'trap (emit-get-slot slots index 'trap) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list slots)))))) (defun emit-n-n-writers () (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (flatten-lap (emit-dlap arglist '(t standard-instance) 'trap (emit-set-slot slots index (dfun-arg-symbol 0)) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list nil slots))))))) (defun emit-checking (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size function miss-fn) dlap-lambda-list (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (with-lap-registers ((function t)) (flatten-lap (opcode :move (operand :cvar 'function) function) (opcode :jmp function))) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) nil)))) (defun emit-caching (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((function t)) (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (flatten-lap (opcode :jmp function)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) function))))) (defun emit-constant-value (metatypes) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes nil))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((value t)) (emit-dlap dlap-lambda-list metatypes 'trap (flatten-lap (opcode :return value)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) value))))) (defun emit-check-1-class-wrapper (wrapper cwrapper-0 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) (opcode :neq wrapper cwrapper miss-label)))) ;wrappers not eq, trap (defun emit-check-2-class-wrapper (wrapper cwrapper-0 cwrapper-1 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) ;This is an OR. Isn't (opcode :eq wrapper cwrapper 'hit-internal) ;assembly code fun (opcode :move (operand :cvar cwrapper-1) cwrapper) ; (opcode :neq wrapper cwrapper miss-label) ; (opcode :label 'hit-internal)))) (defun emit-get-slot (slots index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :iref slots index) val) ;get slot value (opcode :eq val slot-unbound trap-label) ;is the slot unbound? (opcode :return val))))) ;return the slot value (defun emit-set-slot (slots index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) ;get new value into a reg (opcode :move new-val (operand :iref slots index)) ;set slot value (opcode :return new-val)))) (defun emit-get-class-slot (index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :cdr index) val) (opcode :eq val slot-unbound trap-label) (opcode :return val))))) (defun emit-set-class-slot (index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) (opcode :move new-val (operand :cdr index)) (opcode :return new-val)))) (defun emit-miss (miss-fn) (with-lap-registers ((miss-fn-reg t)) (flatten-lap (opcode :move (operand :cvar miss-fn) miss-fn-reg) ;get the miss function (opcode :jmp miss-fn-reg)))) ;and call it (defun dlap-wrappers (metatypes) (mapcar #'(lambda (x) (and (neq x 't) (allocate-register #-structure-wrapper 'vector #+structure-wrapper t))) metatypes)) (defun dlap-wrapper-moves (wrappers args metatypes miss-label slot-regs) (gathering1 (collecting) (iterate ((mt (list-elements metatypes)) (arg (list-elements args)) (wrapper (list-elements wrappers)) (i (interval :from 0))) (when wrapper (gather1 (emit-fetch-wrapper mt arg wrapper miss-label (nth i slot-regs))))))) (defun emit-dlap (args metatypes miss-label hit miss value-reg &optional slot-regs) (let* ((wrappers (dlap-wrappers metatypes)) (nwrappers (remove nil wrappers)) (wrapper-moves (dlap-wrapper-moves wrappers args metatypes miss-label slot-regs))) (prog1 (emit-dlap-internal nwrappers wrapper-moves hit miss miss-label value-reg) (mapc #'deallocate-register nwrappers)))) (defun emit-dlap-internal (wrapper-regs wrapper-moves hit miss miss-label value-reg) (cond ((cdr wrapper-regs) (emit-greater-than-1-dlap wrapper-regs wrapper-moves hit miss miss-label value-reg)) ((null value-reg) (emit-1-nil-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label)) (t (emit-1-t-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label value-reg)))) (defun emit-1-nil-dlap (wrapper wrapper-move hit miss miss-label) (with-lap-registers ((location index) (primary index) (cache-vector vector)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) ;inline hit code (opcode :izerop wrapper-cache-no miss-label))) (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (opcode :label 'continue) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 0)) location) (opcode :go 'continue))) miss))) ;;; ;;; The function below implements CACHE-VECTOR-LOCK-COUNT as the first entry ;;; in a cache (svref cache-vector 0). This should probably be abstracted. ;;; (defun emit-1-t-dlap (wrapper wrapper-move hit miss miss-label value) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get lock-count (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :izerop wrapper-cache-no miss-label))) ;check for obsolescence (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :move (operand :i1+ location) location) (opcode :label 'continue) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 2)) location) (opcode :go 'continue))) (opcode :label 'hit-internal) (opcode :move (operand :i1+ location) location) ;position for getting value (opcode :move (emit-cache-vector-ref cache-vector location) value) (emit-lock-count-test initial-lock-count cache-vector 'hit) miss (opcode :label 'hit) hit))) (defun emit-greater-than-1-dlap (wrappers wrapper-moves hit miss miss-label value) (declare (list wrappers)) (let ((cache-line-size (compute-line-size (if value (the index (1+ (the index (length wrappers)))) (length wrappers))))) (declare (type index cache-line-size)) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t) (next-location index) (line-size index)) ;Line size holds a constant ;that can be folded in if there was ;a way to add a constant to ;an index register (flatten-lap (apply #'flatten-lap wrapper-moves) (opcode :move (operand :constant cache-line-size) line-size) (opcode :move (operand :cvar 'cache-vector) cache-vector) (emit-n-wrapper-compute-primary-cache-location wrappers primary miss-label) (opcode :move primary location) (opcode :move location next-location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get the lock-count (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'continue) (opcode :move (operand :i+ location line-size) next-location) (emit-check-cache-line cache-vector location wrappers 'hit) (emit-adjust-location location next-location primary size 'continue miss-label) (opcode :label 'hit) (and value (opcode :move (emit-cache-vector-ref cache-vector location) value)) (emit-lock-count-test initial-lock-count cache-vector 'hit-internal) miss (opcode :label 'hit-internal) hit)))))) ;;; ;;; Cache related lap code ;;; (defun emit-check-1-wrapper-in-cache (cache-vector location wrapper hit-code) (let ((exit-emit-check-1-wrapper-in-cache (make-symbol "exit-emit-check-1-wrapper-in-cache"))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper exit-emit-check-1-wrapper-in-cache) hit-code (opcode :label exit-emit-check-1-wrapper-in-cache))))) (defun emit-check-cache-entry (cache-vector location wrapper hit-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :eq cwrapper wrapper hit-label)))) (defun emit-check-cache-line (cache-vector location wrappers hit-label) (let ((checks (flatten-lap (gathering1 (flattening-lap) (iterate ((wrapper (list-elements wrappers))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (gather1 (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper 'exit-emit-check-cache-line) (opcode :move (operand :i1+ location) location))))))))) (flatten-lap checks (opcode :go hit-label) (opcode :label 'exit-emit-check-cache-line)))) (defun emit-lock-count-test (initial-lock-count cache-vector hit-label) ;; ;; jumps to hit-label if cache-vector-lock-count consistent, otherwise, continues ;; (with-lap-registers ((new-lock-count t)) (flatten-lap (opcode :move (operand :cref cache-vector 0) new-lock-count) ;get new cache-vector-lock-count (opcode :fix= new-lock-count initial-lock-count hit-label)))) (defun emit-adjust-location (location next-location primary size cont-label miss-label) (flatten-lap (opcode :move next-location location) (opcode :fix= location size 'at-end-of-cache) (opcode :fix= location primary miss-label) (opcode :go cont-label) (opcode :label 'at-end-of-cache) (opcode :fix= primary (operand :constant (index-value->index 1)) miss-label) (opcode :move (operand :constant (index-value->index 1)) location) (opcode :go cont-label)))
71219
;;;-*-Mode:LISP; Package:(PCL LISP 1000); Base:10; Syntax:Common-lisp -*- ;;; ;;; ************************************************************************* ;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation. ;;; All rights reserved. ;;; ;;; Use and copying of this software and preparation of derivative works ;;; based upon this software are permitted. Any distribution of this ;;; software or derivative works must comply with all applicable United ;;; States export control laws. ;;; ;;; This software is made available AS IS, and Xerox Corporation makes no ;;; warranty about the software, its performance or its conformity to any ;;; specification. ;;; ;;; Any person obtaining a copy of this software is requested to send their ;;; name and post office or electronic mail address to: ;;; CommonLoops Coordinator ;;; <NAME> ;;; 3333 Coyote Hill Rd. ;;; Palo Alto, CA 94304 ;;; (or send Arpanet mail to <EMAIL>) ;;; ;;; Suggestions, comments and requests for improvements are also welcome. ;;; ************************************************************************* ;;; (in-package 'pcl) (defun emit-one-class-reader (class-slot-p) (emit-reader/writer :reader 1 class-slot-p)) (defun emit-one-class-writer (class-slot-p) (emit-reader/writer :writer 1 class-slot-p)) (defun emit-two-class-reader (class-slot-p) (emit-reader/writer :reader 2 class-slot-p)) (defun emit-two-class-writer (class-slot-p) (emit-reader/writer :writer 2 class-slot-p)) (defun emit-reader/writer (reader/writer 1-or-2-class class-slot-p) (declare (type index 1-or-2-class) (type boolean class-slot-p)) (let ((instance nil) (arglist ()) (closure-variables ()) (field (first-wrapper-cache-number-index))) ;we need some field to do ;the fast obsolete check (ecase reader/writer (:reader (setq instance (dfun-arg-symbol 0) arglist (list instance))) (:writer (setq instance (dfun-arg-symbol 1) arglist (list (dfun-arg-symbol 0) instance)))) (ecase 1-or-2-class (1 (setq closure-variables '(wrapper-0 index miss-fn))) (2 (setq closure-variables '(wrapper-0 wrapper-1 index miss-fn)))) (generating-lap closure-variables arglist (with-lap-registers ((inst t) ;reg for the instance (wrapper #-structure-wrapper vector ;reg for the wrapper #+structure-wrapper t) #+structure-wrapper (cnv fixnum-vector) (cache-no index)) ;reg for the cache no (let ((index cache-no) ;This register is used ;for different values at ;different times. (slots (and (null class-slot-p) (allocate-register 'vector))) (csv (and class-slot-p (allocate-register t)))) (prog1 (flatten-lap (opcode :move (operand :arg instance) inst) ;get the instance (opcode :std-instance-p inst 'std-instance) ;if not either std-inst (opcode :fsc-instance-p inst 'fsc-instance) ;or fsc-instance then #+pcl-user-instances (opcode :user-instance-p inst 'user-instance) ;if not either std-inst (opcode :go 'trap) ;we lose #+pcl-user-instances (opcode :label 'user-instance) #+pcl-user-instances (opcode :move (operand :user-wrapper inst) wrapper) #+pcl-user-instances (and slots (opcode :move (operand :user-slots inst) slots)) #+pcl-user-instances (opcode :go 'have-wrapper) (opcode :label 'fsc-instance) (opcode :move (operand :fsc-wrapper inst) wrapper) (and slots (opcode :move (operand :fsc-slots inst) slots)) (opcode :go 'have-wrapper) (opcode :label 'std-instance) (opcode :move (operand :std-wrapper inst) wrapper) (and slots (opcode :move (operand :std-slots inst) slots)) (opcode :label 'have-wrapper) #-structure-wrapper (opcode :move (operand :cref wrapper field) cache-no) #+structure-wrapper (opcode :move (emit-wrapper-cache-number-vector wrapper) cnv) #+structure-wrapper (opcode :move (operand :cref cnv field) cache-no) (opcode :izerop cache-no 'trap) ;obsolete wrapper? (ecase 1-or-2-class (1 (emit-check-1-class-wrapper wrapper 'wrapper-0 'trap)) (2 (emit-check-2-class-wrapper wrapper 'wrapper-0 'wrapper-1 'trap))) (if class-slot-p (flatten-lap (opcode :move (operand :cvar 'index) csv) (ecase reader/writer (:reader (emit-get-class-slot csv 'trap inst)) (:writer (emit-set-class-slot csv (car arglist) inst)))) (flatten-lap (opcode :move (operand :cvar 'index) index) (ecase reader/writer (:reader (emit-get-slot slots index 'trap inst)) (:writer (emit-set-slot slots index (car arglist) inst))))) (opcode :label 'trap) (emit-miss 'miss-fn)) (when slots (deallocate-register slots)) (when csv (deallocate-register csv)))))))) (defun emit-one-index-readers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-get-class-slot index 'trap slots) (emit-get-slot slots index 'trap)))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list slots))))))) (defun emit-one-index-writers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(t standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-set-class-slot index (dfun-arg-symbol 0) slots) (emit-set-slot slots index (dfun-arg-symbol 0))))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list nil slots))))))) (defun emit-n-n-readers () (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (emit-dlap arglist '(standard-instance) 'trap (emit-get-slot slots index 'trap) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list slots)))))) (defun emit-n-n-writers () (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (flatten-lap (emit-dlap arglist '(t standard-instance) 'trap (emit-set-slot slots index (dfun-arg-symbol 0)) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list nil slots))))))) (defun emit-checking (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size function miss-fn) dlap-lambda-list (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (with-lap-registers ((function t)) (flatten-lap (opcode :move (operand :cvar 'function) function) (opcode :jmp function))) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) nil)))) (defun emit-caching (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((function t)) (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (flatten-lap (opcode :jmp function)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) function))))) (defun emit-constant-value (metatypes) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes nil))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((value t)) (emit-dlap dlap-lambda-list metatypes 'trap (flatten-lap (opcode :return value)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) value))))) (defun emit-check-1-class-wrapper (wrapper cwrapper-0 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) (opcode :neq wrapper cwrapper miss-label)))) ;wrappers not eq, trap (defun emit-check-2-class-wrapper (wrapper cwrapper-0 cwrapper-1 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) ;This is an OR. Isn't (opcode :eq wrapper cwrapper 'hit-internal) ;assembly code fun (opcode :move (operand :cvar cwrapper-1) cwrapper) ; (opcode :neq wrapper cwrapper miss-label) ; (opcode :label 'hit-internal)))) (defun emit-get-slot (slots index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :iref slots index) val) ;get slot value (opcode :eq val slot-unbound trap-label) ;is the slot unbound? (opcode :return val))))) ;return the slot value (defun emit-set-slot (slots index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) ;get new value into a reg (opcode :move new-val (operand :iref slots index)) ;set slot value (opcode :return new-val)))) (defun emit-get-class-slot (index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :cdr index) val) (opcode :eq val slot-unbound trap-label) (opcode :return val))))) (defun emit-set-class-slot (index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) (opcode :move new-val (operand :cdr index)) (opcode :return new-val)))) (defun emit-miss (miss-fn) (with-lap-registers ((miss-fn-reg t)) (flatten-lap (opcode :move (operand :cvar miss-fn) miss-fn-reg) ;get the miss function (opcode :jmp miss-fn-reg)))) ;and call it (defun dlap-wrappers (metatypes) (mapcar #'(lambda (x) (and (neq x 't) (allocate-register #-structure-wrapper 'vector #+structure-wrapper t))) metatypes)) (defun dlap-wrapper-moves (wrappers args metatypes miss-label slot-regs) (gathering1 (collecting) (iterate ((mt (list-elements metatypes)) (arg (list-elements args)) (wrapper (list-elements wrappers)) (i (interval :from 0))) (when wrapper (gather1 (emit-fetch-wrapper mt arg wrapper miss-label (nth i slot-regs))))))) (defun emit-dlap (args metatypes miss-label hit miss value-reg &optional slot-regs) (let* ((wrappers (dlap-wrappers metatypes)) (nwrappers (remove nil wrappers)) (wrapper-moves (dlap-wrapper-moves wrappers args metatypes miss-label slot-regs))) (prog1 (emit-dlap-internal nwrappers wrapper-moves hit miss miss-label value-reg) (mapc #'deallocate-register nwrappers)))) (defun emit-dlap-internal (wrapper-regs wrapper-moves hit miss miss-label value-reg) (cond ((cdr wrapper-regs) (emit-greater-than-1-dlap wrapper-regs wrapper-moves hit miss miss-label value-reg)) ((null value-reg) (emit-1-nil-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label)) (t (emit-1-t-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label value-reg)))) (defun emit-1-nil-dlap (wrapper wrapper-move hit miss miss-label) (with-lap-registers ((location index) (primary index) (cache-vector vector)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) ;inline hit code (opcode :izerop wrapper-cache-no miss-label))) (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (opcode :label 'continue) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 0)) location) (opcode :go 'continue))) miss))) ;;; ;;; The function below implements CACHE-VECTOR-LOCK-COUNT as the first entry ;;; in a cache (svref cache-vector 0). This should probably be abstracted. ;;; (defun emit-1-t-dlap (wrapper wrapper-move hit miss miss-label value) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get lock-count (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :izerop wrapper-cache-no miss-label))) ;check for obsolescence (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :move (operand :i1+ location) location) (opcode :label 'continue) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 2)) location) (opcode :go 'continue))) (opcode :label 'hit-internal) (opcode :move (operand :i1+ location) location) ;position for getting value (opcode :move (emit-cache-vector-ref cache-vector location) value) (emit-lock-count-test initial-lock-count cache-vector 'hit) miss (opcode :label 'hit) hit))) (defun emit-greater-than-1-dlap (wrappers wrapper-moves hit miss miss-label value) (declare (list wrappers)) (let ((cache-line-size (compute-line-size (if value (the index (1+ (the index (length wrappers)))) (length wrappers))))) (declare (type index cache-line-size)) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t) (next-location index) (line-size index)) ;Line size holds a constant ;that can be folded in if there was ;a way to add a constant to ;an index register (flatten-lap (apply #'flatten-lap wrapper-moves) (opcode :move (operand :constant cache-line-size) line-size) (opcode :move (operand :cvar 'cache-vector) cache-vector) (emit-n-wrapper-compute-primary-cache-location wrappers primary miss-label) (opcode :move primary location) (opcode :move location next-location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get the lock-count (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'continue) (opcode :move (operand :i+ location line-size) next-location) (emit-check-cache-line cache-vector location wrappers 'hit) (emit-adjust-location location next-location primary size 'continue miss-label) (opcode :label 'hit) (and value (opcode :move (emit-cache-vector-ref cache-vector location) value)) (emit-lock-count-test initial-lock-count cache-vector 'hit-internal) miss (opcode :label 'hit-internal) hit)))))) ;;; ;;; Cache related lap code ;;; (defun emit-check-1-wrapper-in-cache (cache-vector location wrapper hit-code) (let ((exit-emit-check-1-wrapper-in-cache (make-symbol "exit-emit-check-1-wrapper-in-cache"))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper exit-emit-check-1-wrapper-in-cache) hit-code (opcode :label exit-emit-check-1-wrapper-in-cache))))) (defun emit-check-cache-entry (cache-vector location wrapper hit-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :eq cwrapper wrapper hit-label)))) (defun emit-check-cache-line (cache-vector location wrappers hit-label) (let ((checks (flatten-lap (gathering1 (flattening-lap) (iterate ((wrapper (list-elements wrappers))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (gather1 (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper 'exit-emit-check-cache-line) (opcode :move (operand :i1+ location) location))))))))) (flatten-lap checks (opcode :go hit-label) (opcode :label 'exit-emit-check-cache-line)))) (defun emit-lock-count-test (initial-lock-count cache-vector hit-label) ;; ;; jumps to hit-label if cache-vector-lock-count consistent, otherwise, continues ;; (with-lap-registers ((new-lock-count t)) (flatten-lap (opcode :move (operand :cref cache-vector 0) new-lock-count) ;get new cache-vector-lock-count (opcode :fix= new-lock-count initial-lock-count hit-label)))) (defun emit-adjust-location (location next-location primary size cont-label miss-label) (flatten-lap (opcode :move next-location location) (opcode :fix= location size 'at-end-of-cache) (opcode :fix= location primary miss-label) (opcode :go cont-label) (opcode :label 'at-end-of-cache) (opcode :fix= primary (operand :constant (index-value->index 1)) miss-label) (opcode :move (operand :constant (index-value->index 1)) location) (opcode :go cont-label)))
true
;;;-*-Mode:LISP; Package:(PCL LISP 1000); Base:10; Syntax:Common-lisp -*- ;;; ;;; ************************************************************************* ;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation. ;;; All rights reserved. ;;; ;;; Use and copying of this software and preparation of derivative works ;;; based upon this software are permitted. Any distribution of this ;;; software or derivative works must comply with all applicable United ;;; States export control laws. ;;; ;;; This software is made available AS IS, and Xerox Corporation makes no ;;; warranty about the software, its performance or its conformity to any ;;; specification. ;;; ;;; Any person obtaining a copy of this software is requested to send their ;;; name and post office or electronic mail address to: ;;; CommonLoops Coordinator ;;; PI:NAME:<NAME>END_PI ;;; 3333 Coyote Hill Rd. ;;; Palo Alto, CA 94304 ;;; (or send Arpanet mail to PI:EMAIL:<EMAIL>END_PI) ;;; ;;; Suggestions, comments and requests for improvements are also welcome. ;;; ************************************************************************* ;;; (in-package 'pcl) (defun emit-one-class-reader (class-slot-p) (emit-reader/writer :reader 1 class-slot-p)) (defun emit-one-class-writer (class-slot-p) (emit-reader/writer :writer 1 class-slot-p)) (defun emit-two-class-reader (class-slot-p) (emit-reader/writer :reader 2 class-slot-p)) (defun emit-two-class-writer (class-slot-p) (emit-reader/writer :writer 2 class-slot-p)) (defun emit-reader/writer (reader/writer 1-or-2-class class-slot-p) (declare (type index 1-or-2-class) (type boolean class-slot-p)) (let ((instance nil) (arglist ()) (closure-variables ()) (field (first-wrapper-cache-number-index))) ;we need some field to do ;the fast obsolete check (ecase reader/writer (:reader (setq instance (dfun-arg-symbol 0) arglist (list instance))) (:writer (setq instance (dfun-arg-symbol 1) arglist (list (dfun-arg-symbol 0) instance)))) (ecase 1-or-2-class (1 (setq closure-variables '(wrapper-0 index miss-fn))) (2 (setq closure-variables '(wrapper-0 wrapper-1 index miss-fn)))) (generating-lap closure-variables arglist (with-lap-registers ((inst t) ;reg for the instance (wrapper #-structure-wrapper vector ;reg for the wrapper #+structure-wrapper t) #+structure-wrapper (cnv fixnum-vector) (cache-no index)) ;reg for the cache no (let ((index cache-no) ;This register is used ;for different values at ;different times. (slots (and (null class-slot-p) (allocate-register 'vector))) (csv (and class-slot-p (allocate-register t)))) (prog1 (flatten-lap (opcode :move (operand :arg instance) inst) ;get the instance (opcode :std-instance-p inst 'std-instance) ;if not either std-inst (opcode :fsc-instance-p inst 'fsc-instance) ;or fsc-instance then #+pcl-user-instances (opcode :user-instance-p inst 'user-instance) ;if not either std-inst (opcode :go 'trap) ;we lose #+pcl-user-instances (opcode :label 'user-instance) #+pcl-user-instances (opcode :move (operand :user-wrapper inst) wrapper) #+pcl-user-instances (and slots (opcode :move (operand :user-slots inst) slots)) #+pcl-user-instances (opcode :go 'have-wrapper) (opcode :label 'fsc-instance) (opcode :move (operand :fsc-wrapper inst) wrapper) (and slots (opcode :move (operand :fsc-slots inst) slots)) (opcode :go 'have-wrapper) (opcode :label 'std-instance) (opcode :move (operand :std-wrapper inst) wrapper) (and slots (opcode :move (operand :std-slots inst) slots)) (opcode :label 'have-wrapper) #-structure-wrapper (opcode :move (operand :cref wrapper field) cache-no) #+structure-wrapper (opcode :move (emit-wrapper-cache-number-vector wrapper) cnv) #+structure-wrapper (opcode :move (operand :cref cnv field) cache-no) (opcode :izerop cache-no 'trap) ;obsolete wrapper? (ecase 1-or-2-class (1 (emit-check-1-class-wrapper wrapper 'wrapper-0 'trap)) (2 (emit-check-2-class-wrapper wrapper 'wrapper-0 'wrapper-1 'trap))) (if class-slot-p (flatten-lap (opcode :move (operand :cvar 'index) csv) (ecase reader/writer (:reader (emit-get-class-slot csv 'trap inst)) (:writer (emit-set-class-slot csv (car arglist) inst)))) (flatten-lap (opcode :move (operand :cvar 'index) index) (ecase reader/writer (:reader (emit-get-slot slots index 'trap inst)) (:writer (emit-set-slot slots index (car arglist) inst))))) (opcode :label 'trap) (emit-miss 'miss-fn)) (when slots (deallocate-register slots)) (when csv (deallocate-register csv)))))))) (defun emit-one-index-readers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-get-class-slot index 'trap slots) (emit-get-slot slots index 'trap)))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list slots))))))) (defun emit-one-index-writers (class-slot-p) (declare (type boolean class-slot-p)) (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size index miss-fn) arglist (with-lap-registers ((slots vector)) (emit-dlap arglist '(t standard-instance) 'trap (with-lap-registers ((index index)) (flatten-lap (opcode :move (operand :cvar 'index) index) (if class-slot-p (emit-set-class-slot index (dfun-arg-symbol 0) slots) (emit-set-slot slots index (dfun-arg-symbol 0))))) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) nil (and (null class-slot-p) (list nil slots))))))) (defun emit-n-n-readers () (let ((arglist (list (dfun-arg-symbol 0)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (emit-dlap arglist '(standard-instance) 'trap (emit-get-slot slots index 'trap) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list slots)))))) (defun emit-n-n-writers () (let ((arglist (list (dfun-arg-symbol 0) (dfun-arg-symbol 1)))) (generating-lap '(field cache-vector mask size miss-fn) arglist (with-lap-registers ((slots vector) (index index)) (flatten-lap (emit-dlap arglist '(t standard-instance) 'trap (emit-set-slot slots index (dfun-arg-symbol 0)) (flatten-lap (opcode :label 'trap) (emit-miss 'miss-fn)) index (list nil slots))))))) (defun emit-checking (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size function miss-fn) dlap-lambda-list (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (with-lap-registers ((function t)) (flatten-lap (opcode :move (operand :cvar 'function) function) (opcode :jmp function))) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) nil)))) (defun emit-caching (metatypes applyp) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes applyp))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((function t)) (emit-dlap (remove '&rest dlap-lambda-list) metatypes 'trap (flatten-lap (opcode :jmp function)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) function))))) (defun emit-constant-value (metatypes) (let ((dlap-lambda-list (make-dlap-lambda-list metatypes nil))) (generating-lap '(field cache-vector mask size miss-fn) dlap-lambda-list (with-lap-registers ((value t)) (emit-dlap dlap-lambda-list metatypes 'trap (flatten-lap (opcode :return value)) (with-lap-registers ((miss-function t)) (flatten-lap (opcode :label 'trap) (opcode :move (operand :cvar 'miss-fn) miss-function) (opcode :jmp miss-function))) value))))) (defun emit-check-1-class-wrapper (wrapper cwrapper-0 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) (opcode :neq wrapper cwrapper miss-label)))) ;wrappers not eq, trap (defun emit-check-2-class-wrapper (wrapper cwrapper-0 cwrapper-1 miss-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (operand :cvar cwrapper-0) cwrapper) ;This is an OR. Isn't (opcode :eq wrapper cwrapper 'hit-internal) ;assembly code fun (opcode :move (operand :cvar cwrapper-1) cwrapper) ; (opcode :neq wrapper cwrapper miss-label) ; (opcode :label 'hit-internal)))) (defun emit-get-slot (slots index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :iref slots index) val) ;get slot value (opcode :eq val slot-unbound trap-label) ;is the slot unbound? (opcode :return val))))) ;return the slot value (defun emit-set-slot (slots index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) ;get new value into a reg (opcode :move new-val (operand :iref slots index)) ;set slot value (opcode :return new-val)))) (defun emit-get-class-slot (index trap-label &optional temp) (let ((slot-unbound (operand :constant *slot-unbound*))) (with-lap-registers ((val t :reuse temp)) (flatten-lap (opcode :move (operand :cdr index) val) (opcode :eq val slot-unbound trap-label) (opcode :return val))))) (defun emit-set-class-slot (index new-value-arg &optional temp) (with-lap-registers ((new-val t :reuse temp)) (flatten-lap (opcode :move (operand :arg new-value-arg) new-val) (opcode :move new-val (operand :cdr index)) (opcode :return new-val)))) (defun emit-miss (miss-fn) (with-lap-registers ((miss-fn-reg t)) (flatten-lap (opcode :move (operand :cvar miss-fn) miss-fn-reg) ;get the miss function (opcode :jmp miss-fn-reg)))) ;and call it (defun dlap-wrappers (metatypes) (mapcar #'(lambda (x) (and (neq x 't) (allocate-register #-structure-wrapper 'vector #+structure-wrapper t))) metatypes)) (defun dlap-wrapper-moves (wrappers args metatypes miss-label slot-regs) (gathering1 (collecting) (iterate ((mt (list-elements metatypes)) (arg (list-elements args)) (wrapper (list-elements wrappers)) (i (interval :from 0))) (when wrapper (gather1 (emit-fetch-wrapper mt arg wrapper miss-label (nth i slot-regs))))))) (defun emit-dlap (args metatypes miss-label hit miss value-reg &optional slot-regs) (let* ((wrappers (dlap-wrappers metatypes)) (nwrappers (remove nil wrappers)) (wrapper-moves (dlap-wrapper-moves wrappers args metatypes miss-label slot-regs))) (prog1 (emit-dlap-internal nwrappers wrapper-moves hit miss miss-label value-reg) (mapc #'deallocate-register nwrappers)))) (defun emit-dlap-internal (wrapper-regs wrapper-moves hit miss miss-label value-reg) (cond ((cdr wrapper-regs) (emit-greater-than-1-dlap wrapper-regs wrapper-moves hit miss miss-label value-reg)) ((null value-reg) (emit-1-nil-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label)) (t (emit-1-t-dlap (car wrapper-regs) (car wrapper-moves) hit miss miss-label value-reg)))) (defun emit-1-nil-dlap (wrapper wrapper-move hit miss miss-label) (with-lap-registers ((location index) (primary index) (cache-vector vector)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) ;inline hit code (opcode :izerop wrapper-cache-no miss-label))) (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (opcode :label 'continue) (emit-check-1-wrapper-in-cache cache-vector location wrapper hit) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 0)) location) (opcode :go 'continue))) miss))) ;;; ;;; The function below implements CACHE-VECTOR-LOCK-COUNT as the first entry ;;; in a cache (svref cache-vector 0). This should probably be abstracted. ;;; (defun emit-1-t-dlap (wrapper wrapper-move hit miss miss-label value) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t)) (flatten-lap wrapper-move (opcode :move (operand :cvar 'cache-vector) cache-vector) (with-lap-registers ((wrapper-cache-no index)) (flatten-lap (emit-1-wrapper-compute-primary-cache-location wrapper primary wrapper-cache-no) (opcode :move primary location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get lock-count (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :izerop wrapper-cache-no miss-label))) ;check for obsolescence (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'loop) (opcode :move (operand :i1+ location) location) (opcode :move (operand :i1+ location) location) (opcode :label 'continue) (opcode :fix= location primary miss-label) (opcode :fix= location size 'set-location-to-min) (emit-check-cache-entry cache-vector location wrapper 'hit-internal) (opcode :go 'loop) (opcode :label 'set-location-to-min) (opcode :izerop primary miss-label) (opcode :move (operand :constant (index-value->index 2)) location) (opcode :go 'continue))) (opcode :label 'hit-internal) (opcode :move (operand :i1+ location) location) ;position for getting value (opcode :move (emit-cache-vector-ref cache-vector location) value) (emit-lock-count-test initial-lock-count cache-vector 'hit) miss (opcode :label 'hit) hit))) (defun emit-greater-than-1-dlap (wrappers wrapper-moves hit miss miss-label value) (declare (list wrappers)) (let ((cache-line-size (compute-line-size (if value (the index (1+ (the index (length wrappers)))) (length wrappers))))) (declare (type index cache-line-size)) (with-lap-registers ((location index) (primary index) (cache-vector vector) (initial-lock-count t) (next-location index) (line-size index)) ;Line size holds a constant ;that can be folded in if there was ;a way to add a constant to ;an index register (flatten-lap (apply #'flatten-lap wrapper-moves) (opcode :move (operand :constant cache-line-size) line-size) (opcode :move (operand :cvar 'cache-vector) cache-vector) (emit-n-wrapper-compute-primary-cache-location wrappers primary miss-label) (opcode :move primary location) (opcode :move location next-location) (opcode :move (operand :cref cache-vector 0) initial-lock-count) ;get the lock-count (with-lap-registers ((size index)) (flatten-lap (opcode :move (operand :cvar 'size) size) (opcode :label 'continue) (opcode :move (operand :i+ location line-size) next-location) (emit-check-cache-line cache-vector location wrappers 'hit) (emit-adjust-location location next-location primary size 'continue miss-label) (opcode :label 'hit) (and value (opcode :move (emit-cache-vector-ref cache-vector location) value)) (emit-lock-count-test initial-lock-count cache-vector 'hit-internal) miss (opcode :label 'hit-internal) hit)))))) ;;; ;;; Cache related lap code ;;; (defun emit-check-1-wrapper-in-cache (cache-vector location wrapper hit-code) (let ((exit-emit-check-1-wrapper-in-cache (make-symbol "exit-emit-check-1-wrapper-in-cache"))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper exit-emit-check-1-wrapper-in-cache) hit-code (opcode :label exit-emit-check-1-wrapper-in-cache))))) (defun emit-check-cache-entry (cache-vector location wrapper hit-label) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :eq cwrapper wrapper hit-label)))) (defun emit-check-cache-line (cache-vector location wrappers hit-label) (let ((checks (flatten-lap (gathering1 (flattening-lap) (iterate ((wrapper (list-elements wrappers))) (with-lap-registers ((cwrapper #-structure-wrapper vector #+structure-wrapper t)) (gather1 (flatten-lap (opcode :move (emit-cache-vector-ref cache-vector location) cwrapper) (opcode :neq cwrapper wrapper 'exit-emit-check-cache-line) (opcode :move (operand :i1+ location) location))))))))) (flatten-lap checks (opcode :go hit-label) (opcode :label 'exit-emit-check-cache-line)))) (defun emit-lock-count-test (initial-lock-count cache-vector hit-label) ;; ;; jumps to hit-label if cache-vector-lock-count consistent, otherwise, continues ;; (with-lap-registers ((new-lock-count t)) (flatten-lap (opcode :move (operand :cref cache-vector 0) new-lock-count) ;get new cache-vector-lock-count (opcode :fix= new-lock-count initial-lock-count hit-label)))) (defun emit-adjust-location (location next-location primary size cont-label miss-label) (flatten-lap (opcode :move next-location location) (opcode :fix= location size 'at-end-of-cache) (opcode :fix= location primary miss-label) (opcode :go cont-label) (opcode :label 'at-end-of-cache) (opcode :fix= primary (operand :constant (index-value->index 1)) miss-label) (opcode :move (operand :constant (index-value->index 1)) location) (opcode :go cont-label)))
[ { "context": "ability System\n;;;\n;;; Copyright (C) 2010, 2017 by Sam Steingold\n;;; This is Free Software, covered by the GNU LGP", "end": 93, "score": 0.999873161315918, "start": 80, "tag": "NAME", "value": "Sam Steingold" }, { "context": "eft/gpl.html\n\n(asdf:defsystem :port\n :author (\"Sam Steingold <[email protected]>\")\n :licence \"LGPL\"\n :descript", "end": 246, "score": 0.9998893141746521, "start": 233, "tag": "NAME", "value": "Sam Steingold" }, { "context": "asdf:defsystem :port\n :author (\"Sam Steingold <[email protected]>\")\n :licence \"LGPL\"\n :description \"Cross-im", "end": 259, "score": 0.9999282956123352, "start": 248, "tag": "EMAIL", "value": "[email protected]" } ]
src/port/port.asd
sbwhitecap/clocc-hg
0
;;; Cross-implementation Portability System ;;; ;;; Copyright (C) 2010, 2017 by Sam Steingold ;;; This is Free Software, covered by the GNU LGPL (v2+) ;;; See http://www.gnu.org/copyleft/gpl.html (asdf:defsystem :port :author ("Sam Steingold <[email protected]>") :licence "LGPL" :description "Cross-implementation Portability System" :depends-on () :components ((:file "ext") (:file "gray" :depends-on ("ext")) (:file "mop" :depends-on ("ext")) (:file "mop-defstruct" :depends-on ("mop")) (:file "net" :depends-on ("ext" "sys")) (:file "path" :depends-on ("ext")) (:file "proc" :depends-on ("ext")) (:file "shell" :depends-on ("ext")) (:file "sys" :depends-on ("ext" "path"))))
78897
;;; Cross-implementation Portability System ;;; ;;; Copyright (C) 2010, 2017 by <NAME> ;;; This is Free Software, covered by the GNU LGPL (v2+) ;;; See http://www.gnu.org/copyleft/gpl.html (asdf:defsystem :port :author ("<NAME> <<EMAIL>>") :licence "LGPL" :description "Cross-implementation Portability System" :depends-on () :components ((:file "ext") (:file "gray" :depends-on ("ext")) (:file "mop" :depends-on ("ext")) (:file "mop-defstruct" :depends-on ("mop")) (:file "net" :depends-on ("ext" "sys")) (:file "path" :depends-on ("ext")) (:file "proc" :depends-on ("ext")) (:file "shell" :depends-on ("ext")) (:file "sys" :depends-on ("ext" "path"))))
true
;;; Cross-implementation Portability System ;;; ;;; Copyright (C) 2010, 2017 by PI:NAME:<NAME>END_PI ;;; This is Free Software, covered by the GNU LGPL (v2+) ;;; See http://www.gnu.org/copyleft/gpl.html (asdf:defsystem :port :author ("PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>") :licence "LGPL" :description "Cross-implementation Portability System" :depends-on () :components ((:file "ext") (:file "gray" :depends-on ("ext")) (:file "mop" :depends-on ("ext")) (:file "mop-defstruct" :depends-on ("mop")) (:file "net" :depends-on ("ext" "sys")) (:file "path" :depends-on ("ext")) (:file "proc" :depends-on ("ext")) (:file "shell" :depends-on ("ext")) (:file "sys" :depends-on ("ext" "path"))))
[ { "context": ")\n\n ; v0.0 - 2017.08.23 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.08.23\n)\n; (defun c:dateTi", "end": 396, "score": 0.9998718500137329, "start": 382, "tag": "NAME", "value": "David Torralba" }, { "context": " ; v0.0 - 2017.08.23 - First issue\n; ; Author: David Torralba\n; ; Last revision: 2017.08.23\n; )\n(defun c:date", "end": 1335, "score": 0.9998807907104492, "start": 1321, "tag": "NAME", "value": "David Torralba" }, { "context": ")\n\n ; v0.0 - 2017.08.23 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.08.23\n)\n(defun DT:DateTim", "end": 2286, "score": 0.9998693466186523, "start": 2272, "tag": "NAME", "value": "David Torralba" }, { "context": "f\n\n ; v0.0 - 2017.08.23 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.08.23\n)\n(defun DT:ParseDa", "end": 3030, "score": 0.9998205900192261, "start": 3016, "tag": "NAME", "value": "David Torralba" }, { "context": "f\n\n ; v0.0 - 2017.10.27 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.10.27\n)\n(defun DT:StringS", "end": 3857, "score": 0.9993136525154114, "start": 3843, "tag": "NAME", "value": "David Torralba" }, { "context": "f\n\n ; v0.0 - 2017.10.27 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.10.27\n)\n(defun DT:GetFirs", "end": 4508, "score": 0.9998937249183655, "start": 4494, "tag": "NAME", "value": "David Torralba" }, { "context": "f\n\n ; v0.0 - 2017.10.27 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.10.27\n)\n(defun DT:GetDate", "end": 5277, "score": 0.9998916387557983, "start": 5263, "tag": "NAME", "value": "David Torralba" }, { "context": "\n\n\n ; v0.0 - 2017.10.27 - First issue\n ; Author: David Torralba\n ; Last revision: 2017.10.27\n)\n", "end": 6493, "score": 0.9998830556869507, "start": 6479, "tag": "NAME", "value": "David Torralba" } ]
Dump folder/DateTime.lsp
dtgoitia/autolisp
30
(defun c:xx () ; Trigger (defun *error* ( errorMessage ) (princ (strcat "n-------- ERROR: " errorMessage " --------n")) (vl-bt) (DT:ReportError)) (DT:AutoLoadFileFromCivilTemp "ErrorTracing.lsp") (DT:AutoLoadFileFromCivilTemp "DateTime.lsp") (princ (strcat "\nTemp file loaded (" (DT:Now) ")\n"))(princ) (c:dateTimeTest) ; v0.0 - 2017.08.23 - First issue ; Author: David Torralba ; Last revision: 2017.08.23 ) ; (defun c:dateTimeTest ( / testCases testResults i ) ; ; test function for date time ; (setq testCases ; (list ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" 1) ; '("2017.08.23" "YYYY.MM.DD") ; );END list ; );END setq ; ; (setq testResults ; (mapcar ; '(lambda (testCase) ; (list ; testCase ; (DT:ParseDateTime (nth 0 testCase) (nth 1 testCase)) ; );END if ; );END lambda ; testCases ; );END mapcar ; );END setq ; (setq i 0) ; (foreach testResult testResults ; (setq i (1+ i)) ; (princ "\nTest ")(princ i)(princ ": ") ; (princ (nth 1 testResult)) ; (if (nth 1 testResult)(princ " ")(princ " ")) ; (princ (nth 0 testResult)) ; (princ "\n") ; );END foreach ; (princ) ; ; ; v0.0 - 2017.08.23 - First issue ; ; Author: David Torralba ; ; Last revision: 2017.08.23 ; ) (defun c:dateTimeTest ( / testCases testResults i ) ; test function for date time (setq testCases (list ; "YYYY" ; "YY" ; "MMMM" ; "MMM" ; "MM" ; "M" ; "DD" ; "D" ; "hh" ; "h" ; "mm" ; "m" ; "SS" ; "S" ; "ss" ; "s" ; "YYYY.MM.DD" "YYYY.MM.DD hh:mm:SS.ss" );END list );END setq (setq testResults (mapcar '(lambda (testCase) (princ testCase)(princ "\n")(list testCase (DT:ParseDatePattern testCase)) ) testCases );END mapcar );END setq (setq i 0) (foreach testResult testResults (setq i (1+ i)) (princ "\nTest ")(princ i)(princ ": ") (princ (nth 1 testResult)) (if (nth 1 testResult)(princ " ")(princ " ")) (princ (nth 0 testResult)) (princ "\n") );END foreach (princ) ; v0.0 - 2017.08.23 - First issue ; Author: David Torralba ; Last revision: 2017.08.23 ) (defun DT:DateTime ( in ) ; Parte input (if (DT:Arg 'DT:DateTime '((in 'str))) (progn (DT:PrintVar 'in) (cond ( (and ; yyyy/mm/dd (= 10 (strlen in)) (= "/" (substr in 5 1) ) (= "/" (substr in 8 1) ) );END and T );END subcond ( (and ; yyyy/mm/dd ; (= 10 (strlen in)) (= "." (substr in 5 1) ) (= "." (substr in 8 1) ) );END and T );END subcond (t (DT:Error 'DT:DateTime "\"in\" no understood mate...") );END subcond );END cond );END progn );END if ; v0.0 - 2017.08.23 - First issue ; Author: David Torralba ; Last revision: 2017.08.23 ) (defun DT:ParseDatePattern ( pattern / remainingPattern result return currentCharPosition ) (if (and pattern (= 'str (type pattern)) ) (progn (setq remainingPattern pattern) (setq currentCharPosition 1) ; 1-index based (while (> (strlen remainingPattern) 0) (setq result (DT:GetFirstLeftDatePattern remainingPattern)) (setq remainingPattern (substr remainingPattern (+ 1 (nth 1 result) (nth 2 result)))) (setq return (append return (list (list (nth 0 result) (+ currentCharPosition (nth 1 result)) (nth 2 result) )))) (setq currentCharPosition (+ currentCharPosition (nth 1 result) (nth 2 result))) );END while return );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: David Torralba ; Last revision: 2017.10.27 ) (defun DT:StringSearch ( pattern string / result ) ; Return the pattern position in the string and the length of the pattern, ; if pattern is found. Otherwise, return nil ; Example: (DT:StringSearch "YYYY" "012YYYY") --> ("YYYY" 3 4) ; - "YYYY": pattern found ; - 3: index (0 based) where the pattern started ; - 4: pattern length (if (and pattern string (= 'str (type pattern)) (= 'str (type string))) (if (setq result (vl-string-search pattern string)) (list pattern result (strlen pattern)) nil );END if );END if ; v0.0 - 2017.10.27 - First issue ; Author: David Torralba ; Last revision: 2017.10.27 ) (defun DT:GetFirstLeftDatePattern ( string / patternList i result ) ; Return a list with: ; - Pattern found ; - The position of the first pattern found in string (0-index based) ; - Length of the pattern ; Example: (DT:GetFirstLeftDatePattern "012345DD") --> ("DD" 6 2) (if (and string (= 'str (type string))) (progn (setq patternList (list "YYYY" "YY" "MMMM" "MMM" "MM" "M" "DD" "D" "hh" "h" "mm" "m" "SS" "S" "ss" "s")) (setq i 0) (while (and (not result) (<= i (length patternList))) (setq result (DT:StringSearch (nth i patternList) string)) (setq i (1+ i)) );END while result );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: David Torralba ; Last revision: 2017.10.27 ) (defun DT:GetDate ( pattern / now logic ) ; Return current time as per passed pattern ; Years: ; YYYY - Full year (2017) ; YY - Year last 2 digits (17) ; Months: ; MMMM - Month as text (August) ; MMM - Month as text short (Aug) ; MM - Month as number. 2 digits (08) ; M - Month as number. 1 digit if possible (8) ; Days: ; DDDD - Day of the week (Wednesday) ; DDD - Day of the week short (Wed) ; DD - Day of the month. 2 digits (06) ; D - Day of the month. 1 digit if possible (6) ; Hours: ; hh - Hours (24h). 2 digits (07) ; h - Hours (24h). 1 digit if possible (7) ; Minutes: ; mm - Minutes. 2 digits (04) ; m - Minutes. 1 digit if possible (4) ; Seconds: ; SS - Seconds. 2 digits (03) ; S - Seconds. 1 digit if possible (3) ; Miliseconds: ; ss - Miliseconds. 2 digits (03) ; s - Miliseconds. 1 digit if possible (3) (if (and pattern (= 'str (type pattern))) (progn (setq now (LM:rtos (getvar 'CDATE) 2 6)) (setq logic (DT:ParseDatePattern pattern)) );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: David Torralba ; Last revision: 2017.10.27 )
3286
(defun c:xx () ; Trigger (defun *error* ( errorMessage ) (princ (strcat "n-------- ERROR: " errorMessage " --------n")) (vl-bt) (DT:ReportError)) (DT:AutoLoadFileFromCivilTemp "ErrorTracing.lsp") (DT:AutoLoadFileFromCivilTemp "DateTime.lsp") (princ (strcat "\nTemp file loaded (" (DT:Now) ")\n"))(princ) (c:dateTimeTest) ; v0.0 - 2017.08.23 - First issue ; Author: <NAME> ; Last revision: 2017.08.23 ) ; (defun c:dateTimeTest ( / testCases testResults i ) ; ; test function for date time ; (setq testCases ; (list ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" 1) ; '("2017.08.23" "YYYY.MM.DD") ; );END list ; );END setq ; ; (setq testResults ; (mapcar ; '(lambda (testCase) ; (list ; testCase ; (DT:ParseDateTime (nth 0 testCase) (nth 1 testCase)) ; );END if ; );END lambda ; testCases ; );END mapcar ; );END setq ; (setq i 0) ; (foreach testResult testResults ; (setq i (1+ i)) ; (princ "\nTest ")(princ i)(princ ": ") ; (princ (nth 1 testResult)) ; (if (nth 1 testResult)(princ " ")(princ " ")) ; (princ (nth 0 testResult)) ; (princ "\n") ; );END foreach ; (princ) ; ; ; v0.0 - 2017.08.23 - First issue ; ; Author: <NAME> ; ; Last revision: 2017.08.23 ; ) (defun c:dateTimeTest ( / testCases testResults i ) ; test function for date time (setq testCases (list ; "YYYY" ; "YY" ; "MMMM" ; "MMM" ; "MM" ; "M" ; "DD" ; "D" ; "hh" ; "h" ; "mm" ; "m" ; "SS" ; "S" ; "ss" ; "s" ; "YYYY.MM.DD" "YYYY.MM.DD hh:mm:SS.ss" );END list );END setq (setq testResults (mapcar '(lambda (testCase) (princ testCase)(princ "\n")(list testCase (DT:ParseDatePattern testCase)) ) testCases );END mapcar );END setq (setq i 0) (foreach testResult testResults (setq i (1+ i)) (princ "\nTest ")(princ i)(princ ": ") (princ (nth 1 testResult)) (if (nth 1 testResult)(princ " ")(princ " ")) (princ (nth 0 testResult)) (princ "\n") );END foreach (princ) ; v0.0 - 2017.08.23 - First issue ; Author: <NAME> ; Last revision: 2017.08.23 ) (defun DT:DateTime ( in ) ; Parte input (if (DT:Arg 'DT:DateTime '((in 'str))) (progn (DT:PrintVar 'in) (cond ( (and ; yyyy/mm/dd (= 10 (strlen in)) (= "/" (substr in 5 1) ) (= "/" (substr in 8 1) ) );END and T );END subcond ( (and ; yyyy/mm/dd ; (= 10 (strlen in)) (= "." (substr in 5 1) ) (= "." (substr in 8 1) ) );END and T );END subcond (t (DT:Error 'DT:DateTime "\"in\" no understood mate...") );END subcond );END cond );END progn );END if ; v0.0 - 2017.08.23 - First issue ; Author: <NAME> ; Last revision: 2017.08.23 ) (defun DT:ParseDatePattern ( pattern / remainingPattern result return currentCharPosition ) (if (and pattern (= 'str (type pattern)) ) (progn (setq remainingPattern pattern) (setq currentCharPosition 1) ; 1-index based (while (> (strlen remainingPattern) 0) (setq result (DT:GetFirstLeftDatePattern remainingPattern)) (setq remainingPattern (substr remainingPattern (+ 1 (nth 1 result) (nth 2 result)))) (setq return (append return (list (list (nth 0 result) (+ currentCharPosition (nth 1 result)) (nth 2 result) )))) (setq currentCharPosition (+ currentCharPosition (nth 1 result) (nth 2 result))) );END while return );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: <NAME> ; Last revision: 2017.10.27 ) (defun DT:StringSearch ( pattern string / result ) ; Return the pattern position in the string and the length of the pattern, ; if pattern is found. Otherwise, return nil ; Example: (DT:StringSearch "YYYY" "012YYYY") --> ("YYYY" 3 4) ; - "YYYY": pattern found ; - 3: index (0 based) where the pattern started ; - 4: pattern length (if (and pattern string (= 'str (type pattern)) (= 'str (type string))) (if (setq result (vl-string-search pattern string)) (list pattern result (strlen pattern)) nil );END if );END if ; v0.0 - 2017.10.27 - First issue ; Author: <NAME> ; Last revision: 2017.10.27 ) (defun DT:GetFirstLeftDatePattern ( string / patternList i result ) ; Return a list with: ; - Pattern found ; - The position of the first pattern found in string (0-index based) ; - Length of the pattern ; Example: (DT:GetFirstLeftDatePattern "012345DD") --> ("DD" 6 2) (if (and string (= 'str (type string))) (progn (setq patternList (list "YYYY" "YY" "MMMM" "MMM" "MM" "M" "DD" "D" "hh" "h" "mm" "m" "SS" "S" "ss" "s")) (setq i 0) (while (and (not result) (<= i (length patternList))) (setq result (DT:StringSearch (nth i patternList) string)) (setq i (1+ i)) );END while result );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: <NAME> ; Last revision: 2017.10.27 ) (defun DT:GetDate ( pattern / now logic ) ; Return current time as per passed pattern ; Years: ; YYYY - Full year (2017) ; YY - Year last 2 digits (17) ; Months: ; MMMM - Month as text (August) ; MMM - Month as text short (Aug) ; MM - Month as number. 2 digits (08) ; M - Month as number. 1 digit if possible (8) ; Days: ; DDDD - Day of the week (Wednesday) ; DDD - Day of the week short (Wed) ; DD - Day of the month. 2 digits (06) ; D - Day of the month. 1 digit if possible (6) ; Hours: ; hh - Hours (24h). 2 digits (07) ; h - Hours (24h). 1 digit if possible (7) ; Minutes: ; mm - Minutes. 2 digits (04) ; m - Minutes. 1 digit if possible (4) ; Seconds: ; SS - Seconds. 2 digits (03) ; S - Seconds. 1 digit if possible (3) ; Miliseconds: ; ss - Miliseconds. 2 digits (03) ; s - Miliseconds. 1 digit if possible (3) (if (and pattern (= 'str (type pattern))) (progn (setq now (LM:rtos (getvar 'CDATE) 2 6)) (setq logic (DT:ParseDatePattern pattern)) );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: <NAME> ; Last revision: 2017.10.27 )
true
(defun c:xx () ; Trigger (defun *error* ( errorMessage ) (princ (strcat "n-------- ERROR: " errorMessage " --------n")) (vl-bt) (DT:ReportError)) (DT:AutoLoadFileFromCivilTemp "ErrorTracing.lsp") (DT:AutoLoadFileFromCivilTemp "DateTime.lsp") (princ (strcat "\nTemp file loaded (" (DT:Now) ")\n"))(princ) (c:dateTimeTest) ; v0.0 - 2017.08.23 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.08.23 ) ; (defun c:dateTimeTest ( / testCases testResults i ) ; ; test function for date time ; (setq testCases ; (list ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" "YYYY.MM.DD") ; '("2017.08.23" 1) ; '("2017.08.23" "YYYY.MM.DD") ; );END list ; );END setq ; ; (setq testResults ; (mapcar ; '(lambda (testCase) ; (list ; testCase ; (DT:ParseDateTime (nth 0 testCase) (nth 1 testCase)) ; );END if ; );END lambda ; testCases ; );END mapcar ; );END setq ; (setq i 0) ; (foreach testResult testResults ; (setq i (1+ i)) ; (princ "\nTest ")(princ i)(princ ": ") ; (princ (nth 1 testResult)) ; (if (nth 1 testResult)(princ " ")(princ " ")) ; (princ (nth 0 testResult)) ; (princ "\n") ; );END foreach ; (princ) ; ; ; v0.0 - 2017.08.23 - First issue ; ; Author: PI:NAME:<NAME>END_PI ; ; Last revision: 2017.08.23 ; ) (defun c:dateTimeTest ( / testCases testResults i ) ; test function for date time (setq testCases (list ; "YYYY" ; "YY" ; "MMMM" ; "MMM" ; "MM" ; "M" ; "DD" ; "D" ; "hh" ; "h" ; "mm" ; "m" ; "SS" ; "S" ; "ss" ; "s" ; "YYYY.MM.DD" "YYYY.MM.DD hh:mm:SS.ss" );END list );END setq (setq testResults (mapcar '(lambda (testCase) (princ testCase)(princ "\n")(list testCase (DT:ParseDatePattern testCase)) ) testCases );END mapcar );END setq (setq i 0) (foreach testResult testResults (setq i (1+ i)) (princ "\nTest ")(princ i)(princ ": ") (princ (nth 1 testResult)) (if (nth 1 testResult)(princ " ")(princ " ")) (princ (nth 0 testResult)) (princ "\n") );END foreach (princ) ; v0.0 - 2017.08.23 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.08.23 ) (defun DT:DateTime ( in ) ; Parte input (if (DT:Arg 'DT:DateTime '((in 'str))) (progn (DT:PrintVar 'in) (cond ( (and ; yyyy/mm/dd (= 10 (strlen in)) (= "/" (substr in 5 1) ) (= "/" (substr in 8 1) ) );END and T );END subcond ( (and ; yyyy/mm/dd ; (= 10 (strlen in)) (= "." (substr in 5 1) ) (= "." (substr in 8 1) ) );END and T );END subcond (t (DT:Error 'DT:DateTime "\"in\" no understood mate...") );END subcond );END cond );END progn );END if ; v0.0 - 2017.08.23 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.08.23 ) (defun DT:ParseDatePattern ( pattern / remainingPattern result return currentCharPosition ) (if (and pattern (= 'str (type pattern)) ) (progn (setq remainingPattern pattern) (setq currentCharPosition 1) ; 1-index based (while (> (strlen remainingPattern) 0) (setq result (DT:GetFirstLeftDatePattern remainingPattern)) (setq remainingPattern (substr remainingPattern (+ 1 (nth 1 result) (nth 2 result)))) (setq return (append return (list (list (nth 0 result) (+ currentCharPosition (nth 1 result)) (nth 2 result) )))) (setq currentCharPosition (+ currentCharPosition (nth 1 result) (nth 2 result))) );END while return );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.10.27 ) (defun DT:StringSearch ( pattern string / result ) ; Return the pattern position in the string and the length of the pattern, ; if pattern is found. Otherwise, return nil ; Example: (DT:StringSearch "YYYY" "012YYYY") --> ("YYYY" 3 4) ; - "YYYY": pattern found ; - 3: index (0 based) where the pattern started ; - 4: pattern length (if (and pattern string (= 'str (type pattern)) (= 'str (type string))) (if (setq result (vl-string-search pattern string)) (list pattern result (strlen pattern)) nil );END if );END if ; v0.0 - 2017.10.27 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.10.27 ) (defun DT:GetFirstLeftDatePattern ( string / patternList i result ) ; Return a list with: ; - Pattern found ; - The position of the first pattern found in string (0-index based) ; - Length of the pattern ; Example: (DT:GetFirstLeftDatePattern "012345DD") --> ("DD" 6 2) (if (and string (= 'str (type string))) (progn (setq patternList (list "YYYY" "YY" "MMMM" "MMM" "MM" "M" "DD" "D" "hh" "h" "mm" "m" "SS" "S" "ss" "s")) (setq i 0) (while (and (not result) (<= i (length patternList))) (setq result (DT:StringSearch (nth i patternList) string)) (setq i (1+ i)) );END while result );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.10.27 ) (defun DT:GetDate ( pattern / now logic ) ; Return current time as per passed pattern ; Years: ; YYYY - Full year (2017) ; YY - Year last 2 digits (17) ; Months: ; MMMM - Month as text (August) ; MMM - Month as text short (Aug) ; MM - Month as number. 2 digits (08) ; M - Month as number. 1 digit if possible (8) ; Days: ; DDDD - Day of the week (Wednesday) ; DDD - Day of the week short (Wed) ; DD - Day of the month. 2 digits (06) ; D - Day of the month. 1 digit if possible (6) ; Hours: ; hh - Hours (24h). 2 digits (07) ; h - Hours (24h). 1 digit if possible (7) ; Minutes: ; mm - Minutes. 2 digits (04) ; m - Minutes. 1 digit if possible (4) ; Seconds: ; SS - Seconds. 2 digits (03) ; S - Seconds. 1 digit if possible (3) ; Miliseconds: ; ss - Miliseconds. 2 digits (03) ; s - Miliseconds. 1 digit if possible (3) (if (and pattern (= 'str (type pattern))) (progn (setq now (LM:rtos (getvar 'CDATE) 2 6)) (setq logic (DT:ParseDatePattern pattern)) );END progn );END if ; v0.0 - 2017.10.27 - First issue ; Author: PI:NAME:<NAME>END_PI ; Last revision: 2017.10.27 )
[ { "context": "SDF system definition\n\n;; Copyright (C) 2019, 2021 Didier Verna\n\n;; Author: Didier Verna <[email protected]>", "end": 96, "score": 0.9998965263366699, "start": 84, "tag": "NAME", "value": "Didier Verna" }, { "context": " Copyright (C) 2019, 2021 Didier Verna\n\n;; Author: Didier Verna <[email protected]>\n\n;; This file is part of", "end": 121, "score": 0.9999005198478699, "start": 109, "tag": "NAME", "value": "Didier Verna" }, { "context": "2019, 2021 Didier Verna\n\n;; Author: Didier Verna <[email protected]>\n\n;; This file is part of TFM.\n\n;; Permission to ", "end": 145, "score": 0.9999350309371948, "start": 123, "tag": "EMAIL", "value": "[email protected]" }, { "context": "ding font information in\nCommon Lisp.\"\n :author \"Didier Verna\"\n :mailto \"[email protected]\"\n :homepage \"", "end": 1352, "score": 0.9999009370803833, "start": 1340, "tag": "NAME", "value": "Didier Verna" }, { "context": "Common Lisp.\"\n :author \"Didier Verna\"\n :mailto \"[email protected]\"\n :homepage \"http://www.lrde.epita.fr/~didier/so", "end": 1387, "score": 0.9999349117279053, "start": 1365, "tag": "EMAIL", "value": "[email protected]" } ]
net.didierverna.tfm.asd
didierverna/tfm
15
;;; net.didierverna.tfm.asd --- ASDF system definition ;; Copyright (C) 2019, 2021 Didier Verna ;; Author: Didier Verna <[email protected]> ;; This file is part of TFM. ;; Permission to use, copy, modify, and distribute this software for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;;; Commentary: ;;; Code: (defsystem :net.didierverna.tfm :long-name "TeX Font Metrics" :description "A Common Lisp interface to the TeX Font Metrics format" :long-description "\ TFM (for TeX Font Metrics) is the standard font description format used by TeX. The TFM library parses and decodes TFM files into an abstract data structure, providing easy access to the corresponding font information in Common Lisp." :author "Didier Verna" :mailto "[email protected]" :homepage "http://www.lrde.epita.fr/~didier/software/lisp/typesetting.php#tfm" :source-control "https://github.com/didierverna/tfm" :license "BSD" :version (:read-file-line #p"make/version.make" :at (1 (lambda (str) (subseq str 19)))) :depends-on (:net.didierverna.tfm.core)) ;;; net.didierverna.tfm.asd ends here
22825
;;; net.didierverna.tfm.asd --- ASDF system definition ;; Copyright (C) 2019, 2021 <NAME> ;; Author: <NAME> <<EMAIL>> ;; This file is part of TFM. ;; Permission to use, copy, modify, and distribute this software for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;;; Commentary: ;;; Code: (defsystem :net.didierverna.tfm :long-name "TeX Font Metrics" :description "A Common Lisp interface to the TeX Font Metrics format" :long-description "\ TFM (for TeX Font Metrics) is the standard font description format used by TeX. The TFM library parses and decodes TFM files into an abstract data structure, providing easy access to the corresponding font information in Common Lisp." :author "<NAME>" :mailto "<EMAIL>" :homepage "http://www.lrde.epita.fr/~didier/software/lisp/typesetting.php#tfm" :source-control "https://github.com/didierverna/tfm" :license "BSD" :version (:read-file-line #p"make/version.make" :at (1 (lambda (str) (subseq str 19)))) :depends-on (:net.didierverna.tfm.core)) ;;; net.didierverna.tfm.asd ends here
true
;;; net.didierverna.tfm.asd --- ASDF system definition ;; Copyright (C) 2019, 2021 PI:NAME:<NAME>END_PI ;; Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> ;; This file is part of TFM. ;; Permission to use, copy, modify, and distribute this software for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;;; Commentary: ;;; Code: (defsystem :net.didierverna.tfm :long-name "TeX Font Metrics" :description "A Common Lisp interface to the TeX Font Metrics format" :long-description "\ TFM (for TeX Font Metrics) is the standard font description format used by TeX. The TFM library parses and decodes TFM files into an abstract data structure, providing easy access to the corresponding font information in Common Lisp." :author "PI:NAME:<NAME>END_PI" :mailto "PI:EMAIL:<EMAIL>END_PI" :homepage "http://www.lrde.epita.fr/~didier/software/lisp/typesetting.php#tfm" :source-control "https://github.com/didierverna/tfm" :license "BSD" :version (:read-file-line #p"make/version.make" :at (1 (lambda (str) (subseq str 19)))) :depends-on (:net.didierverna.tfm.core)) ;;; net.didierverna.tfm.asd ends here
[ { "context": "#|\nThis file is a part of aoc-2021\n(c) 2021 Janne Pakarinen ([email protected])\nAuthor: Janne Pakarinen <", "end": 59, "score": 0.9998930096626282, "start": 44, "tag": "NAME", "value": "Janne Pakarinen" }, { "context": "e is a part of aoc-2021\n(c) 2021 Janne Pakarinen ([email protected])\nAuthor: Janne Pakarinen <[email protected]>\n", "end": 82, "score": 0.9999281764030457, "start": 61, "tag": "EMAIL", "value": "[email protected]" }, { "context": "21 Janne Pakarinen ([email protected])\nAuthor: Janne Pakarinen <[email protected]>\n|#\n\n(in-package #:aoc-202", "end": 107, "score": 0.9998965263366699, "start": 92, "tag": "NAME", "value": "Janne Pakarinen" }, { "context": " ([email protected])\nAuthor: Janne Pakarinen <[email protected]>\n|#\n\n(in-package #:aoc-2021)\n\n(defparameter *day8", "end": 130, "score": 0.9999271035194397, "start": 109, "tag": "EMAIL", "value": "[email protected]" } ]
day8.lisp
gingeralesy/aoc-2021
0
#| This file is a part of aoc-2021 (c) 2021 Janne Pakarinen ([email protected]) Author: Janne Pakarinen <[email protected]> |# (in-package #:aoc-2021) (defparameter *day8-input* (local-file #P"day8.txt" :error T)) (defun d8-ch-to-signal (ch) "Converts the individual code character into its signal value." (ecase ch (#\a 1) (#\b 2) (#\c 4) (#\d 8) (#\e 16) (#\f 32) (#\g 64))) (defun d8-signal-to-ch (number) "Converts the individual code character's signal value into its character." (ecase number (0 NIL) (1 #\a) (2 #\b) (4 #\c) (8 #\d) (16 #\e) (32 #\f) (64 #\g))) (defun d8-code-to-signal (code) "Converts a code to its signal value." (loop with segment = 0 for ch across code do (incf segment (d8-ch-to-signal ch)) finally (return (logand segment #x7f)))) (defun d8-signal-to-code (number) "Converts a signal value to its code." (loop for n from 0 below 7 for ch = (d8-signal-to-ch (logand number (ash 1 n))) when ch collect ch into characters finally (return (format NIL "~{~c~}" characters)))) (defun d8-data () "Returns a list of entries where each entry is an array of ten signal, one for each digit, and four codes to solve." (with-open-file (stream *day8-input* :if-does-not-exist :error) (let ((scanner (cl-ppcre:create-scanner "\\w+"))) (loop for line = (read-line stream NIL) for entry = (make-array 14 :element-type '(unsigned-byte 7) :initial-element 0) for count = 0 while line do (cl-ppcre:do-matches-as-strings (match scanner line) (setf (aref entry count) (d8-code-to-signal match)) (incf count)) collect entry into values finally (return values))))) #| --- Day 8: Seven Segment Search --- You barely reach the safety of the cave when the whale smashes into the cave mouth, collapsing it. Sensors indicate another exit to this cave at a much greater depth, so you have no choice but to press on. As your submarine slowly makes its way through the cave system, you notice that the four-digit seven-segment displays in your submarine are malfunctioning; they must have been damaged during the escape. You'll be in a lot of trouble without them, so you'd better figure out what's wrong. Each digit of a seven-segment display is rendered by turning on or off any of seven segments named a through g: 0: 1: 2: 3: 4: aaaa .... aaaa aaaa .... b c . c . c . c b c b c . c . c . c b c .... .... dddd dddd dddd e f . f e . . f . f e f . f e . . f . f gggg .... gggg gggg .... 5: 6: 7: 8: 9: aaaa aaaa aaaa aaaa aaaa b . b . . c b c b c b . b . . c b c b c dddd dddd .... dddd dddd . f e f . f e f . f . f e f . f e f . f gggg gggg .... gggg gggg So, to render a 1, only segments c and f would be turned on; the rest would be off. To render a 7, only segments a, c, and f would be turned on. The problem is that the signals which control the segments have been mixed up on each display. The submarine is still trying to display numbers by producing output on signal wires a through g, but those wires are connected to segments randomly. Worse, the wire/segment connections are mixed up separately for each four-digit display! (All of the digits within a display use the same connections, though.) So, you might know that only signal wires b and g are turned on, but that doesn't mean segments b and g are turned on: the only digit that uses two segments is 1, so it must mean segments c and f are meant to be on. With just that information, you still can't tell which wire (b/g) goes to which segment (c/f). For that, you'll need to collect more information. For each display, you watch the changing signals for a while, make a note of all ten unique signal patterns you see, and then write down a single four digit output value (your puzzle input). Using the signal patterns, you should be able to work out which pattern corresponds to which digit. For example, here is what you might see in a single entry in your notes: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf Each entry consists of ten unique signal patterns, a | delimiter, and finally the four digit output value. Within an entry, the same wire/segment connections are used (but you don't know what the connections actually are). The unique signal patterns correspond to the ten different ways the submarine tries to render a digit using the current wire/segment connections. Because 7 is the only digit that uses three segments, dab in the above example means that to render a 7, signal lines d, a, and b are on. Because 4 is the only digit that uses four segments, eafb means that to render a 4, signal lines e, a, f, and b are on. Using this information, you should be able to work out which combination of signal wires corresponds to each of the ten digits. Then, you can decode the four digit output value. Unfortunately, in the above example, all of the digits in the output value (cdfeb fcadb cdfeb cdbaf) use five segments and are more difficult to deduce. For now, focus on the easy digits. Consider this larger example: be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce Because the digits 1, 4, 7, and 8 each use a unique number of segments, you should be able to tell which combinations of signals correspond to those digits. Counting only digits in the output values (the part after | on each line), in the above example, there are 26 instances of digits that use a unique number of segments (highlighted above). In the output values, how many times do digits 1, 4, 7, or 8 appear? |# (defun d8-count-active (value) (loop for n from 0 below 7 count (< 0 (logand value (ash 1 n))))) (defun d8p1 () (loop for entry in (d8-data) sum (loop for i from 10 below 14 for segment = (aref entry i) for signals = (d8-count-active segment) count (or (= signals 2) (= signals 3) (= signals 4) (= signals 7))))) ;; Answer: 301 #| --- Part Two --- Through a little deduction, you should now be able to determine the remaining digits. Consider again the first example above: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf After some careful analysis, the mapping between signal wires and segments only make sense in the following configuration: dddd e a e a ffff g b g b cccc So, the unique signal patterns would correspond to the following digits: acedgfb: 8 cdfbe: 5 gcdfa: 2 fbcad: 3 dab: 7 cefabd: 9 cdfgeb: 6 eafb: 4 cagedb: 0 ab: 1 Then, the four digits of the output value can be decoded: cdfeb: 5 fcadb: 3 cdfeb: 5 cdbaf: 3 Therefore, the output value for this entry is 5353. Following this same process for each entry in the second, larger example above, the output value of each entry can be determined: fdgacbe cefdb cefbgd gcbe: 8394 fcgedb cgb dgebacf gc: 9781 cg cg fdcagb cbg: 1197 efabcd cedba gadfec cb: 9361 gecf egdcabf bgf bfgea: 4873 gebdcfa ecba ca fadegcb: 8418 cefg dcbef fcge gbcadfe: 4548 ed bcgafe cdgba cbgef: 1625 gbdfcae bgc cg cgb: 8717 fgae cfgab fg bagce: 4315 Adding all of the output values in this larger example produces 61229. For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values? |# (defun d8-solve (entry) "This is the silly solution where we deduce everything step by step." ;; TODO: The cool solution where we traverse a tree of possibilities. (let ((digit-signal (make-array 10 :element-type '(unsigned-byte 7) :initial-element 0)) (digit-side (make-array 7 :element-type '(unsigned-byte 7) :initial-element 0))) (labels ((get-signal (number) (aref digit-signal number)) (set-signal (number value) (let ((value (logand value #x7f))) (loop for n from 0 until (= value (aref entry n)) when (= 10 n) do (error "Invalid signal: ~a" value)) (setf (aref digit-signal number) value))) (get-side-index (side) (ecase side (:top 0) (:top-left 1) (:top-right 2) (:middle 3) (:bottom-left 4) (:bottom-right 5) (:bottom 6))) (get-side (side) (let ((value (aref digit-side (get-side-index side)))) (unless (< 0 value) (error "Side not found yet: ~a" side)) value)) (get-sides (side &rest sides) (let ((value (get-side side))) (loop for another in sides do (incf value (get-side another))) value)) (set-side (side value) (let ((value (logand value #x7f))) (unless (= 1 (d8-count-active value)) (error "Invalid side value: ~a ~a" side value)) (setf (aref digit-side (get-side-index side)) value)))) ;; 1. Find 1, 4, 7, and 8. (loop for n from 0 below 10 for signal = (aref entry n) for active = (d8-count-active signal) do (case active (2 (set-signal 1 signal)) (4 (set-signal 4 signal)) (3 (set-signal 7 signal)) (7 (set-signal 8 signal)))) ;; We have signals: 1 4 7 8 ;; We have sides : ;; 2. Compare 1 and 7 to find the top. (set-side :top (logxor (get-signal 1) (get-signal 7))) ;; We have signals: 1 4 7 8 ;; We have sides : top ;; 3. Use 4 and the top to find 9. ;; 9 only has one extra, which is the bottom. ;; The missing one from 9 is bottom-left. (loop for n from 0 below 10 for nine = (aref entry n) until (< 0 (get-signal 9)) when (= 6 (d8-count-active nine)) do (let ((four-top (logior (get-signal 4) (get-side :top)))) (when (= 1 (d8-count-active (logxor four-top nine))) (set-signal 9 nine) (set-side :bottom (logxor four-top nine)) (set-side :bottom-left (lognot nine))))) ;; We have signals: 1 4 7 8 9 ;; We have sides : top bottom-left bottom ;; 4. 7 + bottom + some other that is mid = 3. ;; With middle and eight we can get zero. (loop for n from 0 below 10 for three = (aref entry n) until (< 0 (get-signal 3)) when (= 5 (d8-count-active three)) do (let ((seven-bottom (logior (get-signal 7) (get-side :bottom)))) (when (= 1 (d8-count-active (logxor seven-bottom three))) (set-signal 3 three) (set-side :middle (logxor seven-bottom three)) (set-signal 0 (logxor (get-signal 8) (get-side :middle)))))) ;; We have signals: 0 1 3 4 7 8 9 ;; We have sides : top middle bottom-left bottom ;; 5. Top + mid + bottom + bottom-left + some other = 2, some other is top-right. ;; Top right and one reveal bottom right. (loop for n from 0 below 10 for two = (aref entry n) until (< 0 (get-signal 2)) when (= 5 (d8-count-active two)) do (let ((t-m-b-bl (get-sides :top :middle :bottom :bottom-left))) (when (= 1 (d8-count-active (logxor t-m-b-bl two))) (set-signal 2 two) (set-side :top-right (logxor t-m-b-bl two)) (set-side :bottom-right (logxor (get-side :top-right) (get-signal 1)))))) ;; We have signals: 0 1 2 3 4 7 8 9 ;; We have sides : top top-right middle bottom-left bottom-right bottom ;; 6. Rest we can deduce. 4 - (1 + mid) = top-left ;; And then we can just build number five. (let ((one-mid (logior (get-signal 1) (get-side :middle)))) (set-side :top-left (logxor (get-signal 4) one-mid))) (set-signal 5 (get-sides :top :top-left :middle :bottom-right :bottom)) (set-signal 6 (logxor (get-signal 8) (get-side :top-right))) ;; We have signals: 0 1 2 3 4 5 6 7 8 9 ;; Done. ;; We have sides : top top-left top-right middle bottom-left bottom-right bottom ;; Done. (let ((number 0)) (dotimes (i 4) (loop with digit = (aref entry (+ i 10)) for n from 0 while (/= digit (get-signal n)) finally (incf number (* (/ 1000 (expt 10 i)) n)))) number)))) (defun d8p2 () (loop for entry in (d8-data) sum (d8-solve entry))) ;; Answer: 908067
70954
#| This file is a part of aoc-2021 (c) 2021 <NAME> (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:aoc-2021) (defparameter *day8-input* (local-file #P"day8.txt" :error T)) (defun d8-ch-to-signal (ch) "Converts the individual code character into its signal value." (ecase ch (#\a 1) (#\b 2) (#\c 4) (#\d 8) (#\e 16) (#\f 32) (#\g 64))) (defun d8-signal-to-ch (number) "Converts the individual code character's signal value into its character." (ecase number (0 NIL) (1 #\a) (2 #\b) (4 #\c) (8 #\d) (16 #\e) (32 #\f) (64 #\g))) (defun d8-code-to-signal (code) "Converts a code to its signal value." (loop with segment = 0 for ch across code do (incf segment (d8-ch-to-signal ch)) finally (return (logand segment #x7f)))) (defun d8-signal-to-code (number) "Converts a signal value to its code." (loop for n from 0 below 7 for ch = (d8-signal-to-ch (logand number (ash 1 n))) when ch collect ch into characters finally (return (format NIL "~{~c~}" characters)))) (defun d8-data () "Returns a list of entries where each entry is an array of ten signal, one for each digit, and four codes to solve." (with-open-file (stream *day8-input* :if-does-not-exist :error) (let ((scanner (cl-ppcre:create-scanner "\\w+"))) (loop for line = (read-line stream NIL) for entry = (make-array 14 :element-type '(unsigned-byte 7) :initial-element 0) for count = 0 while line do (cl-ppcre:do-matches-as-strings (match scanner line) (setf (aref entry count) (d8-code-to-signal match)) (incf count)) collect entry into values finally (return values))))) #| --- Day 8: Seven Segment Search --- You barely reach the safety of the cave when the whale smashes into the cave mouth, collapsing it. Sensors indicate another exit to this cave at a much greater depth, so you have no choice but to press on. As your submarine slowly makes its way through the cave system, you notice that the four-digit seven-segment displays in your submarine are malfunctioning; they must have been damaged during the escape. You'll be in a lot of trouble without them, so you'd better figure out what's wrong. Each digit of a seven-segment display is rendered by turning on or off any of seven segments named a through g: 0: 1: 2: 3: 4: aaaa .... aaaa aaaa .... b c . c . c . c b c b c . c . c . c b c .... .... dddd dddd dddd e f . f e . . f . f e f . f e . . f . f gggg .... gggg gggg .... 5: 6: 7: 8: 9: aaaa aaaa aaaa aaaa aaaa b . b . . c b c b c b . b . . c b c b c dddd dddd .... dddd dddd . f e f . f e f . f . f e f . f e f . f gggg gggg .... gggg gggg So, to render a 1, only segments c and f would be turned on; the rest would be off. To render a 7, only segments a, c, and f would be turned on. The problem is that the signals which control the segments have been mixed up on each display. The submarine is still trying to display numbers by producing output on signal wires a through g, but those wires are connected to segments randomly. Worse, the wire/segment connections are mixed up separately for each four-digit display! (All of the digits within a display use the same connections, though.) So, you might know that only signal wires b and g are turned on, but that doesn't mean segments b and g are turned on: the only digit that uses two segments is 1, so it must mean segments c and f are meant to be on. With just that information, you still can't tell which wire (b/g) goes to which segment (c/f). For that, you'll need to collect more information. For each display, you watch the changing signals for a while, make a note of all ten unique signal patterns you see, and then write down a single four digit output value (your puzzle input). Using the signal patterns, you should be able to work out which pattern corresponds to which digit. For example, here is what you might see in a single entry in your notes: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf Each entry consists of ten unique signal patterns, a | delimiter, and finally the four digit output value. Within an entry, the same wire/segment connections are used (but you don't know what the connections actually are). The unique signal patterns correspond to the ten different ways the submarine tries to render a digit using the current wire/segment connections. Because 7 is the only digit that uses three segments, dab in the above example means that to render a 7, signal lines d, a, and b are on. Because 4 is the only digit that uses four segments, eafb means that to render a 4, signal lines e, a, f, and b are on. Using this information, you should be able to work out which combination of signal wires corresponds to each of the ten digits. Then, you can decode the four digit output value. Unfortunately, in the above example, all of the digits in the output value (cdfeb fcadb cdfeb cdbaf) use five segments and are more difficult to deduce. For now, focus on the easy digits. Consider this larger example: be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce Because the digits 1, 4, 7, and 8 each use a unique number of segments, you should be able to tell which combinations of signals correspond to those digits. Counting only digits in the output values (the part after | on each line), in the above example, there are 26 instances of digits that use a unique number of segments (highlighted above). In the output values, how many times do digits 1, 4, 7, or 8 appear? |# (defun d8-count-active (value) (loop for n from 0 below 7 count (< 0 (logand value (ash 1 n))))) (defun d8p1 () (loop for entry in (d8-data) sum (loop for i from 10 below 14 for segment = (aref entry i) for signals = (d8-count-active segment) count (or (= signals 2) (= signals 3) (= signals 4) (= signals 7))))) ;; Answer: 301 #| --- Part Two --- Through a little deduction, you should now be able to determine the remaining digits. Consider again the first example above: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf After some careful analysis, the mapping between signal wires and segments only make sense in the following configuration: dddd e a e a ffff g b g b cccc So, the unique signal patterns would correspond to the following digits: acedgfb: 8 cdfbe: 5 gcdfa: 2 fbcad: 3 dab: 7 cefabd: 9 cdfgeb: 6 eafb: 4 cagedb: 0 ab: 1 Then, the four digits of the output value can be decoded: cdfeb: 5 fcadb: 3 cdfeb: 5 cdbaf: 3 Therefore, the output value for this entry is 5353. Following this same process for each entry in the second, larger example above, the output value of each entry can be determined: fdgacbe cefdb cefbgd gcbe: 8394 fcgedb cgb dgebacf gc: 9781 cg cg fdcagb cbg: 1197 efabcd cedba gadfec cb: 9361 gecf egdcabf bgf bfgea: 4873 gebdcfa ecba ca fadegcb: 8418 cefg dcbef fcge gbcadfe: 4548 ed bcgafe cdgba cbgef: 1625 gbdfcae bgc cg cgb: 8717 fgae cfgab fg bagce: 4315 Adding all of the output values in this larger example produces 61229. For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values? |# (defun d8-solve (entry) "This is the silly solution where we deduce everything step by step." ;; TODO: The cool solution where we traverse a tree of possibilities. (let ((digit-signal (make-array 10 :element-type '(unsigned-byte 7) :initial-element 0)) (digit-side (make-array 7 :element-type '(unsigned-byte 7) :initial-element 0))) (labels ((get-signal (number) (aref digit-signal number)) (set-signal (number value) (let ((value (logand value #x7f))) (loop for n from 0 until (= value (aref entry n)) when (= 10 n) do (error "Invalid signal: ~a" value)) (setf (aref digit-signal number) value))) (get-side-index (side) (ecase side (:top 0) (:top-left 1) (:top-right 2) (:middle 3) (:bottom-left 4) (:bottom-right 5) (:bottom 6))) (get-side (side) (let ((value (aref digit-side (get-side-index side)))) (unless (< 0 value) (error "Side not found yet: ~a" side)) value)) (get-sides (side &rest sides) (let ((value (get-side side))) (loop for another in sides do (incf value (get-side another))) value)) (set-side (side value) (let ((value (logand value #x7f))) (unless (= 1 (d8-count-active value)) (error "Invalid side value: ~a ~a" side value)) (setf (aref digit-side (get-side-index side)) value)))) ;; 1. Find 1, 4, 7, and 8. (loop for n from 0 below 10 for signal = (aref entry n) for active = (d8-count-active signal) do (case active (2 (set-signal 1 signal)) (4 (set-signal 4 signal)) (3 (set-signal 7 signal)) (7 (set-signal 8 signal)))) ;; We have signals: 1 4 7 8 ;; We have sides : ;; 2. Compare 1 and 7 to find the top. (set-side :top (logxor (get-signal 1) (get-signal 7))) ;; We have signals: 1 4 7 8 ;; We have sides : top ;; 3. Use 4 and the top to find 9. ;; 9 only has one extra, which is the bottom. ;; The missing one from 9 is bottom-left. (loop for n from 0 below 10 for nine = (aref entry n) until (< 0 (get-signal 9)) when (= 6 (d8-count-active nine)) do (let ((four-top (logior (get-signal 4) (get-side :top)))) (when (= 1 (d8-count-active (logxor four-top nine))) (set-signal 9 nine) (set-side :bottom (logxor four-top nine)) (set-side :bottom-left (lognot nine))))) ;; We have signals: 1 4 7 8 9 ;; We have sides : top bottom-left bottom ;; 4. 7 + bottom + some other that is mid = 3. ;; With middle and eight we can get zero. (loop for n from 0 below 10 for three = (aref entry n) until (< 0 (get-signal 3)) when (= 5 (d8-count-active three)) do (let ((seven-bottom (logior (get-signal 7) (get-side :bottom)))) (when (= 1 (d8-count-active (logxor seven-bottom three))) (set-signal 3 three) (set-side :middle (logxor seven-bottom three)) (set-signal 0 (logxor (get-signal 8) (get-side :middle)))))) ;; We have signals: 0 1 3 4 7 8 9 ;; We have sides : top middle bottom-left bottom ;; 5. Top + mid + bottom + bottom-left + some other = 2, some other is top-right. ;; Top right and one reveal bottom right. (loop for n from 0 below 10 for two = (aref entry n) until (< 0 (get-signal 2)) when (= 5 (d8-count-active two)) do (let ((t-m-b-bl (get-sides :top :middle :bottom :bottom-left))) (when (= 1 (d8-count-active (logxor t-m-b-bl two))) (set-signal 2 two) (set-side :top-right (logxor t-m-b-bl two)) (set-side :bottom-right (logxor (get-side :top-right) (get-signal 1)))))) ;; We have signals: 0 1 2 3 4 7 8 9 ;; We have sides : top top-right middle bottom-left bottom-right bottom ;; 6. Rest we can deduce. 4 - (1 + mid) = top-left ;; And then we can just build number five. (let ((one-mid (logior (get-signal 1) (get-side :middle)))) (set-side :top-left (logxor (get-signal 4) one-mid))) (set-signal 5 (get-sides :top :top-left :middle :bottom-right :bottom)) (set-signal 6 (logxor (get-signal 8) (get-side :top-right))) ;; We have signals: 0 1 2 3 4 5 6 7 8 9 ;; Done. ;; We have sides : top top-left top-right middle bottom-left bottom-right bottom ;; Done. (let ((number 0)) (dotimes (i 4) (loop with digit = (aref entry (+ i 10)) for n from 0 while (/= digit (get-signal n)) finally (incf number (* (/ 1000 (expt 10 i)) n)))) number)))) (defun d8p2 () (loop for entry in (d8-data) sum (d8-solve entry))) ;; Answer: 908067
true
#| This file is a part of aoc-2021 (c) 2021 PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:aoc-2021) (defparameter *day8-input* (local-file #P"day8.txt" :error T)) (defun d8-ch-to-signal (ch) "Converts the individual code character into its signal value." (ecase ch (#\a 1) (#\b 2) (#\c 4) (#\d 8) (#\e 16) (#\f 32) (#\g 64))) (defun d8-signal-to-ch (number) "Converts the individual code character's signal value into its character." (ecase number (0 NIL) (1 #\a) (2 #\b) (4 #\c) (8 #\d) (16 #\e) (32 #\f) (64 #\g))) (defun d8-code-to-signal (code) "Converts a code to its signal value." (loop with segment = 0 for ch across code do (incf segment (d8-ch-to-signal ch)) finally (return (logand segment #x7f)))) (defun d8-signal-to-code (number) "Converts a signal value to its code." (loop for n from 0 below 7 for ch = (d8-signal-to-ch (logand number (ash 1 n))) when ch collect ch into characters finally (return (format NIL "~{~c~}" characters)))) (defun d8-data () "Returns a list of entries where each entry is an array of ten signal, one for each digit, and four codes to solve." (with-open-file (stream *day8-input* :if-does-not-exist :error) (let ((scanner (cl-ppcre:create-scanner "\\w+"))) (loop for line = (read-line stream NIL) for entry = (make-array 14 :element-type '(unsigned-byte 7) :initial-element 0) for count = 0 while line do (cl-ppcre:do-matches-as-strings (match scanner line) (setf (aref entry count) (d8-code-to-signal match)) (incf count)) collect entry into values finally (return values))))) #| --- Day 8: Seven Segment Search --- You barely reach the safety of the cave when the whale smashes into the cave mouth, collapsing it. Sensors indicate another exit to this cave at a much greater depth, so you have no choice but to press on. As your submarine slowly makes its way through the cave system, you notice that the four-digit seven-segment displays in your submarine are malfunctioning; they must have been damaged during the escape. You'll be in a lot of trouble without them, so you'd better figure out what's wrong. Each digit of a seven-segment display is rendered by turning on or off any of seven segments named a through g: 0: 1: 2: 3: 4: aaaa .... aaaa aaaa .... b c . c . c . c b c b c . c . c . c b c .... .... dddd dddd dddd e f . f e . . f . f e f . f e . . f . f gggg .... gggg gggg .... 5: 6: 7: 8: 9: aaaa aaaa aaaa aaaa aaaa b . b . . c b c b c b . b . . c b c b c dddd dddd .... dddd dddd . f e f . f e f . f . f e f . f e f . f gggg gggg .... gggg gggg So, to render a 1, only segments c and f would be turned on; the rest would be off. To render a 7, only segments a, c, and f would be turned on. The problem is that the signals which control the segments have been mixed up on each display. The submarine is still trying to display numbers by producing output on signal wires a through g, but those wires are connected to segments randomly. Worse, the wire/segment connections are mixed up separately for each four-digit display! (All of the digits within a display use the same connections, though.) So, you might know that only signal wires b and g are turned on, but that doesn't mean segments b and g are turned on: the only digit that uses two segments is 1, so it must mean segments c and f are meant to be on. With just that information, you still can't tell which wire (b/g) goes to which segment (c/f). For that, you'll need to collect more information. For each display, you watch the changing signals for a while, make a note of all ten unique signal patterns you see, and then write down a single four digit output value (your puzzle input). Using the signal patterns, you should be able to work out which pattern corresponds to which digit. For example, here is what you might see in a single entry in your notes: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf Each entry consists of ten unique signal patterns, a | delimiter, and finally the four digit output value. Within an entry, the same wire/segment connections are used (but you don't know what the connections actually are). The unique signal patterns correspond to the ten different ways the submarine tries to render a digit using the current wire/segment connections. Because 7 is the only digit that uses three segments, dab in the above example means that to render a 7, signal lines d, a, and b are on. Because 4 is the only digit that uses four segments, eafb means that to render a 4, signal lines e, a, f, and b are on. Using this information, you should be able to work out which combination of signal wires corresponds to each of the ten digits. Then, you can decode the four digit output value. Unfortunately, in the above example, all of the digits in the output value (cdfeb fcadb cdfeb cdbaf) use five segments and are more difficult to deduce. For now, focus on the easy digits. Consider this larger example: be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce Because the digits 1, 4, 7, and 8 each use a unique number of segments, you should be able to tell which combinations of signals correspond to those digits. Counting only digits in the output values (the part after | on each line), in the above example, there are 26 instances of digits that use a unique number of segments (highlighted above). In the output values, how many times do digits 1, 4, 7, or 8 appear? |# (defun d8-count-active (value) (loop for n from 0 below 7 count (< 0 (logand value (ash 1 n))))) (defun d8p1 () (loop for entry in (d8-data) sum (loop for i from 10 below 14 for segment = (aref entry i) for signals = (d8-count-active segment) count (or (= signals 2) (= signals 3) (= signals 4) (= signals 7))))) ;; Answer: 301 #| --- Part Two --- Through a little deduction, you should now be able to determine the remaining digits. Consider again the first example above: acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf After some careful analysis, the mapping between signal wires and segments only make sense in the following configuration: dddd e a e a ffff g b g b cccc So, the unique signal patterns would correspond to the following digits: acedgfb: 8 cdfbe: 5 gcdfa: 2 fbcad: 3 dab: 7 cefabd: 9 cdfgeb: 6 eafb: 4 cagedb: 0 ab: 1 Then, the four digits of the output value can be decoded: cdfeb: 5 fcadb: 3 cdfeb: 5 cdbaf: 3 Therefore, the output value for this entry is 5353. Following this same process for each entry in the second, larger example above, the output value of each entry can be determined: fdgacbe cefdb cefbgd gcbe: 8394 fcgedb cgb dgebacf gc: 9781 cg cg fdcagb cbg: 1197 efabcd cedba gadfec cb: 9361 gecf egdcabf bgf bfgea: 4873 gebdcfa ecba ca fadegcb: 8418 cefg dcbef fcge gbcadfe: 4548 ed bcgafe cdgba cbgef: 1625 gbdfcae bgc cg cgb: 8717 fgae cfgab fg bagce: 4315 Adding all of the output values in this larger example produces 61229. For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values? |# (defun d8-solve (entry) "This is the silly solution where we deduce everything step by step." ;; TODO: The cool solution where we traverse a tree of possibilities. (let ((digit-signal (make-array 10 :element-type '(unsigned-byte 7) :initial-element 0)) (digit-side (make-array 7 :element-type '(unsigned-byte 7) :initial-element 0))) (labels ((get-signal (number) (aref digit-signal number)) (set-signal (number value) (let ((value (logand value #x7f))) (loop for n from 0 until (= value (aref entry n)) when (= 10 n) do (error "Invalid signal: ~a" value)) (setf (aref digit-signal number) value))) (get-side-index (side) (ecase side (:top 0) (:top-left 1) (:top-right 2) (:middle 3) (:bottom-left 4) (:bottom-right 5) (:bottom 6))) (get-side (side) (let ((value (aref digit-side (get-side-index side)))) (unless (< 0 value) (error "Side not found yet: ~a" side)) value)) (get-sides (side &rest sides) (let ((value (get-side side))) (loop for another in sides do (incf value (get-side another))) value)) (set-side (side value) (let ((value (logand value #x7f))) (unless (= 1 (d8-count-active value)) (error "Invalid side value: ~a ~a" side value)) (setf (aref digit-side (get-side-index side)) value)))) ;; 1. Find 1, 4, 7, and 8. (loop for n from 0 below 10 for signal = (aref entry n) for active = (d8-count-active signal) do (case active (2 (set-signal 1 signal)) (4 (set-signal 4 signal)) (3 (set-signal 7 signal)) (7 (set-signal 8 signal)))) ;; We have signals: 1 4 7 8 ;; We have sides : ;; 2. Compare 1 and 7 to find the top. (set-side :top (logxor (get-signal 1) (get-signal 7))) ;; We have signals: 1 4 7 8 ;; We have sides : top ;; 3. Use 4 and the top to find 9. ;; 9 only has one extra, which is the bottom. ;; The missing one from 9 is bottom-left. (loop for n from 0 below 10 for nine = (aref entry n) until (< 0 (get-signal 9)) when (= 6 (d8-count-active nine)) do (let ((four-top (logior (get-signal 4) (get-side :top)))) (when (= 1 (d8-count-active (logxor four-top nine))) (set-signal 9 nine) (set-side :bottom (logxor four-top nine)) (set-side :bottom-left (lognot nine))))) ;; We have signals: 1 4 7 8 9 ;; We have sides : top bottom-left bottom ;; 4. 7 + bottom + some other that is mid = 3. ;; With middle and eight we can get zero. (loop for n from 0 below 10 for three = (aref entry n) until (< 0 (get-signal 3)) when (= 5 (d8-count-active three)) do (let ((seven-bottom (logior (get-signal 7) (get-side :bottom)))) (when (= 1 (d8-count-active (logxor seven-bottom three))) (set-signal 3 three) (set-side :middle (logxor seven-bottom three)) (set-signal 0 (logxor (get-signal 8) (get-side :middle)))))) ;; We have signals: 0 1 3 4 7 8 9 ;; We have sides : top middle bottom-left bottom ;; 5. Top + mid + bottom + bottom-left + some other = 2, some other is top-right. ;; Top right and one reveal bottom right. (loop for n from 0 below 10 for two = (aref entry n) until (< 0 (get-signal 2)) when (= 5 (d8-count-active two)) do (let ((t-m-b-bl (get-sides :top :middle :bottom :bottom-left))) (when (= 1 (d8-count-active (logxor t-m-b-bl two))) (set-signal 2 two) (set-side :top-right (logxor t-m-b-bl two)) (set-side :bottom-right (logxor (get-side :top-right) (get-signal 1)))))) ;; We have signals: 0 1 2 3 4 7 8 9 ;; We have sides : top top-right middle bottom-left bottom-right bottom ;; 6. Rest we can deduce. 4 - (1 + mid) = top-left ;; And then we can just build number five. (let ((one-mid (logior (get-signal 1) (get-side :middle)))) (set-side :top-left (logxor (get-signal 4) one-mid))) (set-signal 5 (get-sides :top :top-left :middle :bottom-right :bottom)) (set-signal 6 (logxor (get-signal 8) (get-side :top-right))) ;; We have signals: 0 1 2 3 4 5 6 7 8 9 ;; Done. ;; We have sides : top top-left top-right middle bottom-left bottom-right bottom ;; Done. (let ((number 0)) (dotimes (i 4) (loop with digit = (aref entry (+ i 10)) for n from 0 while (/= digit (get-signal n)) finally (incf number (* (/ 1000 (expt 10 i)) n)))) number)))) (defun d8p2 () (loop for entry in (d8-data) sum (d8-solve entry))) ;; Answer: 908067
[ { "context": "x:Common-lisp -*-\n;;;\n;;; Copyright (c) 2000-2016, Toshimi Sawada. All rights reserved.\n;;;\n;;; Redistribution and ", "end": 112, "score": 0.9996379017829895, "start": 98, "tag": "NAME", "value": "Toshimi Sawada" } ]
thstuff/citp.lisp
debian-janitor/cafeobj
0
;;;-*-Mode:LISP; Package: CHAOS; Base:10; Syntax:Common-lisp -*- ;;; ;;; Copyright (c) 2000-2016, Toshimi Sawada. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; (in-package :chaos) #|============================================================================= System:CHAOS Module:thstuff File:citp.lisp =============================================================================|# #-:chaos-debug (declaim (optimize (speed 3) (safety 0) #-GCL (debug 0))) #+:chaos-debug (declaim (optimize (speed 1) (safety 3) #-GCL (debug 3))) (defun check-context-module () (unless *current-module* (with-output-chaos-error ('no-context) (format t "No context module is specified, please 'select' or 'open' a module.")))) (defun check-ptree () (unless *proof-tree* (with-output-chaos-error ('no-proof-tree) (format t "No proof is ongoing.")))) (defun check-on-going() (unless (and *proof-tree* (get-unproved-nodes *proof-tree*)) (with-output-chaos-error ('no-target) (format t "There are no unproved goals.")))) (defun check-context-module-and-ptree () (check-context-module) (check-ptree)) ;;; ============================ ;;; CITP related command parsers ;;; ============================ ;;; ;;; :goal { <axiom> . <axiom> . .... <axiom> . } ;;; (defun citp-parse-goal (args) (let ((ax-decls nil)) (dolist (elem (third args)) (push (parse-module-element-1 elem) ax-decls)) (nreverse ax-decls))) ;;; ;;; :apply [to <goal-name>] (<tactic> ...) ;;; ;;; (":apply" ("(" ("tc" "rd" "si") ")")) ;;; (":apply" ("to" ("1-1-1")) ("(" ("RD") ")")) ;;; (defun citp-parse-apply (args) (let ((tactic-forms nil) (tactics nil) (target nil)) (cond ((string-equal (car (second args)) "to") (setq target (car (second (second args)))) (setq tactic-forms (second (third args)))) (t (setq tactic-forms (second (second args))))) (dolist (tac tactic-forms) (let ((tactic (get-tactic tac))) (setq tactics (nconc tactics tactic)))) (cons target tactics))) ;;; citp-parse-ind-on ;;; :ind on (var ... var) ;;; (":ind" ("on" "(" ("A:S-1" "B:S-2" "C:S-3") ")")) ;;; (":ind" ("{" ("on" #1="(" ("L1:List") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("step" #1# ("X:Elm" "T:List") "." nil #2#) "}")) ;;; (":ind" ("{" ("on" #1="(" ("S1:Seq") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("hypo" #1# ("SQ:Seq") "." nil #2#) ;;; ("step" #1# ("EL:Elt" "SQ:Seq") "." nil #2#) "}")) (defun citp-parse-seq-of-terms (module token-list) (let ((terms nil)) (when (atom token-list) (return-from citp-parse-seq-of-terms nil)) (dolist (term? token-list) ;; (format t "~%<<>> ~s" term?) (when (consp term?) (let* ((*parse-variables* nil) (target-term (simple-parse module term? *cosmos*))) (when (or (null (term-sort target-term)) (sort<= (term-sort target-term) *syntax-err-sort* *chaos-sort-order*)) (with-output-chaos-error ('invalid-term) (format t "Could not parse ~s" term?))) (push target-term terms)))) (nreverse terms))) (defun citp-parse-ind-on (args) (check-context-module) (with-in-module (*current-module*) (let ((ind-type (first (second args)))) (flet ((parse-vars (decls) (let ((vars nil)) (dolist (var-decl decls) (let ((var (simple-parse-from-string var-decl))) (when (term-is-an-error var) (with-output-chaos-error ('no-parse) (format t "Illegal variable form: ~a" var-decl))) (unless (term-is-variable? var) (with-output-chaos-error ('no-var) (format t "Invalid argument to ':ind' command: ~a" var-decl))) (push var vars))) (nreverse vars)))) (if (equal ind-type "on") (let ((vars (parse-vars (third (second args))))) (cons :simple vars)) ;; :ind { on () base() [hypo ()] step() } (let* ((decl (second args)) (vars (parse-vars (third (second decl)))) (bases (citp-parse-seq-of-terms *current-module* (third decl))) (hypo (citp-parse-seq-of-terms *current-module* (fourth decl))) (steps (citp-parse-seq-of-terms *current-module* (fifth decl)))) (if steps (list :user vars bases hypo steps) (list :user vars bases nil hypo)))))))) ;;; ;;; :auto ;;; (defun citp-parse-auto (args) (declare (ignore args)) (cons :auto (get-default-tactics))) ;;; ;;; :roll back ;;; (defun citp-parse-roll-back (args) (declare (ignore args)) :roll-back) ;;; ;;; :init {[<label>] | (<axiom>)} by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; first second third four fifth ;;; (":init" ("[" ("test1") "]") "by" "{" (("X:S" "<-" ("X#S")) ";") "}")) ;;; first second third fourth ;;; (":init" ("as" "ts-ss-1") (#1="{" ("eq" ("ts.." "(" "SS:SeqSym" ")") "=" ("true") ".") #3="}") ("by" #1# (("SS:SeqSym" "<-" ("ss")) #2=";" ("XX:Bar" "<-" ("bb")) #2#) #3#))) ;;; (":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}")) ;;; (defun make-axiom-pattern (target) (if (stringp target) (cons :label (list target)) (cons :axiom target))) (defun citp-parse-init (args) (let ((name (if (equal (first (second args)) "as") (second (second args)) nil))) (let ((target-form (make-axiom-pattern (if name (second (third args)) (second (second args))))) (subst-list (if name (third (fourth args)) (third (third args)))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (with-citp-debug () (format t "~%[:init] target = ~s" target-form) (format t "~% subst = ~s" subst-pairs)) (list (first args) target-form subst-pairs name)))) ;;; :imply [<label>] by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; (":imp" ("[" ("test2") "]") ("by" "{" (("Y:S" "<-" ("X#S")) ";") "}")) ;;; (":imp" ("[" ("gt") "]") (".")) ;;; (defun citp-parse-imp (args) (let ((target-form (make-axiom-pattern (second args))) (subst-list (third (third args))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (list target-form subst-pairs))) ;;; :cp ;;; (":cp" ("[" ("label-1") "]") "><" ("[" ("label-2") "]")) ;;; (":cp" ("(" ("ceq" ("LHS") "=" ("RHS") "if" ("C") ".") ")") ;;; "><" ("(" ("ceq" ("LHS-2") "=" ("RHS-2") "if" ("C-2") ".") ")")) ;;; (defun citp-parse-critical-pair (args) (let ((pat-1 (make-axiom-pattern (second args))) (pat-2 (make-axiom-pattern (fourth args)))) (with-citp-debug () (format t "~%[cp] ~s" pat-1) (format t "~% ~s" pat-2)) (list pat-1 pat-2))) ;;; :equation/:rule ;;; (defun citp-parse-equation (args) (if (member (car args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :backward equation/rule ;;; (defun citp-parse-backward (args) (if (member (second args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :select <GoalName> ;;; (defun citp-parse-select (args) (let ((goal-name (car (second args)))) goal-name)) ;;; citp-parse-red ;;; (defun citp-parse-red (e) (let (goal-name preterm mode) (case-equal (first e) ((":red" ":lred" "lred") (setq mode :red)) ((":exec") (setq mode :exec)) ((":bred") (setq mode :bred))) (if (= 4 (length e)) (progn (setq goal-name (cadr (cadr e))) (setq preterm (nth 2 e))) (progn (setq goal-name nil) (setq preterm (nth 1 e)))) (list mode goal-name preterm))) ;;; citp-parse-verbose ;;; :verbose {on | off} (defun citp-parse-verbose (args) (second args)) ;;; citp-parse-normalize ;;; :normalize {on | off} (defun citp-parse-normalize (args) (second args)) ;;; citp-parse-ctf ;;; :ctf { eq <term> = <term> .} ;;; (":ctf" ("{" ("eq" ("1" ">" "2") "=" ("true") ".") "}")) ;;; :ctf [ <term> . ] ;;; (":ctf" ("[" ("1" ">" "2") "." "]")) ;;; ==> (form . (term? . :ctf-?)) ;;; (defun citp-parse-ctf (args) (let ((form (second (second args))) (term? (equal (first (second args)) "["))) (if (equal (first args) ":ctf-") (cons form (cons term? :dash)) (cons form (cons term? nil))))) ;;; citp-parse-csp ;;; :csp { <axiom> ... } ;;; (defun citp-parse-csp (args) (let ((ax-decls nil) (dash? (equal (car args) ":csp-"))) (dolist (elem (third args)) (push elem ax-decls)) (cons (nreverse ax-decls) dash?))) ;;; citp-parse-define ;;; :def <symbol> = <ctf> | <csp> | <init> | ;;; ;;; (":def" "cf1" "=" (":ctf" ("[" (<Term>) "." "]"))) ;;; ==> (:ctf "cf1" nil (:term (<Term>))) ;;; (":def" "cf2" "=" (":ctf-" ("{" (<Equation>) "." "}"))) ;;; ==> (:ctf "cf2" t (:eq (<Equation>))) ;;; (":def" "sp1" "=" (":csp" "{" ((<Equation> ".") (<Equation> ".")) "}")) ;;; ==> (:csp "sp1" nil ((<Equation> ".") (<Equation> "."))) ;;; (":def" "tactic-1" "=" ("(" ("si" "rd" "tc") ")")) ;;; ==> (:seq "tactic-1" ("si" "rd" "tc")) ;;; (":define" "*disr" "=" (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" ("X#PNat")) #1=";" ("Y:PNat.PNAT" "<-" ("Y@PNat")) #1# ("Z:PNat.PNAT" "<-" ("Z@PNat")) #1#) "}")) ;;; (":define" "ts-ss2" "="(":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}"))) ;;; ==> (:init "*disr" nil (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" #) #1=";" ("Y:PNat.PNAT" "<-" #) #1# ("Z:PNat.PNAT" "<-" #) #1#) "}")) (defun citp-parse-define (args) (flet ((name-to-com (name) (cond ((equal name "(") :seq) ((equal (subseq name 0 4) ":ctf") :ctf) ((equal (subseq name 0 4) ":csp") :csp) ((equal (subseq name 0 4) ":ini") :init) (t (with-output-chaos-error ('invalid-def) (format t "Internal error, :def accepted ~a" name)))))) (let* ((name (second args)) (com-name (first (fourth args))) (command (name-to-com com-name)) (dash-or-bang (or (and (member command '(:ctf :csp)) (> (length com-name) 4)) (and (eq command :init) (> (length com-name) 5)))) (body-form (case command (:ctf (if (equal "[" (first (second (fourth args)))) (list :term (second (second (fourth args)))) (list :eq (second (second (fourth args)))))) (:csp (third (fourth args))) (:init (citp-parse-init (fourth args))) (:seq (second (fourth args))) (otherwise (with-output-chaos-error ('invalid-command) (format t "Internal error, :def invalid ~s" command)))))) (list command name dash-or-bang body-form)))) ;;; { :show | :describe } <something> ;;; (defun citp-parse-show (inp) (let ((tag (car inp)) (args (cdr inp)) (com nil)) (cond ((member tag '(":show" ":sh") :test #'equal) (setq com :show)) ((member tag '(":describe" ":desc") :test #'equal) (setq com :describe)) (t (with-output-chaos-error ('internal) (format t "Internal error, unknown citp command ~s" tag)))) (cons com args))) ;;; :spoiler { on | off } ;;; (defun citp-parse-spoiler (form) (let* ((on-off (second form)) (value (if (equal on-off '("on")) t (if (equal on-off '("off")) nil (progn (format t "~&:spoiler flag is ~s" (if *citp-spoiler* "on" "off")) (return-from citp-parse-spoiler t)))))) (setq *citp-spoiler* value) (setf (citp-flag citp-spoiler) value) t)) ;;; {:binspect | binspect} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-binspect (args) (parse-term-in-context args)) (defun parse-term-in-context (args) (let (mode goal-name preterm (type (first args))) (if (and (stringp type) (eql (elt type 0) #\:)) (setq mode :citp) (setq mode :general)) (if (= 4 (length args)) (progn (setq goal-name (cadr (cadr args))) (setq preterm (nth 2 args))) (progn (setq goal-name nil) (setq preterm (nth 1 args)))) (list mode goal-name preterm))) ;;; {:bgrind | bgrind} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-bgrind (args) (parse-term-in-context args)) ;;; {bshow | :bshow} [ { tree | grind } ] ;;; (defun citp-parse-bshow (args) (let ((param (cadr args))) (or param "."))) ;;; :set(<name>, {on | off | show | ? }) ;;; (defun citp-parse-set (inp) (declare (type list inp)) (let ((name (third inp)) (value (fifth inp))) (list name value))) ;;; {bstart | :bstart} <variable-name> ;;; (defun citp-parse-bstart (arg) (cadr arg)) ;;; {bguess | :bguess} <strategy> &optional args ;;; 'bguess <strategy>' ;;; <strategy> ::= { implies | and | or } ;;; p implies q = true (p and q = p) ;;; p and q = false ;;; p or q = true (defun citp-parse-bguess (args) (cdr args)) ;;; citp-parse-use ;;; :use (<label> ... <label>) ;;; :use [<label>] { assoc | comm | id: <term> } ;;; (":use" ("(" ("a" "b" "c") ")")) ;;; (":use" ("[" "foo" "]" "{" (("assoc")) "}")) (defun citp-parse-use (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (cons :use (second body))) ((equal type "[") (let ((label (second body)) (theory (fifth body))) (list* :use-theory label theory))) (t (with-output-chaos-error ('invalid-form) (format t "invalid form of :use ~s" type)))))) ;;; citp-parse-embed ;;; :embed (<label> ... <label>) as <module_name> ;;; (":embed" ("(" ("a" "b" "c") ")" "as" "foo")) ;;; (":embed" ("[" "foo" "]" "{" (("assoc") ("comm")) "}" "as" "foo")) (defun citp-parse-embed (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (let ((labels (second body)) (mod-name (fifth body)) (into (equal (fourth body) "into"))) (list :embed labels mod-name into))) ((equal type "[") (let ((label (second body)) (theory (fifth body)) (into (equal (seventh body) "into")) (mod-name (eighth body))) (list :embed-theory label theory mod-name into))) (t (with-output-chaos-error ('invalid-form) (format t "invalid :embed type ~s" type)))))) ;;; citp-parse-reset ;;; :reset ;;; (defun citp-parse-reset (args) args) ;;; citp-process-opattr-declaration-form ;;; (defun citp-process-opattr-declaration-form (args &rest ignore) (declare (ignore ignore)) (format t "~s" args)) ;;; ================================ ;;; CITP related command evaluators ;;; ================================ ;;; :goal ;;; (defun eval-citp-goal (goal-ax-decls) (check-context-module) (with-in-module (*current-module*) (let ((axs nil)) (dolist (a-decl goal-ax-decls) (cond ((eq (car a-decl) '%fax) (push (parse-fax-declaration a-decl) axs)) (t (push (parse-axiom-declaration a-decl) axs)))) (begin-proof *current-module* (nreverse axs))))) ;;; :apply/:auto (defun eval-citp-apply (list-tactic) (check-ptree) (let ((target (car list-tactic)) (tactics (cdr list-tactic))) (let ((*chaos-verbose* nil) (*chaos-quiet* t)) (if target (case target (:auto (apply-auto *proof-tree*)) (otherwise (apply-tactics-to-goal *proof-tree* target tactics))) (apply-tactics *proof-tree* tactics))))) ;;; :ind on ;;; (defun eval-citp-ind-on (args) (check-ptree) (with-in-module ((get-context-module)) (let ((type (car args)) (ind-form (cdr args))) (if (eq type :simple) (set-induction-variables ind-form) ;; :user defined induction scheme (let ((vars (first ind-form)) (bases (second ind-form)) (hypo (third ind-form)) (steps (fourth ind-form))) (check-on-going) (let ((target-node (get-next-proof-context *proof-tree*))) (set-induction-variables-and-scheme target-node vars bases hypo steps) ;; then do the job (apply-user-defined-induction-scheme target-node))))))) ;;; :roll back ;;; (defun eval-citp-roll-back (&rest com) (declare (ignore com)) (check-ptree) (with-in-module (*current-module*) (roll-back *proof-tree*))) ;;; :init ;;; (defun eval-citp-init (args) (let ((target-goal (ptree-node-goal (get-target-goal-node)))) (instanciate-axiom target-goal (second args) ; target (third args) ; variable-term pairs (fourth args) ; label ))) ;;; :imp ;;; (defun eval-citp-imp (args) (check-ptree) (with-in-module ((goal-context (ptree-node-goal (get-target-goal-node)))) (introduce-implication-to-goal (first args) ; target (second args)))) ;variable-term pairs ;;; :cp (defun eval-citp-critical-pair (args) (check-ptree) (with-in-module (*current-module*) (apply-cp (first args) (second args)))) ;;; :equation : {:equation| :rule} -> void (defun eval-citp-equation (arg) (check-ptree) (add-critical-pairs arg :forward)) ;;; :backward (defun eval-citp-backward (arg) (check-ptree) (add-critical-pairs arg :backward)) ;;; :select (defun eval-citp-select (goal-name) (check-ptree) (select-next-goal goal-name)) ;;; :red, :exec, :bred (defun eval-citp-red (token-seq) (check-ptree) (let ((mode (first token-seq)) (goal-name (second token-seq)) (pre-term (third token-seq))) (reduce-in-goal mode goal-name pre-term))) ;;; :verbose (defun eval-citp-verbose (token) (if (string-equal token "on") (setq *citp-verbose* t) (if (string-equal token "off") (setq *citp-verbose* nil) (if (string-equal token ".") (format t "~&:verbose flag is ~s" (if *citp-verbose* "on" "off")) (with-output-chaos-error ('invlid-value) (format t "Unknown parameter ~s." token)))))) ;;; :normalize init (defun eval-citp-normalize (token) (if (string-equal token "on") (setq *citp-normalize-instance* t) (if (string-equal token "off") (setq *citp-normalize-instance* nil) (if (string-equal token ".") (format t "~&:normalize flag is ~s" (if *citp-normalize-instance* "on" "off")) (with-output-chaos-error ('invalid-value) (format t ":nomalize instance: unknown parameter ~s." token)))))) ;;; :ctf ;;; ax-form ::= (form . (term? . :ctf-?)) ;;; (defun eval-citp-ctf (ax-form) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-ctf (car ax-form) (cadr ax-form) (cddr ax-form)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :csp (defun eval-citp-csp (goal-ax-decls) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-csp (car goal-ax-decls) (cdr goal-ax-decls)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :show, :describe (defun eval-citp-show (token) (let* ((com (car token)) (describe (eq com :describe)) (target (cadr token)) (rest-args (cddr token))) (cond ((member target '("unproved" "unp") :test #'equal) (check-ptree) (print-unproved-goals *proof-tree*)) ((member target '("proved" "discharged") :test #'equal) (check-ptree) (print-discharged-sentences)) ((equal target "goal") (check-ptree) (let ((name (car rest-args))) (print-named-goal *proof-tree* name))) ((equal target "proof") (let ((name (car rest-args))) (when (or (null name) (equal name ".")) (setq name "root")) (print-proof-tree name describe))) ((member target '("." "current") :test #'equal) (check-ptree) (print-current-goal describe)) ((member target '(":def" ":define" "def" "define" ":defs" "defs") :test #'equal) (check-ptree) (let ((goal-name (first rest-args))) (print-defs describe goal-name))) ((member target '("switch" "switches" "flag" "flags") :test #'equal) (print-citp-flag citp-all)) (t (with-output-chaos-error ('unknown) (format t "Unknown parameter to :show/:describe ~S" target)))))) ;;; { :binspect | binspect } ;;; (defun eval-citp-binspect (args) (let ((mode (first args)) (goal-or-mod (second args)) (preterm (third args))) (binspect-in mode goal-or-mod preterm))) ;;; { :bgrind | bgrind } ;;; (defun eval-citp-bgrind (args) (bgrind-in (first args) ; mode (second args) ; goal or module (third args) ; term tokens )) ;;; eval-citp-define : arg -> tactic-ctf or tactic-csp ;;; (:ctf "cf1" nil (:term (<Term>))) ;;; (:ctf "cf2" t (:eq (<Equation>))) ;;; (:csp "sp1" nil ((<Equation> ".") ...)) ;;; (:csp "sp2" t ((<Equation> ".") ...)) ;;; (:init "ini1" nil (:init ....)) ;;; (:seq "tactic-1" nil (<tactic-name> ....)) ;;; (defun eval-citp-define (arg) (check-ptree) (let ((tactic-name (first arg)) (name (second arg)) (dash (third arg)) (form (fourth arg)) (tactic nil)) (when (tactic-name-is-builtin? name) (with-output-chaos-error ('invalid-name) (format t "You can not use the name of builtin tactic ~a." name))) (when (existing-def-name? *proof-tree* name) (with-output-chaos-warning () (format t "The name ~a is already defined in the current proof context." name) (format t "~%Please use the different name.") (return-from eval-citp-define nil))) (let ((current (get-next-proof-context *proof-tree*)) (goal nil)) (unless current (with-output-chaos-error ('no-context) (format t "No target goal."))) (setq goal (ptree-node-goal current)) (with-in-module ((goal-context goal)) (let ((*chaos-quiet* t)) (cond ((eq tactic-name :ctf) ;; ctf (setq tactic (make-tactic-ctf :name name :form (parse-axiom-or-term (second form) (eq :term (first form))) :context *current-module* :minus dash))) ((eq tactic-name :csp) ;; csp (let ((forms nil)) (dolist (ax form) (push (parse-axiom-declaration (parse-module-element-1 ax)) forms)) (setq tactic (make-tactic-csp :name name :forms (nreverse forms) :minus dash :context *current-module*)))) ((eq tactic-name :init) (let ((ax (get-target-axiom *current-module* (second form)))) (setq tactic (make-tactic-init :name name :axiom ax :subst (third form) :context *current-module* :kind (car (last form)))))) ((eq tactic-name :ind) ;; ind (setq tactic (make-tactic-ind :name name :vars () :base () :step ()))) ((eq tactic-name :seq) (setq tactic (make-tactic-seq :name name :tactics (mapcar #'(lambda (x) (or (get-defined-tactic goal x) (get-builtin-tactic x) (with-output-chaos-error ('no-such-tactic) (format t "No such tactic ~a" x)))) form)))) (t ;; internal error (with-output-chaos-error ('internal-error) (format t "Invalid :def parameter ~s" tactic-name)))) (format t "~&~a defined as " name) (princ tactic) (setf (goal-defs goal) (nconc (goal-defs goal) (list tactic))))) (push (canonicalize-tactic-name name) (ptree-defs-so-far *proof-tree*))))) ;;; ;;; SET-FLAG/CLEAR-FLAG ;;; (defun citp-eval-set (args) (let ((name (first args)) (given-value (second args))) (let ((value nil) (index (find-citp-flag-index name))) (unless index (with-output-chaos-error ('no-such-flag) (format t "No such flag ~a" name))) (cond ((or (equal given-value "on") (equal given-value "set")) (setq value t)) ((equal given-value "show") (print-citp-flag index) (return-from citp-eval-set nil)) ((equal given-value "?") (help-citp-flag index) (return-from citp-eval-set nil))) (when (citp-flag citp-print-message) (with-output-msg () (format t "setting flag ~a to ~a" name given-value))) (if (= citp-all index) (dotimes (x *citp-max-flags*) (setf (citp-flag x) value)) (setf (citp-flag index) value)) ;; run hook (funcall (citp-flag-hook index) name value)))) ;;; ;;; :use ;;; (defun citp-eval-use (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:use (use-discharged-goals body)) (:use-theory (let ((label (car body)) (theory (cdr body))) (use-theory label theory)))))) ;;; ;;; :embed ;;; (defun citp-eval-embed (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:embed (let ((labels (car body)) (mod-name (cadr body)) (into (caddr body))) (embed-discharged-goals labels mod-name into))) (:embed-theory (let ((label (first body)) (theory (second body)) (mod-name (third body)) (into (fourth body))) (embed-theory label theory mod-name into)))))) ;;; ;;; :reset ;;; (defun citp-eval-reset (&rest args) (declare (ignore args)) (check-ptree) (reset-proof-session)) ;;; ;;; :theory <opname> : <arity> -> <coarity> { assoc | comm | id: <term> } ;;; (defun add-method-theory (decl) (check-ptree) (let ((theory (%opattrs-theory (%theory-decl-attribute decl))) (name (%theory-decl-name decl)) (arity (%theory-decl-arity decl)) (coarity (%theory-decl-coarity decl)) (goal (ptree-node-goal (get-next-proof-context *proof-tree*)))) (with-in-module ((goal-context goal)) (let ((r-arity (mapcar #'(lambda (x) (or (find-sort-in *current-module* x) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref x)))) arity)) (r-coarity (or (find-sort-in *current-module* coarity) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref coarity))))) (let ((meth (find-method-in *current-module* name r-arity r-coarity))) (unless meth (with-output-chaos-error ('no-op) (format t "No such operator ~s" name))) (add-and-merge-method-theory meth theory *current-module*) (set-needs-parse) (set-needs-rule)))))) ;;; EOF
53341
;;;-*-Mode:LISP; Package: CHAOS; Base:10; Syntax:Common-lisp -*- ;;; ;;; Copyright (c) 2000-2016, <NAME>. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; (in-package :chaos) #|============================================================================= System:CHAOS Module:thstuff File:citp.lisp =============================================================================|# #-:chaos-debug (declaim (optimize (speed 3) (safety 0) #-GCL (debug 0))) #+:chaos-debug (declaim (optimize (speed 1) (safety 3) #-GCL (debug 3))) (defun check-context-module () (unless *current-module* (with-output-chaos-error ('no-context) (format t "No context module is specified, please 'select' or 'open' a module.")))) (defun check-ptree () (unless *proof-tree* (with-output-chaos-error ('no-proof-tree) (format t "No proof is ongoing.")))) (defun check-on-going() (unless (and *proof-tree* (get-unproved-nodes *proof-tree*)) (with-output-chaos-error ('no-target) (format t "There are no unproved goals.")))) (defun check-context-module-and-ptree () (check-context-module) (check-ptree)) ;;; ============================ ;;; CITP related command parsers ;;; ============================ ;;; ;;; :goal { <axiom> . <axiom> . .... <axiom> . } ;;; (defun citp-parse-goal (args) (let ((ax-decls nil)) (dolist (elem (third args)) (push (parse-module-element-1 elem) ax-decls)) (nreverse ax-decls))) ;;; ;;; :apply [to <goal-name>] (<tactic> ...) ;;; ;;; (":apply" ("(" ("tc" "rd" "si") ")")) ;;; (":apply" ("to" ("1-1-1")) ("(" ("RD") ")")) ;;; (defun citp-parse-apply (args) (let ((tactic-forms nil) (tactics nil) (target nil)) (cond ((string-equal (car (second args)) "to") (setq target (car (second (second args)))) (setq tactic-forms (second (third args)))) (t (setq tactic-forms (second (second args))))) (dolist (tac tactic-forms) (let ((tactic (get-tactic tac))) (setq tactics (nconc tactics tactic)))) (cons target tactics))) ;;; citp-parse-ind-on ;;; :ind on (var ... var) ;;; (":ind" ("on" "(" ("A:S-1" "B:S-2" "C:S-3") ")")) ;;; (":ind" ("{" ("on" #1="(" ("L1:List") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("step" #1# ("X:Elm" "T:List") "." nil #2#) "}")) ;;; (":ind" ("{" ("on" #1="(" ("S1:Seq") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("hypo" #1# ("SQ:Seq") "." nil #2#) ;;; ("step" #1# ("EL:Elt" "SQ:Seq") "." nil #2#) "}")) (defun citp-parse-seq-of-terms (module token-list) (let ((terms nil)) (when (atom token-list) (return-from citp-parse-seq-of-terms nil)) (dolist (term? token-list) ;; (format t "~%<<>> ~s" term?) (when (consp term?) (let* ((*parse-variables* nil) (target-term (simple-parse module term? *cosmos*))) (when (or (null (term-sort target-term)) (sort<= (term-sort target-term) *syntax-err-sort* *chaos-sort-order*)) (with-output-chaos-error ('invalid-term) (format t "Could not parse ~s" term?))) (push target-term terms)))) (nreverse terms))) (defun citp-parse-ind-on (args) (check-context-module) (with-in-module (*current-module*) (let ((ind-type (first (second args)))) (flet ((parse-vars (decls) (let ((vars nil)) (dolist (var-decl decls) (let ((var (simple-parse-from-string var-decl))) (when (term-is-an-error var) (with-output-chaos-error ('no-parse) (format t "Illegal variable form: ~a" var-decl))) (unless (term-is-variable? var) (with-output-chaos-error ('no-var) (format t "Invalid argument to ':ind' command: ~a" var-decl))) (push var vars))) (nreverse vars)))) (if (equal ind-type "on") (let ((vars (parse-vars (third (second args))))) (cons :simple vars)) ;; :ind { on () base() [hypo ()] step() } (let* ((decl (second args)) (vars (parse-vars (third (second decl)))) (bases (citp-parse-seq-of-terms *current-module* (third decl))) (hypo (citp-parse-seq-of-terms *current-module* (fourth decl))) (steps (citp-parse-seq-of-terms *current-module* (fifth decl)))) (if steps (list :user vars bases hypo steps) (list :user vars bases nil hypo)))))))) ;;; ;;; :auto ;;; (defun citp-parse-auto (args) (declare (ignore args)) (cons :auto (get-default-tactics))) ;;; ;;; :roll back ;;; (defun citp-parse-roll-back (args) (declare (ignore args)) :roll-back) ;;; ;;; :init {[<label>] | (<axiom>)} by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; first second third four fifth ;;; (":init" ("[" ("test1") "]") "by" "{" (("X:S" "<-" ("X#S")) ";") "}")) ;;; first second third fourth ;;; (":init" ("as" "ts-ss-1") (#1="{" ("eq" ("ts.." "(" "SS:SeqSym" ")") "=" ("true") ".") #3="}") ("by" #1# (("SS:SeqSym" "<-" ("ss")) #2=";" ("XX:Bar" "<-" ("bb")) #2#) #3#))) ;;; (":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}")) ;;; (defun make-axiom-pattern (target) (if (stringp target) (cons :label (list target)) (cons :axiom target))) (defun citp-parse-init (args) (let ((name (if (equal (first (second args)) "as") (second (second args)) nil))) (let ((target-form (make-axiom-pattern (if name (second (third args)) (second (second args))))) (subst-list (if name (third (fourth args)) (third (third args)))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (with-citp-debug () (format t "~%[:init] target = ~s" target-form) (format t "~% subst = ~s" subst-pairs)) (list (first args) target-form subst-pairs name)))) ;;; :imply [<label>] by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; (":imp" ("[" ("test2") "]") ("by" "{" (("Y:S" "<-" ("X#S")) ";") "}")) ;;; (":imp" ("[" ("gt") "]") (".")) ;;; (defun citp-parse-imp (args) (let ((target-form (make-axiom-pattern (second args))) (subst-list (third (third args))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (list target-form subst-pairs))) ;;; :cp ;;; (":cp" ("[" ("label-1") "]") "><" ("[" ("label-2") "]")) ;;; (":cp" ("(" ("ceq" ("LHS") "=" ("RHS") "if" ("C") ".") ")") ;;; "><" ("(" ("ceq" ("LHS-2") "=" ("RHS-2") "if" ("C-2") ".") ")")) ;;; (defun citp-parse-critical-pair (args) (let ((pat-1 (make-axiom-pattern (second args))) (pat-2 (make-axiom-pattern (fourth args)))) (with-citp-debug () (format t "~%[cp] ~s" pat-1) (format t "~% ~s" pat-2)) (list pat-1 pat-2))) ;;; :equation/:rule ;;; (defun citp-parse-equation (args) (if (member (car args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :backward equation/rule ;;; (defun citp-parse-backward (args) (if (member (second args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :select <GoalName> ;;; (defun citp-parse-select (args) (let ((goal-name (car (second args)))) goal-name)) ;;; citp-parse-red ;;; (defun citp-parse-red (e) (let (goal-name preterm mode) (case-equal (first e) ((":red" ":lred" "lred") (setq mode :red)) ((":exec") (setq mode :exec)) ((":bred") (setq mode :bred))) (if (= 4 (length e)) (progn (setq goal-name (cadr (cadr e))) (setq preterm (nth 2 e))) (progn (setq goal-name nil) (setq preterm (nth 1 e)))) (list mode goal-name preterm))) ;;; citp-parse-verbose ;;; :verbose {on | off} (defun citp-parse-verbose (args) (second args)) ;;; citp-parse-normalize ;;; :normalize {on | off} (defun citp-parse-normalize (args) (second args)) ;;; citp-parse-ctf ;;; :ctf { eq <term> = <term> .} ;;; (":ctf" ("{" ("eq" ("1" ">" "2") "=" ("true") ".") "}")) ;;; :ctf [ <term> . ] ;;; (":ctf" ("[" ("1" ">" "2") "." "]")) ;;; ==> (form . (term? . :ctf-?)) ;;; (defun citp-parse-ctf (args) (let ((form (second (second args))) (term? (equal (first (second args)) "["))) (if (equal (first args) ":ctf-") (cons form (cons term? :dash)) (cons form (cons term? nil))))) ;;; citp-parse-csp ;;; :csp { <axiom> ... } ;;; (defun citp-parse-csp (args) (let ((ax-decls nil) (dash? (equal (car args) ":csp-"))) (dolist (elem (third args)) (push elem ax-decls)) (cons (nreverse ax-decls) dash?))) ;;; citp-parse-define ;;; :def <symbol> = <ctf> | <csp> | <init> | ;;; ;;; (":def" "cf1" "=" (":ctf" ("[" (<Term>) "." "]"))) ;;; ==> (:ctf "cf1" nil (:term (<Term>))) ;;; (":def" "cf2" "=" (":ctf-" ("{" (<Equation>) "." "}"))) ;;; ==> (:ctf "cf2" t (:eq (<Equation>))) ;;; (":def" "sp1" "=" (":csp" "{" ((<Equation> ".") (<Equation> ".")) "}")) ;;; ==> (:csp "sp1" nil ((<Equation> ".") (<Equation> "."))) ;;; (":def" "tactic-1" "=" ("(" ("si" "rd" "tc") ")")) ;;; ==> (:seq "tactic-1" ("si" "rd" "tc")) ;;; (":define" "*disr" "=" (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" ("X#PNat")) #1=";" ("Y:PNat.PNAT" "<-" ("Y@PNat")) #1# ("Z:PNat.PNAT" "<-" ("Z@PNat")) #1#) "}")) ;;; (":define" "ts-ss2" "="(":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}"))) ;;; ==> (:init "*disr" nil (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" #) #1=";" ("Y:PNat.PNAT" "<-" #) #1# ("Z:PNat.PNAT" "<-" #) #1#) "}")) (defun citp-parse-define (args) (flet ((name-to-com (name) (cond ((equal name "(") :seq) ((equal (subseq name 0 4) ":ctf") :ctf) ((equal (subseq name 0 4) ":csp") :csp) ((equal (subseq name 0 4) ":ini") :init) (t (with-output-chaos-error ('invalid-def) (format t "Internal error, :def accepted ~a" name)))))) (let* ((name (second args)) (com-name (first (fourth args))) (command (name-to-com com-name)) (dash-or-bang (or (and (member command '(:ctf :csp)) (> (length com-name) 4)) (and (eq command :init) (> (length com-name) 5)))) (body-form (case command (:ctf (if (equal "[" (first (second (fourth args)))) (list :term (second (second (fourth args)))) (list :eq (second (second (fourth args)))))) (:csp (third (fourth args))) (:init (citp-parse-init (fourth args))) (:seq (second (fourth args))) (otherwise (with-output-chaos-error ('invalid-command) (format t "Internal error, :def invalid ~s" command)))))) (list command name dash-or-bang body-form)))) ;;; { :show | :describe } <something> ;;; (defun citp-parse-show (inp) (let ((tag (car inp)) (args (cdr inp)) (com nil)) (cond ((member tag '(":show" ":sh") :test #'equal) (setq com :show)) ((member tag '(":describe" ":desc") :test #'equal) (setq com :describe)) (t (with-output-chaos-error ('internal) (format t "Internal error, unknown citp command ~s" tag)))) (cons com args))) ;;; :spoiler { on | off } ;;; (defun citp-parse-spoiler (form) (let* ((on-off (second form)) (value (if (equal on-off '("on")) t (if (equal on-off '("off")) nil (progn (format t "~&:spoiler flag is ~s" (if *citp-spoiler* "on" "off")) (return-from citp-parse-spoiler t)))))) (setq *citp-spoiler* value) (setf (citp-flag citp-spoiler) value) t)) ;;; {:binspect | binspect} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-binspect (args) (parse-term-in-context args)) (defun parse-term-in-context (args) (let (mode goal-name preterm (type (first args))) (if (and (stringp type) (eql (elt type 0) #\:)) (setq mode :citp) (setq mode :general)) (if (= 4 (length args)) (progn (setq goal-name (cadr (cadr args))) (setq preterm (nth 2 args))) (progn (setq goal-name nil) (setq preterm (nth 1 args)))) (list mode goal-name preterm))) ;;; {:bgrind | bgrind} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-bgrind (args) (parse-term-in-context args)) ;;; {bshow | :bshow} [ { tree | grind } ] ;;; (defun citp-parse-bshow (args) (let ((param (cadr args))) (or param "."))) ;;; :set(<name>, {on | off | show | ? }) ;;; (defun citp-parse-set (inp) (declare (type list inp)) (let ((name (third inp)) (value (fifth inp))) (list name value))) ;;; {bstart | :bstart} <variable-name> ;;; (defun citp-parse-bstart (arg) (cadr arg)) ;;; {bguess | :bguess} <strategy> &optional args ;;; 'bguess <strategy>' ;;; <strategy> ::= { implies | and | or } ;;; p implies q = true (p and q = p) ;;; p and q = false ;;; p or q = true (defun citp-parse-bguess (args) (cdr args)) ;;; citp-parse-use ;;; :use (<label> ... <label>) ;;; :use [<label>] { assoc | comm | id: <term> } ;;; (":use" ("(" ("a" "b" "c") ")")) ;;; (":use" ("[" "foo" "]" "{" (("assoc")) "}")) (defun citp-parse-use (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (cons :use (second body))) ((equal type "[") (let ((label (second body)) (theory (fifth body))) (list* :use-theory label theory))) (t (with-output-chaos-error ('invalid-form) (format t "invalid form of :use ~s" type)))))) ;;; citp-parse-embed ;;; :embed (<label> ... <label>) as <module_name> ;;; (":embed" ("(" ("a" "b" "c") ")" "as" "foo")) ;;; (":embed" ("[" "foo" "]" "{" (("assoc") ("comm")) "}" "as" "foo")) (defun citp-parse-embed (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (let ((labels (second body)) (mod-name (fifth body)) (into (equal (fourth body) "into"))) (list :embed labels mod-name into))) ((equal type "[") (let ((label (second body)) (theory (fifth body)) (into (equal (seventh body) "into")) (mod-name (eighth body))) (list :embed-theory label theory mod-name into))) (t (with-output-chaos-error ('invalid-form) (format t "invalid :embed type ~s" type)))))) ;;; citp-parse-reset ;;; :reset ;;; (defun citp-parse-reset (args) args) ;;; citp-process-opattr-declaration-form ;;; (defun citp-process-opattr-declaration-form (args &rest ignore) (declare (ignore ignore)) (format t "~s" args)) ;;; ================================ ;;; CITP related command evaluators ;;; ================================ ;;; :goal ;;; (defun eval-citp-goal (goal-ax-decls) (check-context-module) (with-in-module (*current-module*) (let ((axs nil)) (dolist (a-decl goal-ax-decls) (cond ((eq (car a-decl) '%fax) (push (parse-fax-declaration a-decl) axs)) (t (push (parse-axiom-declaration a-decl) axs)))) (begin-proof *current-module* (nreverse axs))))) ;;; :apply/:auto (defun eval-citp-apply (list-tactic) (check-ptree) (let ((target (car list-tactic)) (tactics (cdr list-tactic))) (let ((*chaos-verbose* nil) (*chaos-quiet* t)) (if target (case target (:auto (apply-auto *proof-tree*)) (otherwise (apply-tactics-to-goal *proof-tree* target tactics))) (apply-tactics *proof-tree* tactics))))) ;;; :ind on ;;; (defun eval-citp-ind-on (args) (check-ptree) (with-in-module ((get-context-module)) (let ((type (car args)) (ind-form (cdr args))) (if (eq type :simple) (set-induction-variables ind-form) ;; :user defined induction scheme (let ((vars (first ind-form)) (bases (second ind-form)) (hypo (third ind-form)) (steps (fourth ind-form))) (check-on-going) (let ((target-node (get-next-proof-context *proof-tree*))) (set-induction-variables-and-scheme target-node vars bases hypo steps) ;; then do the job (apply-user-defined-induction-scheme target-node))))))) ;;; :roll back ;;; (defun eval-citp-roll-back (&rest com) (declare (ignore com)) (check-ptree) (with-in-module (*current-module*) (roll-back *proof-tree*))) ;;; :init ;;; (defun eval-citp-init (args) (let ((target-goal (ptree-node-goal (get-target-goal-node)))) (instanciate-axiom target-goal (second args) ; target (third args) ; variable-term pairs (fourth args) ; label ))) ;;; :imp ;;; (defun eval-citp-imp (args) (check-ptree) (with-in-module ((goal-context (ptree-node-goal (get-target-goal-node)))) (introduce-implication-to-goal (first args) ; target (second args)))) ;variable-term pairs ;;; :cp (defun eval-citp-critical-pair (args) (check-ptree) (with-in-module (*current-module*) (apply-cp (first args) (second args)))) ;;; :equation : {:equation| :rule} -> void (defun eval-citp-equation (arg) (check-ptree) (add-critical-pairs arg :forward)) ;;; :backward (defun eval-citp-backward (arg) (check-ptree) (add-critical-pairs arg :backward)) ;;; :select (defun eval-citp-select (goal-name) (check-ptree) (select-next-goal goal-name)) ;;; :red, :exec, :bred (defun eval-citp-red (token-seq) (check-ptree) (let ((mode (first token-seq)) (goal-name (second token-seq)) (pre-term (third token-seq))) (reduce-in-goal mode goal-name pre-term))) ;;; :verbose (defun eval-citp-verbose (token) (if (string-equal token "on") (setq *citp-verbose* t) (if (string-equal token "off") (setq *citp-verbose* nil) (if (string-equal token ".") (format t "~&:verbose flag is ~s" (if *citp-verbose* "on" "off")) (with-output-chaos-error ('invlid-value) (format t "Unknown parameter ~s." token)))))) ;;; :normalize init (defun eval-citp-normalize (token) (if (string-equal token "on") (setq *citp-normalize-instance* t) (if (string-equal token "off") (setq *citp-normalize-instance* nil) (if (string-equal token ".") (format t "~&:normalize flag is ~s" (if *citp-normalize-instance* "on" "off")) (with-output-chaos-error ('invalid-value) (format t ":nomalize instance: unknown parameter ~s." token)))))) ;;; :ctf ;;; ax-form ::= (form . (term? . :ctf-?)) ;;; (defun eval-citp-ctf (ax-form) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-ctf (car ax-form) (cadr ax-form) (cddr ax-form)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :csp (defun eval-citp-csp (goal-ax-decls) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-csp (car goal-ax-decls) (cdr goal-ax-decls)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :show, :describe (defun eval-citp-show (token) (let* ((com (car token)) (describe (eq com :describe)) (target (cadr token)) (rest-args (cddr token))) (cond ((member target '("unproved" "unp") :test #'equal) (check-ptree) (print-unproved-goals *proof-tree*)) ((member target '("proved" "discharged") :test #'equal) (check-ptree) (print-discharged-sentences)) ((equal target "goal") (check-ptree) (let ((name (car rest-args))) (print-named-goal *proof-tree* name))) ((equal target "proof") (let ((name (car rest-args))) (when (or (null name) (equal name ".")) (setq name "root")) (print-proof-tree name describe))) ((member target '("." "current") :test #'equal) (check-ptree) (print-current-goal describe)) ((member target '(":def" ":define" "def" "define" ":defs" "defs") :test #'equal) (check-ptree) (let ((goal-name (first rest-args))) (print-defs describe goal-name))) ((member target '("switch" "switches" "flag" "flags") :test #'equal) (print-citp-flag citp-all)) (t (with-output-chaos-error ('unknown) (format t "Unknown parameter to :show/:describe ~S" target)))))) ;;; { :binspect | binspect } ;;; (defun eval-citp-binspect (args) (let ((mode (first args)) (goal-or-mod (second args)) (preterm (third args))) (binspect-in mode goal-or-mod preterm))) ;;; { :bgrind | bgrind } ;;; (defun eval-citp-bgrind (args) (bgrind-in (first args) ; mode (second args) ; goal or module (third args) ; term tokens )) ;;; eval-citp-define : arg -> tactic-ctf or tactic-csp ;;; (:ctf "cf1" nil (:term (<Term>))) ;;; (:ctf "cf2" t (:eq (<Equation>))) ;;; (:csp "sp1" nil ((<Equation> ".") ...)) ;;; (:csp "sp2" t ((<Equation> ".") ...)) ;;; (:init "ini1" nil (:init ....)) ;;; (:seq "tactic-1" nil (<tactic-name> ....)) ;;; (defun eval-citp-define (arg) (check-ptree) (let ((tactic-name (first arg)) (name (second arg)) (dash (third arg)) (form (fourth arg)) (tactic nil)) (when (tactic-name-is-builtin? name) (with-output-chaos-error ('invalid-name) (format t "You can not use the name of builtin tactic ~a." name))) (when (existing-def-name? *proof-tree* name) (with-output-chaos-warning () (format t "The name ~a is already defined in the current proof context." name) (format t "~%Please use the different name.") (return-from eval-citp-define nil))) (let ((current (get-next-proof-context *proof-tree*)) (goal nil)) (unless current (with-output-chaos-error ('no-context) (format t "No target goal."))) (setq goal (ptree-node-goal current)) (with-in-module ((goal-context goal)) (let ((*chaos-quiet* t)) (cond ((eq tactic-name :ctf) ;; ctf (setq tactic (make-tactic-ctf :name name :form (parse-axiom-or-term (second form) (eq :term (first form))) :context *current-module* :minus dash))) ((eq tactic-name :csp) ;; csp (let ((forms nil)) (dolist (ax form) (push (parse-axiom-declaration (parse-module-element-1 ax)) forms)) (setq tactic (make-tactic-csp :name name :forms (nreverse forms) :minus dash :context *current-module*)))) ((eq tactic-name :init) (let ((ax (get-target-axiom *current-module* (second form)))) (setq tactic (make-tactic-init :name name :axiom ax :subst (third form) :context *current-module* :kind (car (last form)))))) ((eq tactic-name :ind) ;; ind (setq tactic (make-tactic-ind :name name :vars () :base () :step ()))) ((eq tactic-name :seq) (setq tactic (make-tactic-seq :name name :tactics (mapcar #'(lambda (x) (or (get-defined-tactic goal x) (get-builtin-tactic x) (with-output-chaos-error ('no-such-tactic) (format t "No such tactic ~a" x)))) form)))) (t ;; internal error (with-output-chaos-error ('internal-error) (format t "Invalid :def parameter ~s" tactic-name)))) (format t "~&~a defined as " name) (princ tactic) (setf (goal-defs goal) (nconc (goal-defs goal) (list tactic))))) (push (canonicalize-tactic-name name) (ptree-defs-so-far *proof-tree*))))) ;;; ;;; SET-FLAG/CLEAR-FLAG ;;; (defun citp-eval-set (args) (let ((name (first args)) (given-value (second args))) (let ((value nil) (index (find-citp-flag-index name))) (unless index (with-output-chaos-error ('no-such-flag) (format t "No such flag ~a" name))) (cond ((or (equal given-value "on") (equal given-value "set")) (setq value t)) ((equal given-value "show") (print-citp-flag index) (return-from citp-eval-set nil)) ((equal given-value "?") (help-citp-flag index) (return-from citp-eval-set nil))) (when (citp-flag citp-print-message) (with-output-msg () (format t "setting flag ~a to ~a" name given-value))) (if (= citp-all index) (dotimes (x *citp-max-flags*) (setf (citp-flag x) value)) (setf (citp-flag index) value)) ;; run hook (funcall (citp-flag-hook index) name value)))) ;;; ;;; :use ;;; (defun citp-eval-use (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:use (use-discharged-goals body)) (:use-theory (let ((label (car body)) (theory (cdr body))) (use-theory label theory)))))) ;;; ;;; :embed ;;; (defun citp-eval-embed (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:embed (let ((labels (car body)) (mod-name (cadr body)) (into (caddr body))) (embed-discharged-goals labels mod-name into))) (:embed-theory (let ((label (first body)) (theory (second body)) (mod-name (third body)) (into (fourth body))) (embed-theory label theory mod-name into)))))) ;;; ;;; :reset ;;; (defun citp-eval-reset (&rest args) (declare (ignore args)) (check-ptree) (reset-proof-session)) ;;; ;;; :theory <opname> : <arity> -> <coarity> { assoc | comm | id: <term> } ;;; (defun add-method-theory (decl) (check-ptree) (let ((theory (%opattrs-theory (%theory-decl-attribute decl))) (name (%theory-decl-name decl)) (arity (%theory-decl-arity decl)) (coarity (%theory-decl-coarity decl)) (goal (ptree-node-goal (get-next-proof-context *proof-tree*)))) (with-in-module ((goal-context goal)) (let ((r-arity (mapcar #'(lambda (x) (or (find-sort-in *current-module* x) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref x)))) arity)) (r-coarity (or (find-sort-in *current-module* coarity) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref coarity))))) (let ((meth (find-method-in *current-module* name r-arity r-coarity))) (unless meth (with-output-chaos-error ('no-op) (format t "No such operator ~s" name))) (add-and-merge-method-theory meth theory *current-module*) (set-needs-parse) (set-needs-rule)))))) ;;; EOF
true
;;;-*-Mode:LISP; Package: CHAOS; Base:10; Syntax:Common-lisp -*- ;;; ;;; Copyright (c) 2000-2016, PI:NAME:<NAME>END_PI. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; (in-package :chaos) #|============================================================================= System:CHAOS Module:thstuff File:citp.lisp =============================================================================|# #-:chaos-debug (declaim (optimize (speed 3) (safety 0) #-GCL (debug 0))) #+:chaos-debug (declaim (optimize (speed 1) (safety 3) #-GCL (debug 3))) (defun check-context-module () (unless *current-module* (with-output-chaos-error ('no-context) (format t "No context module is specified, please 'select' or 'open' a module.")))) (defun check-ptree () (unless *proof-tree* (with-output-chaos-error ('no-proof-tree) (format t "No proof is ongoing.")))) (defun check-on-going() (unless (and *proof-tree* (get-unproved-nodes *proof-tree*)) (with-output-chaos-error ('no-target) (format t "There are no unproved goals.")))) (defun check-context-module-and-ptree () (check-context-module) (check-ptree)) ;;; ============================ ;;; CITP related command parsers ;;; ============================ ;;; ;;; :goal { <axiom> . <axiom> . .... <axiom> . } ;;; (defun citp-parse-goal (args) (let ((ax-decls nil)) (dolist (elem (third args)) (push (parse-module-element-1 elem) ax-decls)) (nreverse ax-decls))) ;;; ;;; :apply [to <goal-name>] (<tactic> ...) ;;; ;;; (":apply" ("(" ("tc" "rd" "si") ")")) ;;; (":apply" ("to" ("1-1-1")) ("(" ("RD") ")")) ;;; (defun citp-parse-apply (args) (let ((tactic-forms nil) (tactics nil) (target nil)) (cond ((string-equal (car (second args)) "to") (setq target (car (second (second args)))) (setq tactic-forms (second (third args)))) (t (setq tactic-forms (second (second args))))) (dolist (tac tactic-forms) (let ((tactic (get-tactic tac))) (setq tactics (nconc tactics tactic)))) (cons target tactics))) ;;; citp-parse-ind-on ;;; :ind on (var ... var) ;;; (":ind" ("on" "(" ("A:S-1" "B:S-2" "C:S-3") ")")) ;;; (":ind" ("{" ("on" #1="(" ("L1:List") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("step" #1# ("X:Elm" "T:List") "." nil #2#) "}")) ;;; (":ind" ("{" ("on" #1="(" ("S1:Seq") #2=")") ;;; ("base" #1# ("nil") "." nil #2#) ;;; ("hypo" #1# ("SQ:Seq") "." nil #2#) ;;; ("step" #1# ("EL:Elt" "SQ:Seq") "." nil #2#) "}")) (defun citp-parse-seq-of-terms (module token-list) (let ((terms nil)) (when (atom token-list) (return-from citp-parse-seq-of-terms nil)) (dolist (term? token-list) ;; (format t "~%<<>> ~s" term?) (when (consp term?) (let* ((*parse-variables* nil) (target-term (simple-parse module term? *cosmos*))) (when (or (null (term-sort target-term)) (sort<= (term-sort target-term) *syntax-err-sort* *chaos-sort-order*)) (with-output-chaos-error ('invalid-term) (format t "Could not parse ~s" term?))) (push target-term terms)))) (nreverse terms))) (defun citp-parse-ind-on (args) (check-context-module) (with-in-module (*current-module*) (let ((ind-type (first (second args)))) (flet ((parse-vars (decls) (let ((vars nil)) (dolist (var-decl decls) (let ((var (simple-parse-from-string var-decl))) (when (term-is-an-error var) (with-output-chaos-error ('no-parse) (format t "Illegal variable form: ~a" var-decl))) (unless (term-is-variable? var) (with-output-chaos-error ('no-var) (format t "Invalid argument to ':ind' command: ~a" var-decl))) (push var vars))) (nreverse vars)))) (if (equal ind-type "on") (let ((vars (parse-vars (third (second args))))) (cons :simple vars)) ;; :ind { on () base() [hypo ()] step() } (let* ((decl (second args)) (vars (parse-vars (third (second decl)))) (bases (citp-parse-seq-of-terms *current-module* (third decl))) (hypo (citp-parse-seq-of-terms *current-module* (fourth decl))) (steps (citp-parse-seq-of-terms *current-module* (fifth decl)))) (if steps (list :user vars bases hypo steps) (list :user vars bases nil hypo)))))))) ;;; ;;; :auto ;;; (defun citp-parse-auto (args) (declare (ignore args)) (cons :auto (get-default-tactics))) ;;; ;;; :roll back ;;; (defun citp-parse-roll-back (args) (declare (ignore args)) :roll-back) ;;; ;;; :init {[<label>] | (<axiom>)} by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; first second third four fifth ;;; (":init" ("[" ("test1") "]") "by" "{" (("X:S" "<-" ("X#S")) ";") "}")) ;;; first second third fourth ;;; (":init" ("as" "ts-ss-1") (#1="{" ("eq" ("ts.." "(" "SS:SeqSym" ")") "=" ("true") ".") #3="}") ("by" #1# (("SS:SeqSym" "<-" ("ss")) #2=";" ("XX:Bar" "<-" ("bb")) #2#) #3#))) ;;; (":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}")) ;;; (defun make-axiom-pattern (target) (if (stringp target) (cons :label (list target)) (cons :axiom target))) (defun citp-parse-init (args) (let ((name (if (equal (first (second args)) "as") (second (second args)) nil))) (let ((target-form (make-axiom-pattern (if name (second (third args)) (second (second args))))) (subst-list (if name (third (fourth args)) (third (third args)))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (with-citp-debug () (format t "~%[:init] target = ~s" target-form) (format t "~% subst = ~s" subst-pairs)) (list (first args) target-form subst-pairs name)))) ;;; :imply [<label>] by { <var> <- <term>; ...<var> <- <term>; } ;;; ;;; (":imp" ("[" ("test2") "]") ("by" "{" (("Y:S" "<-" ("X#S")) ";") "}")) ;;; (":imp" ("[" ("gt") "]") (".")) ;;; (defun citp-parse-imp (args) (let ((target-form (make-axiom-pattern (second args))) (subst-list (third (third args))) (subst-pairs nil)) (dolist (subst-form subst-list) (unless (atom subst-form) (push (cons (first subst-form) (third subst-form)) subst-pairs))) (list target-form subst-pairs))) ;;; :cp ;;; (":cp" ("[" ("label-1") "]") "><" ("[" ("label-2") "]")) ;;; (":cp" ("(" ("ceq" ("LHS") "=" ("RHS") "if" ("C") ".") ")") ;;; "><" ("(" ("ceq" ("LHS-2") "=" ("RHS-2") "if" ("C-2") ".") ")")) ;;; (defun citp-parse-critical-pair (args) (let ((pat-1 (make-axiom-pattern (second args))) (pat-2 (make-axiom-pattern (fourth args)))) (with-citp-debug () (format t "~%[cp] ~s" pat-1) (format t "~% ~s" pat-2)) (list pat-1 pat-2))) ;;; :equation/:rule ;;; (defun citp-parse-equation (args) (if (member (car args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :backward equation/rule ;;; (defun citp-parse-backward (args) (if (member (second args) '(":equation" "equation") :test #'equal) :equation :rule)) ;;; :select <GoalName> ;;; (defun citp-parse-select (args) (let ((goal-name (car (second args)))) goal-name)) ;;; citp-parse-red ;;; (defun citp-parse-red (e) (let (goal-name preterm mode) (case-equal (first e) ((":red" ":lred" "lred") (setq mode :red)) ((":exec") (setq mode :exec)) ((":bred") (setq mode :bred))) (if (= 4 (length e)) (progn (setq goal-name (cadr (cadr e))) (setq preterm (nth 2 e))) (progn (setq goal-name nil) (setq preterm (nth 1 e)))) (list mode goal-name preterm))) ;;; citp-parse-verbose ;;; :verbose {on | off} (defun citp-parse-verbose (args) (second args)) ;;; citp-parse-normalize ;;; :normalize {on | off} (defun citp-parse-normalize (args) (second args)) ;;; citp-parse-ctf ;;; :ctf { eq <term> = <term> .} ;;; (":ctf" ("{" ("eq" ("1" ">" "2") "=" ("true") ".") "}")) ;;; :ctf [ <term> . ] ;;; (":ctf" ("[" ("1" ">" "2") "." "]")) ;;; ==> (form . (term? . :ctf-?)) ;;; (defun citp-parse-ctf (args) (let ((form (second (second args))) (term? (equal (first (second args)) "["))) (if (equal (first args) ":ctf-") (cons form (cons term? :dash)) (cons form (cons term? nil))))) ;;; citp-parse-csp ;;; :csp { <axiom> ... } ;;; (defun citp-parse-csp (args) (let ((ax-decls nil) (dash? (equal (car args) ":csp-"))) (dolist (elem (third args)) (push elem ax-decls)) (cons (nreverse ax-decls) dash?))) ;;; citp-parse-define ;;; :def <symbol> = <ctf> | <csp> | <init> | ;;; ;;; (":def" "cf1" "=" (":ctf" ("[" (<Term>) "." "]"))) ;;; ==> (:ctf "cf1" nil (:term (<Term>))) ;;; (":def" "cf2" "=" (":ctf-" ("{" (<Equation>) "." "}"))) ;;; ==> (:ctf "cf2" t (:eq (<Equation>))) ;;; (":def" "sp1" "=" (":csp" "{" ((<Equation> ".") (<Equation> ".")) "}")) ;;; ==> (:csp "sp1" nil ((<Equation> ".") (<Equation> "."))) ;;; (":def" "tactic-1" "=" ("(" ("si" "rd" "tc") ")")) ;;; ==> (:seq "tactic-1" ("si" "rd" "tc")) ;;; (":define" "*disr" "=" (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" ("X#PNat")) #1=";" ("Y:PNat.PNAT" "<-" ("Y@PNat")) #1# ("Z:PNat.PNAT" "<-" ("Z@PNat")) #1#) "}")) ;;; (":define" "ts-ss2" "="(":init" ("as" "ts-ss-1") (#1="(" ("eq" ("ts.." #1# "SS:SeqSym" #2=")") "=" ("true") ".") #2#) "by" ("{" ("SS:SeqSym" "<-" ("ss")) ";" "}"))) ;;; ==> (:init "*disr" nil (":init" ("[" ("*disr") "]") "by" "{" (("X:PNat.PNAT" "<-" #) #1=";" ("Y:PNat.PNAT" "<-" #) #1# ("Z:PNat.PNAT" "<-" #) #1#) "}")) (defun citp-parse-define (args) (flet ((name-to-com (name) (cond ((equal name "(") :seq) ((equal (subseq name 0 4) ":ctf") :ctf) ((equal (subseq name 0 4) ":csp") :csp) ((equal (subseq name 0 4) ":ini") :init) (t (with-output-chaos-error ('invalid-def) (format t "Internal error, :def accepted ~a" name)))))) (let* ((name (second args)) (com-name (first (fourth args))) (command (name-to-com com-name)) (dash-or-bang (or (and (member command '(:ctf :csp)) (> (length com-name) 4)) (and (eq command :init) (> (length com-name) 5)))) (body-form (case command (:ctf (if (equal "[" (first (second (fourth args)))) (list :term (second (second (fourth args)))) (list :eq (second (second (fourth args)))))) (:csp (third (fourth args))) (:init (citp-parse-init (fourth args))) (:seq (second (fourth args))) (otherwise (with-output-chaos-error ('invalid-command) (format t "Internal error, :def invalid ~s" command)))))) (list command name dash-or-bang body-form)))) ;;; { :show | :describe } <something> ;;; (defun citp-parse-show (inp) (let ((tag (car inp)) (args (cdr inp)) (com nil)) (cond ((member tag '(":show" ":sh") :test #'equal) (setq com :show)) ((member tag '(":describe" ":desc") :test #'equal) (setq com :describe)) (t (with-output-chaos-error ('internal) (format t "Internal error, unknown citp command ~s" tag)))) (cons com args))) ;;; :spoiler { on | off } ;;; (defun citp-parse-spoiler (form) (let* ((on-off (second form)) (value (if (equal on-off '("on")) t (if (equal on-off '("off")) nil (progn (format t "~&:spoiler flag is ~s" (if *citp-spoiler* "on" "off")) (return-from citp-parse-spoiler t)))))) (setq *citp-spoiler* value) (setf (citp-flag citp-spoiler) value) t)) ;;; {:binspect | binspect} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-binspect (args) (parse-term-in-context args)) (defun parse-term-in-context (args) (let (mode goal-name preterm (type (first args))) (if (and (stringp type) (eql (elt type 0) #\:)) (setq mode :citp) (setq mode :general)) (if (= 4 (length args)) (progn (setq goal-name (cadr (cadr args))) (setq preterm (nth 2 args))) (progn (setq goal-name nil) (setq preterm (nth 1 args)))) (list mode goal-name preterm))) ;;; {:bgrind | bgrind} [in {<goal-name> | <module-name>} : ] <boolean-term> . ;;; (defun parse-citp-bgrind (args) (parse-term-in-context args)) ;;; {bshow | :bshow} [ { tree | grind } ] ;;; (defun citp-parse-bshow (args) (let ((param (cadr args))) (or param "."))) ;;; :set(<name>, {on | off | show | ? }) ;;; (defun citp-parse-set (inp) (declare (type list inp)) (let ((name (third inp)) (value (fifth inp))) (list name value))) ;;; {bstart | :bstart} <variable-name> ;;; (defun citp-parse-bstart (arg) (cadr arg)) ;;; {bguess | :bguess} <strategy> &optional args ;;; 'bguess <strategy>' ;;; <strategy> ::= { implies | and | or } ;;; p implies q = true (p and q = p) ;;; p and q = false ;;; p or q = true (defun citp-parse-bguess (args) (cdr args)) ;;; citp-parse-use ;;; :use (<label> ... <label>) ;;; :use [<label>] { assoc | comm | id: <term> } ;;; (":use" ("(" ("a" "b" "c") ")")) ;;; (":use" ("[" "foo" "]" "{" (("assoc")) "}")) (defun citp-parse-use (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (cons :use (second body))) ((equal type "[") (let ((label (second body)) (theory (fifth body))) (list* :use-theory label theory))) (t (with-output-chaos-error ('invalid-form) (format t "invalid form of :use ~s" type)))))) ;;; citp-parse-embed ;;; :embed (<label> ... <label>) as <module_name> ;;; (":embed" ("(" ("a" "b" "c") ")" "as" "foo")) ;;; (":embed" ("[" "foo" "]" "{" (("assoc") ("comm")) "}" "as" "foo")) (defun citp-parse-embed (args) (let* ((body (second args)) (type (first body))) (cond ((equal type "(") (let ((labels (second body)) (mod-name (fifth body)) (into (equal (fourth body) "into"))) (list :embed labels mod-name into))) ((equal type "[") (let ((label (second body)) (theory (fifth body)) (into (equal (seventh body) "into")) (mod-name (eighth body))) (list :embed-theory label theory mod-name into))) (t (with-output-chaos-error ('invalid-form) (format t "invalid :embed type ~s" type)))))) ;;; citp-parse-reset ;;; :reset ;;; (defun citp-parse-reset (args) args) ;;; citp-process-opattr-declaration-form ;;; (defun citp-process-opattr-declaration-form (args &rest ignore) (declare (ignore ignore)) (format t "~s" args)) ;;; ================================ ;;; CITP related command evaluators ;;; ================================ ;;; :goal ;;; (defun eval-citp-goal (goal-ax-decls) (check-context-module) (with-in-module (*current-module*) (let ((axs nil)) (dolist (a-decl goal-ax-decls) (cond ((eq (car a-decl) '%fax) (push (parse-fax-declaration a-decl) axs)) (t (push (parse-axiom-declaration a-decl) axs)))) (begin-proof *current-module* (nreverse axs))))) ;;; :apply/:auto (defun eval-citp-apply (list-tactic) (check-ptree) (let ((target (car list-tactic)) (tactics (cdr list-tactic))) (let ((*chaos-verbose* nil) (*chaos-quiet* t)) (if target (case target (:auto (apply-auto *proof-tree*)) (otherwise (apply-tactics-to-goal *proof-tree* target tactics))) (apply-tactics *proof-tree* tactics))))) ;;; :ind on ;;; (defun eval-citp-ind-on (args) (check-ptree) (with-in-module ((get-context-module)) (let ((type (car args)) (ind-form (cdr args))) (if (eq type :simple) (set-induction-variables ind-form) ;; :user defined induction scheme (let ((vars (first ind-form)) (bases (second ind-form)) (hypo (third ind-form)) (steps (fourth ind-form))) (check-on-going) (let ((target-node (get-next-proof-context *proof-tree*))) (set-induction-variables-and-scheme target-node vars bases hypo steps) ;; then do the job (apply-user-defined-induction-scheme target-node))))))) ;;; :roll back ;;; (defun eval-citp-roll-back (&rest com) (declare (ignore com)) (check-ptree) (with-in-module (*current-module*) (roll-back *proof-tree*))) ;;; :init ;;; (defun eval-citp-init (args) (let ((target-goal (ptree-node-goal (get-target-goal-node)))) (instanciate-axiom target-goal (second args) ; target (third args) ; variable-term pairs (fourth args) ; label ))) ;;; :imp ;;; (defun eval-citp-imp (args) (check-ptree) (with-in-module ((goal-context (ptree-node-goal (get-target-goal-node)))) (introduce-implication-to-goal (first args) ; target (second args)))) ;variable-term pairs ;;; :cp (defun eval-citp-critical-pair (args) (check-ptree) (with-in-module (*current-module*) (apply-cp (first args) (second args)))) ;;; :equation : {:equation| :rule} -> void (defun eval-citp-equation (arg) (check-ptree) (add-critical-pairs arg :forward)) ;;; :backward (defun eval-citp-backward (arg) (check-ptree) (add-critical-pairs arg :backward)) ;;; :select (defun eval-citp-select (goal-name) (check-ptree) (select-next-goal goal-name)) ;;; :red, :exec, :bred (defun eval-citp-red (token-seq) (check-ptree) (let ((mode (first token-seq)) (goal-name (second token-seq)) (pre-term (third token-seq))) (reduce-in-goal mode goal-name pre-term))) ;;; :verbose (defun eval-citp-verbose (token) (if (string-equal token "on") (setq *citp-verbose* t) (if (string-equal token "off") (setq *citp-verbose* nil) (if (string-equal token ".") (format t "~&:verbose flag is ~s" (if *citp-verbose* "on" "off")) (with-output-chaos-error ('invlid-value) (format t "Unknown parameter ~s." token)))))) ;;; :normalize init (defun eval-citp-normalize (token) (if (string-equal token "on") (setq *citp-normalize-instance* t) (if (string-equal token "off") (setq *citp-normalize-instance* nil) (if (string-equal token ".") (format t "~&:normalize flag is ~s" (if *citp-normalize-instance* "on" "off")) (with-output-chaos-error ('invalid-value) (format t ":nomalize instance: unknown parameter ~s." token)))))) ;;; :ctf ;;; ax-form ::= (form . (term? . :ctf-?)) ;;; (defun eval-citp-ctf (ax-form) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-ctf (car ax-form) (cadr ax-form) (cddr ax-form)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :csp (defun eval-citp-csp (goal-ax-decls) (check-ptree) (with-in-module ((get-context-module)) (reset-rewrite-counters) (begin-rewrite) (apply-csp (car goal-ax-decls) (cdr goal-ax-decls)) (end-rewrite) (report-citp-stat) (check-success *proof-tree*))) ;;; :show, :describe (defun eval-citp-show (token) (let* ((com (car token)) (describe (eq com :describe)) (target (cadr token)) (rest-args (cddr token))) (cond ((member target '("unproved" "unp") :test #'equal) (check-ptree) (print-unproved-goals *proof-tree*)) ((member target '("proved" "discharged") :test #'equal) (check-ptree) (print-discharged-sentences)) ((equal target "goal") (check-ptree) (let ((name (car rest-args))) (print-named-goal *proof-tree* name))) ((equal target "proof") (let ((name (car rest-args))) (when (or (null name) (equal name ".")) (setq name "root")) (print-proof-tree name describe))) ((member target '("." "current") :test #'equal) (check-ptree) (print-current-goal describe)) ((member target '(":def" ":define" "def" "define" ":defs" "defs") :test #'equal) (check-ptree) (let ((goal-name (first rest-args))) (print-defs describe goal-name))) ((member target '("switch" "switches" "flag" "flags") :test #'equal) (print-citp-flag citp-all)) (t (with-output-chaos-error ('unknown) (format t "Unknown parameter to :show/:describe ~S" target)))))) ;;; { :binspect | binspect } ;;; (defun eval-citp-binspect (args) (let ((mode (first args)) (goal-or-mod (second args)) (preterm (third args))) (binspect-in mode goal-or-mod preterm))) ;;; { :bgrind | bgrind } ;;; (defun eval-citp-bgrind (args) (bgrind-in (first args) ; mode (second args) ; goal or module (third args) ; term tokens )) ;;; eval-citp-define : arg -> tactic-ctf or tactic-csp ;;; (:ctf "cf1" nil (:term (<Term>))) ;;; (:ctf "cf2" t (:eq (<Equation>))) ;;; (:csp "sp1" nil ((<Equation> ".") ...)) ;;; (:csp "sp2" t ((<Equation> ".") ...)) ;;; (:init "ini1" nil (:init ....)) ;;; (:seq "tactic-1" nil (<tactic-name> ....)) ;;; (defun eval-citp-define (arg) (check-ptree) (let ((tactic-name (first arg)) (name (second arg)) (dash (third arg)) (form (fourth arg)) (tactic nil)) (when (tactic-name-is-builtin? name) (with-output-chaos-error ('invalid-name) (format t "You can not use the name of builtin tactic ~a." name))) (when (existing-def-name? *proof-tree* name) (with-output-chaos-warning () (format t "The name ~a is already defined in the current proof context." name) (format t "~%Please use the different name.") (return-from eval-citp-define nil))) (let ((current (get-next-proof-context *proof-tree*)) (goal nil)) (unless current (with-output-chaos-error ('no-context) (format t "No target goal."))) (setq goal (ptree-node-goal current)) (with-in-module ((goal-context goal)) (let ((*chaos-quiet* t)) (cond ((eq tactic-name :ctf) ;; ctf (setq tactic (make-tactic-ctf :name name :form (parse-axiom-or-term (second form) (eq :term (first form))) :context *current-module* :minus dash))) ((eq tactic-name :csp) ;; csp (let ((forms nil)) (dolist (ax form) (push (parse-axiom-declaration (parse-module-element-1 ax)) forms)) (setq tactic (make-tactic-csp :name name :forms (nreverse forms) :minus dash :context *current-module*)))) ((eq tactic-name :init) (let ((ax (get-target-axiom *current-module* (second form)))) (setq tactic (make-tactic-init :name name :axiom ax :subst (third form) :context *current-module* :kind (car (last form)))))) ((eq tactic-name :ind) ;; ind (setq tactic (make-tactic-ind :name name :vars () :base () :step ()))) ((eq tactic-name :seq) (setq tactic (make-tactic-seq :name name :tactics (mapcar #'(lambda (x) (or (get-defined-tactic goal x) (get-builtin-tactic x) (with-output-chaos-error ('no-such-tactic) (format t "No such tactic ~a" x)))) form)))) (t ;; internal error (with-output-chaos-error ('internal-error) (format t "Invalid :def parameter ~s" tactic-name)))) (format t "~&~a defined as " name) (princ tactic) (setf (goal-defs goal) (nconc (goal-defs goal) (list tactic))))) (push (canonicalize-tactic-name name) (ptree-defs-so-far *proof-tree*))))) ;;; ;;; SET-FLAG/CLEAR-FLAG ;;; (defun citp-eval-set (args) (let ((name (first args)) (given-value (second args))) (let ((value nil) (index (find-citp-flag-index name))) (unless index (with-output-chaos-error ('no-such-flag) (format t "No such flag ~a" name))) (cond ((or (equal given-value "on") (equal given-value "set")) (setq value t)) ((equal given-value "show") (print-citp-flag index) (return-from citp-eval-set nil)) ((equal given-value "?") (help-citp-flag index) (return-from citp-eval-set nil))) (when (citp-flag citp-print-message) (with-output-msg () (format t "setting flag ~a to ~a" name given-value))) (if (= citp-all index) (dotimes (x *citp-max-flags*) (setf (citp-flag x) value)) (setf (citp-flag index) value)) ;; run hook (funcall (citp-flag-hook index) name value)))) ;;; ;;; :use ;;; (defun citp-eval-use (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:use (use-discharged-goals body)) (:use-theory (let ((label (car body)) (theory (cdr body))) (use-theory label theory)))))) ;;; ;;; :embed ;;; (defun citp-eval-embed (args) (check-ptree) (let ((type (car args)) (body (cdr args))) (case type (:embed (let ((labels (car body)) (mod-name (cadr body)) (into (caddr body))) (embed-discharged-goals labels mod-name into))) (:embed-theory (let ((label (first body)) (theory (second body)) (mod-name (third body)) (into (fourth body))) (embed-theory label theory mod-name into)))))) ;;; ;;; :reset ;;; (defun citp-eval-reset (&rest args) (declare (ignore args)) (check-ptree) (reset-proof-session)) ;;; ;;; :theory <opname> : <arity> -> <coarity> { assoc | comm | id: <term> } ;;; (defun add-method-theory (decl) (check-ptree) (let ((theory (%opattrs-theory (%theory-decl-attribute decl))) (name (%theory-decl-name decl)) (arity (%theory-decl-arity decl)) (coarity (%theory-decl-coarity decl)) (goal (ptree-node-goal (get-next-proof-context *proof-tree*)))) (with-in-module ((goal-context goal)) (let ((r-arity (mapcar #'(lambda (x) (or (find-sort-in *current-module* x) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref x)))) arity)) (r-coarity (or (find-sort-in *current-module* coarity) (with-output-chaos-error ('no-sort) (princ "No such sort ") (print-sort-ref coarity))))) (let ((meth (find-method-in *current-module* name r-arity r-coarity))) (unless meth (with-output-chaos-error ('no-op) (format t "No such operator ~s" name))) (add-and-merge-method-theory meth theory *current-module*) (set-needs-parse) (set-needs-rule)))))) ;;; EOF
[ { "context": "; Matt Kaufmann\n\n; This book provides a test for the correct impl", "end": 15, "score": 0.9998480677604675, "start": 2, "tag": "NAME", "value": "Matt Kaufmann" } ]
books/misc/misc2/step-limits.lisp
nzt/acl2
1
; Matt Kaufmann ; This book provides a test for the correct implementation of step-limits. (in-package "ACL2") (include-book "std/testing/eval" :dir :system) (must-succeed ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 435 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 434 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 200 ; we thus expect 201 steps used; "more than 200" reported for the thm (thm (equal (append x (append y z)) (append (append x y) z))))) (set-prover-step-limit 300) ; The following fails without the inner with-prover-step-limit having flag t, ; because otherwise more than the allocated 300 steps are charged to the ; must-fail form (i.e., to the make-event form generated by the call of ; must-fail). (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z))))) ; The following fails unless the extra argument of t is given to the inner ; with-prover-step-limit, because otherwise more than the allocated 300 steps ; are charged to the must-succeed form (i.e., to the make-event form generated ; by the call of must-succeed). (must-succeed (with-prover-step-limit 500 t (thm (equal (append x (append y z)) (append (append x y) z))))) (with-prover-step-limit 200 (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z)))))) (set-prover-step-limit 500) (must-succeed (thm (equal (append x (append y z)) (append (append x y) z)))) (must-fail (with-prover-step-limit 300 (thm (equal (append x (append y z)) (append (append x y) z))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) ; As above: (with-prover-step-limit 500 (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; As above: (with-prover-step-limit 500 (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))))) (must-succeed (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; Extra argument of t is needed as usual, because we exceed the global limit of ; 500. (must-fail (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 200 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) (must-succeed (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))) ; Essentially the same as just above. (must-succeed (with-prover-step-limit 500 (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) (set-prover-step-limit 200) ; As usual, we need the extra argument t below in order to avoid having the ; entire must-fail form exceed the limit of 200 steps. (must-fail (with-prover-step-limit :start t (progn (set-prover-step-limit 500) (defthm test3 (equal (append x (append y z)) (append (append x y) z)))))) ; Setting an explicit limit (even nil, for "unlimited") overrides the global ; default step limit from set-prover-step-limit. (with-prover-step-limit nil (progn (set-prover-step-limit 500) (local ; avoid adding test3 to database upon include-book (defthm test3 (equal (append x (append y z)) (append (append x y) z))))))
39592
; <NAME> ; This book provides a test for the correct implementation of step-limits. (in-package "ACL2") (include-book "std/testing/eval" :dir :system) (must-succeed ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 435 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 434 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 200 ; we thus expect 201 steps used; "more than 200" reported for the thm (thm (equal (append x (append y z)) (append (append x y) z))))) (set-prover-step-limit 300) ; The following fails without the inner with-prover-step-limit having flag t, ; because otherwise more than the allocated 300 steps are charged to the ; must-fail form (i.e., to the make-event form generated by the call of ; must-fail). (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z))))) ; The following fails unless the extra argument of t is given to the inner ; with-prover-step-limit, because otherwise more than the allocated 300 steps ; are charged to the must-succeed form (i.e., to the make-event form generated ; by the call of must-succeed). (must-succeed (with-prover-step-limit 500 t (thm (equal (append x (append y z)) (append (append x y) z))))) (with-prover-step-limit 200 (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z)))))) (set-prover-step-limit 500) (must-succeed (thm (equal (append x (append y z)) (append (append x y) z)))) (must-fail (with-prover-step-limit 300 (thm (equal (append x (append y z)) (append (append x y) z))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) ; As above: (with-prover-step-limit 500 (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; As above: (with-prover-step-limit 500 (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))))) (must-succeed (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; Extra argument of t is needed as usual, because we exceed the global limit of ; 500. (must-fail (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 200 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) (must-succeed (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))) ; Essentially the same as just above. (must-succeed (with-prover-step-limit 500 (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) (set-prover-step-limit 200) ; As usual, we need the extra argument t below in order to avoid having the ; entire must-fail form exceed the limit of 200 steps. (must-fail (with-prover-step-limit :start t (progn (set-prover-step-limit 500) (defthm test3 (equal (append x (append y z)) (append (append x y) z)))))) ; Setting an explicit limit (even nil, for "unlimited") overrides the global ; default step limit from set-prover-step-limit. (with-prover-step-limit nil (progn (set-prover-step-limit 500) (local ; avoid adding test3 to database upon include-book (defthm test3 (equal (append x (append y z)) (append (append x y) z))))))
true
; PI:NAME:<NAME>END_PI ; This book provides a test for the correct implementation of step-limits. (in-package "ACL2") (include-book "std/testing/eval" :dir :system) (must-succeed ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 435 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 434 (thm (equal (append x (append y z)) (append (append x y) z))))) (must-fail ; 435 steps exactly in a version between ACL2 4.2 and 4.3 (with-prover-step-limit 200 ; we thus expect 201 steps used; "more than 200" reported for the thm (thm (equal (append x (append y z)) (append (append x y) z))))) (set-prover-step-limit 300) ; The following fails without the inner with-prover-step-limit having flag t, ; because otherwise more than the allocated 300 steps are charged to the ; must-fail form (i.e., to the make-event form generated by the call of ; must-fail). (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z))))) ; The following fails unless the extra argument of t is given to the inner ; with-prover-step-limit, because otherwise more than the allocated 300 steps ; are charged to the must-succeed form (i.e., to the make-event form generated ; by the call of must-succeed). (must-succeed (with-prover-step-limit 500 t (thm (equal (append x (append y z)) (append (append x y) z))))) (with-prover-step-limit 200 (must-fail (with-prover-step-limit :start t (thm (equal (append x (append y z)) (append (append x y) z)))))) (set-prover-step-limit 500) (must-succeed (thm (equal (append x (append y z)) (append (append x y) z)))) (must-fail (with-prover-step-limit 300 (thm (equal (append x (append y z)) (append (append x y) z))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) ; As above: (with-prover-step-limit 500 (must-fail (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; See long comments "The following fails ...." above for why we need the call ; of with-prover-step-limit just below, with third argument t. (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; As above: (with-prover-step-limit 500 (must-fail ; fails at the very end (with-prover-step-limit :start t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))))) (must-succeed (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 500 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) ; Extra argument of t is needed as usual, because we exceed the global limit of ; 500. (must-fail (with-prover-step-limit 1000 t (encapsulate () (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil) (with-prover-step-limit 200 (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))))) (must-succeed (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil))) ; Essentially the same as just above. (must-succeed (with-prover-step-limit 500 (encapsulate () (with-prover-step-limit 500 t ; Don't charge for this first defthm (defthm test1 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)) (defthm test2 (equal (append x (append y z)) (append (append x y) z)) :rule-classes nil)))) (set-prover-step-limit 200) ; As usual, we need the extra argument t below in order to avoid having the ; entire must-fail form exceed the limit of 200 steps. (must-fail (with-prover-step-limit :start t (progn (set-prover-step-limit 500) (defthm test3 (equal (append x (append y z)) (append (append x y) z)))))) ; Setting an explicit limit (even nil, for "unlimited") overrides the global ; default step limit from set-prover-step-limit. (with-prover-step-limit nil (progn (set-prover-step-limit 500) (local ; avoid adding test3 to database upon include-book (defthm test3 (equal (append x (append y z)) (append (append x y) z))))))
[ { "context": ";;; (C) Copyright 1990 - 2014 by Wade L. Hennessey. All rights reserved.\n\n;;; Cannot self-compile th", "end": 50, "score": 0.9998763799667358, "start": 33, "tag": "NAME", "value": "Wade L. Hennessey" } ]
src/cl/decls/destructuring-bind.lisp
wadehennessey/wcl
73
;;; (C) Copyright 1990 - 2014 by Wade L. Hennessey. All rights reserved. ;;; Cannot self-compile this version - infinite recursion ;(defmacro destructuring-bind (lambda-list form &body body+decls) ; (dbind-1 lambda-list form (cons 'locally body+decls))) (define-macro 'destructuring-bind #'(lambda (whole env) (let ((lambda-list (second whole)) (form (third whole)) (body+decls (cdddr whole))) (dbind-1 lambda-list form (cons 'locally body+decls))))) (defun dbind-1 (pattern form-expr body) (let ((form (gensym "L")) (lambda-list (dot->&rest pattern))) (labels ((pull-apart (required) (if (null required) (let ((hairy (lambda-list-hairy-args lambda-list))) (if (null hairy) body (hairy-dbind hairy form body))) (let ((req (car required))) (if (atom req) `(let ((,req (pop ,form))) ,(pull-apart (cdr required))) (dbind-1 req `(pop ,form) (pull-apart (cdr required)))))))) `(let ((,form ,form-expr)) ,(pull-apart (lambda-list-required-args lambda-list)))))) (defun hairy-dbind (hairy form body) (if (and (eq (first hairy) '&rest) ; just (&rest var) ? (symbolp (second hairy)) (null (cddr hairy))) `(let ((,(second hairy) ,form)) ,body) `(apply #'(lambda ,hairy ,body) ,form))) (defun lambda-list-required-args (list) (subseq list 0 (or (position-if #'(lambda (e) (member e lambda-list-keywords)) list) (length list)))) (defun lambda-list-hairy-args (list) (member-if #'(lambda (x) (member x lambda-list-keywords)) list)) (defun dot->&rest (lambda-list) (let ((end (last lambda-list))) (if (null (cdr end)) lambda-list (nconc (copy-list lambda-list) (list '&rest (cdr end)))))) ;;; This should be called SYNTAX-CHECK or something. ANALYZE uses it. ;;; The expansion could be made more efficient (fewer cars/cdrs) ;;; if we factor out common subexpressions. (defmacro destructure ((vars form) &body body) (labels ((walk-vars (expr path) (if (atom expr) (if (null expr) expr `((,expr ,path))) (append (walk-vars (car expr) `(car ,path)) (walk-vars (cdr expr) `(cdr ,path)))))) (let ((f (gensym "FORM-"))) `(let ((,f ,form)) (let ,(walk-vars vars f) ,@body))))) ;;; Because DESTRUCTURING-BIND expands into code using the following ;;; macros, we must be sure these macro don't use DESTRUCTURING-BIND, ;;; otherwise we encounter an infinite recursion when evaluating them ;;; during a native compile. (define-macro 'pop #'(lambda (whole env) (let* ((var (second whole)) (list (gensym "LIST"))) `(let ((,list ,var)) (prog1 (car ,list) (setf ,var (cdr ,list))))))) (define-macro 'prog1 #'(lambda (whole env) (let ((first (second whole)) (body (cddr whole)) (value (gensym "VALUE"))) `(let ((,value ,first)) ,@body ,value)))) (define-macro 'locally #'(lambda (whole env) `((lambda () ,@(cdr whole))))) ;;; LET cannot use itself when evaled... (define-macro 'let #'(lambda (whole env) ((lambda (bindings) ((lambda (body+decls) (multiple-value-bind (body decls) (parse-body body+decls) (if (and (null bindings) (null decls)) `(progn ,@body) `((lambda ,(mapcar #'(lambda (spec) (if (atom spec) spec (first spec))) bindings) (declare ,@decls) ,@body) ,@(mapcar #'(lambda (spec) (if (atom spec) 'nil (second spec))) bindings))))) (cddr whole))) (second whole)))) (define-macro 'let* #'(lambda (whole env) (let ((bindings (second whole)) (body+decls (cddr whole))) (multiple-value-bind (body decls) (parse-body body+decls) (if (null bindings) (if (null decls) `(progn ,@body) `(locally ,@body+decls)) (let ((first-binding (if (atom (first bindings)) (list (first bindings) nil) (first bindings)))) `((lambda ,(if (null bindings) nil (list (first first-binding))) (let* ,(rest bindings) (declare ,@decls) ,@body)) ,(second first-binding))))))))
24357
;;; (C) Copyright 1990 - 2014 by <NAME>. All rights reserved. ;;; Cannot self-compile this version - infinite recursion ;(defmacro destructuring-bind (lambda-list form &body body+decls) ; (dbind-1 lambda-list form (cons 'locally body+decls))) (define-macro 'destructuring-bind #'(lambda (whole env) (let ((lambda-list (second whole)) (form (third whole)) (body+decls (cdddr whole))) (dbind-1 lambda-list form (cons 'locally body+decls))))) (defun dbind-1 (pattern form-expr body) (let ((form (gensym "L")) (lambda-list (dot->&rest pattern))) (labels ((pull-apart (required) (if (null required) (let ((hairy (lambda-list-hairy-args lambda-list))) (if (null hairy) body (hairy-dbind hairy form body))) (let ((req (car required))) (if (atom req) `(let ((,req (pop ,form))) ,(pull-apart (cdr required))) (dbind-1 req `(pop ,form) (pull-apart (cdr required)))))))) `(let ((,form ,form-expr)) ,(pull-apart (lambda-list-required-args lambda-list)))))) (defun hairy-dbind (hairy form body) (if (and (eq (first hairy) '&rest) ; just (&rest var) ? (symbolp (second hairy)) (null (cddr hairy))) `(let ((,(second hairy) ,form)) ,body) `(apply #'(lambda ,hairy ,body) ,form))) (defun lambda-list-required-args (list) (subseq list 0 (or (position-if #'(lambda (e) (member e lambda-list-keywords)) list) (length list)))) (defun lambda-list-hairy-args (list) (member-if #'(lambda (x) (member x lambda-list-keywords)) list)) (defun dot->&rest (lambda-list) (let ((end (last lambda-list))) (if (null (cdr end)) lambda-list (nconc (copy-list lambda-list) (list '&rest (cdr end)))))) ;;; This should be called SYNTAX-CHECK or something. ANALYZE uses it. ;;; The expansion could be made more efficient (fewer cars/cdrs) ;;; if we factor out common subexpressions. (defmacro destructure ((vars form) &body body) (labels ((walk-vars (expr path) (if (atom expr) (if (null expr) expr `((,expr ,path))) (append (walk-vars (car expr) `(car ,path)) (walk-vars (cdr expr) `(cdr ,path)))))) (let ((f (gensym "FORM-"))) `(let ((,f ,form)) (let ,(walk-vars vars f) ,@body))))) ;;; Because DESTRUCTURING-BIND expands into code using the following ;;; macros, we must be sure these macro don't use DESTRUCTURING-BIND, ;;; otherwise we encounter an infinite recursion when evaluating them ;;; during a native compile. (define-macro 'pop #'(lambda (whole env) (let* ((var (second whole)) (list (gensym "LIST"))) `(let ((,list ,var)) (prog1 (car ,list) (setf ,var (cdr ,list))))))) (define-macro 'prog1 #'(lambda (whole env) (let ((first (second whole)) (body (cddr whole)) (value (gensym "VALUE"))) `(let ((,value ,first)) ,@body ,value)))) (define-macro 'locally #'(lambda (whole env) `((lambda () ,@(cdr whole))))) ;;; LET cannot use itself when evaled... (define-macro 'let #'(lambda (whole env) ((lambda (bindings) ((lambda (body+decls) (multiple-value-bind (body decls) (parse-body body+decls) (if (and (null bindings) (null decls)) `(progn ,@body) `((lambda ,(mapcar #'(lambda (spec) (if (atom spec) spec (first spec))) bindings) (declare ,@decls) ,@body) ,@(mapcar #'(lambda (spec) (if (atom spec) 'nil (second spec))) bindings))))) (cddr whole))) (second whole)))) (define-macro 'let* #'(lambda (whole env) (let ((bindings (second whole)) (body+decls (cddr whole))) (multiple-value-bind (body decls) (parse-body body+decls) (if (null bindings) (if (null decls) `(progn ,@body) `(locally ,@body+decls)) (let ((first-binding (if (atom (first bindings)) (list (first bindings) nil) (first bindings)))) `((lambda ,(if (null bindings) nil (list (first first-binding))) (let* ,(rest bindings) (declare ,@decls) ,@body)) ,(second first-binding))))))))
true
;;; (C) Copyright 1990 - 2014 by PI:NAME:<NAME>END_PI. All rights reserved. ;;; Cannot self-compile this version - infinite recursion ;(defmacro destructuring-bind (lambda-list form &body body+decls) ; (dbind-1 lambda-list form (cons 'locally body+decls))) (define-macro 'destructuring-bind #'(lambda (whole env) (let ((lambda-list (second whole)) (form (third whole)) (body+decls (cdddr whole))) (dbind-1 lambda-list form (cons 'locally body+decls))))) (defun dbind-1 (pattern form-expr body) (let ((form (gensym "L")) (lambda-list (dot->&rest pattern))) (labels ((pull-apart (required) (if (null required) (let ((hairy (lambda-list-hairy-args lambda-list))) (if (null hairy) body (hairy-dbind hairy form body))) (let ((req (car required))) (if (atom req) `(let ((,req (pop ,form))) ,(pull-apart (cdr required))) (dbind-1 req `(pop ,form) (pull-apart (cdr required)))))))) `(let ((,form ,form-expr)) ,(pull-apart (lambda-list-required-args lambda-list)))))) (defun hairy-dbind (hairy form body) (if (and (eq (first hairy) '&rest) ; just (&rest var) ? (symbolp (second hairy)) (null (cddr hairy))) `(let ((,(second hairy) ,form)) ,body) `(apply #'(lambda ,hairy ,body) ,form))) (defun lambda-list-required-args (list) (subseq list 0 (or (position-if #'(lambda (e) (member e lambda-list-keywords)) list) (length list)))) (defun lambda-list-hairy-args (list) (member-if #'(lambda (x) (member x lambda-list-keywords)) list)) (defun dot->&rest (lambda-list) (let ((end (last lambda-list))) (if (null (cdr end)) lambda-list (nconc (copy-list lambda-list) (list '&rest (cdr end)))))) ;;; This should be called SYNTAX-CHECK or something. ANALYZE uses it. ;;; The expansion could be made more efficient (fewer cars/cdrs) ;;; if we factor out common subexpressions. (defmacro destructure ((vars form) &body body) (labels ((walk-vars (expr path) (if (atom expr) (if (null expr) expr `((,expr ,path))) (append (walk-vars (car expr) `(car ,path)) (walk-vars (cdr expr) `(cdr ,path)))))) (let ((f (gensym "FORM-"))) `(let ((,f ,form)) (let ,(walk-vars vars f) ,@body))))) ;;; Because DESTRUCTURING-BIND expands into code using the following ;;; macros, we must be sure these macro don't use DESTRUCTURING-BIND, ;;; otherwise we encounter an infinite recursion when evaluating them ;;; during a native compile. (define-macro 'pop #'(lambda (whole env) (let* ((var (second whole)) (list (gensym "LIST"))) `(let ((,list ,var)) (prog1 (car ,list) (setf ,var (cdr ,list))))))) (define-macro 'prog1 #'(lambda (whole env) (let ((first (second whole)) (body (cddr whole)) (value (gensym "VALUE"))) `(let ((,value ,first)) ,@body ,value)))) (define-macro 'locally #'(lambda (whole env) `((lambda () ,@(cdr whole))))) ;;; LET cannot use itself when evaled... (define-macro 'let #'(lambda (whole env) ((lambda (bindings) ((lambda (body+decls) (multiple-value-bind (body decls) (parse-body body+decls) (if (and (null bindings) (null decls)) `(progn ,@body) `((lambda ,(mapcar #'(lambda (spec) (if (atom spec) spec (first spec))) bindings) (declare ,@decls) ,@body) ,@(mapcar #'(lambda (spec) (if (atom spec) 'nil (second spec))) bindings))))) (cddr whole))) (second whole)))) (define-macro 'let* #'(lambda (whole env) (let ((bindings (second whole)) (body+decls (cddr whole))) (multiple-value-bind (body decls) (parse-body body+decls) (if (null bindings) (if (null decls) `(progn ,@body) `(locally ,@body+decls)) (let ((first-binding (if (atom (first bindings)) (list (first bindings) nil) (first bindings)))) `((lambda ,(if (null bindings) nil (list (first first-binding))) (let* ,(rest bindings) (declare ,@decls) ,@body)) ,(second first-binding))))))))
[ { "context": "; DEALINGS IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(includ", "end": 1416, "score": 0.9998753666877747, "start": 1406, "tag": "NAME", "value": "Sol Swords" }, { "context": "IN THE SOFTWARE.\n;\n; Original author: Sol Swords <[email protected]>\n\n(in-package \"GL\")\n(include-book \"gl-util\")\n(inc", "end": 1438, "score": 0.9999309778213501, "start": 1418, "tag": "EMAIL", "value": "[email protected]" } ]
books/centaur/gl/gl-mbe.lisp
solswords/acl2
0
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: Sol Swords <[email protected]> (in-package "GL") (include-book "gl-util") (include-book "std/util/define" :dir :system) ;; This is turning into a dumping ground for logically-simple functions that ;; have a special meaning under symbolic execution. Maybe we should rename ;; this file. (define acl2::always-equal (x y) :parents (reference) :short "Alias for @(see equal) that has a special meaning in @(see gl-bdd-mode)." :long "<p>Logically this is just @(see equal), but @(see GL) treats @('always-equal') in a special way.</p> <p>Suppose GL is asked to prove @('(equal spec impl)') when this does not actually hold. Sometimes, the symbolic objects for spec and impl can be created, but the BDD representing their equality is too large to fit in memory. This stops you from seeing any counterexamples, even though GL knows that the two objects aren't equal.</p> <p>To work around this, you may restate your theorem using @('always-equal') instead of @('equal') as the final comparison. @('always-equal') has a custom symbolic counterpart that returns @('t') when its arguments are equivalent, or else produces a symbolic object that captures just one counterexample and is indeterminate in all other cases.</p> <p>Note that there is not really any reason to use @('always-equal') if you are using an AIG-based GL mode, such as @(see gl-satlink-mode).</p>" :enabled t ;; BOZO could inline this (but will probably need to adjust its special ;; handling if we do that) (equal x y)) (defsection gl-assert :parents (reference) :short "During GL symbolic execution, check that a condition holds, causing an error if it does not." :long "<p>@('(gl-assert x)'), logically speaking, just returns @('(if x t nil)'). In concrete execution, it causes an error if @('x') is false, and in symbolic execution, it forces a check that @('x') is true and produces a counterexample if not.</p>" (defun-inline gl-assert-fn (x msg gmsg) (declare (xargs :guard t) (ignore gmsg)) (mbe :logic (and x t) :exec (if x t (er hard? 'gl-assert "~@0" msg)))) (defmacro gl-assert (x &key (msg 'nil msgp) (gmsg 'nil gmsgp)) (let* ((msg (if msgp msg (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))) (gmsg (cond (gmsgp gmsg) (msgp msg) (t (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))))) `(gl-assert-fn ,x ,msg ,gmsg)))) (define gl-concretize (x) :parents (reference) :short "During GL symbolic execution, try to reduce a symbolic object to a concrete one." :long "<p>@('(gl-concretize x)'), logically speaking, just returns @('x'). However, during symbolic simulation (in AIG mode), it tries to reduce @('x') to a concrete object by finding one object it could represent and trying to prove that it is always equal to that object.</p>" :inline t :enabled t x) (defsection gl-mbe :parents (reference) :short "Assert that a particular symbolic object is equivalent to a second form, and use the second in place of the first." :long "<p>@(call gl-mbe) is defined to simply check whether its two arguments @('spec') and @('impl') are equal, throwing an error if not, and return @('spec').</p> <p>However, when @('gl-mbe') is symbolically executed, the equality of the two arguments is checked symbolically. If it can be proved (e.g., via a BDD equality or SAT check) that they are always equal, then @('impl') is returned instead of @('spec'), otherwise an error is produced.</p> <p>This is most useful when symbolically executing in AIG mode. For example, suppose that through a series of shifting operations, the symbolic representation of some numeric operand X is expanded to thousands of bits. However, the user knows that only the bottom 25 bits may be non-zero. Then the following form may speed up the rest of the computation involving X by cutting off all the upper bits, which are known to be zero:</p> @({ (let ((x-chop (gl-mbe x (logand (1- (ash 1 25)) x)))) ...) }) <p>When GL symbolically executes this, it tries to prove that @('x') and the @(see logand) expression are equivalent, that is, their symbolic representations evaluate to the same concrete values under all environments. If this can be proved, @('x-chop') is bound to the @(see logand) result, which cuts off the upper bits of @('x'), which may improve symbolic execution performance. However, logically @('gl-mbe') just binds @('x-chop') to @('x'), so this @('logand') term does not complicate reasoning about the specification.</p> <p>See also @(see gl-mbe-fast).</p>" (defun gl-mbe-fn (spec impl spec-form impl-form) (declare (xargs :guard t)) (mbe :logic spec :exec (prog2$ (or (equal spec impl) (er hard? 'gl-mbe "GL-MBE failure: ~x0 and ~x1 unequal.~% ~ Values: ~x2 versus ~x3." spec-form impl-form spec impl)) spec))) (defthm gl-mbe-gl-def (equal (gl-mbe-fn spec impl spec-form impl-form) (if (gl-assert (acl2::always-equal spec impl) :msg (msg "GL-MBE failure: ~x0 and ~x1 unequal." spec-form impl-form)) impl spec)) :rule-classes ((:definition :install-body nil))) (set-preferred-def gl-mbe-fn gl-mbe-gl-def) (defmacro gl-mbe (spec impl) `(gl-mbe-fn ,spec ,impl ',spec ',impl))) (defsection gl-mbe-fast :parents (gl-mbe) :short "Like @(see gl-mbe), but faster and without error checking during execution." :long "<p>See @(see gl-mbe) for background. @('(gl-mbe-fast spec exec)') is logically identical to @('gl-mbe') and should have exactly the same effect during symbolic execution. However, @('gl-mbe-fast') may run more quickly during concrete execution, at the cost of some error checking.</p> <p>In particular, for ordinary, concrete execution, a @('(gl-mbe spec impl)') form requires both the @('spec') and @('impl') forms to be evaluated and checked for equality. In contrast, @('gl-mbe-fast') is essentially a macro that expands to:</p> @({ (mbe :logic (gl-mbe spec exec) :exec spec) }) <p>The guard proof you will incur should be trivial because @('gl-mbe') always just logically returns @('spec').</p> <p>Aside from performance, this <b>behaves differently</b> than @(see gl-mbe) in the degenerate case where your @('spec') and @('exec') forms produce different results. For example:</p> @({ (defun test1 (x y) (declare (xargs :guard t)) (gl-mbe x y)) (defun test2 (x y) (declare (xargs :guard t)) (gl-mbe-fast x y)) (test1 3 7) --> causes a hard error (test2 3 7) --> no error, returns 3 })" (defmacro gl-mbe-fast (spec impl) `(let ((spec ,spec)) (mbe :logic (gl-mbe spec ,impl) :exec spec)))) ;; BOZO document these (defun gl-force-check-fn (x strong direction) (declare (xargs :guard t) (ignore strong direction)) x) (defmacro gl-force-check (x &key strong (direction ':both)) `(gl-force-check-fn ,x ,strong ,direction)) (defmacro gl-force-check-strong (x) `(gl-force-check-fn ,x t :both)) (defxdoc gl-force-check :parents (reference) :short "When found in an @('if') test, forces GL to check satisfiability of the test." :long "<p>When using GL's AIG-based modes, it is sometimes important to force GL to check whether an IF test is constant-true or constant-false. For example, if the @('if') guards a recursive call, then symbolic interpretation of the function may diverge if the test isn't checked.</p> <p>Usage:</p> @({ (gl-force-check test :strong nil :dir :both) }) <p>Here @(':strong') governs whether the path condition is considered; by default it is not, because it is potentially much more expensive to do the check when considering the path condition. @(':dir') may be @('t'), @('nil'), or @(':both') (the default). If @('t'), then we only try to show that @('test') is constant-true; if @('nil'), we only try to show it constant-false; if @(':both'), then we try both directions.</p> ") (defmacro gl-force-true (x &key strong) `(gl-force-check-fn ,x ,strong t)) (defmacro gl-force-true-strong (x) `(gl-force-check-fn ,x t t)) (defmacro gl-force-false (x &key strong) `(gl-force-check-fn ,x ,strong nil)) (defmacro gl-force-false-strong (x) `(gl-force-check-fn ,x t nil)) (table gl-uninterpreted-functions 'gl-force-check-fn t) (define gl-aside (form) :parents (reference) :short "A debugging facility that is typically used for printing messages during GL symbolic execution." :long #{"""<p>In the logic and during ordinary execution, @(call gl-aside) is just an ordinary function that ignores its argument and returns @('nil'). However, during GL symbolic execution it has a special meaning which is useful for printing debugging messages and doing other kinds of low-level hacking.</p> <p><b>Note:</b> @('gl-aside') is fairly flexible but it can be <b>tricky to use</b> correctly. You should probably read this documentation carefully and also see the ``Tricks and Pitfalls'' section below!</p> <h3>Basic Example</h3> <p>Here is a typical usage of gl-aside:</p> @({ (defun spec1 (x y) (b* ((sum (+ x y)) (?msg (gl-aside (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) }) <p>During the normal execution of @('spec1'), this Note will (of course) be printed: @('gl-aside') is just an ordinary function, so ACL2 will (eagerly) evaluate the @('cw') call before even invoking @('gl-aside').</p> <p>What happens during symbolic execution? If we try to prove the following, simple GL theorem, e.g.,:</p> @({ (def-gl-thm spec1-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec1 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then our Note will still be printed <b>even though X and Y are @(see symbolic-objects)</b> when @('spec1') is being executed! In particular, we will see, in @(see gl-satlink-mode):</p> @({ Note: X is (:G-NUMBER (0 1 2 NIL) (T) NIL) and Y is (:G-NUMBER (4 5 6 NIL) (T) NIL). }) <p>The numbers 0-6 here are AIG variables. If we were instead in @(see gl-bdd-mode), we would see large BDD variables (trees of T and NIL) here instead of these numbers.</p> <p>The technical explanation of how this works is: when GL's symbolic interpreter encounters a call of @('(gl-aside form')), it executes @('form') inside a @(see wormhole), with the variables bound to their symbolic versions.</p> <h3>Why do we even need this?</h3> <p>Couldn't we just write our spec without @('gl-aside')? If we just wrote:</p> @({ (defun spec2 (x y) (b* ((sum (+ x y)) (?msg (cw "Note: X is ~x0 and Y is ~x1.~%" x y))) sum)) }) <p>Then our Note would still get printed during normal execution. It would also get printed during <i>some</i> symbolic executions. In particular, if we know that X and Y are particular concrete values, then we will still see our note. For example, if we heavily constrain @('X') and @('Y') so to be constants:</p> @({ (def-gl-thm spec2-correct-for-3-and-4 :hyp (and (equal x 3) (equal y 4)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then we will indeed see our Note printed:</p> @({ Note: X is 3 and Y is 4. }) <p>here, the @(see cw) form is being applied to all-constant arguments, so GL can simply evaluate it, causing the message to be printed. However, if we instead submit something more like our original theorem:</p> @({ (def-gl-thm spec2-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then the Note is not printed. Why not? In this case, when GL's interpreter reaches the @('cw') form, @('x') and @('y') are still symbolic objects, so it cannot simply concretely execute @('cw'). Instead, GL symbolically executes the logical definition of @('cw')&mdash;really @(see fmt-to-comment-window). But in the logic, this function (of course) does not print anything, but instead just returns @('nil'). At any rate, GL ends up binding @('msg') to @('nil') and nothing gets printed.</p> <h3>Tricks and Pitfalls</h3> <h5>Pitfall: @(see progn$) and its ilk</h5> <p>You probably <b>never</b> want to use @(see prog2$) or @(see progn$) to invoke a @('gl-aside'). For instance, you do NOT want to do this:</p> @({ (progn$ (gl-aside ...) ;; WRONG sum) }) <p>Why not? During symbolic execution, GL just completely skips directly to the last form in the @('progn$'), so it will never even see your @('gl-aside')!</p> <p>For similar reasons, you should also generally not use @(see b*) binders like @('-'), @('&'), and @('?!'), or the implicit @('progn$') forms that @('b*') permits. For example:</p> @({ (b* ((ans (f x y ...)) (?msg (gl-aside ...)) ;; GOOD, bind to an ignored variable (?!msg (gl-aside ...)) ;; BAD, won't get evaluated (- (gl-aside ...)) ;; BAD, won't get evaluated ((when condition) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans)) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans) }) <h5>Trick: print only during symbolic execution</h5> <p>The above @('spec1') function will print its Note during <b>both</b> regular execution and symbolic execution. It is also possible to use @(see mbe) to get a message that only prints during symbolic execution.</p> @({ (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil)) (defun spec3 (x y) (declare (xargs :guard (and (natp x) (natp y)))) (b* ((sum (+ x y)) (?msg (gl-aside-symbolic (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) (spec3 3 4) ;; No Note is printed 7 (def-gl-thm spec3-correct ...) ;; Note is printed }) <p>Of course, this only works for guard-verified functions.</p>"""} :enabled t (declare (ignore form)) nil) (defsection gl-aside-symbolic :parents (gl-aside) :short "Alternative to @(see gl-aside) that is only evaluated during GL symbolic execution." :long "@(def gl-aside-symbolic)" (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil))) (defun gl-ignore (x) (declare (xargs :guard t) (ignore x)) nil) (defund gl-error (x) (declare (xargs :guard t) (ignore x)) (prog2$ (er hard? 'gl-error "GL-ERROR call encountered; quitting~%") nil)) (defthm gl-error-is-nil (equal (gl-error x) nil) :hints(("Goal" :in-theory (enable gl-error)))) (defun gl-hide (x) (declare (xargs :guard t)) x)
60800
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: <NAME> <<EMAIL>> (in-package "GL") (include-book "gl-util") (include-book "std/util/define" :dir :system) ;; This is turning into a dumping ground for logically-simple functions that ;; have a special meaning under symbolic execution. Maybe we should rename ;; this file. (define acl2::always-equal (x y) :parents (reference) :short "Alias for @(see equal) that has a special meaning in @(see gl-bdd-mode)." :long "<p>Logically this is just @(see equal), but @(see GL) treats @('always-equal') in a special way.</p> <p>Suppose GL is asked to prove @('(equal spec impl)') when this does not actually hold. Sometimes, the symbolic objects for spec and impl can be created, but the BDD representing their equality is too large to fit in memory. This stops you from seeing any counterexamples, even though GL knows that the two objects aren't equal.</p> <p>To work around this, you may restate your theorem using @('always-equal') instead of @('equal') as the final comparison. @('always-equal') has a custom symbolic counterpart that returns @('t') when its arguments are equivalent, or else produces a symbolic object that captures just one counterexample and is indeterminate in all other cases.</p> <p>Note that there is not really any reason to use @('always-equal') if you are using an AIG-based GL mode, such as @(see gl-satlink-mode).</p>" :enabled t ;; BOZO could inline this (but will probably need to adjust its special ;; handling if we do that) (equal x y)) (defsection gl-assert :parents (reference) :short "During GL symbolic execution, check that a condition holds, causing an error if it does not." :long "<p>@('(gl-assert x)'), logically speaking, just returns @('(if x t nil)'). In concrete execution, it causes an error if @('x') is false, and in symbolic execution, it forces a check that @('x') is true and produces a counterexample if not.</p>" (defun-inline gl-assert-fn (x msg gmsg) (declare (xargs :guard t) (ignore gmsg)) (mbe :logic (and x t) :exec (if x t (er hard? 'gl-assert "~@0" msg)))) (defmacro gl-assert (x &key (msg 'nil msgp) (gmsg 'nil gmsgp)) (let* ((msg (if msgp msg (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))) (gmsg (cond (gmsgp gmsg) (msgp msg) (t (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))))) `(gl-assert-fn ,x ,msg ,gmsg)))) (define gl-concretize (x) :parents (reference) :short "During GL symbolic execution, try to reduce a symbolic object to a concrete one." :long "<p>@('(gl-concretize x)'), logically speaking, just returns @('x'). However, during symbolic simulation (in AIG mode), it tries to reduce @('x') to a concrete object by finding one object it could represent and trying to prove that it is always equal to that object.</p>" :inline t :enabled t x) (defsection gl-mbe :parents (reference) :short "Assert that a particular symbolic object is equivalent to a second form, and use the second in place of the first." :long "<p>@(call gl-mbe) is defined to simply check whether its two arguments @('spec') and @('impl') are equal, throwing an error if not, and return @('spec').</p> <p>However, when @('gl-mbe') is symbolically executed, the equality of the two arguments is checked symbolically. If it can be proved (e.g., via a BDD equality or SAT check) that they are always equal, then @('impl') is returned instead of @('spec'), otherwise an error is produced.</p> <p>This is most useful when symbolically executing in AIG mode. For example, suppose that through a series of shifting operations, the symbolic representation of some numeric operand X is expanded to thousands of bits. However, the user knows that only the bottom 25 bits may be non-zero. Then the following form may speed up the rest of the computation involving X by cutting off all the upper bits, which are known to be zero:</p> @({ (let ((x-chop (gl-mbe x (logand (1- (ash 1 25)) x)))) ...) }) <p>When GL symbolically executes this, it tries to prove that @('x') and the @(see logand) expression are equivalent, that is, their symbolic representations evaluate to the same concrete values under all environments. If this can be proved, @('x-chop') is bound to the @(see logand) result, which cuts off the upper bits of @('x'), which may improve symbolic execution performance. However, logically @('gl-mbe') just binds @('x-chop') to @('x'), so this @('logand') term does not complicate reasoning about the specification.</p> <p>See also @(see gl-mbe-fast).</p>" (defun gl-mbe-fn (spec impl spec-form impl-form) (declare (xargs :guard t)) (mbe :logic spec :exec (prog2$ (or (equal spec impl) (er hard? 'gl-mbe "GL-MBE failure: ~x0 and ~x1 unequal.~% ~ Values: ~x2 versus ~x3." spec-form impl-form spec impl)) spec))) (defthm gl-mbe-gl-def (equal (gl-mbe-fn spec impl spec-form impl-form) (if (gl-assert (acl2::always-equal spec impl) :msg (msg "GL-MBE failure: ~x0 and ~x1 unequal." spec-form impl-form)) impl spec)) :rule-classes ((:definition :install-body nil))) (set-preferred-def gl-mbe-fn gl-mbe-gl-def) (defmacro gl-mbe (spec impl) `(gl-mbe-fn ,spec ,impl ',spec ',impl))) (defsection gl-mbe-fast :parents (gl-mbe) :short "Like @(see gl-mbe), but faster and without error checking during execution." :long "<p>See @(see gl-mbe) for background. @('(gl-mbe-fast spec exec)') is logically identical to @('gl-mbe') and should have exactly the same effect during symbolic execution. However, @('gl-mbe-fast') may run more quickly during concrete execution, at the cost of some error checking.</p> <p>In particular, for ordinary, concrete execution, a @('(gl-mbe spec impl)') form requires both the @('spec') and @('impl') forms to be evaluated and checked for equality. In contrast, @('gl-mbe-fast') is essentially a macro that expands to:</p> @({ (mbe :logic (gl-mbe spec exec) :exec spec) }) <p>The guard proof you will incur should be trivial because @('gl-mbe') always just logically returns @('spec').</p> <p>Aside from performance, this <b>behaves differently</b> than @(see gl-mbe) in the degenerate case where your @('spec') and @('exec') forms produce different results. For example:</p> @({ (defun test1 (x y) (declare (xargs :guard t)) (gl-mbe x y)) (defun test2 (x y) (declare (xargs :guard t)) (gl-mbe-fast x y)) (test1 3 7) --> causes a hard error (test2 3 7) --> no error, returns 3 })" (defmacro gl-mbe-fast (spec impl) `(let ((spec ,spec)) (mbe :logic (gl-mbe spec ,impl) :exec spec)))) ;; BOZO document these (defun gl-force-check-fn (x strong direction) (declare (xargs :guard t) (ignore strong direction)) x) (defmacro gl-force-check (x &key strong (direction ':both)) `(gl-force-check-fn ,x ,strong ,direction)) (defmacro gl-force-check-strong (x) `(gl-force-check-fn ,x t :both)) (defxdoc gl-force-check :parents (reference) :short "When found in an @('if') test, forces GL to check satisfiability of the test." :long "<p>When using GL's AIG-based modes, it is sometimes important to force GL to check whether an IF test is constant-true or constant-false. For example, if the @('if') guards a recursive call, then symbolic interpretation of the function may diverge if the test isn't checked.</p> <p>Usage:</p> @({ (gl-force-check test :strong nil :dir :both) }) <p>Here @(':strong') governs whether the path condition is considered; by default it is not, because it is potentially much more expensive to do the check when considering the path condition. @(':dir') may be @('t'), @('nil'), or @(':both') (the default). If @('t'), then we only try to show that @('test') is constant-true; if @('nil'), we only try to show it constant-false; if @(':both'), then we try both directions.</p> ") (defmacro gl-force-true (x &key strong) `(gl-force-check-fn ,x ,strong t)) (defmacro gl-force-true-strong (x) `(gl-force-check-fn ,x t t)) (defmacro gl-force-false (x &key strong) `(gl-force-check-fn ,x ,strong nil)) (defmacro gl-force-false-strong (x) `(gl-force-check-fn ,x t nil)) (table gl-uninterpreted-functions 'gl-force-check-fn t) (define gl-aside (form) :parents (reference) :short "A debugging facility that is typically used for printing messages during GL symbolic execution." :long #{"""<p>In the logic and during ordinary execution, @(call gl-aside) is just an ordinary function that ignores its argument and returns @('nil'). However, during GL symbolic execution it has a special meaning which is useful for printing debugging messages and doing other kinds of low-level hacking.</p> <p><b>Note:</b> @('gl-aside') is fairly flexible but it can be <b>tricky to use</b> correctly. You should probably read this documentation carefully and also see the ``Tricks and Pitfalls'' section below!</p> <h3>Basic Example</h3> <p>Here is a typical usage of gl-aside:</p> @({ (defun spec1 (x y) (b* ((sum (+ x y)) (?msg (gl-aside (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) }) <p>During the normal execution of @('spec1'), this Note will (of course) be printed: @('gl-aside') is just an ordinary function, so ACL2 will (eagerly) evaluate the @('cw') call before even invoking @('gl-aside').</p> <p>What happens during symbolic execution? If we try to prove the following, simple GL theorem, e.g.,:</p> @({ (def-gl-thm spec1-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec1 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then our Note will still be printed <b>even though X and Y are @(see symbolic-objects)</b> when @('spec1') is being executed! In particular, we will see, in @(see gl-satlink-mode):</p> @({ Note: X is (:G-NUMBER (0 1 2 NIL) (T) NIL) and Y is (:G-NUMBER (4 5 6 NIL) (T) NIL). }) <p>The numbers 0-6 here are AIG variables. If we were instead in @(see gl-bdd-mode), we would see large BDD variables (trees of T and NIL) here instead of these numbers.</p> <p>The technical explanation of how this works is: when GL's symbolic interpreter encounters a call of @('(gl-aside form')), it executes @('form') inside a @(see wormhole), with the variables bound to their symbolic versions.</p> <h3>Why do we even need this?</h3> <p>Couldn't we just write our spec without @('gl-aside')? If we just wrote:</p> @({ (defun spec2 (x y) (b* ((sum (+ x y)) (?msg (cw "Note: X is ~x0 and Y is ~x1.~%" x y))) sum)) }) <p>Then our Note would still get printed during normal execution. It would also get printed during <i>some</i> symbolic executions. In particular, if we know that X and Y are particular concrete values, then we will still see our note. For example, if we heavily constrain @('X') and @('Y') so to be constants:</p> @({ (def-gl-thm spec2-correct-for-3-and-4 :hyp (and (equal x 3) (equal y 4)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then we will indeed see our Note printed:</p> @({ Note: X is 3 and Y is 4. }) <p>here, the @(see cw) form is being applied to all-constant arguments, so GL can simply evaluate it, causing the message to be printed. However, if we instead submit something more like our original theorem:</p> @({ (def-gl-thm spec2-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then the Note is not printed. Why not? In this case, when GL's interpreter reaches the @('cw') form, @('x') and @('y') are still symbolic objects, so it cannot simply concretely execute @('cw'). Instead, GL symbolically executes the logical definition of @('cw')&mdash;really @(see fmt-to-comment-window). But in the logic, this function (of course) does not print anything, but instead just returns @('nil'). At any rate, GL ends up binding @('msg') to @('nil') and nothing gets printed.</p> <h3>Tricks and Pitfalls</h3> <h5>Pitfall: @(see progn$) and its ilk</h5> <p>You probably <b>never</b> want to use @(see prog2$) or @(see progn$) to invoke a @('gl-aside'). For instance, you do NOT want to do this:</p> @({ (progn$ (gl-aside ...) ;; WRONG sum) }) <p>Why not? During symbolic execution, GL just completely skips directly to the last form in the @('progn$'), so it will never even see your @('gl-aside')!</p> <p>For similar reasons, you should also generally not use @(see b*) binders like @('-'), @('&'), and @('?!'), or the implicit @('progn$') forms that @('b*') permits. For example:</p> @({ (b* ((ans (f x y ...)) (?msg (gl-aside ...)) ;; GOOD, bind to an ignored variable (?!msg (gl-aside ...)) ;; BAD, won't get evaluated (- (gl-aside ...)) ;; BAD, won't get evaluated ((when condition) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans)) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans) }) <h5>Trick: print only during symbolic execution</h5> <p>The above @('spec1') function will print its Note during <b>both</b> regular execution and symbolic execution. It is also possible to use @(see mbe) to get a message that only prints during symbolic execution.</p> @({ (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil)) (defun spec3 (x y) (declare (xargs :guard (and (natp x) (natp y)))) (b* ((sum (+ x y)) (?msg (gl-aside-symbolic (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) (spec3 3 4) ;; No Note is printed 7 (def-gl-thm spec3-correct ...) ;; Note is printed }) <p>Of course, this only works for guard-verified functions.</p>"""} :enabled t (declare (ignore form)) nil) (defsection gl-aside-symbolic :parents (gl-aside) :short "Alternative to @(see gl-aside) that is only evaluated during GL symbolic execution." :long "@(def gl-aside-symbolic)" (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil))) (defun gl-ignore (x) (declare (xargs :guard t) (ignore x)) nil) (defund gl-error (x) (declare (xargs :guard t) (ignore x)) (prog2$ (er hard? 'gl-error "GL-ERROR call encountered; quitting~%") nil)) (defthm gl-error-is-nil (equal (gl-error x) nil) :hints(("Goal" :in-theory (enable gl-error)))) (defun gl-hide (x) (declare (xargs :guard t)) x)
true
; GL - A Symbolic Simulation Framework for ACL2 ; Copyright (C) 2008-2013 Centaur Technology ; ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; ; License: (An MIT/X11-style license) ; ; Permission is hereby granted, free of charge, to any person obtaining a ; copy of this software and associated documentation files (the "Software"), ; to deal in the Software without restriction, including without limitation ; the rights to use, copy, modify, merge, publish, distribute, sublicense, ; and/or sell copies of the Software, and to permit persons to whom the ; Software is furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ; DEALINGS IN THE SOFTWARE. ; ; Original author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "GL") (include-book "gl-util") (include-book "std/util/define" :dir :system) ;; This is turning into a dumping ground for logically-simple functions that ;; have a special meaning under symbolic execution. Maybe we should rename ;; this file. (define acl2::always-equal (x y) :parents (reference) :short "Alias for @(see equal) that has a special meaning in @(see gl-bdd-mode)." :long "<p>Logically this is just @(see equal), but @(see GL) treats @('always-equal') in a special way.</p> <p>Suppose GL is asked to prove @('(equal spec impl)') when this does not actually hold. Sometimes, the symbolic objects for spec and impl can be created, but the BDD representing their equality is too large to fit in memory. This stops you from seeing any counterexamples, even though GL knows that the two objects aren't equal.</p> <p>To work around this, you may restate your theorem using @('always-equal') instead of @('equal') as the final comparison. @('always-equal') has a custom symbolic counterpart that returns @('t') when its arguments are equivalent, or else produces a symbolic object that captures just one counterexample and is indeterminate in all other cases.</p> <p>Note that there is not really any reason to use @('always-equal') if you are using an AIG-based GL mode, such as @(see gl-satlink-mode).</p>" :enabled t ;; BOZO could inline this (but will probably need to adjust its special ;; handling if we do that) (equal x y)) (defsection gl-assert :parents (reference) :short "During GL symbolic execution, check that a condition holds, causing an error if it does not." :long "<p>@('(gl-assert x)'), logically speaking, just returns @('(if x t nil)'). In concrete execution, it causes an error if @('x') is false, and in symbolic execution, it forces a check that @('x') is true and produces a counterexample if not.</p>" (defun-inline gl-assert-fn (x msg gmsg) (declare (xargs :guard t) (ignore gmsg)) (mbe :logic (and x t) :exec (if x t (er hard? 'gl-assert "~@0" msg)))) (defmacro gl-assert (x &key (msg 'nil msgp) (gmsg 'nil gmsgp)) (let* ((msg (if msgp msg (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))) (gmsg (cond (gmsgp gmsg) (msgp msg) (t (list 'quote (acl2::msg "GL-ASSERT failure: ~x0" x)))))) `(gl-assert-fn ,x ,msg ,gmsg)))) (define gl-concretize (x) :parents (reference) :short "During GL symbolic execution, try to reduce a symbolic object to a concrete one." :long "<p>@('(gl-concretize x)'), logically speaking, just returns @('x'). However, during symbolic simulation (in AIG mode), it tries to reduce @('x') to a concrete object by finding one object it could represent and trying to prove that it is always equal to that object.</p>" :inline t :enabled t x) (defsection gl-mbe :parents (reference) :short "Assert that a particular symbolic object is equivalent to a second form, and use the second in place of the first." :long "<p>@(call gl-mbe) is defined to simply check whether its two arguments @('spec') and @('impl') are equal, throwing an error if not, and return @('spec').</p> <p>However, when @('gl-mbe') is symbolically executed, the equality of the two arguments is checked symbolically. If it can be proved (e.g., via a BDD equality or SAT check) that they are always equal, then @('impl') is returned instead of @('spec'), otherwise an error is produced.</p> <p>This is most useful when symbolically executing in AIG mode. For example, suppose that through a series of shifting operations, the symbolic representation of some numeric operand X is expanded to thousands of bits. However, the user knows that only the bottom 25 bits may be non-zero. Then the following form may speed up the rest of the computation involving X by cutting off all the upper bits, which are known to be zero:</p> @({ (let ((x-chop (gl-mbe x (logand (1- (ash 1 25)) x)))) ...) }) <p>When GL symbolically executes this, it tries to prove that @('x') and the @(see logand) expression are equivalent, that is, their symbolic representations evaluate to the same concrete values under all environments. If this can be proved, @('x-chop') is bound to the @(see logand) result, which cuts off the upper bits of @('x'), which may improve symbolic execution performance. However, logically @('gl-mbe') just binds @('x-chop') to @('x'), so this @('logand') term does not complicate reasoning about the specification.</p> <p>See also @(see gl-mbe-fast).</p>" (defun gl-mbe-fn (spec impl spec-form impl-form) (declare (xargs :guard t)) (mbe :logic spec :exec (prog2$ (or (equal spec impl) (er hard? 'gl-mbe "GL-MBE failure: ~x0 and ~x1 unequal.~% ~ Values: ~x2 versus ~x3." spec-form impl-form spec impl)) spec))) (defthm gl-mbe-gl-def (equal (gl-mbe-fn spec impl spec-form impl-form) (if (gl-assert (acl2::always-equal spec impl) :msg (msg "GL-MBE failure: ~x0 and ~x1 unequal." spec-form impl-form)) impl spec)) :rule-classes ((:definition :install-body nil))) (set-preferred-def gl-mbe-fn gl-mbe-gl-def) (defmacro gl-mbe (spec impl) `(gl-mbe-fn ,spec ,impl ',spec ',impl))) (defsection gl-mbe-fast :parents (gl-mbe) :short "Like @(see gl-mbe), but faster and without error checking during execution." :long "<p>See @(see gl-mbe) for background. @('(gl-mbe-fast spec exec)') is logically identical to @('gl-mbe') and should have exactly the same effect during symbolic execution. However, @('gl-mbe-fast') may run more quickly during concrete execution, at the cost of some error checking.</p> <p>In particular, for ordinary, concrete execution, a @('(gl-mbe spec impl)') form requires both the @('spec') and @('impl') forms to be evaluated and checked for equality. In contrast, @('gl-mbe-fast') is essentially a macro that expands to:</p> @({ (mbe :logic (gl-mbe spec exec) :exec spec) }) <p>The guard proof you will incur should be trivial because @('gl-mbe') always just logically returns @('spec').</p> <p>Aside from performance, this <b>behaves differently</b> than @(see gl-mbe) in the degenerate case where your @('spec') and @('exec') forms produce different results. For example:</p> @({ (defun test1 (x y) (declare (xargs :guard t)) (gl-mbe x y)) (defun test2 (x y) (declare (xargs :guard t)) (gl-mbe-fast x y)) (test1 3 7) --> causes a hard error (test2 3 7) --> no error, returns 3 })" (defmacro gl-mbe-fast (spec impl) `(let ((spec ,spec)) (mbe :logic (gl-mbe spec ,impl) :exec spec)))) ;; BOZO document these (defun gl-force-check-fn (x strong direction) (declare (xargs :guard t) (ignore strong direction)) x) (defmacro gl-force-check (x &key strong (direction ':both)) `(gl-force-check-fn ,x ,strong ,direction)) (defmacro gl-force-check-strong (x) `(gl-force-check-fn ,x t :both)) (defxdoc gl-force-check :parents (reference) :short "When found in an @('if') test, forces GL to check satisfiability of the test." :long "<p>When using GL's AIG-based modes, it is sometimes important to force GL to check whether an IF test is constant-true or constant-false. For example, if the @('if') guards a recursive call, then symbolic interpretation of the function may diverge if the test isn't checked.</p> <p>Usage:</p> @({ (gl-force-check test :strong nil :dir :both) }) <p>Here @(':strong') governs whether the path condition is considered; by default it is not, because it is potentially much more expensive to do the check when considering the path condition. @(':dir') may be @('t'), @('nil'), or @(':both') (the default). If @('t'), then we only try to show that @('test') is constant-true; if @('nil'), we only try to show it constant-false; if @(':both'), then we try both directions.</p> ") (defmacro gl-force-true (x &key strong) `(gl-force-check-fn ,x ,strong t)) (defmacro gl-force-true-strong (x) `(gl-force-check-fn ,x t t)) (defmacro gl-force-false (x &key strong) `(gl-force-check-fn ,x ,strong nil)) (defmacro gl-force-false-strong (x) `(gl-force-check-fn ,x t nil)) (table gl-uninterpreted-functions 'gl-force-check-fn t) (define gl-aside (form) :parents (reference) :short "A debugging facility that is typically used for printing messages during GL symbolic execution." :long #{"""<p>In the logic and during ordinary execution, @(call gl-aside) is just an ordinary function that ignores its argument and returns @('nil'). However, during GL symbolic execution it has a special meaning which is useful for printing debugging messages and doing other kinds of low-level hacking.</p> <p><b>Note:</b> @('gl-aside') is fairly flexible but it can be <b>tricky to use</b> correctly. You should probably read this documentation carefully and also see the ``Tricks and Pitfalls'' section below!</p> <h3>Basic Example</h3> <p>Here is a typical usage of gl-aside:</p> @({ (defun spec1 (x y) (b* ((sum (+ x y)) (?msg (gl-aside (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) }) <p>During the normal execution of @('spec1'), this Note will (of course) be printed: @('gl-aside') is just an ordinary function, so ACL2 will (eagerly) evaluate the @('cw') call before even invoking @('gl-aside').</p> <p>What happens during symbolic execution? If we try to prove the following, simple GL theorem, e.g.,:</p> @({ (def-gl-thm spec1-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec1 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then our Note will still be printed <b>even though X and Y are @(see symbolic-objects)</b> when @('spec1') is being executed! In particular, we will see, in @(see gl-satlink-mode):</p> @({ Note: X is (:G-NUMBER (0 1 2 NIL) (T) NIL) and Y is (:G-NUMBER (4 5 6 NIL) (T) NIL). }) <p>The numbers 0-6 here are AIG variables. If we were instead in @(see gl-bdd-mode), we would see large BDD variables (trees of T and NIL) here instead of these numbers.</p> <p>The technical explanation of how this works is: when GL's symbolic interpreter encounters a call of @('(gl-aside form')), it executes @('form') inside a @(see wormhole), with the variables bound to their symbolic versions.</p> <h3>Why do we even need this?</h3> <p>Couldn't we just write our spec without @('gl-aside')? If we just wrote:</p> @({ (defun spec2 (x y) (b* ((sum (+ x y)) (?msg (cw "Note: X is ~x0 and Y is ~x1.~%" x y))) sum)) }) <p>Then our Note would still get printed during normal execution. It would also get printed during <i>some</i> symbolic executions. In particular, if we know that X and Y are particular concrete values, then we will still see our note. For example, if we heavily constrain @('X') and @('Y') so to be constants:</p> @({ (def-gl-thm spec2-correct-for-3-and-4 :hyp (and (equal x 3) (equal y 4)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then we will indeed see our Note printed:</p> @({ Note: X is 3 and Y is 4. }) <p>here, the @(see cw) form is being applied to all-constant arguments, so GL can simply evaluate it, causing the message to be printed. However, if we instead submit something more like our original theorem:</p> @({ (def-gl-thm spec2-correct :hyp (and (unsigned-byte-p 3 x) (unsigned-byte-p 3 y)) :concl (equal (spec2 x y) (+ x y)) :g-bindings (auto-bindings (:nat x 3) (:nat y 3))) }) <p>then the Note is not printed. Why not? In this case, when GL's interpreter reaches the @('cw') form, @('x') and @('y') are still symbolic objects, so it cannot simply concretely execute @('cw'). Instead, GL symbolically executes the logical definition of @('cw')&mdash;really @(see fmt-to-comment-window). But in the logic, this function (of course) does not print anything, but instead just returns @('nil'). At any rate, GL ends up binding @('msg') to @('nil') and nothing gets printed.</p> <h3>Tricks and Pitfalls</h3> <h5>Pitfall: @(see progn$) and its ilk</h5> <p>You probably <b>never</b> want to use @(see prog2$) or @(see progn$) to invoke a @('gl-aside'). For instance, you do NOT want to do this:</p> @({ (progn$ (gl-aside ...) ;; WRONG sum) }) <p>Why not? During symbolic execution, GL just completely skips directly to the last form in the @('progn$'), so it will never even see your @('gl-aside')!</p> <p>For similar reasons, you should also generally not use @(see b*) binders like @('-'), @('&'), and @('?!'), or the implicit @('progn$') forms that @('b*') permits. For example:</p> @({ (b* ((ans (f x y ...)) (?msg (gl-aside ...)) ;; GOOD, bind to an ignored variable (?!msg (gl-aside ...)) ;; BAD, won't get evaluated (- (gl-aside ...)) ;; BAD, won't get evaluated ((when condition) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans)) ;; implicit b* progn$: (gl-aside ...) ;; BAD, won't get evaluated ans) }) <h5>Trick: print only during symbolic execution</h5> <p>The above @('spec1') function will print its Note during <b>both</b> regular execution and symbolic execution. It is also possible to use @(see mbe) to get a message that only prints during symbolic execution.</p> @({ (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil)) (defun spec3 (x y) (declare (xargs :guard (and (natp x) (natp y)))) (b* ((sum (+ x y)) (?msg (gl-aside-symbolic (cw "Note: X is ~x0 and Y is ~x1.~%" x y)))) sum)) (spec3 3 4) ;; No Note is printed 7 (def-gl-thm spec3-correct ...) ;; Note is printed }) <p>Of course, this only works for guard-verified functions.</p>"""} :enabled t (declare (ignore form)) nil) (defsection gl-aside-symbolic :parents (gl-aside) :short "Alternative to @(see gl-aside) that is only evaluated during GL symbolic execution." :long "@(def gl-aside-symbolic)" (defmacro gl-aside-symbolic (form) `(mbe :logic (gl-aside ,form) :exec nil))) (defun gl-ignore (x) (declare (xargs :guard t) (ignore x)) nil) (defund gl-error (x) (declare (xargs :guard t) (ignore x)) (prog2$ (er hard? 'gl-error "GL-ERROR call encountered; quitting~%") nil)) (defthm gl-error-is-nil (equal (gl-error x) nil) :hints(("Goal" :in-theory (enable gl-error)))) (defun gl-hide (x) (declare (xargs :guard t)) x)
[ { "context": "rt of flare\n (c) 2015 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 89, "score": 0.9999174475669861, "start": 71, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 114, "score": 0.9998905658721924, "start": 100, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.flare)\n\n(defmacr", "end": 134, "score": 0.9999226331710815, "start": 116, "tag": "EMAIL", "value": "[email protected]" } ]
toolkit.lisp
Shinmera/flare
21
#| This file is a part of flare (c) 2015 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.flare) (defmacro define-self-returning-method (name arglist) (let ((o (first arglist))) `(defmethod ,name :around ,arglist (declare (ignore ,@(lambda-fiddle:extract-lambda-vars (cdr arglist)))) (call-next-method) ,(if (listp o) (first o) o)))) (defun ensure-sorted (vec sorting &key key) (let ((sorted (stable-sort vec sorting :key key))) (unless (eq vec sorted) (loop for i from 0 to (length vec) do (setf (aref vec i) (aref sorted i)))) vec))
49293
#| This file is a part of flare (c) 2015 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.flare) (defmacro define-self-returning-method (name arglist) (let ((o (first arglist))) `(defmethod ,name :around ,arglist (declare (ignore ,@(lambda-fiddle:extract-lambda-vars (cdr arglist)))) (call-next-method) ,(if (listp o) (first o) o)))) (defun ensure-sorted (vec sorting &key key) (let ((sorted (stable-sort vec sorting :key key))) (unless (eq vec sorted) (loop for i from 0 to (length vec) do (setf (aref vec i) (aref sorted i)))) vec))
true
#| This file is a part of flare (c) 2015 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.flare) (defmacro define-self-returning-method (name arglist) (let ((o (first arglist))) `(defmethod ,name :around ,arglist (declare (ignore ,@(lambda-fiddle:extract-lambda-vars (cdr arglist)))) (call-next-method) ,(if (listp o) (first o) o)))) (defun ensure-sorted (vec sorting &key key) (let ((sorted (stable-sort vec sorting :key key))) (unless (eq vec sorted) (loop for i from 0 to (length vec) do (setf (aref vec i) (aref sorted i)))) vec))
[ { "context": "\r\n;;; Copyright 2008 Gabor Balazs\r\n;;; Licensed under the Apache License, Version 2", "end": 33, "score": 0.9996762275695801, "start": 21, "tag": "NAME", "value": "Gabor Balazs" } ]
Domains/InfiniteMario/15-rl-competition-2009/system/codecs/Lisp/src/rl-glue-utils/rl-utils-package.lisp
sleyzerzon/soar
1
;;; Copyright 2008 Gabor Balazs ;;; Licensed under the Apache License, Version 2.0 (the "License"); ;;; you may not use this file except in compliance with the License. ;;; You may obtain a copy of the License at ;;; ;;; http://www.apache.org/licenses/LICENSE-2.0 ;;; ;;; Unless required by applicable law or agreed to in writing, software ;;; distributed under the License is distributed on an "AS IS" BASIS, ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;;; See the License for the specific language governing permissions and ;;; limitations under the License. ;;; ;;; $Revision: 734 $ ;;; $Date: 2009-02-11 15:28:13 -0500 (Wed, 11 Feb 2009) $ (in-package #:cl-user) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpackage #:org.rl-community.rl-glue-utils (:nicknames #:rl-glue-utils) (:use #:common-lisp #:rl-glue-codec) (:export ;; generic #:to-string ;; task-spec-parser #:range #:int-range #:make-int-range #:float-range #:make-float-range #:repeat-count #:min-value #:max-value #:make-int-range-array #:make-float-range-array #:task-spec #:make-task-spec #:version #:problem-type #:discount-factor #:int-observations #:float-observations #:char-observations #:int-actions #:float-actions #:char-actions #:rewards #:extra-spec #:parse-task-spec #:across-ranges #:ranges-dimension))
54130
;;; Copyright 2008 <NAME> ;;; Licensed under the Apache License, Version 2.0 (the "License"); ;;; you may not use this file except in compliance with the License. ;;; You may obtain a copy of the License at ;;; ;;; http://www.apache.org/licenses/LICENSE-2.0 ;;; ;;; Unless required by applicable law or agreed to in writing, software ;;; distributed under the License is distributed on an "AS IS" BASIS, ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;;; See the License for the specific language governing permissions and ;;; limitations under the License. ;;; ;;; $Revision: 734 $ ;;; $Date: 2009-02-11 15:28:13 -0500 (Wed, 11 Feb 2009) $ (in-package #:cl-user) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpackage #:org.rl-community.rl-glue-utils (:nicknames #:rl-glue-utils) (:use #:common-lisp #:rl-glue-codec) (:export ;; generic #:to-string ;; task-spec-parser #:range #:int-range #:make-int-range #:float-range #:make-float-range #:repeat-count #:min-value #:max-value #:make-int-range-array #:make-float-range-array #:task-spec #:make-task-spec #:version #:problem-type #:discount-factor #:int-observations #:float-observations #:char-observations #:int-actions #:float-actions #:char-actions #:rewards #:extra-spec #:parse-task-spec #:across-ranges #:ranges-dimension))
true
;;; Copyright 2008 PI:NAME:<NAME>END_PI ;;; Licensed under the Apache License, Version 2.0 (the "License"); ;;; you may not use this file except in compliance with the License. ;;; You may obtain a copy of the License at ;;; ;;; http://www.apache.org/licenses/LICENSE-2.0 ;;; ;;; Unless required by applicable law or agreed to in writing, software ;;; distributed under the License is distributed on an "AS IS" BASIS, ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;;; See the License for the specific language governing permissions and ;;; limitations under the License. ;;; ;;; $Revision: 734 $ ;;; $Date: 2009-02-11 15:28:13 -0500 (Wed, 11 Feb 2009) $ (in-package #:cl-user) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defpackage #:org.rl-community.rl-glue-utils (:nicknames #:rl-glue-utils) (:use #:common-lisp #:rl-glue-codec) (:export ;; generic #:to-string ;; task-spec-parser #:range #:int-range #:make-int-range #:float-range #:make-float-range #:repeat-count #:min-value #:max-value #:make-int-range-array #:make-float-range-array #:task-spec #:make-task-spec #:version #:problem-type #:discount-factor #:int-observations #:float-observations #:char-observations #:int-actions #:float-actions #:char-actions #:rewards #:extra-spec #:parse-task-spec #:across-ranges #:ranges-dimension))
[ { "context": "he LICENSE file distributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 202, "score": 0.999878466129303, "start": 185, "tag": "NAME", "value": "Alessandro Coglio" }, { "context": "ributed with ACL2.\n;\n; Author: Alessandro Coglio ([email protected])\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 222, "score": 0.9999282956123352, "start": 204, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/utilities/numbered-names-tests.lisp
solswords/acl2
0
; Numbered Names -- Tests ; ; Copyright (C) 2017 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: Alessandro Coglio ([email protected]) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "numbered-names") (include-book "testing") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-start (w state)) *default-numbered-name-index-start*) (must-succeed* (set-numbered-name-index-start "{{") (assert-equal (get-numbered-name-index-start (w state)) "{{")) (must-succeed* (set-numbered-name-index-start "$") (assert-equal (get-numbered-name-index-start (w state)) "$")) (must-fail (set-numbered-name-index-start "")) (must-fail (set-numbered-name-index-start "$1")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-end (w state)) *default-numbered-name-index-end*) (must-succeed* (set-numbered-name-index-end "}}") (assert-equal (get-numbered-name-index-end (w state)) "}}")) (must-succeed* (set-numbered-name-index-end "") (assert-equal (get-numbered-name-index-end (w state)) "")) (must-fail (set-numbered-name-index-end "2@")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-wildcard (w state)) *default-numbered-name-index-wildcard*) (must-succeed* (set-numbered-name-index-wildcard "?") (assert-equal (get-numbered-name-index-wildcard (w state)) "?")) (must-fail (set-numbered-name-index-wildcard "")) (must-fail (set-numbered-name-index-wildcard "0")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{q} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{**} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{43} (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f{*} (w state))) '(t f 0))) (must-succeed* (set-numbered-name-index-start "$") (set-numbered-name-index-end "") (set-numbered-name-index-wildcard "?") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$ (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$q (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$?? (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$43 (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f$? (w state))) '(t f 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (make-numbered-name 'gg 61 (w state)) 'gg{61}) (assert-equal (make-numbered-name 'h 2 (w state)) 'h{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (set-numbered-name-index 'abc 4 (w state)) 'abc{4}) (assert-equal (set-numbered-name-index 'bar{2} 4 (w state)) 'bar{4})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (add-numbered-name-in-use fn{4}) (add-numbered-name-in-use fn{1}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{3}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{9}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use ffn{12}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use g) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (resolve-numbered-name-wildcard 'f (w state)) 'f) (assert-equal (resolve-numbered-name-wildcard 'f{3} (w state)) 'f{3}) (add-numbered-name-in-use f{2}) (add-numbered-name-in-use f{5}) (assert-equal (resolve-numbered-name-wildcard 'f{*} (w state)) 'f{5})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (next-numbered-name 'g (w state)) 'g{1}) (assert-equal (next-numbered-name 'g{44} (w state)) 'g{45}) (defun g{5} (x) x) (defun g{6} (x) x) (assert-equal (next-numbered-name 'g{4} (w state)) 'g{7}) (defun g{1} (x) x) (assert-equal (next-numbered-name 'g (w state)) 'g{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}) (increment-global-numbered-name-index) (increment-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 3) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{3}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{3}) (reset-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}))
4892
; Numbered Names -- Tests ; ; Copyright (C) 2017 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: <NAME> (<EMAIL>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "numbered-names") (include-book "testing") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-start (w state)) *default-numbered-name-index-start*) (must-succeed* (set-numbered-name-index-start "{{") (assert-equal (get-numbered-name-index-start (w state)) "{{")) (must-succeed* (set-numbered-name-index-start "$") (assert-equal (get-numbered-name-index-start (w state)) "$")) (must-fail (set-numbered-name-index-start "")) (must-fail (set-numbered-name-index-start "$1")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-end (w state)) *default-numbered-name-index-end*) (must-succeed* (set-numbered-name-index-end "}}") (assert-equal (get-numbered-name-index-end (w state)) "}}")) (must-succeed* (set-numbered-name-index-end "") (assert-equal (get-numbered-name-index-end (w state)) "")) (must-fail (set-numbered-name-index-end "2@")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-wildcard (w state)) *default-numbered-name-index-wildcard*) (must-succeed* (set-numbered-name-index-wildcard "?") (assert-equal (get-numbered-name-index-wildcard (w state)) "?")) (must-fail (set-numbered-name-index-wildcard "")) (must-fail (set-numbered-name-index-wildcard "0")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{q} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{**} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{43} (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f{*} (w state))) '(t f 0))) (must-succeed* (set-numbered-name-index-start "$") (set-numbered-name-index-end "") (set-numbered-name-index-wildcard "?") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$ (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$q (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$?? (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$43 (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f$? (w state))) '(t f 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (make-numbered-name 'gg 61 (w state)) 'gg{61}) (assert-equal (make-numbered-name 'h 2 (w state)) 'h{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (set-numbered-name-index 'abc 4 (w state)) 'abc{4}) (assert-equal (set-numbered-name-index 'bar{2} 4 (w state)) 'bar{4})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (add-numbered-name-in-use fn{4}) (add-numbered-name-in-use fn{1}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{3}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{9}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use ffn{12}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use g) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (resolve-numbered-name-wildcard 'f (w state)) 'f) (assert-equal (resolve-numbered-name-wildcard 'f{3} (w state)) 'f{3}) (add-numbered-name-in-use f{2}) (add-numbered-name-in-use f{5}) (assert-equal (resolve-numbered-name-wildcard 'f{*} (w state)) 'f{5})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (next-numbered-name 'g (w state)) 'g{1}) (assert-equal (next-numbered-name 'g{44} (w state)) 'g{45}) (defun g{5} (x) x) (defun g{6} (x) x) (assert-equal (next-numbered-name 'g{4} (w state)) 'g{7}) (defun g{1} (x) x) (assert-equal (next-numbered-name 'g (w state)) 'g{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}) (increment-global-numbered-name-index) (increment-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 3) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{3}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{3}) (reset-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}))
true
; Numbered Names -- Tests ; ; Copyright (C) 2017 Kestrel Institute (http://www.kestrel.edu) ; ; License: A 3-clause BSD license. See the LICENSE file distributed with ACL2. ; ; Author: PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") (include-book "numbered-names") (include-book "testing") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-start (w state)) *default-numbered-name-index-start*) (must-succeed* (set-numbered-name-index-start "{{") (assert-equal (get-numbered-name-index-start (w state)) "{{")) (must-succeed* (set-numbered-name-index-start "$") (assert-equal (get-numbered-name-index-start (w state)) "$")) (must-fail (set-numbered-name-index-start "")) (must-fail (set-numbered-name-index-start "$1")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-end (w state)) *default-numbered-name-index-end*) (must-succeed* (set-numbered-name-index-end "}}") (assert-equal (get-numbered-name-index-end (w state)) "}}")) (must-succeed* (set-numbered-name-index-end "") (assert-equal (get-numbered-name-index-end (w state)) "")) (must-fail (set-numbered-name-index-end "2@")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (assert-equal (get-numbered-name-index-wildcard (w state)) *default-numbered-name-index-wildcard*) (must-succeed* (set-numbered-name-index-wildcard "?") (assert-equal (get-numbered-name-index-wildcard (w state)) "?")) (must-fail (set-numbered-name-index-wildcard "")) (must-fail (set-numbered-name-index-wildcard "0")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{q} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{**} (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f{43} (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f{*} (w state))) '(t f 0))) (must-succeed* (set-numbered-name-index-start "$") (set-numbered-name-index-end "") (set-numbered-name-index-wildcard "?") (assert-equal (mv-list 3 (check-numbered-name 'none (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$ (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$q (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$?? (w state))) '(nil nil nil)) (assert-equal (mv-list 3 (check-numbered-name 'f$43 (w state))) '(t f 43)) (assert-equal (mv-list 3 (check-numbered-name 'f$? (w state))) '(t f 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (make-numbered-name 'gg 61 (w state)) 'gg{61}) (assert-equal (make-numbered-name 'h 2 (w state)) 'h{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (set-numbered-name-index 'abc 4 (w state)) 'abc{4}) (assert-equal (set-numbered-name-index 'bar{2} 4 (w state)) 'bar{4})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (add-numbered-name-in-use fn{4}) (add-numbered-name-in-use fn{1}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{3}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 4) (add-numbered-name-in-use fn{9}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use ffn{12}) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9) (add-numbered-name-in-use g) (assert-equal (max-numbered-name-index-in-use 'fn (w state)) 9)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (resolve-numbered-name-wildcard 'f (w state)) 'f) (assert-equal (resolve-numbered-name-wildcard 'f{3} (w state)) 'f{3}) (add-numbered-name-in-use f{2}) (add-numbered-name-in-use f{5}) (assert-equal (resolve-numbered-name-wildcard 'f{*} (w state)) 'f{5})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (next-numbered-name 'g (w state)) 'g{1}) (assert-equal (next-numbered-name 'g{44} (w state)) 'g{45}) (defun g{5} (x) x) (defun g{6} (x) x) (assert-equal (next-numbered-name 'g{4} (w state)) 'g{7}) (defun g{1} (x) x) (assert-equal (next-numbered-name 'g (w state)) 'g{2})) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (must-succeed* (set-numbered-name-index-start "{") (set-numbered-name-index-end "}") (set-numbered-name-index-wildcard "*") (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}) (increment-global-numbered-name-index) (increment-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 3) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{3}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{3}) (reset-global-numbered-name-index) (assert-equal (get-global-numbered-name-index (w state)) 1) (assert-equal (set-numbered-name-index-to-global 'h (w state)) 'h{1}) (assert-equal (set-numbered-name-index-to-global 'h{55} (w state)) 'h{1}))
[ { "context": "fpackage :svg\n (:nicknames :wt.svg)\n (:use :cl :alexandria)\n (:shadow :use :symbol :switch)\n (:export\n :", "end": 86, "score": 0.9858947396278381, "start": 76, "tag": "NAME", "value": "alexandria" } ]
svg/package.lisp
xh4/web-toolk
81
(in-package :cl-user) (defpackage :svg (:nicknames :wt.svg) (:use :cl :alexandria) (:shadow :use :symbol :switch) (:export :element :graphics-element :geometry-element :container-element :structural-element :shape-element :renderable-element :never-rendered-element :descriptive-element :graphics-referencing-element :structurally-external-element :text-content-element :text-content-child-element :animation-element :paint-server-element :svg :g :defs :desc :metadata :title :symbol :use :switch :path :rect :circle :ellipse :line :polyline :polygon :text :tspan :text-path :image :foreign-object :marker :a :view :style))
87218
(in-package :cl-user) (defpackage :svg (:nicknames :wt.svg) (:use :cl :<NAME>) (:shadow :use :symbol :switch) (:export :element :graphics-element :geometry-element :container-element :structural-element :shape-element :renderable-element :never-rendered-element :descriptive-element :graphics-referencing-element :structurally-external-element :text-content-element :text-content-child-element :animation-element :paint-server-element :svg :g :defs :desc :metadata :title :symbol :use :switch :path :rect :circle :ellipse :line :polyline :polygon :text :tspan :text-path :image :foreign-object :marker :a :view :style))
true
(in-package :cl-user) (defpackage :svg (:nicknames :wt.svg) (:use :cl :PI:NAME:<NAME>END_PI) (:shadow :use :symbol :switch) (:export :element :graphics-element :geometry-element :container-element :structural-element :shape-element :renderable-element :never-rendered-element :descriptive-element :graphics-referencing-element :structurally-external-element :text-content-element :text-content-child-element :animation-element :paint-server-element :svg :g :defs :desc :metadata :title :symbol :use :switch :path :rect :circle :ellipse :line :polyline :polygon :text :tspan :text-path :image :foreign-object :marker :a :view :style))
[ { "context": "SSIBILITY OF SUCH DAMAGE.\n\n; Original Author(s):\n; Shilpi Goel <[email protected]>\n\n(in-package \"X86", "end": 1717, "score": 0.9998518228530884, "start": 1706, "tag": "NAME", "value": "Shilpi Goel" }, { "context": "GE.\n\n; Original Author(s):\n; Shilpi Goel <[email protected]>\n\n(in-package \"X86ISA\")\n(include-book \"common-sys", "end": 1748, "score": 0.9999343752861023, "start": 1727, "tag": "EMAIL", "value": "[email protected]" } ]
books/projects/x86isa/proofs/utilities/sys-view/non-marking-view-top.lisp
mayankmanj/acl2
305
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Copyright (C) 2015, Regents of the University of Texas ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; Shilpi Goel <[email protected]> (in-package "X86ISA") (include-book "common-system-level-utils") (include-book "paging/common-paging-lemmas") (local (include-book "centaur/bitops/ihs-extensions" :dir :system)) (local (include-book "centaur/bitops/signed-byte-p" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) (local (include-book "centaur/gl/gl" :dir :system)) (local (in-theory (e/d* () (signed-byte-p unsigned-byte-p)))) ;; ====================================================================== (defsection non-marking-view-proof-utilities :parents (proof-utilities debugging-code-proofs) :short "General-purpose code-proof libraries to include in the system-level non-marking view (with A/D flag updates off)" :long "<p>When reasoning about an supervisor-mode program in the system-level <i>non-marking</i> view of the x86 ISA model, include the book @('x86isa/proofs/utilities/sys-view/non-marking-view-top') to make use of some standard rules you would need to control the symbolic simulation of the program.</p> <p>If unwinding the @('(x86-run ... x86)') expression during your proof attempt does not result in a 'clean' expression (i.e., one entirely in terms of updates made to the initial state as opposed to in terms of @(see x86-fetch-decode-execute) or @(see x86-run)), then there is a good chance that you're missing some preconditions, or that the existing rules are not good enough. In any case, it can help to @(see acl2::monitor) the existing rules to figure out what's wrong. Feel free to send on suggestions for new rules or improving existing ones!</p> <p>You can monitor the following rules, depending on the kind of subgoals you see, to get some clues. You can find definitions of these rules in @(see unwind-x86-interpreter-in-non-marking-view).</p> <ul> <li>When the subgoal has calls of @('x86-run'): <br/> Monitor @('x86-run-opener-not-ms-not-zp-n'). </li> <li>When the subgoal has calls of @(see x86-fetch-decode-execute): <br/> Monitor @('x86-fetch-decode-execute-opener'). </li> <li>When monitoring @('x86-fetch-decode-execute-opener') tells you that a hypothesis involving @(see get-prefixes) was not rewritten to @('t'): <br/> Monitor @('get-prefixes-opener-lemma-no-prefix-byte') or @('get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix'). <br/> Note that if the instruction under consideration has prefix bytes, you should monitor one of these rules instead: <br/> @('get-prefixes-opener-lemma-group-1-prefix') <br/> @('get-prefixes-opener-lemma-group-2-prefix') <br/> @('get-prefixes-opener-lemma-group-3-prefix') <br/> @('get-prefixes-opener-lemma-group-4-prefix'). </li> <li>When monitoring other rules above indicates that an instruction is not being fetched successfully using @(see rb): <br/> Monitor @('one-read-with-rb-from-program-at-in-non-marking-view'). </li> <li>When monitoring other rules above indicates that ACL2 can't resolve that the program remained unchanged (@(see program-at)) after a write operation @(see wb) occurred: <br/> Monitor @('program-at-wb-disjoint-in-non-marking-view'). <br/> <br/> An instance of where monitoring this rule might be helpful is when the @('program-at') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When inferring the canonical nature of a linear address:<br/> Monitor @('member-p-canonical-address-listp'). <br/> <br/> This is useful if you believe that the canonical nature of a linear address should be inferable from the canonical nature of a list of addresses, of which that address is a member. An instance of where monitoring this rule might be helpful is when the @('member-p') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When reasoning about disjointness/overlap of memory regions: <br/> @('rb-wb-disjoint-in-non-marking-view') <br/> @('rb-wb-equal-in-non-marking-view') <br/> @('la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view') <br/> @('all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view') </li> </ul> <p>When symbolically simulating supervisor-mode programs, you might also want to do the following, which replaces ACL2's default ancestor check with something simpler:</p> <code> (local (include-book \"tools/trivial-ancestors-check\" :dir :system)) (local (acl2::use-trivial-ancestors-check)) </code> ") (defsection unwind-x86-interpreter-in-non-marking-view :parents (non-marking-view-proof-utilities) ;; A benefit of defining this topic (apart from letting the user ;; view the definitions of the rules) is that if the rule names ;; mentioned in the parent topic are changed, the manual build ;; process will complain about broken links, and we'll know to ;; modify these two doc topics. :short "Definitions of rules to monitor in the system-level non-marking view" :long " <h3>Rules about @('x86-run') and @('x86-fetch-decode-execute')</h3> @(def x86-run-opener-not-ms-not-zp-n) @(def x86-fetch-decode-execute-opener) <h3>Rules about @('get-prefixes')</h3> @(def get-prefixes-opener-lemma-no-prefix-byte) @(def get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) @(def get-prefixes-opener-lemma-group-1-prefix) @(def get-prefixes-opener-lemma-group-2-prefix) @(def get-prefixes-opener-lemma-group-3-prefix) @(def get-prefixes-opener-lemma-group-4-prefix) <h3>Rules related to instruction fetches and program location</h3> @(def one-read-with-rb-from-program-at-in-non-marking-view) @(def program-at-wb-disjoint-in-non-marking-view) <h3>Rules related to canonical linear addresses</h3> @(def member-p-canonical-address-listp) <h3>Rules related to disjointness/overlap of memory regions</h3> @(def rb-wb-disjoint-in-non-marking-view) @(def rb-wb-equal-in-non-marking-view) @(def la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) @(def all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view) ") (local (xdoc::set-default-parents non-marking-view-proof-utilities)) ;; (acl2::why x86-run-opener-not-ms-not-zp-n) ;; (acl2::why x86-fetch-decode-execute-opener) ;; (acl2::why get-prefixes-opener-lemma-no-prefix-byte) ;; (acl2::why get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) ;; (acl2::why ia32e-la-to-pa-values-and-mv-nth-1-wb) ;; (acl2::why one-read-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why combine-bytes-many-reads-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why program-at-wb-disjoint-in-non-marking-view) ;; (acl2::why rb-wb-disjoint-in-non-marking-view) ;; (acl2::why disjointness-of-xlation-governing-entries-paddrs-from-all-xlation-governing-entries-paddrs) ;; (acl2::why la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) ;; ====================================================================== ;; Lemmas about memory writes: (defthm xr-mem-wb-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n lin-addr :w x86))) (disjoint-p (list index) (mv-nth 1 (las-to-pas n lin-addr :w x86))) (not (marking-view x86)) (not (app-view x86))) (equal (xr :mem index (mv-nth 1 (wb n lin-addr w value x86))) (xr :mem index x86))) :hints (("Goal" :in-theory (e/d* (wb write-to-physical-memory disjoint-p member-p) ((:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm mv-nth-0-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n addr) r-w-x mfc state) (n addr)) ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (equal (mv-nth 0 (ia32e-la-to-pa a r-w-x x86)) nil))) (defthm mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x x86)) (mv-nth 1 (las-to-pas n addr r-w-x x86)))) :hints (("Goal" :in-theory (e/d* (member-p) ())))) (defthm mv-nth-1-ia32e-la-to-pa-not-member-of-mv-nth-1-las-to-pas (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x-1 mfc state) (n-1 addr-1)) (disjoint-p (mv-nth 1 (las-to-pas n-1 addr-1 r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) ;; <1,a> is a subset of <n-1,addr-1>. (<= addr-1 a) (< a (+ n-1 addr-1)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x-1 x86))) (not (marking-view x86)) (posp n-1) (integerp a)) (equal (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) nil)) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p) (mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view)) :use ((:instance mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (n n-1) (addr addr-1) (r-w-x r-w-x-1) (a a)))))) (defthm las-to-pas-values-and-xw-mem-not-member-in-non-marking-view (implies (and (not (member-p index (all-xlation-governing-entries-paddrs n lin-addr x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :in-theory (e/d* (disjoint-p member-p) (xlation-governing-entries-paddrs))))) ;; ====================================================================== ;; Lemmas about interaction of writes and paging walkers: (defthm rm-low-32-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 4 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86))) (equal (rm-low-32 index (mv-nth 1 (wb n addr w value x86))) (rm-low-32 index x86))) :hints (("Goal" :in-theory (e/d* (rm-low-32 disjoint-p member-p) (write-to-physical-memory (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm rm-low-64-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 8 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86)) (integerp index)) (equal (rm-low-64 index (mv-nth 1 (wb n addr w value x86))) (rm-low-64 index x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (rm-low-64 rm-low-32 disjoint-p) (wb (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm las-to-pas-values-in-non-marking-view-and-write-to-physical-memory-disjoint (implies (and (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) p-addrs) (physical-address-listp p-addrs) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (las-to-pas n lin-addr r-w-x x86) :in-theory (e/d* (disjoint-p disjoint-p-commutative) (xlation-governing-entries-paddrs))))) (defthm ia32e-la-to-pa-page-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-table xlation-governing-entries-paddrs-for-page-table) (wb bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-directory-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-directory lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-directory xlation-governing-entries-paddrs-for-page-directory) (wb xlation-governing-entries-paddrs-for-page-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-dir-ptr-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-dir-ptr-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-dir-ptr-table xlation-governing-entries-paddrs-for-page-dir-ptr-table) (wb xlation-governing-entries-paddrs-for-page-directory bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-pml4-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-pml4-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-pml4-table xlation-governing-entries-paddrs-for-pml4-table) (wb xlation-governing-entries-paddrs-for-page-dir-ptr-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr)) (and (equal (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86))) (equal (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa xlation-governing-entries-paddrs) (wb xlation-governing-entries-paddrs-for-pml4-table (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (cons (all-xlation-governing-entries-paddrs n lin-addr x86) (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) :in-theory (e/d* (las-to-pas) (wb xlation-governing-entries-paddrs (:meta acl2::mv-nth-cons-meta) force (force)))))) ;; ====================================================================== ;; Lemmas about interaction of memory reads and writes: (defthm rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (and (equal (mv-nth 0 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (rb n-r read-addr r-x x86))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (rb n-r read-addr r-x x86))))) :hints (("Goal" :do-not-induct t))) (defthm read-from-physical-memory-and-mv-nth-1-wb-disjoint-in-non-marking-view ;; Similar to rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p p-addrs (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86))) (equal (read-from-physical-memory p-addrs (mv-nth 1 (wb n-w write-addr w value x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* (wb) ())))) (defthmd rb-wb-equal-in-non-marking-view (implies (and (equal (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-r read-addr r-x x86))) (no-duplicates-p (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-r read-addr r-x x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (loghead (ash (nfix n-w) 3) value))) :hints (("Goal" :do-not-induct t :in-theory (e/d* () (force (force)))))) ;; ====================================================================== ;; las-to-pas error: (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (implies (and (equal addr-2 addr-1) ;; <n-2,addr-2> is a subset of <n-1,addr-1>. (<= (+ n-2 addr-2) (+ n-1 addr-2)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) (posp n-1)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)))) (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1 (implies (and (signed-byte-p 48 addr-1) (<= (+ addr-1 n-2) (+ addr-1 n-1)) (not (mv-nth 0 (ia32e-la-to-pa addr-1 r-w-x x86))) (not (mv-nth 0 (las-to-pas (+ -1 n-1) (+ 1 addr-1) r-w-x x86))) (not (xr :marking-view nil x86)) (integerp n-1) (< 0 n-2)) (not (mv-nth 0 (las-to-pas n-2 addr-1 r-w-x x86)))) :hints (("Goal" :do-not-induct t :use ((:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (addr-2 addr-1))))))) (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x mfc state) (n-1 addr-1)) (syntaxp (and (not (eq n-1 n-2)) (not (eq addr-1 addr-2)))) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) ;; <n-2,addr-2> is a (not strict) subset of <n-1,addr-1>. (<= addr-1 addr-2) (<= (+ n-2 addr-2) (+ n-1 addr-1)) (not (marking-view x86)) (posp n-1) (posp n-2) (integerp addr-2)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)) :hints (("Goal" :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1) ())))) ;; ====================================================================== ;; Lemmas about program-at: (defthm program-at-nil-when-translation-error (implies (and (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86)) (not (app-view x86))) (equal (program-at prog-addr bytes x86) nil)) :hints (("Goal" :in-theory (e/d* (program-at) (force (force)))))) (defthm no-errors-when-translating-program-bytes-in-non-marking-view ;; This rule will help in fetching instruction bytes given relevant ;; information about the program (using program-at). ;; If I use (not (mv-nth 0 (las-to-pas n-bytes prog-addr :x x86))) ;; instead of (program-at prog-addr bytes x86) hypothesis below, this ;; rule would become as horrendously expensive as ;; mv-nth-0-las-to-pas-subset-p-in-non-marking-view. (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) ;; We don't need the following hypothesis because we ;; have program-at-nil-when-translation-error. ;; (not (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86))) ;; <n,addr> is a subset of <(len bytes),prog-addr>. (<= prog-addr addr) (< (+ n addr) (+ (len bytes) prog-addr)) (posp n) (integerp addr) (not (app-view x86)) (not (marking-view x86))) (equal (mv-nth 0 (las-to-pas n addr :x x86)) nil)) :hints (("Goal" :use ((:instance program-at-nil-when-translation-error)) :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view) (program-at-nil-when-translation-error))))) (defthm program-at-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas (len bytes) prog-addr :x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs (len bytes) prog-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (program-at prog-addr bytes (mv-nth 1 (wb n-w write-addr w value x86))) (program-at prog-addr bytes x86))) :hints (("Goal" :in-theory (e/d (program-at) (rb wb))))) ;; ====================================================================== ;; Lemmas about memory reads: (defthm read-from-physical-memory-and-mv-nth-2-ia32e-la-to-pa-in-non-marking-view (implies (not (marking-view x86)) (equal (read-from-physical-memory p-addrs (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* () (force (force)))))) (defthmd rb-unwinding-thm-in-non-marking-view (implies (and (not (mv-nth 0 (rb n lin-addr r-w-x x86))) (posp n) (not (marking-view x86))) (equal (mv-nth 1 (rb n lin-addr r-w-x x86)) (logior (mv-nth 1 (rb 1 lin-addr r-w-x x86)) (ash (mv-nth 1 (rb (1- n) (1+ lin-addr) r-w-x x86)) 8)))) :hints (("Goal" :in-theory (e/d (rb) (acl2::mv-nth-cons-meta force (force)))))) (local (defthmd rb-rb-subset-helper-1 (implies (and (posp j) (x86p x86)) (equal (loghead (ash j 3) (xr :mem index x86)) (xr :mem index x86))) :hints (("Goal" :use ((:instance n08p-xr-mem (i index))) :in-theory (e/d* () (unsigned-byte-p elem-p-of-xr-mem n08p-xr-mem)))))) (local (encapsulate () (local (include-book "arithmetic-3/top" :dir :system)) (defthmd rb-rb-subset-helper-2 (implies (natp j) (equal (ash (loghead (ash j 3) x) 8) (loghead (ash (1+ j) 3) (ash x 8)))) :hints (("Goal" :in-theory (e/d* (loghead ash) ())))))) (local (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view-helper (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (canonical-address-p (+ -1 i addr)) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) ;; The following should be inferrable from the above... (not (mv-nth 0 (las-to-pas j addr r-w-x x86))) (posp j) (<= j i) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2) (unsigned-byte-p)))))) (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) (posp j) (<= j i) (canonical-address-p (+ -1 i addr)) (integerp addr) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view-helper) (:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view (n-1 i) (addr-1 addr) (n-2 j) (addr-2 addr))) :in-theory (e/d* () (unsigned-byte-p signed-byte-p))))) (defun-nx rb-rb-induction-scheme (n-1 a-1 n-2 a-2 val x86) ; a-2 ; ------------------------------------------------------------------------ ; ... | | | | w | w | w | w | | | | | | | | | | ... ; ------------------------------------------------------------------------ ; 0 a-1 max (cond ((or (zp n-1) (zp n-2) (< n-2 n-1) (< a-1 a-2)) (mv n-1 a-1 n-2 a-2 val x86)) ((equal a-1 a-2) (mv n-1 a-1 n-2 a-2 val x86)) ((< a-2 a-1) ;; Byte that won't be read by the most recent rb. (b* ((n-2 (1- n-2)) (a-2 (1+ a-2)) (val (logtail 8 val))) (rb-rb-induction-scheme n-1 a-1 n-2 a-2 val x86))))) (defthmd rb-rb-subset-in-non-marking-view ;; [Shilpi]: Expensive rule. Keep this disabled. (implies (and (equal (mv-nth 1 (rb i addr-i r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr-i r-w-x x86))) ;; <j,addr-j> is a subset (not strict) of <i,addr-i>. ;; This non-strictness is nice because it lets me have ;; a better hyp in one-read-with-rb-from-program-at-in-non-marking-view --- ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)) (<= (+ j addr-j) (+ i addr-i)) (<= addr-i addr-j) (canonical-address-p addr-i) (canonical-address-p (+ -1 i addr-i)) (canonical-address-p addr-j) (posp i) (posp j) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr-j r-w-x x86)) (part-select val :low (ash (- addr-j addr-i) 3) :width (ash j 3)))) :hints (("Goal" :induct (list (rb-rb-induction-scheme j addr-j i addr-i val x86) (las-to-pas i addr-i r-w-x x86) (las-to-pas j addr-j r-w-x x86)) :in-theory (e/d* (signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p))) (if (equal (car id) '(0 1)) '(:expand ((las-to-pas i addr-i r-w-x x86)) :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view (addr addr-i))) :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2 signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p signed-byte-p))) nil))) (defthm many-reads-with-rb-from-program-at-in-non-marking-view (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (syntaxp (quotep n)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< (+ n lin-addr) (+ (len bytes) prog-addr)) (posp n) (canonical-address-p lin-addr) (byte-listp bytes) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb n lin-addr :x x86)) ;; During symbolic simulation of a program, we'd know the ;; concrete value of "bytes". Moreover, note that using ;; combine-bytes instead of combine-n-bytes would have been ;; expensive because the former would combine all program ;; bytes whereas the latter only combines n of them. (combine-n-bytes (- lin-addr prog-addr) n bytes))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j n) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses)) :in-theory (e/d (program-at relating-nth-and-combine-bytes relating-combine-bytes-and-part-select) (rb canonical-address-p acl2::mv-nth-cons-meta))))) (defthm one-read-with-rb-from-program-at-in-non-marking-view ;; Even though we have ;; many-reads-with-rb-from-program-at-in-non-marking-view, I like having ;; this lemma around because it has a weaker hyp of ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)). (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< lin-addr (+ (len bytes) prog-addr)) (canonical-address-p lin-addr) (byte-listp bytes) (not (marking-view x86)) (not (app-view x86)) (x86p x86)) (equal (mv-nth 1 (rb 1 lin-addr :x x86)) (nth (- lin-addr prog-addr) bytes))) :hints (("Goal" :do-not-induct t :in-theory (e/d (program-at relating-nth-and-combine-bytes) (rb nth signed-byte-p not acl2::mv-nth-cons-meta)) :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j 1) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses))))) ;; ====================================================================== (local (define r-x-irrelevant-ind-scheme (n lin-addr r-x-1 r-x-2 x86) :verify-guards nil :non-executable t :enabled t (if (zp n) (mv nil nil x86) (b* (((unless (canonical-address-p lin-addr)) (mv t nil x86)) ((mv flg-1 p-addr-1 x86-1) (ia32e-la-to-pa lin-addr r-x-1 x86)) ((mv flg-2 p-addr-2 x86-2) (ia32e-la-to-pa lin-addr r-x-2 x86)) ((unless (and (equal flg-1 flg-2) (equal p-addr-1 p-addr-2) (equal x86-1 x86-2))) (mv t nil x86-1)) ((when flg-1) (mv flg-1 nil x86-1)) ((mv flgs p-addrs x86) (r-x-irrelevant-ind-scheme (1- n) (1+ lin-addr) r-x-1 r-x-2 x86))) (mv flgs (if flgs nil (cons p-addr-1 p-addrs)) x86))))) (defthm r-x-is-irrelevant-for-mv-nth-1-las-to-pas-when-no-errors-in-non-marking-view (implies (and (bind-free (find-almost-matching-las-to-pas 'r-x-1 n lin-addr mfc state) (r-x-1)) (syntaxp (and (not (eq r-x-2 r-x-1)) ;; r-x-2 must be "smaller" than r-x-1. (term-order r-x-2 r-x-1))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-1 x86))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-2 x86))) (not (marking-view x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-x-2 x86)) (mv-nth 1 (las-to-pas n lin-addr r-x-1 x86)))) :hints (("Goal" :induct (r-x-irrelevant-ind-scheme n lin-addr r-x-1 r-x-2 x86)))) (defthm xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-p-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (xlation-governing-entries-paddrs lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (xlation-governing-entries-paddrs lin-addr x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p wb) ())))) (defthm all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (all-xlation-governing-entries-paddrs n lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (all-xlation-governing-entries-paddrs n lin-addr x86))) :hints (("Goal" :in-theory (e/d* (all-xlation-governing-entries-paddrs) (xlation-governing-entries-paddrs wb)) :induct (all-xlation-governing-entries-paddrs n lin-addr x86)))) ;; ====================================================================== (globally-disable '(rb wb canonical-address-p program-at unsigned-byte-p signed-byte-p las-to-pas all-xlation-governing-entries-paddrs)) (in-theory (e/d* ;; We enable all these functions so that reasoning about ;; memory can be done in terms of rb and wb. (riml-size rml-size wiml-size wml-size rml08 riml08 wml08 wiml08 rml16 riml16 wml16 wiml16 rml32 riml32 wml32 wiml32 rml64 riml64 wml64 wiml64 ea-to-la rme08 rime08 wme08 wime08) ())) ;; ======================================================================
27169
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Copyright (C) 2015, Regents of the University of Texas ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; <NAME> <<EMAIL>> (in-package "X86ISA") (include-book "common-system-level-utils") (include-book "paging/common-paging-lemmas") (local (include-book "centaur/bitops/ihs-extensions" :dir :system)) (local (include-book "centaur/bitops/signed-byte-p" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) (local (include-book "centaur/gl/gl" :dir :system)) (local (in-theory (e/d* () (signed-byte-p unsigned-byte-p)))) ;; ====================================================================== (defsection non-marking-view-proof-utilities :parents (proof-utilities debugging-code-proofs) :short "General-purpose code-proof libraries to include in the system-level non-marking view (with A/D flag updates off)" :long "<p>When reasoning about an supervisor-mode program in the system-level <i>non-marking</i> view of the x86 ISA model, include the book @('x86isa/proofs/utilities/sys-view/non-marking-view-top') to make use of some standard rules you would need to control the symbolic simulation of the program.</p> <p>If unwinding the @('(x86-run ... x86)') expression during your proof attempt does not result in a 'clean' expression (i.e., one entirely in terms of updates made to the initial state as opposed to in terms of @(see x86-fetch-decode-execute) or @(see x86-run)), then there is a good chance that you're missing some preconditions, or that the existing rules are not good enough. In any case, it can help to @(see acl2::monitor) the existing rules to figure out what's wrong. Feel free to send on suggestions for new rules or improving existing ones!</p> <p>You can monitor the following rules, depending on the kind of subgoals you see, to get some clues. You can find definitions of these rules in @(see unwind-x86-interpreter-in-non-marking-view).</p> <ul> <li>When the subgoal has calls of @('x86-run'): <br/> Monitor @('x86-run-opener-not-ms-not-zp-n'). </li> <li>When the subgoal has calls of @(see x86-fetch-decode-execute): <br/> Monitor @('x86-fetch-decode-execute-opener'). </li> <li>When monitoring @('x86-fetch-decode-execute-opener') tells you that a hypothesis involving @(see get-prefixes) was not rewritten to @('t'): <br/> Monitor @('get-prefixes-opener-lemma-no-prefix-byte') or @('get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix'). <br/> Note that if the instruction under consideration has prefix bytes, you should monitor one of these rules instead: <br/> @('get-prefixes-opener-lemma-group-1-prefix') <br/> @('get-prefixes-opener-lemma-group-2-prefix') <br/> @('get-prefixes-opener-lemma-group-3-prefix') <br/> @('get-prefixes-opener-lemma-group-4-prefix'). </li> <li>When monitoring other rules above indicates that an instruction is not being fetched successfully using @(see rb): <br/> Monitor @('one-read-with-rb-from-program-at-in-non-marking-view'). </li> <li>When monitoring other rules above indicates that ACL2 can't resolve that the program remained unchanged (@(see program-at)) after a write operation @(see wb) occurred: <br/> Monitor @('program-at-wb-disjoint-in-non-marking-view'). <br/> <br/> An instance of where monitoring this rule might be helpful is when the @('program-at') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When inferring the canonical nature of a linear address:<br/> Monitor @('member-p-canonical-address-listp'). <br/> <br/> This is useful if you believe that the canonical nature of a linear address should be inferable from the canonical nature of a list of addresses, of which that address is a member. An instance of where monitoring this rule might be helpful is when the @('member-p') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When reasoning about disjointness/overlap of memory regions: <br/> @('rb-wb-disjoint-in-non-marking-view') <br/> @('rb-wb-equal-in-non-marking-view') <br/> @('la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view') <br/> @('all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view') </li> </ul> <p>When symbolically simulating supervisor-mode programs, you might also want to do the following, which replaces ACL2's default ancestor check with something simpler:</p> <code> (local (include-book \"tools/trivial-ancestors-check\" :dir :system)) (local (acl2::use-trivial-ancestors-check)) </code> ") (defsection unwind-x86-interpreter-in-non-marking-view :parents (non-marking-view-proof-utilities) ;; A benefit of defining this topic (apart from letting the user ;; view the definitions of the rules) is that if the rule names ;; mentioned in the parent topic are changed, the manual build ;; process will complain about broken links, and we'll know to ;; modify these two doc topics. :short "Definitions of rules to monitor in the system-level non-marking view" :long " <h3>Rules about @('x86-run') and @('x86-fetch-decode-execute')</h3> @(def x86-run-opener-not-ms-not-zp-n) @(def x86-fetch-decode-execute-opener) <h3>Rules about @('get-prefixes')</h3> @(def get-prefixes-opener-lemma-no-prefix-byte) @(def get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) @(def get-prefixes-opener-lemma-group-1-prefix) @(def get-prefixes-opener-lemma-group-2-prefix) @(def get-prefixes-opener-lemma-group-3-prefix) @(def get-prefixes-opener-lemma-group-4-prefix) <h3>Rules related to instruction fetches and program location</h3> @(def one-read-with-rb-from-program-at-in-non-marking-view) @(def program-at-wb-disjoint-in-non-marking-view) <h3>Rules related to canonical linear addresses</h3> @(def member-p-canonical-address-listp) <h3>Rules related to disjointness/overlap of memory regions</h3> @(def rb-wb-disjoint-in-non-marking-view) @(def rb-wb-equal-in-non-marking-view) @(def la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) @(def all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view) ") (local (xdoc::set-default-parents non-marking-view-proof-utilities)) ;; (acl2::why x86-run-opener-not-ms-not-zp-n) ;; (acl2::why x86-fetch-decode-execute-opener) ;; (acl2::why get-prefixes-opener-lemma-no-prefix-byte) ;; (acl2::why get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) ;; (acl2::why ia32e-la-to-pa-values-and-mv-nth-1-wb) ;; (acl2::why one-read-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why combine-bytes-many-reads-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why program-at-wb-disjoint-in-non-marking-view) ;; (acl2::why rb-wb-disjoint-in-non-marking-view) ;; (acl2::why disjointness-of-xlation-governing-entries-paddrs-from-all-xlation-governing-entries-paddrs) ;; (acl2::why la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) ;; ====================================================================== ;; Lemmas about memory writes: (defthm xr-mem-wb-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n lin-addr :w x86))) (disjoint-p (list index) (mv-nth 1 (las-to-pas n lin-addr :w x86))) (not (marking-view x86)) (not (app-view x86))) (equal (xr :mem index (mv-nth 1 (wb n lin-addr w value x86))) (xr :mem index x86))) :hints (("Goal" :in-theory (e/d* (wb write-to-physical-memory disjoint-p member-p) ((:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm mv-nth-0-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n addr) r-w-x mfc state) (n addr)) ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (equal (mv-nth 0 (ia32e-la-to-pa a r-w-x x86)) nil))) (defthm mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x x86)) (mv-nth 1 (las-to-pas n addr r-w-x x86)))) :hints (("Goal" :in-theory (e/d* (member-p) ())))) (defthm mv-nth-1-ia32e-la-to-pa-not-member-of-mv-nth-1-las-to-pas (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x-1 mfc state) (n-1 addr-1)) (disjoint-p (mv-nth 1 (las-to-pas n-1 addr-1 r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) ;; <1,a> is a subset of <n-1,addr-1>. (<= addr-1 a) (< a (+ n-1 addr-1)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x-1 x86))) (not (marking-view x86)) (posp n-1) (integerp a)) (equal (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) nil)) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p) (mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view)) :use ((:instance mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (n n-1) (addr addr-1) (r-w-x r-w-x-1) (a a)))))) (defthm las-to-pas-values-and-xw-mem-not-member-in-non-marking-view (implies (and (not (member-p index (all-xlation-governing-entries-paddrs n lin-addr x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :in-theory (e/d* (disjoint-p member-p) (xlation-governing-entries-paddrs))))) ;; ====================================================================== ;; Lemmas about interaction of writes and paging walkers: (defthm rm-low-32-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 4 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86))) (equal (rm-low-32 index (mv-nth 1 (wb n addr w value x86))) (rm-low-32 index x86))) :hints (("Goal" :in-theory (e/d* (rm-low-32 disjoint-p member-p) (write-to-physical-memory (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm rm-low-64-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 8 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86)) (integerp index)) (equal (rm-low-64 index (mv-nth 1 (wb n addr w value x86))) (rm-low-64 index x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (rm-low-64 rm-low-32 disjoint-p) (wb (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm las-to-pas-values-in-non-marking-view-and-write-to-physical-memory-disjoint (implies (and (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) p-addrs) (physical-address-listp p-addrs) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (las-to-pas n lin-addr r-w-x x86) :in-theory (e/d* (disjoint-p disjoint-p-commutative) (xlation-governing-entries-paddrs))))) (defthm ia32e-la-to-pa-page-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-table xlation-governing-entries-paddrs-for-page-table) (wb bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-directory-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-directory lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-directory xlation-governing-entries-paddrs-for-page-directory) (wb xlation-governing-entries-paddrs-for-page-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-dir-ptr-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-dir-ptr-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-dir-ptr-table xlation-governing-entries-paddrs-for-page-dir-ptr-table) (wb xlation-governing-entries-paddrs-for-page-directory bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-pml4-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-pml4-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-pml4-table xlation-governing-entries-paddrs-for-pml4-table) (wb xlation-governing-entries-paddrs-for-page-dir-ptr-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr)) (and (equal (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86))) (equal (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa xlation-governing-entries-paddrs) (wb xlation-governing-entries-paddrs-for-pml4-table (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (cons (all-xlation-governing-entries-paddrs n lin-addr x86) (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) :in-theory (e/d* (las-to-pas) (wb xlation-governing-entries-paddrs (:meta acl2::mv-nth-cons-meta) force (force)))))) ;; ====================================================================== ;; Lemmas about interaction of memory reads and writes: (defthm rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (and (equal (mv-nth 0 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (rb n-r read-addr r-x x86))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (rb n-r read-addr r-x x86))))) :hints (("Goal" :do-not-induct t))) (defthm read-from-physical-memory-and-mv-nth-1-wb-disjoint-in-non-marking-view ;; Similar to rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p p-addrs (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86))) (equal (read-from-physical-memory p-addrs (mv-nth 1 (wb n-w write-addr w value x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* (wb) ())))) (defthmd rb-wb-equal-in-non-marking-view (implies (and (equal (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-r read-addr r-x x86))) (no-duplicates-p (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-r read-addr r-x x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (loghead (ash (nfix n-w) 3) value))) :hints (("Goal" :do-not-induct t :in-theory (e/d* () (force (force)))))) ;; ====================================================================== ;; las-to-pas error: (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (implies (and (equal addr-2 addr-1) ;; <n-2,addr-2> is a subset of <n-1,addr-1>. (<= (+ n-2 addr-2) (+ n-1 addr-2)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) (posp n-1)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)))) (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1 (implies (and (signed-byte-p 48 addr-1) (<= (+ addr-1 n-2) (+ addr-1 n-1)) (not (mv-nth 0 (ia32e-la-to-pa addr-1 r-w-x x86))) (not (mv-nth 0 (las-to-pas (+ -1 n-1) (+ 1 addr-1) r-w-x x86))) (not (xr :marking-view nil x86)) (integerp n-1) (< 0 n-2)) (not (mv-nth 0 (las-to-pas n-2 addr-1 r-w-x x86)))) :hints (("Goal" :do-not-induct t :use ((:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (addr-2 addr-1))))))) (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x mfc state) (n-1 addr-1)) (syntaxp (and (not (eq n-1 n-2)) (not (eq addr-1 addr-2)))) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) ;; <n-2,addr-2> is a (not strict) subset of <n-1,addr-1>. (<= addr-1 addr-2) (<= (+ n-2 addr-2) (+ n-1 addr-1)) (not (marking-view x86)) (posp n-1) (posp n-2) (integerp addr-2)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)) :hints (("Goal" :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1) ())))) ;; ====================================================================== ;; Lemmas about program-at: (defthm program-at-nil-when-translation-error (implies (and (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86)) (not (app-view x86))) (equal (program-at prog-addr bytes x86) nil)) :hints (("Goal" :in-theory (e/d* (program-at) (force (force)))))) (defthm no-errors-when-translating-program-bytes-in-non-marking-view ;; This rule will help in fetching instruction bytes given relevant ;; information about the program (using program-at). ;; If I use (not (mv-nth 0 (las-to-pas n-bytes prog-addr :x x86))) ;; instead of (program-at prog-addr bytes x86) hypothesis below, this ;; rule would become as horrendously expensive as ;; mv-nth-0-las-to-pas-subset-p-in-non-marking-view. (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) ;; We don't need the following hypothesis because we ;; have program-at-nil-when-translation-error. ;; (not (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86))) ;; <n,addr> is a subset of <(len bytes),prog-addr>. (<= prog-addr addr) (< (+ n addr) (+ (len bytes) prog-addr)) (posp n) (integerp addr) (not (app-view x86)) (not (marking-view x86))) (equal (mv-nth 0 (las-to-pas n addr :x x86)) nil)) :hints (("Goal" :use ((:instance program-at-nil-when-translation-error)) :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view) (program-at-nil-when-translation-error))))) (defthm program-at-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas (len bytes) prog-addr :x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs (len bytes) prog-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (program-at prog-addr bytes (mv-nth 1 (wb n-w write-addr w value x86))) (program-at prog-addr bytes x86))) :hints (("Goal" :in-theory (e/d (program-at) (rb wb))))) ;; ====================================================================== ;; Lemmas about memory reads: (defthm read-from-physical-memory-and-mv-nth-2-ia32e-la-to-pa-in-non-marking-view (implies (not (marking-view x86)) (equal (read-from-physical-memory p-addrs (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* () (force (force)))))) (defthmd rb-unwinding-thm-in-non-marking-view (implies (and (not (mv-nth 0 (rb n lin-addr r-w-x x86))) (posp n) (not (marking-view x86))) (equal (mv-nth 1 (rb n lin-addr r-w-x x86)) (logior (mv-nth 1 (rb 1 lin-addr r-w-x x86)) (ash (mv-nth 1 (rb (1- n) (1+ lin-addr) r-w-x x86)) 8)))) :hints (("Goal" :in-theory (e/d (rb) (acl2::mv-nth-cons-meta force (force)))))) (local (defthmd rb-rb-subset-helper-1 (implies (and (posp j) (x86p x86)) (equal (loghead (ash j 3) (xr :mem index x86)) (xr :mem index x86))) :hints (("Goal" :use ((:instance n08p-xr-mem (i index))) :in-theory (e/d* () (unsigned-byte-p elem-p-of-xr-mem n08p-xr-mem)))))) (local (encapsulate () (local (include-book "arithmetic-3/top" :dir :system)) (defthmd rb-rb-subset-helper-2 (implies (natp j) (equal (ash (loghead (ash j 3) x) 8) (loghead (ash (1+ j) 3) (ash x 8)))) :hints (("Goal" :in-theory (e/d* (loghead ash) ())))))) (local (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view-helper (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (canonical-address-p (+ -1 i addr)) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) ;; The following should be inferrable from the above... (not (mv-nth 0 (las-to-pas j addr r-w-x x86))) (posp j) (<= j i) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2) (unsigned-byte-p)))))) (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) (posp j) (<= j i) (canonical-address-p (+ -1 i addr)) (integerp addr) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view-helper) (:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view (n-1 i) (addr-1 addr) (n-2 j) (addr-2 addr))) :in-theory (e/d* () (unsigned-byte-p signed-byte-p))))) (defun-nx rb-rb-induction-scheme (n-1 a-1 n-2 a-2 val x86) ; a-2 ; ------------------------------------------------------------------------ ; ... | | | | w | w | w | w | | | | | | | | | | ... ; ------------------------------------------------------------------------ ; 0 a-1 max (cond ((or (zp n-1) (zp n-2) (< n-2 n-1) (< a-1 a-2)) (mv n-1 a-1 n-2 a-2 val x86)) ((equal a-1 a-2) (mv n-1 a-1 n-2 a-2 val x86)) ((< a-2 a-1) ;; Byte that won't be read by the most recent rb. (b* ((n-2 (1- n-2)) (a-2 (1+ a-2)) (val (logtail 8 val))) (rb-rb-induction-scheme n-1 a-1 n-2 a-2 val x86))))) (defthmd rb-rb-subset-in-non-marking-view ;; [Shilpi]: Expensive rule. Keep this disabled. (implies (and (equal (mv-nth 1 (rb i addr-i r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr-i r-w-x x86))) ;; <j,addr-j> is a subset (not strict) of <i,addr-i>. ;; This non-strictness is nice because it lets me have ;; a better hyp in one-read-with-rb-from-program-at-in-non-marking-view --- ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)) (<= (+ j addr-j) (+ i addr-i)) (<= addr-i addr-j) (canonical-address-p addr-i) (canonical-address-p (+ -1 i addr-i)) (canonical-address-p addr-j) (posp i) (posp j) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr-j r-w-x x86)) (part-select val :low (ash (- addr-j addr-i) 3) :width (ash j 3)))) :hints (("Goal" :induct (list (rb-rb-induction-scheme j addr-j i addr-i val x86) (las-to-pas i addr-i r-w-x x86) (las-to-pas j addr-j r-w-x x86)) :in-theory (e/d* (signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p))) (if (equal (car id) '(0 1)) '(:expand ((las-to-pas i addr-i r-w-x x86)) :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view (addr addr-i))) :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2 signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p signed-byte-p))) nil))) (defthm many-reads-with-rb-from-program-at-in-non-marking-view (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (syntaxp (quotep n)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< (+ n lin-addr) (+ (len bytes) prog-addr)) (posp n) (canonical-address-p lin-addr) (byte-listp bytes) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb n lin-addr :x x86)) ;; During symbolic simulation of a program, we'd know the ;; concrete value of "bytes". Moreover, note that using ;; combine-bytes instead of combine-n-bytes would have been ;; expensive because the former would combine all program ;; bytes whereas the latter only combines n of them. (combine-n-bytes (- lin-addr prog-addr) n bytes))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j n) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses)) :in-theory (e/d (program-at relating-nth-and-combine-bytes relating-combine-bytes-and-part-select) (rb canonical-address-p acl2::mv-nth-cons-meta))))) (defthm one-read-with-rb-from-program-at-in-non-marking-view ;; Even though we have ;; many-reads-with-rb-from-program-at-in-non-marking-view, I like having ;; this lemma around because it has a weaker hyp of ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)). (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< lin-addr (+ (len bytes) prog-addr)) (canonical-address-p lin-addr) (byte-listp bytes) (not (marking-view x86)) (not (app-view x86)) (x86p x86)) (equal (mv-nth 1 (rb 1 lin-addr :x x86)) (nth (- lin-addr prog-addr) bytes))) :hints (("Goal" :do-not-induct t :in-theory (e/d (program-at relating-nth-and-combine-bytes) (rb nth signed-byte-p not acl2::mv-nth-cons-meta)) :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j 1) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses))))) ;; ====================================================================== (local (define r-x-irrelevant-ind-scheme (n lin-addr r-x-1 r-x-2 x86) :verify-guards nil :non-executable t :enabled t (if (zp n) (mv nil nil x86) (b* (((unless (canonical-address-p lin-addr)) (mv t nil x86)) ((mv flg-1 p-addr-1 x86-1) (ia32e-la-to-pa lin-addr r-x-1 x86)) ((mv flg-2 p-addr-2 x86-2) (ia32e-la-to-pa lin-addr r-x-2 x86)) ((unless (and (equal flg-1 flg-2) (equal p-addr-1 p-addr-2) (equal x86-1 x86-2))) (mv t nil x86-1)) ((when flg-1) (mv flg-1 nil x86-1)) ((mv flgs p-addrs x86) (r-x-irrelevant-ind-scheme (1- n) (1+ lin-addr) r-x-1 r-x-2 x86))) (mv flgs (if flgs nil (cons p-addr-1 p-addrs)) x86))))) (defthm r-x-is-irrelevant-for-mv-nth-1-las-to-pas-when-no-errors-in-non-marking-view (implies (and (bind-free (find-almost-matching-las-to-pas 'r-x-1 n lin-addr mfc state) (r-x-1)) (syntaxp (and (not (eq r-x-2 r-x-1)) ;; r-x-2 must be "smaller" than r-x-1. (term-order r-x-2 r-x-1))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-1 x86))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-2 x86))) (not (marking-view x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-x-2 x86)) (mv-nth 1 (las-to-pas n lin-addr r-x-1 x86)))) :hints (("Goal" :induct (r-x-irrelevant-ind-scheme n lin-addr r-x-1 r-x-2 x86)))) (defthm xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-p-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (xlation-governing-entries-paddrs lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (xlation-governing-entries-paddrs lin-addr x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p wb) ())))) (defthm all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (all-xlation-governing-entries-paddrs n lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (all-xlation-governing-entries-paddrs n lin-addr x86))) :hints (("Goal" :in-theory (e/d* (all-xlation-governing-entries-paddrs) (xlation-governing-entries-paddrs wb)) :induct (all-xlation-governing-entries-paddrs n lin-addr x86)))) ;; ====================================================================== (globally-disable '(rb wb canonical-address-p program-at unsigned-byte-p signed-byte-p las-to-pas all-xlation-governing-entries-paddrs)) (in-theory (e/d* ;; We enable all these functions so that reasoning about ;; memory can be done in terms of rb and wb. (riml-size rml-size wiml-size wml-size rml08 riml08 wml08 wiml08 rml16 riml16 wml16 wiml16 rml32 riml32 wml32 wiml32 rml64 riml64 wml64 wiml64 ea-to-la rme08 rime08 wme08 wime08) ())) ;; ======================================================================
true
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Copyright (C) 2015, Regents of the University of Texas ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "X86ISA") (include-book "common-system-level-utils") (include-book "paging/common-paging-lemmas") (local (include-book "centaur/bitops/ihs-extensions" :dir :system)) (local (include-book "centaur/bitops/signed-byte-p" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) (local (include-book "centaur/gl/gl" :dir :system)) (local (in-theory (e/d* () (signed-byte-p unsigned-byte-p)))) ;; ====================================================================== (defsection non-marking-view-proof-utilities :parents (proof-utilities debugging-code-proofs) :short "General-purpose code-proof libraries to include in the system-level non-marking view (with A/D flag updates off)" :long "<p>When reasoning about an supervisor-mode program in the system-level <i>non-marking</i> view of the x86 ISA model, include the book @('x86isa/proofs/utilities/sys-view/non-marking-view-top') to make use of some standard rules you would need to control the symbolic simulation of the program.</p> <p>If unwinding the @('(x86-run ... x86)') expression during your proof attempt does not result in a 'clean' expression (i.e., one entirely in terms of updates made to the initial state as opposed to in terms of @(see x86-fetch-decode-execute) or @(see x86-run)), then there is a good chance that you're missing some preconditions, or that the existing rules are not good enough. In any case, it can help to @(see acl2::monitor) the existing rules to figure out what's wrong. Feel free to send on suggestions for new rules or improving existing ones!</p> <p>You can monitor the following rules, depending on the kind of subgoals you see, to get some clues. You can find definitions of these rules in @(see unwind-x86-interpreter-in-non-marking-view).</p> <ul> <li>When the subgoal has calls of @('x86-run'): <br/> Monitor @('x86-run-opener-not-ms-not-zp-n'). </li> <li>When the subgoal has calls of @(see x86-fetch-decode-execute): <br/> Monitor @('x86-fetch-decode-execute-opener'). </li> <li>When monitoring @('x86-fetch-decode-execute-opener') tells you that a hypothesis involving @(see get-prefixes) was not rewritten to @('t'): <br/> Monitor @('get-prefixes-opener-lemma-no-prefix-byte') or @('get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix'). <br/> Note that if the instruction under consideration has prefix bytes, you should monitor one of these rules instead: <br/> @('get-prefixes-opener-lemma-group-1-prefix') <br/> @('get-prefixes-opener-lemma-group-2-prefix') <br/> @('get-prefixes-opener-lemma-group-3-prefix') <br/> @('get-prefixes-opener-lemma-group-4-prefix'). </li> <li>When monitoring other rules above indicates that an instruction is not being fetched successfully using @(see rb): <br/> Monitor @('one-read-with-rb-from-program-at-in-non-marking-view'). </li> <li>When monitoring other rules above indicates that ACL2 can't resolve that the program remained unchanged (@(see program-at)) after a write operation @(see wb) occurred: <br/> Monitor @('program-at-wb-disjoint-in-non-marking-view'). <br/> <br/> An instance of where monitoring this rule might be helpful is when the @('program-at') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When inferring the canonical nature of a linear address:<br/> Monitor @('member-p-canonical-address-listp'). <br/> <br/> This is useful if you believe that the canonical nature of a linear address should be inferable from the canonical nature of a list of addresses, of which that address is a member. An instance of where monitoring this rule might be helpful is when the @('member-p') hypothesis of @('one-read-with-rb-from-program-at-in-non-marking-view') is not being relieved. </li> <li>When reasoning about disjointness/overlap of memory regions: <br/> @('rb-wb-disjoint-in-non-marking-view') <br/> @('rb-wb-equal-in-non-marking-view') <br/> @('la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view') <br/> @('all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view') </li> </ul> <p>When symbolically simulating supervisor-mode programs, you might also want to do the following, which replaces ACL2's default ancestor check with something simpler:</p> <code> (local (include-book \"tools/trivial-ancestors-check\" :dir :system)) (local (acl2::use-trivial-ancestors-check)) </code> ") (defsection unwind-x86-interpreter-in-non-marking-view :parents (non-marking-view-proof-utilities) ;; A benefit of defining this topic (apart from letting the user ;; view the definitions of the rules) is that if the rule names ;; mentioned in the parent topic are changed, the manual build ;; process will complain about broken links, and we'll know to ;; modify these two doc topics. :short "Definitions of rules to monitor in the system-level non-marking view" :long " <h3>Rules about @('x86-run') and @('x86-fetch-decode-execute')</h3> @(def x86-run-opener-not-ms-not-zp-n) @(def x86-fetch-decode-execute-opener) <h3>Rules about @('get-prefixes')</h3> @(def get-prefixes-opener-lemma-no-prefix-byte) @(def get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) @(def get-prefixes-opener-lemma-group-1-prefix) @(def get-prefixes-opener-lemma-group-2-prefix) @(def get-prefixes-opener-lemma-group-3-prefix) @(def get-prefixes-opener-lemma-group-4-prefix) <h3>Rules related to instruction fetches and program location</h3> @(def one-read-with-rb-from-program-at-in-non-marking-view) @(def program-at-wb-disjoint-in-non-marking-view) <h3>Rules related to canonical linear addresses</h3> @(def member-p-canonical-address-listp) <h3>Rules related to disjointness/overlap of memory regions</h3> @(def rb-wb-disjoint-in-non-marking-view) @(def rb-wb-equal-in-non-marking-view) @(def la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) @(def all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view) ") (local (xdoc::set-default-parents non-marking-view-proof-utilities)) ;; (acl2::why x86-run-opener-not-ms-not-zp-n) ;; (acl2::why x86-fetch-decode-execute-opener) ;; (acl2::why get-prefixes-opener-lemma-no-prefix-byte) ;; (acl2::why get-prefixes-opener-lemma-no-legacy-prefix-but-rex-prefix) ;; (acl2::why ia32e-la-to-pa-values-and-mv-nth-1-wb) ;; (acl2::why one-read-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why combine-bytes-many-reads-with-rb-from-program-at-in-non-marking-view) ;; (acl2::why program-at-wb-disjoint-in-non-marking-view) ;; (acl2::why rb-wb-disjoint-in-non-marking-view) ;; (acl2::why disjointness-of-xlation-governing-entries-paddrs-from-all-xlation-governing-entries-paddrs) ;; (acl2::why la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view) ;; ====================================================================== ;; Lemmas about memory writes: (defthm xr-mem-wb-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n lin-addr :w x86))) (disjoint-p (list index) (mv-nth 1 (las-to-pas n lin-addr :w x86))) (not (marking-view x86)) (not (app-view x86))) (equal (xr :mem index (mv-nth 1 (wb n lin-addr w value x86))) (xr :mem index x86))) :hints (("Goal" :in-theory (e/d* (wb write-to-physical-memory disjoint-p member-p) ((:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm mv-nth-0-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n addr) r-w-x mfc state) (n addr)) ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (equal (mv-nth 0 (ia32e-la-to-pa a r-w-x x86)) nil))) (defthm mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (implies (and ;; <1,a> is a subset of <n,addr>. (<= addr a) (< a (+ n addr)) (not (mv-nth 0 (las-to-pas n addr r-w-x x86))) (not (marking-view x86)) (posp n) (integerp a)) (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x x86)) (mv-nth 1 (las-to-pas n addr r-w-x x86)))) :hints (("Goal" :in-theory (e/d* (member-p) ())))) (defthm mv-nth-1-ia32e-la-to-pa-not-member-of-mv-nth-1-las-to-pas (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x-1 mfc state) (n-1 addr-1)) (disjoint-p (mv-nth 1 (las-to-pas n-1 addr-1 r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) ;; <1,a> is a subset of <n-1,addr-1>. (<= addr-1 a) (< a (+ n-1 addr-1)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x-1 x86))) (not (marking-view x86)) (posp n-1) (integerp a)) (equal (member-p (mv-nth 1 (ia32e-la-to-pa a r-w-x-1 x86)) (mv-nth 1 (las-to-pas n-2 addr-2 r-w-x-2 x86))) nil)) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p) (mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view)) :use ((:instance mv-nth-1-ia32e-la-to-pa-member-of-mv-nth-1-las-to-pas-if-lin-addr-member-p-in-non-marking-view (n n-1) (addr addr-1) (r-w-x r-w-x-1) (a a)))))) (defthm las-to-pas-values-and-xw-mem-not-member-in-non-marking-view (implies (and (not (member-p index (all-xlation-governing-entries-paddrs n lin-addr x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (xw :mem index byte x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :in-theory (e/d* (disjoint-p member-p) (xlation-governing-entries-paddrs))))) ;; ====================================================================== ;; Lemmas about interaction of writes and paging walkers: (defthm rm-low-32-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 4 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86))) (equal (rm-low-32 index (mv-nth 1 (wb n addr w value x86))) (rm-low-32 index x86))) :hints (("Goal" :in-theory (e/d* (rm-low-32 disjoint-p member-p) (write-to-physical-memory (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm rm-low-64-wb-in-non-marking-view-disjoint (implies (and (not (mv-nth 0 (las-to-pas n addr :w x86))) (disjoint-p (addr-range 8 index) (mv-nth 1 (las-to-pas n addr :w x86))) (not (marking-view x86)) (integerp index)) (equal (rm-low-64 index (mv-nth 1 (wb n addr w value x86))) (rm-low-64 index x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (rm-low-64 rm-low-32 disjoint-p) (wb (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm las-to-pas-values-in-non-marking-view-and-write-to-physical-memory-disjoint (implies (and (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) p-addrs) (physical-address-listp p-addrs) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (write-to-physical-memory p-addrs bytes x86))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (las-to-pas n lin-addr r-w-x x86) :in-theory (e/d* (disjoint-p disjoint-p-commutative) (xlation-governing-entries-paddrs))))) (defthm ia32e-la-to-pa-page-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-table xlation-governing-entries-paddrs-for-page-table) (wb bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-directory-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-directory lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-directory lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-directory xlation-governing-entries-paddrs-for-page-directory) (wb xlation-governing-entries-paddrs-for-page-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-page-dir-ptr-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-page-dir-ptr-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-page-dir-ptr-table lin-addr base-addr u/s-acc r/w-acc x/d-acc wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-page-dir-ptr-table xlation-governing-entries-paddrs-for-page-dir-ptr-table) (wb xlation-governing-entries-paddrs-for-page-directory bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-pml4-table-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs-for-pml4-table lin-addr base-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr) (physical-address-p base-addr) (equal (loghead 12 base-addr) 0)) (and (equal (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))) (equal (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa-pml4-table lin-addr base-addr wp smep smap ac nxe r-w-x cpl x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa-pml4-table xlation-governing-entries-paddrs-for-pml4-table) (wb xlation-governing-entries-paddrs-for-page-dir-ptr-table bitops::logand-with-negated-bitmask (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm ia32e-la-to-pa-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n write-addr :w x86))) (not (marking-view x86)) (canonical-address-p lin-addr)) (and (equal (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86))) (equal (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x (mv-nth 1 (wb n write-addr w value x86)))) (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86))))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p member-p ia32e-la-to-pa xlation-governing-entries-paddrs) (wb xlation-governing-entries-paddrs-for-pml4-table (:meta acl2::mv-nth-cons-meta) force (force)))))) (defthm la-to-pas-values-and-mv-nth-1-wb-disjoint-from-xlation-gov-addrs-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (marking-view x86))) (and (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (las-to-pas n lin-addr r-w-x x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (las-to-pas n lin-addr r-w-x x86))))) :hints (("Goal" :induct (cons (all-xlation-governing-entries-paddrs n lin-addr x86) (las-to-pas n lin-addr r-w-x (mv-nth 1 (wb n-w write-addr w value x86)))) :in-theory (e/d* (las-to-pas) (wb xlation-governing-entries-paddrs (:meta acl2::mv-nth-cons-meta) force (force)))))) ;; ====================================================================== ;; Lemmas about interaction of memory reads and writes: (defthm rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (and (equal (mv-nth 0 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 0 (rb n-r read-addr r-x x86))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (mv-nth 1 (rb n-r read-addr r-x x86))))) :hints (("Goal" :do-not-induct t))) (defthm read-from-physical-memory-and-mv-nth-1-wb-disjoint-in-non-marking-view ;; Similar to rb-wb-disjoint-in-non-marking-view (implies (and (disjoint-p p-addrs (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86))) (equal (read-from-physical-memory p-addrs (mv-nth 1 (wb n-w write-addr w value x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* (wb) ())))) (defthmd rb-wb-equal-in-non-marking-view (implies (and (equal (mv-nth 1 (las-to-pas n-r read-addr r-x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n-r read-addr x86) (mv-nth 1 (las-to-pas n-r read-addr r-x x86))) (no-duplicates-p (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-r read-addr r-x x86))) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (mv-nth 1 (rb n-r read-addr r-x (mv-nth 1 (wb n-w write-addr w value x86)))) (loghead (ash (nfix n-w) 3) value))) :hints (("Goal" :do-not-induct t :in-theory (e/d* () (force (force)))))) ;; ====================================================================== ;; las-to-pas error: (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (implies (and (equal addr-2 addr-1) ;; <n-2,addr-2> is a subset of <n-1,addr-1>. (<= (+ n-2 addr-2) (+ n-1 addr-2)) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) (posp n-1)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)))) (local (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1 (implies (and (signed-byte-p 48 addr-1) (<= (+ addr-1 n-2) (+ addr-1 n-1)) (not (mv-nth 0 (ia32e-la-to-pa addr-1 r-w-x x86))) (not (mv-nth 0 (las-to-pas (+ -1 n-1) (+ 1 addr-1) r-w-x x86))) (not (xr :marking-view nil x86)) (integerp n-1) (< 0 n-2)) (not (mv-nth 0 (las-to-pas n-2 addr-1 r-w-x x86)))) :hints (("Goal" :do-not-induct t :use ((:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-0 (addr-2 addr-1))))))) (defthmd mv-nth-0-las-to-pas-subset-p-in-non-marking-view (implies (and (bind-free (find-l-addrs-from-las-to-pas '(n-1 addr-1) r-w-x mfc state) (n-1 addr-1)) (syntaxp (and (not (eq n-1 n-2)) (not (eq addr-1 addr-2)))) (not (mv-nth 0 (las-to-pas n-1 addr-1 r-w-x x86))) ;; <n-2,addr-2> is a (not strict) subset of <n-1,addr-1>. (<= addr-1 addr-2) (<= (+ n-2 addr-2) (+ n-1 addr-1)) (not (marking-view x86)) (posp n-1) (posp n-2) (integerp addr-2)) (equal (mv-nth 0 (las-to-pas n-2 addr-2 r-w-x x86)) nil)) :hints (("Goal" :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view-helper-1) ())))) ;; ====================================================================== ;; Lemmas about program-at: (defthm program-at-nil-when-translation-error (implies (and (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86)) (not (app-view x86))) (equal (program-at prog-addr bytes x86) nil)) :hints (("Goal" :in-theory (e/d* (program-at) (force (force)))))) (defthm no-errors-when-translating-program-bytes-in-non-marking-view ;; This rule will help in fetching instruction bytes given relevant ;; information about the program (using program-at). ;; If I use (not (mv-nth 0 (las-to-pas n-bytes prog-addr :x x86))) ;; instead of (program-at prog-addr bytes x86) hypothesis below, this ;; rule would become as horrendously expensive as ;; mv-nth-0-las-to-pas-subset-p-in-non-marking-view. (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) ;; We don't need the following hypothesis because we ;; have program-at-nil-when-translation-error. ;; (not (mv-nth 0 (las-to-pas (len bytes) prog-addr :x x86))) ;; <n,addr> is a subset of <(len bytes),prog-addr>. (<= prog-addr addr) (< (+ n addr) (+ (len bytes) prog-addr)) (posp n) (integerp addr) (not (app-view x86)) (not (marking-view x86))) (equal (mv-nth 0 (las-to-pas n addr :x x86)) nil)) :hints (("Goal" :use ((:instance program-at-nil-when-translation-error)) :in-theory (e/d* (mv-nth-0-las-to-pas-subset-p-in-non-marking-view) (program-at-nil-when-translation-error))))) (defthm program-at-wb-disjoint-in-non-marking-view (implies (and (disjoint-p (mv-nth 1 (las-to-pas (len bytes) prog-addr :x x86)) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs (len bytes) prog-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (not (mv-nth 0 (las-to-pas n-w write-addr :w x86)))) (equal (program-at prog-addr bytes (mv-nth 1 (wb n-w write-addr w value x86))) (program-at prog-addr bytes x86))) :hints (("Goal" :in-theory (e/d (program-at) (rb wb))))) ;; ====================================================================== ;; Lemmas about memory reads: (defthm read-from-physical-memory-and-mv-nth-2-ia32e-la-to-pa-in-non-marking-view (implies (not (marking-view x86)) (equal (read-from-physical-memory p-addrs (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))) (read-from-physical-memory p-addrs x86))) :hints (("Goal" :in-theory (e/d* () (force (force)))))) (defthmd rb-unwinding-thm-in-non-marking-view (implies (and (not (mv-nth 0 (rb n lin-addr r-w-x x86))) (posp n) (not (marking-view x86))) (equal (mv-nth 1 (rb n lin-addr r-w-x x86)) (logior (mv-nth 1 (rb 1 lin-addr r-w-x x86)) (ash (mv-nth 1 (rb (1- n) (1+ lin-addr) r-w-x x86)) 8)))) :hints (("Goal" :in-theory (e/d (rb) (acl2::mv-nth-cons-meta force (force)))))) (local (defthmd rb-rb-subset-helper-1 (implies (and (posp j) (x86p x86)) (equal (loghead (ash j 3) (xr :mem index x86)) (xr :mem index x86))) :hints (("Goal" :use ((:instance n08p-xr-mem (i index))) :in-theory (e/d* () (unsigned-byte-p elem-p-of-xr-mem n08p-xr-mem)))))) (local (encapsulate () (local (include-book "arithmetic-3/top" :dir :system)) (defthmd rb-rb-subset-helper-2 (implies (natp j) (equal (ash (loghead (ash j 3) x) 8) (loghead (ash (1+ j) 3) (ash x 8)))) :hints (("Goal" :in-theory (e/d* (loghead ash) ())))))) (local (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view-helper (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (canonical-address-p (+ -1 i addr)) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) ;; The following should be inferrable from the above... (not (mv-nth 0 (las-to-pas j addr r-w-x x86))) (posp j) (<= j i) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2) (unsigned-byte-p)))))) (defthmd rb-rb-same-start-address-different-op-sizes-non-marking-view (implies (and (equal (mv-nth 1 (rb i addr r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr r-w-x x86))) (posp j) (<= j i) (canonical-address-p (+ -1 i addr)) (integerp addr) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr r-w-x x86)) (loghead (ash j 3) val))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view-helper) (:instance mv-nth-0-las-to-pas-subset-p-in-non-marking-view (n-1 i) (addr-1 addr) (n-2 j) (addr-2 addr))) :in-theory (e/d* () (unsigned-byte-p signed-byte-p))))) (defun-nx rb-rb-induction-scheme (n-1 a-1 n-2 a-2 val x86) ; a-2 ; ------------------------------------------------------------------------ ; ... | | | | w | w | w | w | | | | | | | | | | ... ; ------------------------------------------------------------------------ ; 0 a-1 max (cond ((or (zp n-1) (zp n-2) (< n-2 n-1) (< a-1 a-2)) (mv n-1 a-1 n-2 a-2 val x86)) ((equal a-1 a-2) (mv n-1 a-1 n-2 a-2 val x86)) ((< a-2 a-1) ;; Byte that won't be read by the most recent rb. (b* ((n-2 (1- n-2)) (a-2 (1+ a-2)) (val (logtail 8 val))) (rb-rb-induction-scheme n-1 a-1 n-2 a-2 val x86))))) (defthmd rb-rb-subset-in-non-marking-view ;; [Shilpi]: Expensive rule. Keep this disabled. (implies (and (equal (mv-nth 1 (rb i addr-i r-w-x x86)) val) (not (mv-nth 0 (las-to-pas i addr-i r-w-x x86))) ;; <j,addr-j> is a subset (not strict) of <i,addr-i>. ;; This non-strictness is nice because it lets me have ;; a better hyp in one-read-with-rb-from-program-at-in-non-marking-view --- ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)) (<= (+ j addr-j) (+ i addr-i)) (<= addr-i addr-j) (canonical-address-p addr-i) (canonical-address-p (+ -1 i addr-i)) (canonical-address-p addr-j) (posp i) (posp j) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb j addr-j r-w-x x86)) (part-select val :low (ash (- addr-j addr-i) 3) :width (ash j 3)))) :hints (("Goal" :induct (list (rb-rb-induction-scheme j addr-j i addr-i val x86) (las-to-pas i addr-i r-w-x x86) (las-to-pas j addr-j r-w-x x86)) :in-theory (e/d* (signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p))) (if (equal (car id) '(0 1)) '(:expand ((las-to-pas i addr-i r-w-x x86)) :use ((:instance rb-rb-same-start-address-different-op-sizes-non-marking-view (addr addr-i))) :in-theory (e/d* (rb-rb-subset-helper-1 rb-rb-subset-helper-2 signed-byte-p ifix nfix rb-1-opener-theorem) (unsigned-byte-p signed-byte-p))) nil))) (defthm many-reads-with-rb-from-program-at-in-non-marking-view (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (syntaxp (quotep n)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< (+ n lin-addr) (+ (len bytes) prog-addr)) (posp n) (canonical-address-p lin-addr) (byte-listp bytes) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (mv-nth 1 (rb n lin-addr :x x86)) ;; During symbolic simulation of a program, we'd know the ;; concrete value of "bytes". Moreover, note that using ;; combine-bytes instead of combine-n-bytes would have been ;; expensive because the former would combine all program ;; bytes whereas the latter only combines n of them. (combine-n-bytes (- lin-addr prog-addr) n bytes))) :hints (("Goal" :do-not-induct t :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j n) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses)) :in-theory (e/d (program-at relating-nth-and-combine-bytes relating-combine-bytes-and-part-select) (rb canonical-address-p acl2::mv-nth-cons-meta))))) (defthm one-read-with-rb-from-program-at-in-non-marking-view ;; Even though we have ;; many-reads-with-rb-from-program-at-in-non-marking-view, I like having ;; this lemma around because it has a weaker hyp of ;; (< lin-addr (+ (len bytes) prog-addr)) ;; instead of ;; (< (+ 1 lin-addr) (+ (len bytes) prog-addr)). (implies (and (bind-free (find-program-at-info 'prog-addr 'bytes mfc state) (prog-addr bytes)) (program-at prog-addr bytes x86) (<= prog-addr lin-addr) (< lin-addr (+ (len bytes) prog-addr)) (canonical-address-p lin-addr) (byte-listp bytes) (not (marking-view x86)) (not (app-view x86)) (x86p x86)) (equal (mv-nth 1 (rb 1 lin-addr :x x86)) (nth (- lin-addr prog-addr) bytes))) :hints (("Goal" :do-not-induct t :in-theory (e/d (program-at relating-nth-and-combine-bytes) (rb nth signed-byte-p not acl2::mv-nth-cons-meta)) :use ((:instance rb-rb-subset-in-non-marking-view (addr-i prog-addr) (i (len bytes)) (addr-j lin-addr) (j 1) (r-w-x :x) (val (combine-bytes bytes))) (:instance program-at-implies-canonical-addresses))))) ;; ====================================================================== (local (define r-x-irrelevant-ind-scheme (n lin-addr r-x-1 r-x-2 x86) :verify-guards nil :non-executable t :enabled t (if (zp n) (mv nil nil x86) (b* (((unless (canonical-address-p lin-addr)) (mv t nil x86)) ((mv flg-1 p-addr-1 x86-1) (ia32e-la-to-pa lin-addr r-x-1 x86)) ((mv flg-2 p-addr-2 x86-2) (ia32e-la-to-pa lin-addr r-x-2 x86)) ((unless (and (equal flg-1 flg-2) (equal p-addr-1 p-addr-2) (equal x86-1 x86-2))) (mv t nil x86-1)) ((when flg-1) (mv flg-1 nil x86-1)) ((mv flgs p-addrs x86) (r-x-irrelevant-ind-scheme (1- n) (1+ lin-addr) r-x-1 r-x-2 x86))) (mv flgs (if flgs nil (cons p-addr-1 p-addrs)) x86))))) (defthm r-x-is-irrelevant-for-mv-nth-1-las-to-pas-when-no-errors-in-non-marking-view (implies (and (bind-free (find-almost-matching-las-to-pas 'r-x-1 n lin-addr mfc state) (r-x-1)) (syntaxp (and (not (eq r-x-2 r-x-1)) ;; r-x-2 must be "smaller" than r-x-1. (term-order r-x-2 r-x-1))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-1 x86))) (not (mv-nth 0 (las-to-pas n lin-addr r-x-2 x86))) (not (marking-view x86))) (equal (mv-nth 1 (las-to-pas n lin-addr r-x-2 x86)) (mv-nth 1 (las-to-pas n lin-addr r-x-1 x86)))) :hints (("Goal" :induct (r-x-irrelevant-ind-scheme n lin-addr r-x-1 r-x-2 x86)))) (defthm xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-p-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (xlation-governing-entries-paddrs lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (xlation-governing-entries-paddrs lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (xlation-governing-entries-paddrs lin-addr x86))) :hints (("Goal" :do-not-induct t :in-theory (e/d* (disjoint-p wb) ())))) (defthm all-xlation-governing-entries-paddrs-and-mv-nth-1-wb-disjoint-in-non-marking-view (implies (and (not (mv-nth 0 (las-to-pas n-w write-addr :w x86))) (disjoint-p (all-xlation-governing-entries-paddrs n lin-addr x86) (mv-nth 1 (las-to-pas n-w write-addr :w x86))) (not (app-view x86)) (not (marking-view x86)) (x86p x86)) (equal (all-xlation-governing-entries-paddrs n lin-addr (mv-nth 1 (wb n-w write-addr w value x86))) (all-xlation-governing-entries-paddrs n lin-addr x86))) :hints (("Goal" :in-theory (e/d* (all-xlation-governing-entries-paddrs) (xlation-governing-entries-paddrs wb)) :induct (all-xlation-governing-entries-paddrs n lin-addr x86)))) ;; ====================================================================== (globally-disable '(rb wb canonical-address-p program-at unsigned-byte-p signed-byte-p las-to-pas all-xlation-governing-entries-paddrs)) (in-theory (e/d* ;; We enable all these functions so that reasoning about ;; memory can be done in terms of rb and wb. (riml-size rml-size wiml-size wml-size rml08 riml08 wml08 wiml08 rml16 riml16 wml16 wiml16 rml32 riml32 wml32 wiml32 rml64 riml64 wml64 wiml64 ea-to-la rme08 rime08 wme08 wime08) ())) ;; ======================================================================
[ { "context": ";;;; arithmetic.lisp\n;;;;\n;;;; Copyright 2018-2021 Alexander Gutev\n;;;;\n;;;; Permission is hereby granted, free of c", "end": 66, "score": 0.9998520016670227, "start": 51, "tag": "NAME", "value": "Alexander Gutev" } ]
test/arithmetic.lisp
tani/generic-cl
99
;;;; arithmetic.lisp ;;;; ;;;; Copyright 2018-2021 Alexander Gutev ;;;; ;;;; Permission is hereby granted, free of charge, to any person ;;;; obtaining a copy of this software and associated documentation ;;;; files (the "Software"), to deal in the Software without ;;;; restriction, including without limitation the rights to use, ;;;; copy, modify, merge, publish, distribute, sublicense, and/or sell ;;;; copies of the Software, and to permit persons to whom the ;;;; Software is furnished to do so, subject to the following ;;;; conditions: ;;;; ;;;; The above copyright notice and this permission notice shall be ;;;; included in all copies or substantial portions of the Software. ;;;; ;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ;;;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ;;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ;;;; OTHER DEALINGS IN THE SOFTWARE. ;;;; Unit tests for arithmetic functions (in-package :generic-cl/test) ;;; Test Suite Definition (def-suite arithmetic :description "Test arithmetic functions" :in generic-cl) (in-suite arithmetic) ;;; Tests (test number-add "Test ADD on numbers" (is (= 3 (add 1 2))) (signals error (add 1 'x))) (test-nary number + (is (= 0 (+))) (is (= 2 (+ 2))) (is (= 10 (+ 1 2 3 4)))) (test number-subtract "Test SUBTRACT on numbers" (is (= -1 (subtract 3 4))) (signals error (subtract 3 "z"))) (test-nary number - (is (= -3 (- 3))) (is (= -2 (- 5 4 3)))) (test number-multiply "Test MULTIPLY on numbers" (is (= 8 (multiply 2 4))) (signals error (multiply 4 #\a))) (test-nary number * (is (= 1 (*))) (is (= 3 (* 3))) (is (= 120 (* 2 3 4 5)))) (test number-divide "Test DIVIDE on numbers" (is (= 2 (divide 6 3))) (signals error (divide 'a 'b))) (test-nary number / (is (= 1/5 (/ 5))) (is (= 1 (/ 6 3 2)))) (test number-negate "Test NEGATE on numbers" (is (= -4 (negate 4))) (signals error (negate 'x))) (test number-increments "Test 1+, 1-, INCF and DECF on numbers" (is (= 5 (1+ 4))) (is (= 7 (1- 8))) (let ((x 2)) (is (= 3 (incf x))) (is (= 3 x)) (is (= 7 (incf x 4))) (is (= 7 x))) (let ((x 6)) (is (= 5 (decf x))) (is (= 5 x)) (is (= 2 (decf x 3))) (is (= 2 x)))) (test number-minusp "Test MINUSP on numbers" (is-true (minusp -5)) (is-true (minusp -1)) (is-false (minusp 0)) (is-false (minusp 3))) (test number-plusp "Test PLUSP on numbers" (is-true (plusp 5)) (is-true (plusp 1)) (is-false (plusp 0)) (is-false (plusp -3))) (test number-zerop "Test ZEROP on numbers" (is-true (zerop 0)) (is-false (zerop -1)) (is-false (zerop 5))) (test number-signum "Test SIGNUM on numbers" (is (= 1 (signum 3))) (is (= -1 (signum -1))) (is (= 0 (signum 0)))) (test number-abs "Test ABS on numbers" (is (= 10 (abs 10))) (is (= 0 (abs 0))) (is (= 3 (abs -3)))) (test number-evenp "Test EVENP on numbers" (is-true (evenp 2)) (is-true (evenp 10)) (is-true (evenp 0)) (is-true (evenp -4)) (is-false (evenp 5)) (is-false (evenp -3))) (test number-oddp "Test ODDP on numbers" (is-true (oddp 3)) (is-true (oddp 7)) (is-true (oddp -5)) (is-false (oddp 0)) (is-false (oddp 4)) (is-false (oddp -6))) (test number-floor "Test FLOOR on numbers" (is (= 3 (floor 3.0222))) (is (= -4 (floor -3.0222))) (is (= '(3 1) (multiple-value-list (floor 10 3)))) (is (= '(-4 2) (multiple-value-list (floor -10 3))))) (test number-ceiling "Test CEILING on numbers" (is (= 4 (ceiling 3.0222))) (is (= -3 (ceiling -3.0222))) (is (= '(4 -2) (multiple-value-list (ceiling 10 3)))) (is (= '(-3 -1) (multiple-value-list (ceiling -10 3))))) (test number-truncate "Test TRUNCATE on numbers" (is (= 3 (truncate 3.0222))) (is (= -3 (truncate -3.0222))) (is (= '(3 1) (multiple-value-list (truncate 10 3)))) (is (= '(-3 -1) (multiple-value-list (truncate -10 3))))) (test number-round "Test ROUND on numbers" (is (= 3 (round 3.0222))) (is (= -3 (round -3.0222))) (is (= 4 (round 3.7222))) (is (= -4 (round -3.7222))) (is (= 4 (round 4.5))) (is (= -4 (round -4.5))) (is (= 2 (round 1.5))) (is (= -2 (round -1.5))) (is (= '(3 1) (multiple-value-list (round 10 3)))) (is (= '(-3 -1) (multiple-value-list (round -10 3)))) (is (= '(2 1) (multiple-value-list (round 5 2)))) (is (= '(-2 -1) (multiple-value-list (round -5 2))))) (test number-mod "Test MOD on numbers" (is (= 2 (mod 5 3))) (is (= 1 (mod -5 3)))) (test number-rem "Test REM on numbers" (is (= 2 (rem 5 3))) (is (= -2 (rem -5 3))))
6735
;;;; arithmetic.lisp ;;;; ;;;; Copyright 2018-2021 <NAME> ;;;; ;;;; Permission is hereby granted, free of charge, to any person ;;;; obtaining a copy of this software and associated documentation ;;;; files (the "Software"), to deal in the Software without ;;;; restriction, including without limitation the rights to use, ;;;; copy, modify, merge, publish, distribute, sublicense, and/or sell ;;;; copies of the Software, and to permit persons to whom the ;;;; Software is furnished to do so, subject to the following ;;;; conditions: ;;;; ;;;; The above copyright notice and this permission notice shall be ;;;; included in all copies or substantial portions of the Software. ;;;; ;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ;;;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ;;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ;;;; OTHER DEALINGS IN THE SOFTWARE. ;;;; Unit tests for arithmetic functions (in-package :generic-cl/test) ;;; Test Suite Definition (def-suite arithmetic :description "Test arithmetic functions" :in generic-cl) (in-suite arithmetic) ;;; Tests (test number-add "Test ADD on numbers" (is (= 3 (add 1 2))) (signals error (add 1 'x))) (test-nary number + (is (= 0 (+))) (is (= 2 (+ 2))) (is (= 10 (+ 1 2 3 4)))) (test number-subtract "Test SUBTRACT on numbers" (is (= -1 (subtract 3 4))) (signals error (subtract 3 "z"))) (test-nary number - (is (= -3 (- 3))) (is (= -2 (- 5 4 3)))) (test number-multiply "Test MULTIPLY on numbers" (is (= 8 (multiply 2 4))) (signals error (multiply 4 #\a))) (test-nary number * (is (= 1 (*))) (is (= 3 (* 3))) (is (= 120 (* 2 3 4 5)))) (test number-divide "Test DIVIDE on numbers" (is (= 2 (divide 6 3))) (signals error (divide 'a 'b))) (test-nary number / (is (= 1/5 (/ 5))) (is (= 1 (/ 6 3 2)))) (test number-negate "Test NEGATE on numbers" (is (= -4 (negate 4))) (signals error (negate 'x))) (test number-increments "Test 1+, 1-, INCF and DECF on numbers" (is (= 5 (1+ 4))) (is (= 7 (1- 8))) (let ((x 2)) (is (= 3 (incf x))) (is (= 3 x)) (is (= 7 (incf x 4))) (is (= 7 x))) (let ((x 6)) (is (= 5 (decf x))) (is (= 5 x)) (is (= 2 (decf x 3))) (is (= 2 x)))) (test number-minusp "Test MINUSP on numbers" (is-true (minusp -5)) (is-true (minusp -1)) (is-false (minusp 0)) (is-false (minusp 3))) (test number-plusp "Test PLUSP on numbers" (is-true (plusp 5)) (is-true (plusp 1)) (is-false (plusp 0)) (is-false (plusp -3))) (test number-zerop "Test ZEROP on numbers" (is-true (zerop 0)) (is-false (zerop -1)) (is-false (zerop 5))) (test number-signum "Test SIGNUM on numbers" (is (= 1 (signum 3))) (is (= -1 (signum -1))) (is (= 0 (signum 0)))) (test number-abs "Test ABS on numbers" (is (= 10 (abs 10))) (is (= 0 (abs 0))) (is (= 3 (abs -3)))) (test number-evenp "Test EVENP on numbers" (is-true (evenp 2)) (is-true (evenp 10)) (is-true (evenp 0)) (is-true (evenp -4)) (is-false (evenp 5)) (is-false (evenp -3))) (test number-oddp "Test ODDP on numbers" (is-true (oddp 3)) (is-true (oddp 7)) (is-true (oddp -5)) (is-false (oddp 0)) (is-false (oddp 4)) (is-false (oddp -6))) (test number-floor "Test FLOOR on numbers" (is (= 3 (floor 3.0222))) (is (= -4 (floor -3.0222))) (is (= '(3 1) (multiple-value-list (floor 10 3)))) (is (= '(-4 2) (multiple-value-list (floor -10 3))))) (test number-ceiling "Test CEILING on numbers" (is (= 4 (ceiling 3.0222))) (is (= -3 (ceiling -3.0222))) (is (= '(4 -2) (multiple-value-list (ceiling 10 3)))) (is (= '(-3 -1) (multiple-value-list (ceiling -10 3))))) (test number-truncate "Test TRUNCATE on numbers" (is (= 3 (truncate 3.0222))) (is (= -3 (truncate -3.0222))) (is (= '(3 1) (multiple-value-list (truncate 10 3)))) (is (= '(-3 -1) (multiple-value-list (truncate -10 3))))) (test number-round "Test ROUND on numbers" (is (= 3 (round 3.0222))) (is (= -3 (round -3.0222))) (is (= 4 (round 3.7222))) (is (= -4 (round -3.7222))) (is (= 4 (round 4.5))) (is (= -4 (round -4.5))) (is (= 2 (round 1.5))) (is (= -2 (round -1.5))) (is (= '(3 1) (multiple-value-list (round 10 3)))) (is (= '(-3 -1) (multiple-value-list (round -10 3)))) (is (= '(2 1) (multiple-value-list (round 5 2)))) (is (= '(-2 -1) (multiple-value-list (round -5 2))))) (test number-mod "Test MOD on numbers" (is (= 2 (mod 5 3))) (is (= 1 (mod -5 3)))) (test number-rem "Test REM on numbers" (is (= 2 (rem 5 3))) (is (= -2 (rem -5 3))))
true
;;;; arithmetic.lisp ;;;; ;;;; Copyright 2018-2021 PI:NAME:<NAME>END_PI ;;;; ;;;; Permission is hereby granted, free of charge, to any person ;;;; obtaining a copy of this software and associated documentation ;;;; files (the "Software"), to deal in the Software without ;;;; restriction, including without limitation the rights to use, ;;;; copy, modify, merge, publish, distribute, sublicense, and/or sell ;;;; copies of the Software, and to permit persons to whom the ;;;; Software is furnished to do so, subject to the following ;;;; conditions: ;;;; ;;;; The above copyright notice and this permission notice shall be ;;;; included in all copies or substantial portions of the Software. ;;;; ;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ;;;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ;;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ;;;; OTHER DEALINGS IN THE SOFTWARE. ;;;; Unit tests for arithmetic functions (in-package :generic-cl/test) ;;; Test Suite Definition (def-suite arithmetic :description "Test arithmetic functions" :in generic-cl) (in-suite arithmetic) ;;; Tests (test number-add "Test ADD on numbers" (is (= 3 (add 1 2))) (signals error (add 1 'x))) (test-nary number + (is (= 0 (+))) (is (= 2 (+ 2))) (is (= 10 (+ 1 2 3 4)))) (test number-subtract "Test SUBTRACT on numbers" (is (= -1 (subtract 3 4))) (signals error (subtract 3 "z"))) (test-nary number - (is (= -3 (- 3))) (is (= -2 (- 5 4 3)))) (test number-multiply "Test MULTIPLY on numbers" (is (= 8 (multiply 2 4))) (signals error (multiply 4 #\a))) (test-nary number * (is (= 1 (*))) (is (= 3 (* 3))) (is (= 120 (* 2 3 4 5)))) (test number-divide "Test DIVIDE on numbers" (is (= 2 (divide 6 3))) (signals error (divide 'a 'b))) (test-nary number / (is (= 1/5 (/ 5))) (is (= 1 (/ 6 3 2)))) (test number-negate "Test NEGATE on numbers" (is (= -4 (negate 4))) (signals error (negate 'x))) (test number-increments "Test 1+, 1-, INCF and DECF on numbers" (is (= 5 (1+ 4))) (is (= 7 (1- 8))) (let ((x 2)) (is (= 3 (incf x))) (is (= 3 x)) (is (= 7 (incf x 4))) (is (= 7 x))) (let ((x 6)) (is (= 5 (decf x))) (is (= 5 x)) (is (= 2 (decf x 3))) (is (= 2 x)))) (test number-minusp "Test MINUSP on numbers" (is-true (minusp -5)) (is-true (minusp -1)) (is-false (minusp 0)) (is-false (minusp 3))) (test number-plusp "Test PLUSP on numbers" (is-true (plusp 5)) (is-true (plusp 1)) (is-false (plusp 0)) (is-false (plusp -3))) (test number-zerop "Test ZEROP on numbers" (is-true (zerop 0)) (is-false (zerop -1)) (is-false (zerop 5))) (test number-signum "Test SIGNUM on numbers" (is (= 1 (signum 3))) (is (= -1 (signum -1))) (is (= 0 (signum 0)))) (test number-abs "Test ABS on numbers" (is (= 10 (abs 10))) (is (= 0 (abs 0))) (is (= 3 (abs -3)))) (test number-evenp "Test EVENP on numbers" (is-true (evenp 2)) (is-true (evenp 10)) (is-true (evenp 0)) (is-true (evenp -4)) (is-false (evenp 5)) (is-false (evenp -3))) (test number-oddp "Test ODDP on numbers" (is-true (oddp 3)) (is-true (oddp 7)) (is-true (oddp -5)) (is-false (oddp 0)) (is-false (oddp 4)) (is-false (oddp -6))) (test number-floor "Test FLOOR on numbers" (is (= 3 (floor 3.0222))) (is (= -4 (floor -3.0222))) (is (= '(3 1) (multiple-value-list (floor 10 3)))) (is (= '(-4 2) (multiple-value-list (floor -10 3))))) (test number-ceiling "Test CEILING on numbers" (is (= 4 (ceiling 3.0222))) (is (= -3 (ceiling -3.0222))) (is (= '(4 -2) (multiple-value-list (ceiling 10 3)))) (is (= '(-3 -1) (multiple-value-list (ceiling -10 3))))) (test number-truncate "Test TRUNCATE on numbers" (is (= 3 (truncate 3.0222))) (is (= -3 (truncate -3.0222))) (is (= '(3 1) (multiple-value-list (truncate 10 3)))) (is (= '(-3 -1) (multiple-value-list (truncate -10 3))))) (test number-round "Test ROUND on numbers" (is (= 3 (round 3.0222))) (is (= -3 (round -3.0222))) (is (= 4 (round 3.7222))) (is (= -4 (round -3.7222))) (is (= 4 (round 4.5))) (is (= -4 (round -4.5))) (is (= 2 (round 1.5))) (is (= -2 (round -1.5))) (is (= '(3 1) (multiple-value-list (round 10 3)))) (is (= '(-3 -1) (multiple-value-list (round -10 3)))) (is (= '(2 1) (multiple-value-list (round 5 2)))) (is (= '(-2 -1) (multiple-value-list (round -5 2))))) (test number-mod "Test MOD on numbers" (is (= 2 (mod 5 3))) (is (= 1 (mod -5 3)))) (test number-rem "Test REM on numbers" (is (= 2 (rem 5 3))) (is (= -2 (rem -5 3))))
[ { "context": "t of Maiden\n (c) 2016 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 90, "score": 0.999918520450592, "start": 72, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 115, "score": 0.9998863339424133, "start": 101, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.maiden.agents.qu", "end": 135, "score": 0.9999268054962158, "start": 117, "tag": "EMAIL", "value": "[email protected]" } ]
agents/quicklisp/quicklisp.lisp
Shirakumo/maiden
50
#| This file is a part of Maiden (c) 2016 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.maiden.agents.quicklisp) (defun dists-and-versions (&optional (dists (ql-dist:all-dists))) (loop for dist in dists collect (list (ql-dist:name dist) (ql-dist:version dist)))) (defun dist-for-system (system) (loop for dist in (ql-dist:all-dists) thereis (and (ql-dist:find-system-in-dist system dist) (etypecase dist (string (ql-dist:find-dist dist)) (ql-dist:dist dist))))) (defun check-dists-available (dists) (dolist (dist dists) (unless (ql-dist:find-dist dist) (error "No such dist ~s." dist)))) (defun check-systems-available (systems) (dolist (sys systems) (unless (ql-dist:find-system sys) (error "No such system ~s." sys)))) (defun check-systems-upgradable (systems) (dolist (sys systems) (unless (asdf:find-system sys) (error "No such system ~s." sys)) (when (and (find sys (ql:list-local-systems) :test #'string-equal) (not (legit:git-location-p (ql:where-is-system sys)))) (error "Cannot upgrade ~s as it is a local, non-git system. Manual intervention is required." sys)))) (defun update (&rest dists) (let ((dists (or dists (mapcar #'ql-dist:name (ql-dist:all-dists))))) (check-dists-available dists) (dolist (dist dists) (ql:update-dist dist :prompt NIL)))) (defun upgrade (&rest systems) (let ((systems (or systems (asdf/operate:already-loaded-systems)))) (check-systems-upgradable systems) (dolist (sys systems) (cond ((find sys (ql:list-local-systems)) (legit:pull (ql:where-is-system sys))) ((dist-for-system sys) (ql:update-dist (dist-for-system sys) :prompt NIL))) (ql:quickload sys :prompt NIL :silent T)))) (define-consumer quicklisp (agent) ()) (define-command (quicklisp version) (c ev &optional system) :command "show version" (let* ((system (or system "maiden")) (dist (dist-for-system system))) (reply ev "~a is on version ~a~{ (~a ~a)~}" system (asdf:component-version (asdf:find-system system T)) (when dist (list (ql-dist:name dist) (ql-dist:version dist)))))) (define-command (quicklisp update) (c ev &rest dists) :advice (not public) (apply #'update dists) (reply ev "Update done. ~{~{~a ~a~}~^, ~}" (dists-and-versions dists))) (define-command (quicklisp upgrade) (c ev &rest systems) :advice (not public) (apply #'upgrade systems) (reply ev "~{~a~^, ~} upgraded." systems)) (define-command (quicklisp quickload) (c ev &rest systems) :advice (not public) (check-systems-available systems) (ql:quickload systems :prompt NIL :silent T) (reply ev "~{~a~^, ~} quickloaded." systems)) (define-command (quicklisp uninstall) (c ev &rest systems) :advice (not public) (check-systems-available systems) (dolist (sys systems) (ql-dist:uninstall (ql-dist:find-system sys))) (reply ev "~{~a~^, ~} uninstalled. Note that the code for the selected systems is still active if it was loaded." systems)) (define-command (quicklisp install-dist) (c ev url &key replace) :command "install dist" :advice (not public) (ql-dist:install-dist url :prompt NIL :replace replace) (reply ev "Dist installed.")) (define-command (quicklisp uninstall-dist) (c ev dist) :command "uninstall dist" :advice (not public) (check-dists-available (list dist)) (ql-dist:uninstall (ql-dist:find-dist dist)) (reply ev "Dist uninstalled."))
16690
#| This file is a part of Maiden (c) 2016 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.maiden.agents.quicklisp) (defun dists-and-versions (&optional (dists (ql-dist:all-dists))) (loop for dist in dists collect (list (ql-dist:name dist) (ql-dist:version dist)))) (defun dist-for-system (system) (loop for dist in (ql-dist:all-dists) thereis (and (ql-dist:find-system-in-dist system dist) (etypecase dist (string (ql-dist:find-dist dist)) (ql-dist:dist dist))))) (defun check-dists-available (dists) (dolist (dist dists) (unless (ql-dist:find-dist dist) (error "No such dist ~s." dist)))) (defun check-systems-available (systems) (dolist (sys systems) (unless (ql-dist:find-system sys) (error "No such system ~s." sys)))) (defun check-systems-upgradable (systems) (dolist (sys systems) (unless (asdf:find-system sys) (error "No such system ~s." sys)) (when (and (find sys (ql:list-local-systems) :test #'string-equal) (not (legit:git-location-p (ql:where-is-system sys)))) (error "Cannot upgrade ~s as it is a local, non-git system. Manual intervention is required." sys)))) (defun update (&rest dists) (let ((dists (or dists (mapcar #'ql-dist:name (ql-dist:all-dists))))) (check-dists-available dists) (dolist (dist dists) (ql:update-dist dist :prompt NIL)))) (defun upgrade (&rest systems) (let ((systems (or systems (asdf/operate:already-loaded-systems)))) (check-systems-upgradable systems) (dolist (sys systems) (cond ((find sys (ql:list-local-systems)) (legit:pull (ql:where-is-system sys))) ((dist-for-system sys) (ql:update-dist (dist-for-system sys) :prompt NIL))) (ql:quickload sys :prompt NIL :silent T)))) (define-consumer quicklisp (agent) ()) (define-command (quicklisp version) (c ev &optional system) :command "show version" (let* ((system (or system "maiden")) (dist (dist-for-system system))) (reply ev "~a is on version ~a~{ (~a ~a)~}" system (asdf:component-version (asdf:find-system system T)) (when dist (list (ql-dist:name dist) (ql-dist:version dist)))))) (define-command (quicklisp update) (c ev &rest dists) :advice (not public) (apply #'update dists) (reply ev "Update done. ~{~{~a ~a~}~^, ~}" (dists-and-versions dists))) (define-command (quicklisp upgrade) (c ev &rest systems) :advice (not public) (apply #'upgrade systems) (reply ev "~{~a~^, ~} upgraded." systems)) (define-command (quicklisp quickload) (c ev &rest systems) :advice (not public) (check-systems-available systems) (ql:quickload systems :prompt NIL :silent T) (reply ev "~{~a~^, ~} quickloaded." systems)) (define-command (quicklisp uninstall) (c ev &rest systems) :advice (not public) (check-systems-available systems) (dolist (sys systems) (ql-dist:uninstall (ql-dist:find-system sys))) (reply ev "~{~a~^, ~} uninstalled. Note that the code for the selected systems is still active if it was loaded." systems)) (define-command (quicklisp install-dist) (c ev url &key replace) :command "install dist" :advice (not public) (ql-dist:install-dist url :prompt NIL :replace replace) (reply ev "Dist installed.")) (define-command (quicklisp uninstall-dist) (c ev dist) :command "uninstall dist" :advice (not public) (check-dists-available (list dist)) (ql-dist:uninstall (ql-dist:find-dist dist)) (reply ev "Dist uninstalled."))
true
#| This file is a part of Maiden (c) 2016 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.maiden.agents.quicklisp) (defun dists-and-versions (&optional (dists (ql-dist:all-dists))) (loop for dist in dists collect (list (ql-dist:name dist) (ql-dist:version dist)))) (defun dist-for-system (system) (loop for dist in (ql-dist:all-dists) thereis (and (ql-dist:find-system-in-dist system dist) (etypecase dist (string (ql-dist:find-dist dist)) (ql-dist:dist dist))))) (defun check-dists-available (dists) (dolist (dist dists) (unless (ql-dist:find-dist dist) (error "No such dist ~s." dist)))) (defun check-systems-available (systems) (dolist (sys systems) (unless (ql-dist:find-system sys) (error "No such system ~s." sys)))) (defun check-systems-upgradable (systems) (dolist (sys systems) (unless (asdf:find-system sys) (error "No such system ~s." sys)) (when (and (find sys (ql:list-local-systems) :test #'string-equal) (not (legit:git-location-p (ql:where-is-system sys)))) (error "Cannot upgrade ~s as it is a local, non-git system. Manual intervention is required." sys)))) (defun update (&rest dists) (let ((dists (or dists (mapcar #'ql-dist:name (ql-dist:all-dists))))) (check-dists-available dists) (dolist (dist dists) (ql:update-dist dist :prompt NIL)))) (defun upgrade (&rest systems) (let ((systems (or systems (asdf/operate:already-loaded-systems)))) (check-systems-upgradable systems) (dolist (sys systems) (cond ((find sys (ql:list-local-systems)) (legit:pull (ql:where-is-system sys))) ((dist-for-system sys) (ql:update-dist (dist-for-system sys) :prompt NIL))) (ql:quickload sys :prompt NIL :silent T)))) (define-consumer quicklisp (agent) ()) (define-command (quicklisp version) (c ev &optional system) :command "show version" (let* ((system (or system "maiden")) (dist (dist-for-system system))) (reply ev "~a is on version ~a~{ (~a ~a)~}" system (asdf:component-version (asdf:find-system system T)) (when dist (list (ql-dist:name dist) (ql-dist:version dist)))))) (define-command (quicklisp update) (c ev &rest dists) :advice (not public) (apply #'update dists) (reply ev "Update done. ~{~{~a ~a~}~^, ~}" (dists-and-versions dists))) (define-command (quicklisp upgrade) (c ev &rest systems) :advice (not public) (apply #'upgrade systems) (reply ev "~{~a~^, ~} upgraded." systems)) (define-command (quicklisp quickload) (c ev &rest systems) :advice (not public) (check-systems-available systems) (ql:quickload systems :prompt NIL :silent T) (reply ev "~{~a~^, ~} quickloaded." systems)) (define-command (quicklisp uninstall) (c ev &rest systems) :advice (not public) (check-systems-available systems) (dolist (sys systems) (ql-dist:uninstall (ql-dist:find-system sys))) (reply ev "~{~a~^, ~} uninstalled. Note that the code for the selected systems is still active if it was loaded." systems)) (define-command (quicklisp install-dist) (c ev url &key replace) :command "install dist" :advice (not public) (ql-dist:install-dist url :prompt NIL :replace replace) (reply ev "Dist installed.")) (define-command (quicklisp uninstall-dist) (c ev dist) :command "uninstall dist" :advice (not public) (check-dists-available (list dist)) (ql-dist:uninstall (ql-dist:find-dist dist)) (reply ev "Dist uninstalled."))
[ { "context": "rt of trial\n (c) 2016 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 89, "score": 0.9999122619628906, "start": 71, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 114, "score": 0.999891996383667, "start": 100, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.fraf.trial)\n\n(de", "end": 134, "score": 0.9999217987060547, "start": 116, "tag": "EMAIL", "value": "[email protected]" } ]
type-info.lisp
pupcraft/trial
0
#| This file is a part of trial (c) 2016 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.fraf.trial) (defun check-integer-size (thing size &optional unsigned) (declare (type (unsigned-byte 8) size)) (declare (optimize speed)) (if unsigned (unless (<= 0 thing (expt 2 size)) (error "~a does not fit within [0,2^~a]." thing size)) (let ((size (1- size))) (unless (<= (- (expt 2 size)) thing (1- (expt 2 size))) (error "~a does not fit within [-2^~a,2^~:*~a-1]." thing size))))) (define-constant-fold-function cl-type->gl-type (type) (cond ((eql type 'fixnum) :int) ((subtypep type '(signed-byte 8)) :char) ((subtypep type '(unsigned-byte 32)) :uint) ((subtypep type '(signed-byte 32)) :int) ((subtypep type '(unsigned-byte 64)) :ulong) ((subtypep type '(signed-byte 64)) :long) ((subtypep type 'single-float) :float) ((subtypep type 'double-float) :double) ((eql type 'vec2) :vec2) ((eql type 'vec3) :vec3) ((eql type 'vec4) :vec4) ((eql type 'mat2) :mat2) ((eql type 'mat3) :mat3) ((eql type 'mat4) :mat4) (T (error "Don't know how to convert ~s to a GL type." type)))) (define-constant-fold-function gl-type->cl-type (type) (ecase type ((:boolean :ubyte :unsigned-byte :unsigned-char) '(unsigned-byte 8)) ((:byte :char) '(signed-byte 8)) ((:ushort :unsigned-short) '(unsigned-byte 16)) (:short '(signed-byte 16)) ((:uint :unsigend-int) '(unsigned-byte 32)) ((:int :fixed :sizei :enum :bitfield) '(signed-byte 32)) ((:uint64 :ulong :unsigned-long) '(unsigned-byte 64)) ((:int64 :long) '(signed-byte 64)) ((:half :half-float) 'short-float) ((:float :clampf) 'single-float) ((:double :clampd) 'double-float) (:vec2 'vec2) (:vec3 'vec3) (:vec4 'vec4) (:mat2 'mat2) (:mat3 'mat3) (:mat4 'mat4))) (defun gl-coerce (thing type) (declare (optimize speed)) (ecase type ((:double :double-float) (float thing 0.0d0)) ((:float :single-float) (float thing 0.0f0)) ((:int) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing))) ((:uint :unsigned-int) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing))) ((:char :byte) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing))) ((:uchar :unsigned-char :unsigned-byte) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing))))) (define-compiler-macro gl-coerce (&whole whole &environment env thing type) (if (constantp type env) `(funcall (load-time-value (ecase ,type ((:double :double-float) (lambda (thing) (float thing 0.0d0))) ((:float :single-float) (lambda (thing) (float thing 0.0f0))) ((:int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing)))) ((:uint :unsigned-int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing)))) ((:char :byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing)))) ((:uchar :unsigned-char :unsigned-byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing)))))) ,thing) whole)) (define-constant-fold-function gl-type-size (type) (ecase type (:boolean 1) ((:ubyte :unsigned-byte :byte :char) 1) ((:ushort :unsigned-short :short) 2) ((:uint :unsigned-int :int) 4) (:fixed 4) ((:ulong :unsigned-long :uint64 :int64) 8) (:sizei 4) (:enum 4) ((:intptr :sizeiptr :sync) #+x86 4 #+x86-64 8) (:bitfield 4) ((:half :half-float) 2) ((:float :clampf) 4) ((:double :clampd) 8) (:vec2 (* 2 4)) (:vec3 (* 3 4)) (:vec4 (* 4 4)) (:mat2 (* 2 2 4)) (:mat3 (* 3 3 4)) (:mat4 (* 4 44))))
53316
#| This file is a part of trial (c) 2016 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.fraf.trial) (defun check-integer-size (thing size &optional unsigned) (declare (type (unsigned-byte 8) size)) (declare (optimize speed)) (if unsigned (unless (<= 0 thing (expt 2 size)) (error "~a does not fit within [0,2^~a]." thing size)) (let ((size (1- size))) (unless (<= (- (expt 2 size)) thing (1- (expt 2 size))) (error "~a does not fit within [-2^~a,2^~:*~a-1]." thing size))))) (define-constant-fold-function cl-type->gl-type (type) (cond ((eql type 'fixnum) :int) ((subtypep type '(signed-byte 8)) :char) ((subtypep type '(unsigned-byte 32)) :uint) ((subtypep type '(signed-byte 32)) :int) ((subtypep type '(unsigned-byte 64)) :ulong) ((subtypep type '(signed-byte 64)) :long) ((subtypep type 'single-float) :float) ((subtypep type 'double-float) :double) ((eql type 'vec2) :vec2) ((eql type 'vec3) :vec3) ((eql type 'vec4) :vec4) ((eql type 'mat2) :mat2) ((eql type 'mat3) :mat3) ((eql type 'mat4) :mat4) (T (error "Don't know how to convert ~s to a GL type." type)))) (define-constant-fold-function gl-type->cl-type (type) (ecase type ((:boolean :ubyte :unsigned-byte :unsigned-char) '(unsigned-byte 8)) ((:byte :char) '(signed-byte 8)) ((:ushort :unsigned-short) '(unsigned-byte 16)) (:short '(signed-byte 16)) ((:uint :unsigend-int) '(unsigned-byte 32)) ((:int :fixed :sizei :enum :bitfield) '(signed-byte 32)) ((:uint64 :ulong :unsigned-long) '(unsigned-byte 64)) ((:int64 :long) '(signed-byte 64)) ((:half :half-float) 'short-float) ((:float :clampf) 'single-float) ((:double :clampd) 'double-float) (:vec2 'vec2) (:vec3 'vec3) (:vec4 'vec4) (:mat2 'mat2) (:mat3 'mat3) (:mat4 'mat4))) (defun gl-coerce (thing type) (declare (optimize speed)) (ecase type ((:double :double-float) (float thing 0.0d0)) ((:float :single-float) (float thing 0.0f0)) ((:int) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing))) ((:uint :unsigned-int) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing))) ((:char :byte) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing))) ((:uchar :unsigned-char :unsigned-byte) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing))))) (define-compiler-macro gl-coerce (&whole whole &environment env thing type) (if (constantp type env) `(funcall (load-time-value (ecase ,type ((:double :double-float) (lambda (thing) (float thing 0.0d0))) ((:float :single-float) (lambda (thing) (float thing 0.0f0))) ((:int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing)))) ((:uint :unsigned-int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing)))) ((:char :byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing)))) ((:uchar :unsigned-char :unsigned-byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing)))))) ,thing) whole)) (define-constant-fold-function gl-type-size (type) (ecase type (:boolean 1) ((:ubyte :unsigned-byte :byte :char) 1) ((:ushort :unsigned-short :short) 2) ((:uint :unsigned-int :int) 4) (:fixed 4) ((:ulong :unsigned-long :uint64 :int64) 8) (:sizei 4) (:enum 4) ((:intptr :sizeiptr :sync) #+x86 4 #+x86-64 8) (:bitfield 4) ((:half :half-float) 2) ((:float :clampf) 4) ((:double :clampd) 8) (:vec2 (* 2 4)) (:vec3 (* 3 4)) (:vec4 (* 4 4)) (:mat2 (* 2 2 4)) (:mat3 (* 3 3 4)) (:mat4 (* 4 44))))
true
#| This file is a part of trial (c) 2016 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.fraf.trial) (defun check-integer-size (thing size &optional unsigned) (declare (type (unsigned-byte 8) size)) (declare (optimize speed)) (if unsigned (unless (<= 0 thing (expt 2 size)) (error "~a does not fit within [0,2^~a]." thing size)) (let ((size (1- size))) (unless (<= (- (expt 2 size)) thing (1- (expt 2 size))) (error "~a does not fit within [-2^~a,2^~:*~a-1]." thing size))))) (define-constant-fold-function cl-type->gl-type (type) (cond ((eql type 'fixnum) :int) ((subtypep type '(signed-byte 8)) :char) ((subtypep type '(unsigned-byte 32)) :uint) ((subtypep type '(signed-byte 32)) :int) ((subtypep type '(unsigned-byte 64)) :ulong) ((subtypep type '(signed-byte 64)) :long) ((subtypep type 'single-float) :float) ((subtypep type 'double-float) :double) ((eql type 'vec2) :vec2) ((eql type 'vec3) :vec3) ((eql type 'vec4) :vec4) ((eql type 'mat2) :mat2) ((eql type 'mat3) :mat3) ((eql type 'mat4) :mat4) (T (error "Don't know how to convert ~s to a GL type." type)))) (define-constant-fold-function gl-type->cl-type (type) (ecase type ((:boolean :ubyte :unsigned-byte :unsigned-char) '(unsigned-byte 8)) ((:byte :char) '(signed-byte 8)) ((:ushort :unsigned-short) '(unsigned-byte 16)) (:short '(signed-byte 16)) ((:uint :unsigend-int) '(unsigned-byte 32)) ((:int :fixed :sizei :enum :bitfield) '(signed-byte 32)) ((:uint64 :ulong :unsigned-long) '(unsigned-byte 64)) ((:int64 :long) '(signed-byte 64)) ((:half :half-float) 'short-float) ((:float :clampf) 'single-float) ((:double :clampd) 'double-float) (:vec2 'vec2) (:vec3 'vec3) (:vec4 'vec4) (:mat2 'mat2) (:mat3 'mat3) (:mat4 'mat4))) (defun gl-coerce (thing type) (declare (optimize speed)) (ecase type ((:double :double-float) (float thing 0.0d0)) ((:float :single-float) (float thing 0.0f0)) ((:int) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing))) ((:uint :unsigned-int) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing))) ((:char :byte) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing))) ((:uchar :unsigned-char :unsigned-byte) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing))))) (define-compiler-macro gl-coerce (&whole whole &environment env thing type) (if (constantp type env) `(funcall (load-time-value (ecase ,type ((:double :double-float) (lambda (thing) (float thing 0.0d0))) ((:float :single-float) (lambda (thing) (float thing 0.0f0))) ((:int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32) (values (round thing)))) ((:uint :unsigned-int) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 32 T) (values (round thing)))) ((:char :byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8) (values (round thing)))) ((:uchar :unsigned-char :unsigned-byte) (lambda (thing) #-elide-coercion-size-checks (check-integer-size thing 8 T) (values (round thing)))))) ,thing) whole)) (define-constant-fold-function gl-type-size (type) (ecase type (:boolean 1) ((:ubyte :unsigned-byte :byte :char) 1) ((:ushort :unsigned-short :short) 2) ((:uint :unsigned-int :int) 4) (:fixed 4) ((:ulong :unsigned-long :uint64 :int64) 8) (:sizei 4) (:enum 4) ((:intptr :sizeiptr :sync) #+x86 4 #+x86-64 8) (:bitfield 4) ((:half :half-float) 2) ((:float :clampf) 4) ((:double :clampd) 8) (:vec2 (* 2 4)) (:vec3 (* 3 4)) (:vec4 (* 4 4)) (:mat2 (* 2 2 4)) (:mat3 (* 3 3 4)) (:mat4 (* 4 44))))
[ { "context": "; Dependency Trees for Data Dependency Analysis\n;; Jared Davis \n;;\n;;\n;; erase.lisp\n;;\n;; Introduces erase, the ", "end": 463, "score": 0.9997255206108093, "start": 452, "tag": "NAME", "value": "Jared Davis" } ]
books/coi/dtrees/erase.lisp
ragerdl/acl2-defthm-rc2
1
#|-*-Lisp-*-=================================================================|# #| |# #| coi: Computational Object Inference |# #| |# #|===========================================================================|# ;; Dependency Trees for Data Dependency Analysis ;; Jared Davis ;; ;; ;; erase.lisp ;; ;; Introduces erase, the function for removing paths from dtrees. (in-package "DTREE") (include-book "set") (include-book "../paths/dominates") (include-book "../paths/diverge") (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; Here is the erase function. It operates on dtrees, and handles its own ;; recursion down into the children, which is sort of nice because it is ;; similar to the recursive schemes of "in" or "get" (defund erase (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm erase-of-dtreefix (equal (erase path (dtreefix dtree)) (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm dtreep-of-erase (dtreep (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm localdeps-of-erase (equal (localdeps (erase path dtree)) (if (atom path) (SET::emptyset) (localdeps dtree))) :hints(("Goal" :in-theory (enable erase)))) (verify-guards erase) ;; Congruences for Erase ;; ;; We show that erase produces EQUAL results whenever it is given path-equal ;; paths on some dtree, and that it produces EQUIV! results whenever it is ;; applied to some path on EQUIV! dtrees. ;; ;; Note that it is NOT true that "!-less" equiv is a congruence over erase. ;; Imagine, for example, the dtrees x and y, each with the same child who has ;; dependencies { x1 }. If x has localdeps { x1, x2 } and y has localdeps { x2 ;; }, then x and y are equiv (but not equiv!). But in this event, erasing the ;; child from both trees will result in non-equiv trees! This discovery led us ;; to introduce the more strict equiv! relation. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defcong list::equiv equal (erase path dtree) 1 :hints(("Goal" :in-theory (enable erase) :induct (erase-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (erase path dtree) 2 :hints(("Goal" :in-theory (enable erase)))) ;; Membership/Domains After Erasure ;; ;; In the following rule, we show how how membership in the tree is affected by ;; erasing some node in the tree. I wondered for awhile if there is some ;; better way to explain this, but now I think this rule is probably about what ;; we want. After all, anything we come up with to describe how the domain ;; itself is changed would need a new recursive function that would probably be ;; somewhat difficult to reason about. This fact about membership still ;; describes, in a complete sense, the shape of the resulting domain, it's just ;; that you will need to reason in terms of membership later, as well. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm in-erase (equal (in ipath (erase epath dtree)) (and (or (not (PATH::dominates epath ipath)) (PATH::dominates ipath epath)) (in ipath dtree))) :hints(("Goal" :in-theory (enable path::dominates in erase) :induct (erase-induction ipath epath dtree)))) (defthm in-of-erase-same (equal (in path (erase path dtree)) (in path dtree))) (defthm in-erase-2 (implies (in ipath (erase epath dtree)) (in ipath dtree))) (defthm subset-domain-erase (set::subset (domain (erase path dtree)) (domain dtree))) ;; Standard Erasure Cancellation ;; ;; We adapt the rules in maps.lisp to suit our new erase function. We provide ;; two rules, one which cancels erasures when we know they are irrelevant, and ;; one which moves erasures next to one another based on the term order. The ;; reordering rule isn't provided until later in this file. (defthm erase-when-non-consp-one (implies (not (consp path)) (equal (erase path dtree) *default*)) :hints(("Goal" :in-theory (enable erase)))) (defthm erase-when-not-in (implies (not (in path dtree)) (equiv (erase path dtree) dtree)) :hints(("Goal" :in-theory (enable erase in)))) ;; Get After Erasure ;; ;; Erasure can impact the retrieved values from a get in a number of ways. ;; Suppose we are looking up "lpath" after erasing "epath". ;; ;; 1. If epath dominated lpath, then lpath has also been erased because it was ;; a child of epath. So, in that case, the get retrieves the default ;; value. ;; ;; 2. If epath and lpath diverge, i.e., if neither dominates the other, then ;; lpath is not affected by erasing epath, and we have no change whatsoever. ;; ;; 3. If lpath dominates epath, then a portion of lpath has been erased. We ;; can actually describe the result using nthcdr, but it is a rather ugly rule ;; as you can see below. ;; ;; We will now prove each of these rules individually, with the appropriate ;; hypotheses about domination. ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-epath-dominates (implies (PATH::dominates epath gpath) (equal (get gpath (erase epath dtree)) *default*)) :hints(("Goal" :in-theory (enable erase PATH::DOMINATES get) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-diverge (implies (PATH::diverge gpath epath) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-neither-dominates (implies (and (not (PATH::dominates gpath epath)) (not (PATH::dominates epath gpath))) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (disable get-of-erase-when-diverge) :use (:instance get-of-erase-when-diverge)))) ;; note: they are not truly equal in this case, only equiv! (defthm get-of-erase-when-gpath-dominates (implies (PATH::dominates gpath epath) (equiv (get gpath (erase epath dtree)) (erase (nthcdr (len gpath) epath) (get gpath dtree)))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; We now combine the individual cases into a case-splitting rule capable of ;; rewriting any (get path1 (erase path2 dtree)) term that might arise. ;; ;; I was hesitant to put this rule in, because it seems overly-aggressive. Its ;; name reflects this, so hopefully it should stand out if/when it causes ;; problems, and people can just disable it. ;; ;; This rule subsumes get-erase-dominator, get-erase-dominated, and ;; get-erase-divergent, but I leave those enabled so if you disable this, ;; you can still reason about the particular cases if they arise. (defthm get-of-erase-with-aggressive-case-splitting (equiv (get gpath (erase epath dtree)) (if (PATH::dominates gpath epath) (erase (nthcdr (len gpath) epath) (get gpath dtree)) (if (PATH::dominates epath gpath) *default* (get gpath dtree))))) ;; Deps After Erasure ;; ;; Much like domains, it seems that there are few good rules that we can write ;; about deps after erasure directly. However, between the rules in-erase and ;; get-erase, we should still be able to describe the deps in a membership ;; oriented fashion. This might be sometimes complicated, because of the need ;; to reason about an "existential" sort of property. (defthm in-deps-when-in-deps-of-erase (implies (set::in a (deps (erase path dtree))) (set::in a (deps dtree))) :hints(("Goal" :in-theory (disable in-localdeps-of-get-depsource) :use ((:instance in-localdeps-of-get-depsource (a a) (dtree (erase path dtree))) (:instance in-deps-when-in-localdeps-of-get (a a) (path (depsource a (erase path dtree))) (dtree dtree)))))) (defthm subset-of-deps-of-erase-with-deps (set::subset (deps (erase path dtree)) (deps dtree))) ;; Erase After Erase Reordering ;; ;; This proof goes through automatically using the pick a point method, which ;; is quite nice since I had spent some time trying to prove it inductively ;; without success. This is essentially the same as the "restrained" approach ;; to reducing erase/erase nests described in maps.lisp. (defthm erase-of-erase (equiv (erase path1 (erase path2 dtree)) (erase path2 (erase path1 dtree))) :rule-classes ((:rewrite :loop-stopper ((path1 path2 set)))) :hints(("Goal" :in-theory (enable equiv)))) (defthm erase-is-idempotent (equiv (erase path (erase path dtree)) (erase path dtree)) :hints(("goal" :in-theory (enable equiv)))) (local (encapsulate () ;; This is a test to ensure that our erasure strategy seems to be working as ;; intended. Don't remove this just becuase it has no effect on the logical ;; world! (local (encapsulate (((foo1 *) => *) ((foo2 *) => *) ((foo3 *) => *) ((foo4 *) => *) ((foo5 *) => *) ((foo6 *) => *)) (local (defun foo1 (x) x)) (local (defun foo2 (x) x)) (local (defun foo3 (x) x)) (local (defun foo4 (x) x)) (local (defun foo5 (x) x)) (local (defun foo6 (x) x)) (defthm test-constraint (equal (foo1 x) (foo3 x))))) (local (defthm test-erasure-reductions (equiv (erase (foo1 x) (erase (foo2 x) (erase (foo3 x) (erase (foo4 x) (erase (foo5 x) (erase (foo6 x) Y)))))) (erase (foo6 x) (erase (foo2 x) (erase (foo4 x) (erase (foo3 x) (erase (foo5 x) Y)))))))))) ;; bzo - still need lots of theorems, e.g., erases of sets, and so forth. ;; Here is another version of "erase" that does more of what we ;; probably want from such a function. Following execution of (remove ;; path dtree), path will not be in the "gkeys" of the dtree. (defund remove (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defthm remove-of-dtreefix (equal (remove path (dtreefix dtree)) (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm dtreep-of-remove (dtreep (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm localdeps-of-remove (equal (localdeps (remove path dtree)) (SET::emptyset)) :hints(("Goal" :in-theory (enable remove)))) (defthm remove-from-empty-dtree (equal (dtree::remove path dtree::*default*) dtree::*default*) :hints (("Goal" :in-theory (enable dtree::remove)))) (defun cdr? (x) (if (consp x) (cdr x) nil)) (set-irrelevant-formals-ok t) (defun remove-induction (other path dtree) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove-induction (cdr? other) (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defcong list::equiv equal (remove path dtree) 1 :hints(("Goal" :in-theory (enable remove) :induct (remove-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (remove path dtree) 2 :hints(("Goal" :in-theory (enable remove)))) (defthm open-in (implies (consp path) (equal (in path dtree) (AND (MAP::IN (CAR PATH) (CHILDREN DTREE)) (IN (CDR PATH) (MAP::GET (CAR PATH) (CHILDREN DTREE)))))) :hints (("goal" :in-theory (enable in)))) (defthm open-dominates (implies (consp path::x) (equal (PATH::DOMINATES PATH::X PATH::Y) (OR (NOT (CONSP PATH::X)) (AND (CONSP PATH::Y) (EQUAL (CAR PATH::X) (CAR PATH::Y)) (PATH::DOMINATES (CDR PATH::X) (CDR PATH::Y))))))) (defthm remove-induction-is-remove (equal (remove-induction ipath epath dtree) (remove epath dtree)) :hints (("goal" :induct (remove-induction ipath epath dtree) :in-theory (enable remove)))) ;; What does (hooey ipath epath dtree) mean? First there are the ;; nuisance cases: ;; ;; 1. Both ipath and epath are atoms, or ;; 2. Just ipath is an atom. ;; ;; The meat of the defun is the following case ;; ;; 3. Both epath and ipath are CONSPs: Get the value associated with ;; ipath in dtree. Take the tail of epath beyond the length of ;; ipath and remove it from the value above. The result is not ;; an empty map. ;; ;; The intuition seems to be that there is more stored at ipath in dtree ;; than can be taken away by removing the tail of epath. (defund hooey (ipath epath dtree) (if (path::dominates epath ipath) ;; 1. and therefore (not (consp epath)) (not (consp ipath)) (or ;; 2. and therefore (consp epath) (not (consp ipath)) ;; 3. (not (map::empty (children (remove (nthcdr (len ipath) epath) (get ipath dtree)))))))) (in-theory (disable open-dominates )) (defthmd open-nthcdr (implies (not (zp n)) (equal (nthcdr n l) (NTHCDR (+ N -1) (CDR L)))) :hints (("goal" :in-theory (enable nthcdr)))) (defthmd in-to-hooey (implies (and (in ipath dtree) (not (path::diverge epath ipath))) (equal (in ipath (remove epath dtree)) (hooey ipath epath dtree))) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable hooey get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable open-nthcdr path::diverge path::dominates in remove))))) (defthmd in-remove-1 (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (in ipath (remove epath dtree))) nil)) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable nthcdr hooey path::diverge path::dominates in remove))))) (defthm in-remove (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (hooey ipath epath dtree)) nil)) :hints (("goal" :in-theory (enable in-to-hooey) :use in-remove-1))) (defthm subset-domain-remove (set::subset (domain (remove path dtree)) (domain dtree))) (defthm remove-when-non-consp-one (implies (not (consp path)) (equal (remove path dtree) *default*)) :hints(("Goal" :in-theory (enable remove)))) ;; Not true, hence joed. #+joe (defthm remove-when-not-in (implies (not (in path dtree)) (equiv (remove path dtree) dtree)) :hints(("Goal" :in-theory (enable remove in)))) (defthm remove-path-from-leaf (equal (remove path (leaf v)) *default*) :hints (("Goal" :expand (remove path (leaf v)) :do-not-induct t))) (in-theory (disable dtree::open-in)) (verify-guards remove)
86379
#|-*-Lisp-*-=================================================================|# #| |# #| coi: Computational Object Inference |# #| |# #|===========================================================================|# ;; Dependency Trees for Data Dependency Analysis ;; <NAME> ;; ;; ;; erase.lisp ;; ;; Introduces erase, the function for removing paths from dtrees. (in-package "DTREE") (include-book "set") (include-book "../paths/dominates") (include-book "../paths/diverge") (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; Here is the erase function. It operates on dtrees, and handles its own ;; recursion down into the children, which is sort of nice because it is ;; similar to the recursive schemes of "in" or "get" (defund erase (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm erase-of-dtreefix (equal (erase path (dtreefix dtree)) (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm dtreep-of-erase (dtreep (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm localdeps-of-erase (equal (localdeps (erase path dtree)) (if (atom path) (SET::emptyset) (localdeps dtree))) :hints(("Goal" :in-theory (enable erase)))) (verify-guards erase) ;; Congruences for Erase ;; ;; We show that erase produces EQUAL results whenever it is given path-equal ;; paths on some dtree, and that it produces EQUIV! results whenever it is ;; applied to some path on EQUIV! dtrees. ;; ;; Note that it is NOT true that "!-less" equiv is a congruence over erase. ;; Imagine, for example, the dtrees x and y, each with the same child who has ;; dependencies { x1 }. If x has localdeps { x1, x2 } and y has localdeps { x2 ;; }, then x and y are equiv (but not equiv!). But in this event, erasing the ;; child from both trees will result in non-equiv trees! This discovery led us ;; to introduce the more strict equiv! relation. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defcong list::equiv equal (erase path dtree) 1 :hints(("Goal" :in-theory (enable erase) :induct (erase-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (erase path dtree) 2 :hints(("Goal" :in-theory (enable erase)))) ;; Membership/Domains After Erasure ;; ;; In the following rule, we show how how membership in the tree is affected by ;; erasing some node in the tree. I wondered for awhile if there is some ;; better way to explain this, but now I think this rule is probably about what ;; we want. After all, anything we come up with to describe how the domain ;; itself is changed would need a new recursive function that would probably be ;; somewhat difficult to reason about. This fact about membership still ;; describes, in a complete sense, the shape of the resulting domain, it's just ;; that you will need to reason in terms of membership later, as well. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm in-erase (equal (in ipath (erase epath dtree)) (and (or (not (PATH::dominates epath ipath)) (PATH::dominates ipath epath)) (in ipath dtree))) :hints(("Goal" :in-theory (enable path::dominates in erase) :induct (erase-induction ipath epath dtree)))) (defthm in-of-erase-same (equal (in path (erase path dtree)) (in path dtree))) (defthm in-erase-2 (implies (in ipath (erase epath dtree)) (in ipath dtree))) (defthm subset-domain-erase (set::subset (domain (erase path dtree)) (domain dtree))) ;; Standard Erasure Cancellation ;; ;; We adapt the rules in maps.lisp to suit our new erase function. We provide ;; two rules, one which cancels erasures when we know they are irrelevant, and ;; one which moves erasures next to one another based on the term order. The ;; reordering rule isn't provided until later in this file. (defthm erase-when-non-consp-one (implies (not (consp path)) (equal (erase path dtree) *default*)) :hints(("Goal" :in-theory (enable erase)))) (defthm erase-when-not-in (implies (not (in path dtree)) (equiv (erase path dtree) dtree)) :hints(("Goal" :in-theory (enable erase in)))) ;; Get After Erasure ;; ;; Erasure can impact the retrieved values from a get in a number of ways. ;; Suppose we are looking up "lpath" after erasing "epath". ;; ;; 1. If epath dominated lpath, then lpath has also been erased because it was ;; a child of epath. So, in that case, the get retrieves the default ;; value. ;; ;; 2. If epath and lpath diverge, i.e., if neither dominates the other, then ;; lpath is not affected by erasing epath, and we have no change whatsoever. ;; ;; 3. If lpath dominates epath, then a portion of lpath has been erased. We ;; can actually describe the result using nthcdr, but it is a rather ugly rule ;; as you can see below. ;; ;; We will now prove each of these rules individually, with the appropriate ;; hypotheses about domination. ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-epath-dominates (implies (PATH::dominates epath gpath) (equal (get gpath (erase epath dtree)) *default*)) :hints(("Goal" :in-theory (enable erase PATH::DOMINATES get) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-diverge (implies (PATH::diverge gpath epath) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-neither-dominates (implies (and (not (PATH::dominates gpath epath)) (not (PATH::dominates epath gpath))) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (disable get-of-erase-when-diverge) :use (:instance get-of-erase-when-diverge)))) ;; note: they are not truly equal in this case, only equiv! (defthm get-of-erase-when-gpath-dominates (implies (PATH::dominates gpath epath) (equiv (get gpath (erase epath dtree)) (erase (nthcdr (len gpath) epath) (get gpath dtree)))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; We now combine the individual cases into a case-splitting rule capable of ;; rewriting any (get path1 (erase path2 dtree)) term that might arise. ;; ;; I was hesitant to put this rule in, because it seems overly-aggressive. Its ;; name reflects this, so hopefully it should stand out if/when it causes ;; problems, and people can just disable it. ;; ;; This rule subsumes get-erase-dominator, get-erase-dominated, and ;; get-erase-divergent, but I leave those enabled so if you disable this, ;; you can still reason about the particular cases if they arise. (defthm get-of-erase-with-aggressive-case-splitting (equiv (get gpath (erase epath dtree)) (if (PATH::dominates gpath epath) (erase (nthcdr (len gpath) epath) (get gpath dtree)) (if (PATH::dominates epath gpath) *default* (get gpath dtree))))) ;; Deps After Erasure ;; ;; Much like domains, it seems that there are few good rules that we can write ;; about deps after erasure directly. However, between the rules in-erase and ;; get-erase, we should still be able to describe the deps in a membership ;; oriented fashion. This might be sometimes complicated, because of the need ;; to reason about an "existential" sort of property. (defthm in-deps-when-in-deps-of-erase (implies (set::in a (deps (erase path dtree))) (set::in a (deps dtree))) :hints(("Goal" :in-theory (disable in-localdeps-of-get-depsource) :use ((:instance in-localdeps-of-get-depsource (a a) (dtree (erase path dtree))) (:instance in-deps-when-in-localdeps-of-get (a a) (path (depsource a (erase path dtree))) (dtree dtree)))))) (defthm subset-of-deps-of-erase-with-deps (set::subset (deps (erase path dtree)) (deps dtree))) ;; Erase After Erase Reordering ;; ;; This proof goes through automatically using the pick a point method, which ;; is quite nice since I had spent some time trying to prove it inductively ;; without success. This is essentially the same as the "restrained" approach ;; to reducing erase/erase nests described in maps.lisp. (defthm erase-of-erase (equiv (erase path1 (erase path2 dtree)) (erase path2 (erase path1 dtree))) :rule-classes ((:rewrite :loop-stopper ((path1 path2 set)))) :hints(("Goal" :in-theory (enable equiv)))) (defthm erase-is-idempotent (equiv (erase path (erase path dtree)) (erase path dtree)) :hints(("goal" :in-theory (enable equiv)))) (local (encapsulate () ;; This is a test to ensure that our erasure strategy seems to be working as ;; intended. Don't remove this just becuase it has no effect on the logical ;; world! (local (encapsulate (((foo1 *) => *) ((foo2 *) => *) ((foo3 *) => *) ((foo4 *) => *) ((foo5 *) => *) ((foo6 *) => *)) (local (defun foo1 (x) x)) (local (defun foo2 (x) x)) (local (defun foo3 (x) x)) (local (defun foo4 (x) x)) (local (defun foo5 (x) x)) (local (defun foo6 (x) x)) (defthm test-constraint (equal (foo1 x) (foo3 x))))) (local (defthm test-erasure-reductions (equiv (erase (foo1 x) (erase (foo2 x) (erase (foo3 x) (erase (foo4 x) (erase (foo5 x) (erase (foo6 x) Y)))))) (erase (foo6 x) (erase (foo2 x) (erase (foo4 x) (erase (foo3 x) (erase (foo5 x) Y)))))))))) ;; bzo - still need lots of theorems, e.g., erases of sets, and so forth. ;; Here is another version of "erase" that does more of what we ;; probably want from such a function. Following execution of (remove ;; path dtree), path will not be in the "gkeys" of the dtree. (defund remove (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defthm remove-of-dtreefix (equal (remove path (dtreefix dtree)) (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm dtreep-of-remove (dtreep (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm localdeps-of-remove (equal (localdeps (remove path dtree)) (SET::emptyset)) :hints(("Goal" :in-theory (enable remove)))) (defthm remove-from-empty-dtree (equal (dtree::remove path dtree::*default*) dtree::*default*) :hints (("Goal" :in-theory (enable dtree::remove)))) (defun cdr? (x) (if (consp x) (cdr x) nil)) (set-irrelevant-formals-ok t) (defun remove-induction (other path dtree) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove-induction (cdr? other) (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defcong list::equiv equal (remove path dtree) 1 :hints(("Goal" :in-theory (enable remove) :induct (remove-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (remove path dtree) 2 :hints(("Goal" :in-theory (enable remove)))) (defthm open-in (implies (consp path) (equal (in path dtree) (AND (MAP::IN (CAR PATH) (CHILDREN DTREE)) (IN (CDR PATH) (MAP::GET (CAR PATH) (CHILDREN DTREE)))))) :hints (("goal" :in-theory (enable in)))) (defthm open-dominates (implies (consp path::x) (equal (PATH::DOMINATES PATH::X PATH::Y) (OR (NOT (CONSP PATH::X)) (AND (CONSP PATH::Y) (EQUAL (CAR PATH::X) (CAR PATH::Y)) (PATH::DOMINATES (CDR PATH::X) (CDR PATH::Y))))))) (defthm remove-induction-is-remove (equal (remove-induction ipath epath dtree) (remove epath dtree)) :hints (("goal" :induct (remove-induction ipath epath dtree) :in-theory (enable remove)))) ;; What does (hooey ipath epath dtree) mean? First there are the ;; nuisance cases: ;; ;; 1. Both ipath and epath are atoms, or ;; 2. Just ipath is an atom. ;; ;; The meat of the defun is the following case ;; ;; 3. Both epath and ipath are CONSPs: Get the value associated with ;; ipath in dtree. Take the tail of epath beyond the length of ;; ipath and remove it from the value above. The result is not ;; an empty map. ;; ;; The intuition seems to be that there is more stored at ipath in dtree ;; than can be taken away by removing the tail of epath. (defund hooey (ipath epath dtree) (if (path::dominates epath ipath) ;; 1. and therefore (not (consp epath)) (not (consp ipath)) (or ;; 2. and therefore (consp epath) (not (consp ipath)) ;; 3. (not (map::empty (children (remove (nthcdr (len ipath) epath) (get ipath dtree)))))))) (in-theory (disable open-dominates )) (defthmd open-nthcdr (implies (not (zp n)) (equal (nthcdr n l) (NTHCDR (+ N -1) (CDR L)))) :hints (("goal" :in-theory (enable nthcdr)))) (defthmd in-to-hooey (implies (and (in ipath dtree) (not (path::diverge epath ipath))) (equal (in ipath (remove epath dtree)) (hooey ipath epath dtree))) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable hooey get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable open-nthcdr path::diverge path::dominates in remove))))) (defthmd in-remove-1 (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (in ipath (remove epath dtree))) nil)) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable nthcdr hooey path::diverge path::dominates in remove))))) (defthm in-remove (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (hooey ipath epath dtree)) nil)) :hints (("goal" :in-theory (enable in-to-hooey) :use in-remove-1))) (defthm subset-domain-remove (set::subset (domain (remove path dtree)) (domain dtree))) (defthm remove-when-non-consp-one (implies (not (consp path)) (equal (remove path dtree) *default*)) :hints(("Goal" :in-theory (enable remove)))) ;; Not true, hence joed. #+joe (defthm remove-when-not-in (implies (not (in path dtree)) (equiv (remove path dtree) dtree)) :hints(("Goal" :in-theory (enable remove in)))) (defthm remove-path-from-leaf (equal (remove path (leaf v)) *default*) :hints (("Goal" :expand (remove path (leaf v)) :do-not-induct t))) (in-theory (disable dtree::open-in)) (verify-guards remove)
true
#|-*-Lisp-*-=================================================================|# #| |# #| coi: Computational Object Inference |# #| |# #|===========================================================================|# ;; Dependency Trees for Data Dependency Analysis ;; PI:NAME:<NAME>END_PI ;; ;; ;; erase.lisp ;; ;; Introduces erase, the function for removing paths from dtrees. (in-package "DTREE") (include-book "set") (include-book "../paths/dominates") (include-book "../paths/diverge") (local (include-book "arithmetic/top-with-meta" :dir :system)) ;; Here is the erase function. It operates on dtrees, and handles its own ;; recursion down into the children, which is sort of nice because it is ;; similar to the recursive schemes of "in" or "get" (defund erase (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm erase-of-dtreefix (equal (erase path (dtreefix dtree)) (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm dtreep-of-erase (dtreep (erase path dtree)) :hints(("Goal" :in-theory (enable erase)))) (defthm localdeps-of-erase (equal (localdeps (erase path dtree)) (if (atom path) (SET::emptyset) (localdeps dtree))) :hints(("Goal" :in-theory (enable erase)))) (verify-guards erase) ;; Congruences for Erase ;; ;; We show that erase produces EQUAL results whenever it is given path-equal ;; paths on some dtree, and that it produces EQUIV! results whenever it is ;; applied to some path on EQUIV! dtrees. ;; ;; Note that it is NOT true that "!-less" equiv is a congruence over erase. ;; Imagine, for example, the dtrees x and y, each with the same child who has ;; dependencies { x1 }. If x has localdeps { x1, x2 } and y has localdeps { x2 ;; }, then x and y are equiv (but not equiv!). But in this event, erasing the ;; child from both trees will result in non-equiv trees! This discovery led us ;; to introduce the more strict equiv! relation. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defcong list::equiv equal (erase path dtree) 1 :hints(("Goal" :in-theory (enable erase) :induct (erase-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (erase path dtree) 2 :hints(("Goal" :in-theory (enable erase)))) ;; Membership/Domains After Erasure ;; ;; In the following rule, we show how how membership in the tree is affected by ;; erasing some node in the tree. I wondered for awhile if there is some ;; better way to explain this, but now I think this rule is probably about what ;; we want. After all, anything we come up with to describe how the domain ;; itself is changed would need a new recursive function that would probably be ;; somewhat difficult to reason about. This fact about membership still ;; describes, in a complete sense, the shape of the resulting domain, it's just ;; that you will need to reason in terms of membership later, as well. (defun erase-induction (other path dtree) (if (or (atom other) (atom path)) *default* (let ((children (children dtree))) (rawdtree (localdeps dtree) (cond #+erase ((atom (cdr path)) (map::erase (car path) children)) ((map::in (car path) children) (map::set (car path) (erase-induction (cdr other) (cdr path) (map::get (car path) children)) children)) (t children)))))) (defthm in-erase (equal (in ipath (erase epath dtree)) (and (or (not (PATH::dominates epath ipath)) (PATH::dominates ipath epath)) (in ipath dtree))) :hints(("Goal" :in-theory (enable path::dominates in erase) :induct (erase-induction ipath epath dtree)))) (defthm in-of-erase-same (equal (in path (erase path dtree)) (in path dtree))) (defthm in-erase-2 (implies (in ipath (erase epath dtree)) (in ipath dtree))) (defthm subset-domain-erase (set::subset (domain (erase path dtree)) (domain dtree))) ;; Standard Erasure Cancellation ;; ;; We adapt the rules in maps.lisp to suit our new erase function. We provide ;; two rules, one which cancels erasures when we know they are irrelevant, and ;; one which moves erasures next to one another based on the term order. The ;; reordering rule isn't provided until later in this file. (defthm erase-when-non-consp-one (implies (not (consp path)) (equal (erase path dtree) *default*)) :hints(("Goal" :in-theory (enable erase)))) (defthm erase-when-not-in (implies (not (in path dtree)) (equiv (erase path dtree) dtree)) :hints(("Goal" :in-theory (enable erase in)))) ;; Get After Erasure ;; ;; Erasure can impact the retrieved values from a get in a number of ways. ;; Suppose we are looking up "lpath" after erasing "epath". ;; ;; 1. If epath dominated lpath, then lpath has also been erased because it was ;; a child of epath. So, in that case, the get retrieves the default ;; value. ;; ;; 2. If epath and lpath diverge, i.e., if neither dominates the other, then ;; lpath is not affected by erasing epath, and we have no change whatsoever. ;; ;; 3. If lpath dominates epath, then a portion of lpath has been erased. We ;; can actually describe the result using nthcdr, but it is a rather ugly rule ;; as you can see below. ;; ;; We will now prove each of these rules individually, with the appropriate ;; hypotheses about domination. ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-epath-dominates (implies (PATH::dominates epath gpath) (equal (get gpath (erase epath dtree)) *default*)) :hints(("Goal" :in-theory (enable erase PATH::DOMINATES get) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-diverge (implies (PATH::diverge gpath epath) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; note: they are truly equal in this case, not just equiv! (defthm get-of-erase-when-neither-dominates (implies (and (not (PATH::dominates gpath epath)) (not (PATH::dominates epath gpath))) (equal (get gpath (erase epath dtree)) (get gpath dtree))) :hints(("Goal" :in-theory (disable get-of-erase-when-diverge) :use (:instance get-of-erase-when-diverge)))) ;; note: they are not truly equal in this case, only equiv! (defthm get-of-erase-when-gpath-dominates (implies (PATH::dominates gpath epath) (equiv (get gpath (erase epath dtree)) (erase (nthcdr (len gpath) epath) (get gpath dtree)))) :hints(("Goal" :in-theory (enable get erase) :induct (erase-induction gpath epath dtree)))) ;; We now combine the individual cases into a case-splitting rule capable of ;; rewriting any (get path1 (erase path2 dtree)) term that might arise. ;; ;; I was hesitant to put this rule in, because it seems overly-aggressive. Its ;; name reflects this, so hopefully it should stand out if/when it causes ;; problems, and people can just disable it. ;; ;; This rule subsumes get-erase-dominator, get-erase-dominated, and ;; get-erase-divergent, but I leave those enabled so if you disable this, ;; you can still reason about the particular cases if they arise. (defthm get-of-erase-with-aggressive-case-splitting (equiv (get gpath (erase epath dtree)) (if (PATH::dominates gpath epath) (erase (nthcdr (len gpath) epath) (get gpath dtree)) (if (PATH::dominates epath gpath) *default* (get gpath dtree))))) ;; Deps After Erasure ;; ;; Much like domains, it seems that there are few good rules that we can write ;; about deps after erasure directly. However, between the rules in-erase and ;; get-erase, we should still be able to describe the deps in a membership ;; oriented fashion. This might be sometimes complicated, because of the need ;; to reason about an "existential" sort of property. (defthm in-deps-when-in-deps-of-erase (implies (set::in a (deps (erase path dtree))) (set::in a (deps dtree))) :hints(("Goal" :in-theory (disable in-localdeps-of-get-depsource) :use ((:instance in-localdeps-of-get-depsource (a a) (dtree (erase path dtree))) (:instance in-deps-when-in-localdeps-of-get (a a) (path (depsource a (erase path dtree))) (dtree dtree)))))) (defthm subset-of-deps-of-erase-with-deps (set::subset (deps (erase path dtree)) (deps dtree))) ;; Erase After Erase Reordering ;; ;; This proof goes through automatically using the pick a point method, which ;; is quite nice since I had spent some time trying to prove it inductively ;; without success. This is essentially the same as the "restrained" approach ;; to reducing erase/erase nests described in maps.lisp. (defthm erase-of-erase (equiv (erase path1 (erase path2 dtree)) (erase path2 (erase path1 dtree))) :rule-classes ((:rewrite :loop-stopper ((path1 path2 set)))) :hints(("Goal" :in-theory (enable equiv)))) (defthm erase-is-idempotent (equiv (erase path (erase path dtree)) (erase path dtree)) :hints(("goal" :in-theory (enable equiv)))) (local (encapsulate () ;; This is a test to ensure that our erasure strategy seems to be working as ;; intended. Don't remove this just becuase it has no effect on the logical ;; world! (local (encapsulate (((foo1 *) => *) ((foo2 *) => *) ((foo3 *) => *) ((foo4 *) => *) ((foo5 *) => *) ((foo6 *) => *)) (local (defun foo1 (x) x)) (local (defun foo2 (x) x)) (local (defun foo3 (x) x)) (local (defun foo4 (x) x)) (local (defun foo5 (x) x)) (local (defun foo6 (x) x)) (defthm test-constraint (equal (foo1 x) (foo3 x))))) (local (defthm test-erasure-reductions (equiv (erase (foo1 x) (erase (foo2 x) (erase (foo3 x) (erase (foo4 x) (erase (foo5 x) (erase (foo6 x) Y)))))) (erase (foo6 x) (erase (foo2 x) (erase (foo4 x) (erase (foo3 x) (erase (foo5 x) Y)))))))))) ;; bzo - still need lots of theorems, e.g., erases of sets, and so forth. ;; Here is another version of "erase" that does more of what we ;; probably want from such a function. Following execution of (remove ;; path dtree), path will not be in the "gkeys" of the dtree. (defund remove (path dtree) (declare (xargs :guard (dtreep dtree) :verify-guards nil)) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defthm remove-of-dtreefix (equal (remove path (dtreefix dtree)) (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm dtreep-of-remove (dtreep (remove path dtree)) :hints(("Goal" :in-theory (enable remove)))) (defthm localdeps-of-remove (equal (localdeps (remove path dtree)) (SET::emptyset)) :hints(("Goal" :in-theory (enable remove)))) (defthm remove-from-empty-dtree (equal (dtree::remove path dtree::*default*) dtree::*default*) :hints (("Goal" :in-theory (enable dtree::remove)))) (defun cdr? (x) (if (consp x) (cdr x) nil)) (set-irrelevant-formals-ok t) (defun remove-induction (other path dtree) (if (atom path) *default* (let ((children (children dtree)) (localdeps (set::emptyset))) (if (map::in (car path) children) (let ((subtree (remove-induction (cdr? other) (cdr path) (map::get (car path) children)))) (let ((children (map::erase (car path) children))) (cond ((map::empty (children subtree)) (rawdtree localdeps (map::erase (car path) children))) (t (rawdtree localdeps (map::set (car path) subtree children)))))) (rawdtree localdeps children))))) (defcong list::equiv equal (remove path dtree) 1 :hints(("Goal" :in-theory (enable remove) :induct (remove-induction path LIST::path-equiv dtree)))) (defcong equiv equiv (remove path dtree) 2 :hints(("Goal" :in-theory (enable remove)))) (defthm open-in (implies (consp path) (equal (in path dtree) (AND (MAP::IN (CAR PATH) (CHILDREN DTREE)) (IN (CDR PATH) (MAP::GET (CAR PATH) (CHILDREN DTREE)))))) :hints (("goal" :in-theory (enable in)))) (defthm open-dominates (implies (consp path::x) (equal (PATH::DOMINATES PATH::X PATH::Y) (OR (NOT (CONSP PATH::X)) (AND (CONSP PATH::Y) (EQUAL (CAR PATH::X) (CAR PATH::Y)) (PATH::DOMINATES (CDR PATH::X) (CDR PATH::Y))))))) (defthm remove-induction-is-remove (equal (remove-induction ipath epath dtree) (remove epath dtree)) :hints (("goal" :induct (remove-induction ipath epath dtree) :in-theory (enable remove)))) ;; What does (hooey ipath epath dtree) mean? First there are the ;; nuisance cases: ;; ;; 1. Both ipath and epath are atoms, or ;; 2. Just ipath is an atom. ;; ;; The meat of the defun is the following case ;; ;; 3. Both epath and ipath are CONSPs: Get the value associated with ;; ipath in dtree. Take the tail of epath beyond the length of ;; ipath and remove it from the value above. The result is not ;; an empty map. ;; ;; The intuition seems to be that there is more stored at ipath in dtree ;; than can be taken away by removing the tail of epath. (defund hooey (ipath epath dtree) (if (path::dominates epath ipath) ;; 1. and therefore (not (consp epath)) (not (consp ipath)) (or ;; 2. and therefore (consp epath) (not (consp ipath)) ;; 3. (not (map::empty (children (remove (nthcdr (len ipath) epath) (get ipath dtree)))))))) (in-theory (disable open-dominates )) (defthmd open-nthcdr (implies (not (zp n)) (equal (nthcdr n l) (NTHCDR (+ N -1) (CDR L)))) :hints (("goal" :in-theory (enable nthcdr)))) (defthmd in-to-hooey (implies (and (in ipath dtree) (not (path::diverge epath ipath))) (equal (in ipath (remove epath dtree)) (hooey ipath epath dtree))) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable hooey get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable open-nthcdr path::diverge path::dominates in remove))))) (defthmd in-remove-1 (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (in ipath (remove epath dtree))) nil)) :hints(("Goal" :do-not '(generalize eliminate-destructors) :in-theory (enable get nthcdr path::diverge path::dominates in remove) :induct (remove-induction ipath epath dtree)) (and acl2::stable-under-simplificationp '(:in-theory (enable nthcdr hooey path::diverge path::dominates in remove))))) (defthm in-remove (equal (in ipath (remove epath dtree)) (if (in ipath dtree) (if (path::diverge epath ipath) t (hooey ipath epath dtree)) nil)) :hints (("goal" :in-theory (enable in-to-hooey) :use in-remove-1))) (defthm subset-domain-remove (set::subset (domain (remove path dtree)) (domain dtree))) (defthm remove-when-non-consp-one (implies (not (consp path)) (equal (remove path dtree) *default*)) :hints(("Goal" :in-theory (enable remove)))) ;; Not true, hence joed. #+joe (defthm remove-when-not-in (implies (not (in path dtree)) (equiv (remove path dtree) dtree)) :hints(("Goal" :in-theory (enable remove in)))) (defthm remove-path-from-leaf (equal (remove path (leaf v)) *default*) :hints (("Goal" :expand (remove path (leaf v)) :do-not-induct t))) (in-theory (disable dtree::open-in)) (verify-guards remove)
[ { "context": "SSIBILITY OF SUCH DAMAGE.\n\n; Original Author(s):\n; Shilpi Goel <[email protected]>\n\n(in-package \"X86IS", "end": 1871, "score": 0.9998709559440613, "start": 1860, "tag": "NAME", "value": "Shilpi Goel" }, { "context": "GE.\n\n; Original Author(s):\n; Shilpi Goel <[email protected]>\n\n(in-package \"X86ISA\")\n\n(include-book \"../top\" :", "end": 1900, "score": 0.9999298453330994, "start": 1881, "tag": "EMAIL", "value": "[email protected]" } ]
books/projects/x86isa/tools/execution/examples/fibonacci32.lisp
nadezhin/acl2
0
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; Copyright (C) 2018, Centaur Technology, Inc. ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; Shilpi Goel <[email protected]> (in-package "X86ISA") (include-book "../top" :ttags :all) (defsection fibonacci32-cosim :parents (concrete-simulation-examples) :short "Test to check if a 32-bit fibonacci program behaves as expected" ) (local (xdoc::set-default-parents fibonacci32-cosim)) ;; (include-book "centaur/memoize/old/profile" :dir :system) ;; ====================================================================== #|| // Source program (in C): // gcc -m32 -O2 -o fib32.o fib32.c #include <stdio.h> #include <stdlib.h> long fib (int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } else return (fib(n-1) + fib(n-2)); } int main (int argc, char *argv[], char *env[]) { if (argc != 2) { printf("Error: Need one arg.\n"); exit(1); } int n = atoi(argv[1]); printf("fib(%d) = %ld\n", n, fib(n)); } ||# ;; ---------------------------------------------------------------------- ;; The following ACL2 representation of the fibonacci binary (with the ;; assembly instructions preserved as comments) was obtained from the ;; fibonacci machine-code program. ;; fib32.o: ;; (__TEXT,__text) section ;; _fib: ;; 00001e90 55 ; pushl %ebp ;; 00001e91 89 e5 ; movl %esp, %ebp ;; 00001e93 57 ; pushl %edi ;; 00001e94 56 ; pushl %esi ;; 00001e95 83 ec 10 ; subl $0x10, %esp ;; 00001e98 8b 7d 08 ; movl 0x8(%ebp), %edi ;; 00001e9b 85 ff ; testl %edi, %edi ;; 00001e9d 7e 26 ; jle 0x1ec5 ;; 00001e9f b8 01 00 00 00 ; movl $0x1, %eax ;; 00001ea4 83 ff 01 ; cmpl $0x1, %edi ;; 00001ea7 74 1e je ; 0x1ec7 ;; 00001ea9 8d 47 ff ; leal -0x1(%edi), %eax ;; 00001eac 89 04 24 ; movl %eax, (%esp) ;; 00001eaf e8 dc ff ff ff ; calll _fib ;; 00001eb4 89 c6 ; movl %eax, %esi ;; 00001eb6 83 c7 fe ; addl $-0x2, %edi ;; 00001eb9 89 3c 24 ; movl %edi, (%esp) ;; 00001ebc e8 cf ff ff ff ; calll _fib ;; 00001ec1 01 f0 ; addl %esi, %eax ;; 00001ec3 eb 02 ; jmp 0x1ec7 ;; 00001ec5 31 c0 ; xorl %eax, %eax ;; 00001ec7 83 c4 10 ; addl $0x10, %esp ;; 00001eca 5e ; popl %esi ;; 00001ecb 5f ; popl %edi ;; 00001ecc 5d ; popl %ebp ;; 00001ecd c3 ; retl ;; 00001ece 66 90 ; nop ;; _main: ;; 00001ed0 55 pushl %ebp ;; 00001ed1 89 e5 movl %esp, %ebp ;; 00001ed3 57 pushl %edi ;; 00001ed4 56 pushl %esi ;; 00001ed5 83 ec 10 subl $0x10, %esp ;; 00001ed8 e8 00 00 00 00 calll 0x1edd ;; 00001edd 5f popl %edi ;; 00001ede 83 7d 08 02 cmpl $0x2, 0x8(%ebp) ;; 00001ee2 75 37 jne 0x1f1b ;; 00001ee4 8b 45 0c movl 0xc(%ebp), %eax ;; 00001ee7 8b 40 04 movl 0x4(%eax), %eax ;; 00001eea 89 04 24 movl %eax, (%esp) ;; 00001eed e8 46 00 00 00 calll 0x1f38 ;; 00001ef2 89 c6 movl %eax, %esi ;; 00001ef4 89 34 24 movl %esi, (%esp) ;; 00001ef7 e8 94 ff ff ff calll 0x1e90 ;; 00001efc 89 44 24 08 movl %eax, 0x8(%esp) ;; 00001f00 89 74 24 04 movl %esi, 0x4(%esp) ;; 00001f04 8d 87 b3 00 00 00 leal 0xb3(%edi), %eax ;; 00001f0a 89 04 24 movl %eax, (%esp) ;; 00001f0d e8 32 00 00 00 calll 0x1f44 ;; 00001f12 31 c0 xorl %eax, %eax ;; 00001f14 83 c4 10 addl $0x10, %esp ;; 00001f17 5e popl %esi ;; 00001f18 5f popl %edi ;; 00001f19 5d popl %ebp ;; 00001f1a c3 retl ;; 00001f1b 8d 87 c3 00 00 00 leal 0xc3(%edi), %eax ;; 00001f21 89 04 24 movl %eax, (%esp) ;; 00001f24 e8 21 00 00 00 calll 0x1f4a ;; 00001f29 c7 04 24 01 00 00 00 movl $0x1, (%esp) ;; 00001f30 e8 09 00 00 00 calll 0x1f3e ;; 00001f35 83 ec 04 subl $0x4, %esp (defconst *fibonacci-bytes* ;; (__TEXT,__text) section ;; _fib: (list #x55 ; pushl %ebp #x89 #xe5 ; movl %esp, %ebp #x57 ; pushl %edi #x56 ; pushl %esi #x83 #xec #x10 ; subl $0x10, %esp #x8b #x7d #x08 ; movl 0x8(%ebp), %edi #x85 #xff ; testl %edi, %edi #x7e #x26 ; jle 0x1ec5 #xb8 #x01 #x00 #x00 #x00 ; movl $0x1, %eax #x83 #xff #x01 ; cmpl $0x1, %edi #x74 #x1e ; je 0x1ec7 #x8d #x47 #xff ; leal -0x1(%edi), %eax #x89 #x04 #x24 ; movl %eax, (%esp) #xe8 #xdc #xff #xff #xff ; calll _fib #x89 #xc6 ; movl %eax, %esi #x83 #xc7 #xfe ; addl $-0x2, %edi #x89 #x3c #x24 ; movl %edi, (%esp) #xe8 #xcf #xff #xff #xff ; calll _fib #x01 #xf0 ; addl %esi, %eax #xeb #x02 ; jmp 0x1ec7 #x31 #xc0 ; xorl %eax, %eax #x83 #xc4 #x10 ; addl $0x10, %esp #x5e ; popl %esi #x5f ; popl %edi #x5d ; popl %ebp #xc3 ; retl #x66 #x90 ; nop )) (defconst *some-main-bytes* (list ;; ... ;; _main: #x89 #xc6 ;; movl %eax, %esi 00001ef2 #x89 #x34 #x24 ;; movl %esi, (%esp) 00001ef4 #xe8 #x94 #xff #xff #xff ;; calll 0x1e90 00001ef7 #x89 #x44 #x24 #x08 ;; movl %eax, 0x8(%esp) 00001efc )) (define make-fib32-addr-alst (start-addr halt-addr) :measure (nfix (- halt-addr start-addr)) (if (or (not (integerp start-addr)) (not (integerp halt-addr)) (not (< start-addr halt-addr))) (list halt-addr) (cons start-addr (make-fib32-addr-alst (1+ start-addr) halt-addr)))) (defconst *fibonacci32-binary* (append (pairlis$ (make-fib32-addr-alst #x00001e90 #x00001ecf) *fibonacci-bytes*) (pairlis$ (make-fib32-addr-alst #x00001ef2 #x00001eff) *some-main-bytes*))) (define fib32 ((n natp)) ;; Specification Function in ACL2 (declare (xargs :guard (natp n))) (cond ((zp n) 0) ((eql n 1) 1) (t (+ (fib32 (- n 1)) (fib32 (- n 2)))))) ;; ====================================================================== (defconst *fib32-xrun-limit* #u_100_000_000_000) (define check-fib32-output ((input :type (unsigned-byte 8)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (x86 "Output x86 State")) (cond ((or (fault x86) (not (equal (ms x86) `((x86-fetch-decode-execute-halt :rip ,halt-address))))) (cw "~|(ms x86) = ~x0 (fault x86) = ~x1~%" (ms x86) (fault x86))) (t (let ((expected (fib32 input))) (cond ((equal (rgfi *eax* x86) expected) (prog2$ (cw "~|(x86isa-fib ~x0) was correctly computed as ~x1.~%" input expected) t)) (t (prog2$ (cw "~|(x86isa-fib ~x0) = ~x1, but eax is ~x2.~%" input expected (rgfi *eax* x86)) t))))))) (define x86isa-one-fib32-cosim ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (b* ((ctx __function__) ((mv flg x86) (init-x86-state ;; Status (MS and fault field) nil start-address ;; Initial values of General-Purpose Registers `((#.*RAX* . ,input) (#.*RBX* . #xbffff954) (#.*RCX* . #xffffffff) (#.*RDX* . ,input) (#.*RDI* . #x00001edd) (#.*RSI* . ,input) (#.*RBP* . #xbffff898) (#.*RSP* . #xbffff880)) ;; Initial values of Control Registers (already initialized in ;; init-sys-view) nil ;; Initial values of Model-Specific Registers (already initialized ;; in init-sys-view) nil ;; seg-visibles `((#.*cs* . #x0000001b) (#.*ss* . #x00000023) (#.*ds* . #x00000023)) ;; For initial seg-hidden values: ;; See segment-base-and-bounds. ;; See add-to-*sp. ;; seg-hidden base (acons #.*cs* 0 (acons #.*ss* 0 (acons #.*ds* 0 nil))) ;; seg-hidden limit (acons #.*cs* #uxffff (acons #.*ss* #uxffff_ffff (acons #.*ds* #uxffff_ffff nil))) ;; seg-hidden attr (acons #.*cs* (!code-segment-descriptor-attributesBits->d 1 0) ;; op size = 4 (acons #.*ss* (!data-segment-descriptor-attributesBits->w 1 0) ;; writable stack segment nil)) ;; Initial value of the Rflags Register #x282 ;; Initial memory image (acons #xbffff880 ;; init value of esp (i.e., just before the call to _fib.) input *fibonacci32-binary*) ;; x86 state x86)) ((when flg) (let ((x86 (!!ms-fresh :init-x86-state-error flg))) (mv nil 0 x86))) ((mv steps x86) (time$ (x86-run-halt-count halt-address xrun-limit x86 xrun-limit))) (ok? (check-fib32-output input halt-address x86)) ((unless ok?) (mv nil 0 x86))) (mv t steps x86))) (define run-x86isa-fib32 ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (if (zp input) (mv t 0 x86) (b* (((mv flg steps x86) (x86isa-one-fib32-cosim (1- input) start-address halt-address xrun-limit x86)) ((unless flg) (cw "~% Mismatch found!~%") (mv flg 0 x86)) (- (cw "Input: ~p0 Steps: ~p1 ~%" input steps))) (run-x86isa-fib32 (1- input) start-address halt-address xrun-limit x86)))) ;; ---------------------------------------------------------------------- ;; For efficient execution of 64-BIT-MODEP and SEGMENT-BASE-AND-BOUNDS: (local (include-book "std/bitsets/bignum-extract-opt" :dir :system)) ;; One run: ;; (b* ((start-address #x00001ef7) ;; address of call _fib (in main) ;; (halt-address #x00001efc) ;; address of instruction following call _fib (in main) ;; (input 30) ;; ((mv flg steps x86) ;; (x86isa-one-fib32-cosim ;; input start-address halt-address *fib32-xrun-limit* x86))) ;; (mv flg steps x86)) ;; Multiple runs: (acl2::assert!-stobj (b* ((start-address #x00001ef7) (halt-address #x00001efc) (input 20) ((mv flg & x86) (run-x86isa-fib32 input start-address halt-address *fib32-xrun-limit* x86))) (mv flg x86)) x86) ;; ----------------------------------------------------------------------
27252
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; Copyright (C) 2018, Centaur Technology, Inc. ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; <NAME> <<EMAIL>> (in-package "X86ISA") (include-book "../top" :ttags :all) (defsection fibonacci32-cosim :parents (concrete-simulation-examples) :short "Test to check if a 32-bit fibonacci program behaves as expected" ) (local (xdoc::set-default-parents fibonacci32-cosim)) ;; (include-book "centaur/memoize/old/profile" :dir :system) ;; ====================================================================== #|| // Source program (in C): // gcc -m32 -O2 -o fib32.o fib32.c #include <stdio.h> #include <stdlib.h> long fib (int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } else return (fib(n-1) + fib(n-2)); } int main (int argc, char *argv[], char *env[]) { if (argc != 2) { printf("Error: Need one arg.\n"); exit(1); } int n = atoi(argv[1]); printf("fib(%d) = %ld\n", n, fib(n)); } ||# ;; ---------------------------------------------------------------------- ;; The following ACL2 representation of the fibonacci binary (with the ;; assembly instructions preserved as comments) was obtained from the ;; fibonacci machine-code program. ;; fib32.o: ;; (__TEXT,__text) section ;; _fib: ;; 00001e90 55 ; pushl %ebp ;; 00001e91 89 e5 ; movl %esp, %ebp ;; 00001e93 57 ; pushl %edi ;; 00001e94 56 ; pushl %esi ;; 00001e95 83 ec 10 ; subl $0x10, %esp ;; 00001e98 8b 7d 08 ; movl 0x8(%ebp), %edi ;; 00001e9b 85 ff ; testl %edi, %edi ;; 00001e9d 7e 26 ; jle 0x1ec5 ;; 00001e9f b8 01 00 00 00 ; movl $0x1, %eax ;; 00001ea4 83 ff 01 ; cmpl $0x1, %edi ;; 00001ea7 74 1e je ; 0x1ec7 ;; 00001ea9 8d 47 ff ; leal -0x1(%edi), %eax ;; 00001eac 89 04 24 ; movl %eax, (%esp) ;; 00001eaf e8 dc ff ff ff ; calll _fib ;; 00001eb4 89 c6 ; movl %eax, %esi ;; 00001eb6 83 c7 fe ; addl $-0x2, %edi ;; 00001eb9 89 3c 24 ; movl %edi, (%esp) ;; 00001ebc e8 cf ff ff ff ; calll _fib ;; 00001ec1 01 f0 ; addl %esi, %eax ;; 00001ec3 eb 02 ; jmp 0x1ec7 ;; 00001ec5 31 c0 ; xorl %eax, %eax ;; 00001ec7 83 c4 10 ; addl $0x10, %esp ;; 00001eca 5e ; popl %esi ;; 00001ecb 5f ; popl %edi ;; 00001ecc 5d ; popl %ebp ;; 00001ecd c3 ; retl ;; 00001ece 66 90 ; nop ;; _main: ;; 00001ed0 55 pushl %ebp ;; 00001ed1 89 e5 movl %esp, %ebp ;; 00001ed3 57 pushl %edi ;; 00001ed4 56 pushl %esi ;; 00001ed5 83 ec 10 subl $0x10, %esp ;; 00001ed8 e8 00 00 00 00 calll 0x1edd ;; 00001edd 5f popl %edi ;; 00001ede 83 7d 08 02 cmpl $0x2, 0x8(%ebp) ;; 00001ee2 75 37 jne 0x1f1b ;; 00001ee4 8b 45 0c movl 0xc(%ebp), %eax ;; 00001ee7 8b 40 04 movl 0x4(%eax), %eax ;; 00001eea 89 04 24 movl %eax, (%esp) ;; 00001eed e8 46 00 00 00 calll 0x1f38 ;; 00001ef2 89 c6 movl %eax, %esi ;; 00001ef4 89 34 24 movl %esi, (%esp) ;; 00001ef7 e8 94 ff ff ff calll 0x1e90 ;; 00001efc 89 44 24 08 movl %eax, 0x8(%esp) ;; 00001f00 89 74 24 04 movl %esi, 0x4(%esp) ;; 00001f04 8d 87 b3 00 00 00 leal 0xb3(%edi), %eax ;; 00001f0a 89 04 24 movl %eax, (%esp) ;; 00001f0d e8 32 00 00 00 calll 0x1f44 ;; 00001f12 31 c0 xorl %eax, %eax ;; 00001f14 83 c4 10 addl $0x10, %esp ;; 00001f17 5e popl %esi ;; 00001f18 5f popl %edi ;; 00001f19 5d popl %ebp ;; 00001f1a c3 retl ;; 00001f1b 8d 87 c3 00 00 00 leal 0xc3(%edi), %eax ;; 00001f21 89 04 24 movl %eax, (%esp) ;; 00001f24 e8 21 00 00 00 calll 0x1f4a ;; 00001f29 c7 04 24 01 00 00 00 movl $0x1, (%esp) ;; 00001f30 e8 09 00 00 00 calll 0x1f3e ;; 00001f35 83 ec 04 subl $0x4, %esp (defconst *fibonacci-bytes* ;; (__TEXT,__text) section ;; _fib: (list #x55 ; pushl %ebp #x89 #xe5 ; movl %esp, %ebp #x57 ; pushl %edi #x56 ; pushl %esi #x83 #xec #x10 ; subl $0x10, %esp #x8b #x7d #x08 ; movl 0x8(%ebp), %edi #x85 #xff ; testl %edi, %edi #x7e #x26 ; jle 0x1ec5 #xb8 #x01 #x00 #x00 #x00 ; movl $0x1, %eax #x83 #xff #x01 ; cmpl $0x1, %edi #x74 #x1e ; je 0x1ec7 #x8d #x47 #xff ; leal -0x1(%edi), %eax #x89 #x04 #x24 ; movl %eax, (%esp) #xe8 #xdc #xff #xff #xff ; calll _fib #x89 #xc6 ; movl %eax, %esi #x83 #xc7 #xfe ; addl $-0x2, %edi #x89 #x3c #x24 ; movl %edi, (%esp) #xe8 #xcf #xff #xff #xff ; calll _fib #x01 #xf0 ; addl %esi, %eax #xeb #x02 ; jmp 0x1ec7 #x31 #xc0 ; xorl %eax, %eax #x83 #xc4 #x10 ; addl $0x10, %esp #x5e ; popl %esi #x5f ; popl %edi #x5d ; popl %ebp #xc3 ; retl #x66 #x90 ; nop )) (defconst *some-main-bytes* (list ;; ... ;; _main: #x89 #xc6 ;; movl %eax, %esi 00001ef2 #x89 #x34 #x24 ;; movl %esi, (%esp) 00001ef4 #xe8 #x94 #xff #xff #xff ;; calll 0x1e90 00001ef7 #x89 #x44 #x24 #x08 ;; movl %eax, 0x8(%esp) 00001efc )) (define make-fib32-addr-alst (start-addr halt-addr) :measure (nfix (- halt-addr start-addr)) (if (or (not (integerp start-addr)) (not (integerp halt-addr)) (not (< start-addr halt-addr))) (list halt-addr) (cons start-addr (make-fib32-addr-alst (1+ start-addr) halt-addr)))) (defconst *fibonacci32-binary* (append (pairlis$ (make-fib32-addr-alst #x00001e90 #x00001ecf) *fibonacci-bytes*) (pairlis$ (make-fib32-addr-alst #x00001ef2 #x00001eff) *some-main-bytes*))) (define fib32 ((n natp)) ;; Specification Function in ACL2 (declare (xargs :guard (natp n))) (cond ((zp n) 0) ((eql n 1) 1) (t (+ (fib32 (- n 1)) (fib32 (- n 2)))))) ;; ====================================================================== (defconst *fib32-xrun-limit* #u_100_000_000_000) (define check-fib32-output ((input :type (unsigned-byte 8)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (x86 "Output x86 State")) (cond ((or (fault x86) (not (equal (ms x86) `((x86-fetch-decode-execute-halt :rip ,halt-address))))) (cw "~|(ms x86) = ~x0 (fault x86) = ~x1~%" (ms x86) (fault x86))) (t (let ((expected (fib32 input))) (cond ((equal (rgfi *eax* x86) expected) (prog2$ (cw "~|(x86isa-fib ~x0) was correctly computed as ~x1.~%" input expected) t)) (t (prog2$ (cw "~|(x86isa-fib ~x0) = ~x1, but eax is ~x2.~%" input expected (rgfi *eax* x86)) t))))))) (define x86isa-one-fib32-cosim ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (b* ((ctx __function__) ((mv flg x86) (init-x86-state ;; Status (MS and fault field) nil start-address ;; Initial values of General-Purpose Registers `((#.*RAX* . ,input) (#.*RBX* . #xbffff954) (#.*RCX* . #xffffffff) (#.*RDX* . ,input) (#.*RDI* . #x00001edd) (#.*RSI* . ,input) (#.*RBP* . #xbffff898) (#.*RSP* . #xbffff880)) ;; Initial values of Control Registers (already initialized in ;; init-sys-view) nil ;; Initial values of Model-Specific Registers (already initialized ;; in init-sys-view) nil ;; seg-visibles `((#.*cs* . #x0000001b) (#.*ss* . #x00000023) (#.*ds* . #x00000023)) ;; For initial seg-hidden values: ;; See segment-base-and-bounds. ;; See add-to-*sp. ;; seg-hidden base (acons #.*cs* 0 (acons #.*ss* 0 (acons #.*ds* 0 nil))) ;; seg-hidden limit (acons #.*cs* #uxffff (acons #.*ss* #uxffff_ffff (acons #.*ds* #uxffff_ffff nil))) ;; seg-hidden attr (acons #.*cs* (!code-segment-descriptor-attributesBits->d 1 0) ;; op size = 4 (acons #.*ss* (!data-segment-descriptor-attributesBits->w 1 0) ;; writable stack segment nil)) ;; Initial value of the Rflags Register #x282 ;; Initial memory image (acons #xbffff880 ;; init value of esp (i.e., just before the call to _fib.) input *fibonacci32-binary*) ;; x86 state x86)) ((when flg) (let ((x86 (!!ms-fresh :init-x86-state-error flg))) (mv nil 0 x86))) ((mv steps x86) (time$ (x86-run-halt-count halt-address xrun-limit x86 xrun-limit))) (ok? (check-fib32-output input halt-address x86)) ((unless ok?) (mv nil 0 x86))) (mv t steps x86))) (define run-x86isa-fib32 ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (if (zp input) (mv t 0 x86) (b* (((mv flg steps x86) (x86isa-one-fib32-cosim (1- input) start-address halt-address xrun-limit x86)) ((unless flg) (cw "~% Mismatch found!~%") (mv flg 0 x86)) (- (cw "Input: ~p0 Steps: ~p1 ~%" input steps))) (run-x86isa-fib32 (1- input) start-address halt-address xrun-limit x86)))) ;; ---------------------------------------------------------------------- ;; For efficient execution of 64-BIT-MODEP and SEGMENT-BASE-AND-BOUNDS: (local (include-book "std/bitsets/bignum-extract-opt" :dir :system)) ;; One run: ;; (b* ((start-address #x00001ef7) ;; address of call _fib (in main) ;; (halt-address #x00001efc) ;; address of instruction following call _fib (in main) ;; (input 30) ;; ((mv flg steps x86) ;; (x86isa-one-fib32-cosim ;; input start-address halt-address *fib32-xrun-limit* x86))) ;; (mv flg steps x86)) ;; Multiple runs: (acl2::assert!-stobj (b* ((start-address #x00001ef7) (halt-address #x00001efc) (input 20) ((mv flg & x86) (run-x86isa-fib32 input start-address halt-address *fib32-xrun-limit* x86))) (mv flg x86)) x86) ;; ----------------------------------------------------------------------
true
; X86ISA Library ; Note: The license below is based on the template at: ; http://opensource.org/licenses/BSD-3-Clause ; Contact: ; Centaur Technology Formal Verification Group ; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA. ; http://www.centtech.com/ ; Copyright (C) 2018, Centaur Technology, Inc. ; All rights reserved. ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; o Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; o Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; o Neither the name of the copyright holders nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; Original Author(s): ; PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> (in-package "X86ISA") (include-book "../top" :ttags :all) (defsection fibonacci32-cosim :parents (concrete-simulation-examples) :short "Test to check if a 32-bit fibonacci program behaves as expected" ) (local (xdoc::set-default-parents fibonacci32-cosim)) ;; (include-book "centaur/memoize/old/profile" :dir :system) ;; ====================================================================== #|| // Source program (in C): // gcc -m32 -O2 -o fib32.o fib32.c #include <stdio.h> #include <stdlib.h> long fib (int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } else return (fib(n-1) + fib(n-2)); } int main (int argc, char *argv[], char *env[]) { if (argc != 2) { printf("Error: Need one arg.\n"); exit(1); } int n = atoi(argv[1]); printf("fib(%d) = %ld\n", n, fib(n)); } ||# ;; ---------------------------------------------------------------------- ;; The following ACL2 representation of the fibonacci binary (with the ;; assembly instructions preserved as comments) was obtained from the ;; fibonacci machine-code program. ;; fib32.o: ;; (__TEXT,__text) section ;; _fib: ;; 00001e90 55 ; pushl %ebp ;; 00001e91 89 e5 ; movl %esp, %ebp ;; 00001e93 57 ; pushl %edi ;; 00001e94 56 ; pushl %esi ;; 00001e95 83 ec 10 ; subl $0x10, %esp ;; 00001e98 8b 7d 08 ; movl 0x8(%ebp), %edi ;; 00001e9b 85 ff ; testl %edi, %edi ;; 00001e9d 7e 26 ; jle 0x1ec5 ;; 00001e9f b8 01 00 00 00 ; movl $0x1, %eax ;; 00001ea4 83 ff 01 ; cmpl $0x1, %edi ;; 00001ea7 74 1e je ; 0x1ec7 ;; 00001ea9 8d 47 ff ; leal -0x1(%edi), %eax ;; 00001eac 89 04 24 ; movl %eax, (%esp) ;; 00001eaf e8 dc ff ff ff ; calll _fib ;; 00001eb4 89 c6 ; movl %eax, %esi ;; 00001eb6 83 c7 fe ; addl $-0x2, %edi ;; 00001eb9 89 3c 24 ; movl %edi, (%esp) ;; 00001ebc e8 cf ff ff ff ; calll _fib ;; 00001ec1 01 f0 ; addl %esi, %eax ;; 00001ec3 eb 02 ; jmp 0x1ec7 ;; 00001ec5 31 c0 ; xorl %eax, %eax ;; 00001ec7 83 c4 10 ; addl $0x10, %esp ;; 00001eca 5e ; popl %esi ;; 00001ecb 5f ; popl %edi ;; 00001ecc 5d ; popl %ebp ;; 00001ecd c3 ; retl ;; 00001ece 66 90 ; nop ;; _main: ;; 00001ed0 55 pushl %ebp ;; 00001ed1 89 e5 movl %esp, %ebp ;; 00001ed3 57 pushl %edi ;; 00001ed4 56 pushl %esi ;; 00001ed5 83 ec 10 subl $0x10, %esp ;; 00001ed8 e8 00 00 00 00 calll 0x1edd ;; 00001edd 5f popl %edi ;; 00001ede 83 7d 08 02 cmpl $0x2, 0x8(%ebp) ;; 00001ee2 75 37 jne 0x1f1b ;; 00001ee4 8b 45 0c movl 0xc(%ebp), %eax ;; 00001ee7 8b 40 04 movl 0x4(%eax), %eax ;; 00001eea 89 04 24 movl %eax, (%esp) ;; 00001eed e8 46 00 00 00 calll 0x1f38 ;; 00001ef2 89 c6 movl %eax, %esi ;; 00001ef4 89 34 24 movl %esi, (%esp) ;; 00001ef7 e8 94 ff ff ff calll 0x1e90 ;; 00001efc 89 44 24 08 movl %eax, 0x8(%esp) ;; 00001f00 89 74 24 04 movl %esi, 0x4(%esp) ;; 00001f04 8d 87 b3 00 00 00 leal 0xb3(%edi), %eax ;; 00001f0a 89 04 24 movl %eax, (%esp) ;; 00001f0d e8 32 00 00 00 calll 0x1f44 ;; 00001f12 31 c0 xorl %eax, %eax ;; 00001f14 83 c4 10 addl $0x10, %esp ;; 00001f17 5e popl %esi ;; 00001f18 5f popl %edi ;; 00001f19 5d popl %ebp ;; 00001f1a c3 retl ;; 00001f1b 8d 87 c3 00 00 00 leal 0xc3(%edi), %eax ;; 00001f21 89 04 24 movl %eax, (%esp) ;; 00001f24 e8 21 00 00 00 calll 0x1f4a ;; 00001f29 c7 04 24 01 00 00 00 movl $0x1, (%esp) ;; 00001f30 e8 09 00 00 00 calll 0x1f3e ;; 00001f35 83 ec 04 subl $0x4, %esp (defconst *fibonacci-bytes* ;; (__TEXT,__text) section ;; _fib: (list #x55 ; pushl %ebp #x89 #xe5 ; movl %esp, %ebp #x57 ; pushl %edi #x56 ; pushl %esi #x83 #xec #x10 ; subl $0x10, %esp #x8b #x7d #x08 ; movl 0x8(%ebp), %edi #x85 #xff ; testl %edi, %edi #x7e #x26 ; jle 0x1ec5 #xb8 #x01 #x00 #x00 #x00 ; movl $0x1, %eax #x83 #xff #x01 ; cmpl $0x1, %edi #x74 #x1e ; je 0x1ec7 #x8d #x47 #xff ; leal -0x1(%edi), %eax #x89 #x04 #x24 ; movl %eax, (%esp) #xe8 #xdc #xff #xff #xff ; calll _fib #x89 #xc6 ; movl %eax, %esi #x83 #xc7 #xfe ; addl $-0x2, %edi #x89 #x3c #x24 ; movl %edi, (%esp) #xe8 #xcf #xff #xff #xff ; calll _fib #x01 #xf0 ; addl %esi, %eax #xeb #x02 ; jmp 0x1ec7 #x31 #xc0 ; xorl %eax, %eax #x83 #xc4 #x10 ; addl $0x10, %esp #x5e ; popl %esi #x5f ; popl %edi #x5d ; popl %ebp #xc3 ; retl #x66 #x90 ; nop )) (defconst *some-main-bytes* (list ;; ... ;; _main: #x89 #xc6 ;; movl %eax, %esi 00001ef2 #x89 #x34 #x24 ;; movl %esi, (%esp) 00001ef4 #xe8 #x94 #xff #xff #xff ;; calll 0x1e90 00001ef7 #x89 #x44 #x24 #x08 ;; movl %eax, 0x8(%esp) 00001efc )) (define make-fib32-addr-alst (start-addr halt-addr) :measure (nfix (- halt-addr start-addr)) (if (or (not (integerp start-addr)) (not (integerp halt-addr)) (not (< start-addr halt-addr))) (list halt-addr) (cons start-addr (make-fib32-addr-alst (1+ start-addr) halt-addr)))) (defconst *fibonacci32-binary* (append (pairlis$ (make-fib32-addr-alst #x00001e90 #x00001ecf) *fibonacci-bytes*) (pairlis$ (make-fib32-addr-alst #x00001ef2 #x00001eff) *some-main-bytes*))) (define fib32 ((n natp)) ;; Specification Function in ACL2 (declare (xargs :guard (natp n))) (cond ((zp n) 0) ((eql n 1) 1) (t (+ (fib32 (- n 1)) (fib32 (- n 2)))))) ;; ====================================================================== (defconst *fib32-xrun-limit* #u_100_000_000_000) (define check-fib32-output ((input :type (unsigned-byte 8)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (x86 "Output x86 State")) (cond ((or (fault x86) (not (equal (ms x86) `((x86-fetch-decode-execute-halt :rip ,halt-address))))) (cw "~|(ms x86) = ~x0 (fault x86) = ~x1~%" (ms x86) (fault x86))) (t (let ((expected (fib32 input))) (cond ((equal (rgfi *eax* x86) expected) (prog2$ (cw "~|(x86isa-fib ~x0) was correctly computed as ~x1.~%" input expected) t)) (t (prog2$ (cw "~|(x86isa-fib ~x0) = ~x1, but eax is ~x2.~%" input expected (rgfi *eax* x86)) t))))))) (define x86isa-one-fib32-cosim ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (b* ((ctx __function__) ((mv flg x86) (init-x86-state ;; Status (MS and fault field) nil start-address ;; Initial values of General-Purpose Registers `((#.*RAX* . ,input) (#.*RBX* . #xbffff954) (#.*RCX* . #xffffffff) (#.*RDX* . ,input) (#.*RDI* . #x00001edd) (#.*RSI* . ,input) (#.*RBP* . #xbffff898) (#.*RSP* . #xbffff880)) ;; Initial values of Control Registers (already initialized in ;; init-sys-view) nil ;; Initial values of Model-Specific Registers (already initialized ;; in init-sys-view) nil ;; seg-visibles `((#.*cs* . #x0000001b) (#.*ss* . #x00000023) (#.*ds* . #x00000023)) ;; For initial seg-hidden values: ;; See segment-base-and-bounds. ;; See add-to-*sp. ;; seg-hidden base (acons #.*cs* 0 (acons #.*ss* 0 (acons #.*ds* 0 nil))) ;; seg-hidden limit (acons #.*cs* #uxffff (acons #.*ss* #uxffff_ffff (acons #.*ds* #uxffff_ffff nil))) ;; seg-hidden attr (acons #.*cs* (!code-segment-descriptor-attributesBits->d 1 0) ;; op size = 4 (acons #.*ss* (!data-segment-descriptor-attributesBits->w 1 0) ;; writable stack segment nil)) ;; Initial value of the Rflags Register #x282 ;; Initial memory image (acons #xbffff880 ;; init value of esp (i.e., just before the call to _fib.) input *fibonacci32-binary*) ;; x86 state x86)) ((when flg) (let ((x86 (!!ms-fresh :init-x86-state-error flg))) (mv nil 0 x86))) ((mv steps x86) (time$ (x86-run-halt-count halt-address xrun-limit x86 xrun-limit))) (ok? (check-fib32-output input halt-address x86)) ((unless ok?) (mv nil 0 x86))) (mv t steps x86))) (define run-x86isa-fib32 ((input :type (unsigned-byte 8)) (start-address :type (signed-byte #.*max-linear-address-size*)) (halt-address :type (signed-byte #.*max-linear-address-size*)) (xrun-limit :type (unsigned-byte 50)) x86) (if (zp input) (mv t 0 x86) (b* (((mv flg steps x86) (x86isa-one-fib32-cosim (1- input) start-address halt-address xrun-limit x86)) ((unless flg) (cw "~% Mismatch found!~%") (mv flg 0 x86)) (- (cw "Input: ~p0 Steps: ~p1 ~%" input steps))) (run-x86isa-fib32 (1- input) start-address halt-address xrun-limit x86)))) ;; ---------------------------------------------------------------------- ;; For efficient execution of 64-BIT-MODEP and SEGMENT-BASE-AND-BOUNDS: (local (include-book "std/bitsets/bignum-extract-opt" :dir :system)) ;; One run: ;; (b* ((start-address #x00001ef7) ;; address of call _fib (in main) ;; (halt-address #x00001efc) ;; address of instruction following call _fib (in main) ;; (input 30) ;; ((mv flg steps x86) ;; (x86isa-one-fib32-cosim ;; input start-address halt-address *fib32-xrun-limit* x86))) ;; (mv flg steps x86)) ;; Multiple runs: (acl2::assert!-stobj (b* ((start-address #x00001ef7) (halt-address #x00001efc) (input 20) ((mv flg & x86) (run-x86isa-fib32 input start-address halt-address *fib32-xrun-limit* x86))) (mv flg x86)) x86) ;; ----------------------------------------------------------------------
[ { "context": "2018, University of British Columbia\n;; Written by Yan Peng (Oct 2018)\n;;\n;; License: A 3-clause BSD license.", "end": 76, "score": 0.99965900182724, "start": 68, "tag": "NAME", "value": "Yan Peng" } ]
test-env.lisp
pennyan/asp
0
;; Copyright (C) 2018, University of British Columbia ;; Written by Yan Peng (Oct 2018) ;; ;; License: A 3-clause BSD license. ;; See the LICENSE file distributed with this software ;; (in-package "ASP") (include-book "std/util/define" :dir :system) (include-book "tools/bstar" :dir :system) (include-book "centaur/fty/top" :dir :system) ; for defalist, etc. (include-book "rational2str") (define pretty-print (failed-clauses) :guard t (if failed-clauses failed-clauses 'passed)) (define sig-value-to-string ((sv sig-value-p) (prec natp)) :returns (s stringp) (b* (((unless (sig-value-p sv)) "???") ((sig-value sv) sv) (val (coerce (if sv.value "t" "nil") 'list)) (at (coerce " @ " 'list)) (tim (coerce (rational-to-string sv.time prec) 'list))) (coerce (append val at tim) 'string))) (define interval-to-string ((iv interval-p) (prec natp)) :returns (s stringp) (b* (((unless (interval-p iv)) "???") (prec (if (natp prec) prec 4)) (lo (rational-to-string (interval->lo iv) prec)) (hi (rational-to-string (interval->hi iv) prec))) (concatenate 'string "[" lo ", " hi ")"))) (define show-sig ((sig sig-path-p) (st gstate-p) (name stringp) (prec natp)) (b* ((sig (sig-path-fix sig)) (st (gstate-fix st)) (pair (assoc-equal sig st)) ((unless pair) (cw "Sig ~p0 not found!~%" sig)) (v (cdr (assoc-equal sig st)))) (cw " ~s0 = ~x1 @ ~s2~%" name (sig-value->value v) (rational-to-string (sig-value->time v) prec) :fmt-control-alist `((fmt-soft-right-margin . 1000) (fmt-hard-right-margin . 1000))))) (define test ((cex t)) :verify-guards nil (b* ((lenv (cdr (assoc 'lenv cex))) (renv (cdr (assoc 'renv cex))) (prev (cdr (assoc 's1 cex))) (next (cdr (assoc 's2 cex))) (inf (cdr (assoc 'inf cex))) (prec 8) (tprev (gstate-t->statet prev)) (prevv (gstate-t->statev prev)) (tnext (gstate-t->statet next)) (nextv (gstate-t->statev next)) (li-path (lenv->left-internal lenv)) (req-path (lenv->req-out lenv)) (ack-path (renv->ack-out renv)) (ri-path (renv->right-internal renv)) (delta (lenv->delta lenv)) (- (cw "-----------------------------------------------------~%")) (- (cw "prev: tprev = ~s0~%" (rational-to-string tprev prec))) (- (show-sig li-path prevv "left-internal" prec)) (- (show-sig req-path prevv "req" prec)) (- (show-sig ack-path prevv "ack" prec)) (- (show-sig ri-path prevv "right-internal" prec)) (- (cw "next: tnext = ~s0~%(inf = ~s1,~% delta = [~s2, ~s3))~%" (rational-to-string tnext prec) (rational-to-string inf prec) (rational-to-string (interval->lo delta) prec) (rational-to-string (interval->hi delta) prec))) (- (show-sig li-path nextv "left-internal" prec)) (- (show-sig req-path nextv "req" prec)) (- (show-sig ack-path nextv "ack" prec)) (- (show-sig ri-path nextv "right-internal" prec)) (- (cw "-----------------------------------------------------~%")) (lstep (lenv-step lenv prev next inf)) (rstep (renv-step renv prev next inf)) (- (cw "lstep = ~x0, rstep=~x1~%" lstep rstep)) (- (cw "-----------------------------------------------------~%")) (- (cw "Testing invariant on next state~%")) (li (cdr (assoc-equal li-path nextv))) (req (cdr (assoc-equal req-path nextv))) (ack (cdr (assoc-equal ack-path nextv))) (ri (cdr (assoc-equal ri-path nextv))) (testbench (make-asp-env-testbench :req req :ack ack :li li :ri ri :delta delta :inf inf)) (inv (invariant-env lenv renv next inf)) (- (cw "~%Testing the whole invariant on next state: ~q0" (if inv 'passed 'failed))) (inv-lenv (invariant-lenv-failed testbench tnext)) (- (cw "Testing invariant on the left env: ~q0" (pretty-print inv-lenv))) (inv-renv (invariant-renv-failed testbench tnext)) (- (cw "Testing invariant on the right env: ~q0" (pretty-print inv-renv))) (inv-interact-env (interact-env-failed testbench)) (- (cw "Testing invariant on the interaction between envs: ~q0" (pretty-print inv-interact-env))) (lb (leftbench testbench)) (rb (rightbench testbench)) (- (cw "li_idle = ~s0~%" (interval-to-string (internal-idle-time lb) prec))) (- (cw "li_ready = ~s0~%" (interval-to-string (internal-next-ready-time lb) prec))) (- (cw "lx_idle = ~s0~%" (interval-to-string (external-idle-time lb) prec))) (- (cw "lx_ready = ~s0~%" (interval-to-string (external-next-ready-time lb) prec))) (- (cw "ri_idle = ~s0~%" (interval-to-string (internal-idle-time rb) prec))) (- (cw "ri_ready = ~s0~%" (interval-to-string (internal-next-ready-time rb) prec))) (- (cw "rx_idle = ~s0~%" (interval-to-string (external-idle-time rb) prec))) (- (cw "rx_ready = ~s0~%" (interval-to-string (external-next-ready-time rb) prec))) (- (cw "-----------------------------------------------------~%")) (- (cw "li-step-oracle: ~q0" (li-step-oracle lenv prev inf))) (- (cw "req-step-oracle: ~q0" (req-step-oracle lenv prev inf))) (- (cw "ri-step-oracle: ~q0" (ri-step-oracle renv prev inf))) (- (cw "ack-step-oracle: ~q0" (ack-step-oracle renv prev inf))) (- (cw "lenv-step-oracle: ~q0" (lenv-step-oracle lenv prev inf))) (- (cw "renv-step-oracle: ~q0" (renv-step-oracle renv prev inf))) (- (cw "prev: ~q0" prev)) (- (cw "renv-lenv-step-oracle: ~q0" (renv-lenv-step-oracle lenv renv prev inf))) (- (cw "lenv-valid: ~q0" (lenv-step lenv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) (- (cw "renv-valid: ~q0" (renv-step renv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) ) nil))
35524
;; Copyright (C) 2018, University of British Columbia ;; Written by <NAME> (Oct 2018) ;; ;; License: A 3-clause BSD license. ;; See the LICENSE file distributed with this software ;; (in-package "ASP") (include-book "std/util/define" :dir :system) (include-book "tools/bstar" :dir :system) (include-book "centaur/fty/top" :dir :system) ; for defalist, etc. (include-book "rational2str") (define pretty-print (failed-clauses) :guard t (if failed-clauses failed-clauses 'passed)) (define sig-value-to-string ((sv sig-value-p) (prec natp)) :returns (s stringp) (b* (((unless (sig-value-p sv)) "???") ((sig-value sv) sv) (val (coerce (if sv.value "t" "nil") 'list)) (at (coerce " @ " 'list)) (tim (coerce (rational-to-string sv.time prec) 'list))) (coerce (append val at tim) 'string))) (define interval-to-string ((iv interval-p) (prec natp)) :returns (s stringp) (b* (((unless (interval-p iv)) "???") (prec (if (natp prec) prec 4)) (lo (rational-to-string (interval->lo iv) prec)) (hi (rational-to-string (interval->hi iv) prec))) (concatenate 'string "[" lo ", " hi ")"))) (define show-sig ((sig sig-path-p) (st gstate-p) (name stringp) (prec natp)) (b* ((sig (sig-path-fix sig)) (st (gstate-fix st)) (pair (assoc-equal sig st)) ((unless pair) (cw "Sig ~p0 not found!~%" sig)) (v (cdr (assoc-equal sig st)))) (cw " ~s0 = ~x1 @ ~s2~%" name (sig-value->value v) (rational-to-string (sig-value->time v) prec) :fmt-control-alist `((fmt-soft-right-margin . 1000) (fmt-hard-right-margin . 1000))))) (define test ((cex t)) :verify-guards nil (b* ((lenv (cdr (assoc 'lenv cex))) (renv (cdr (assoc 'renv cex))) (prev (cdr (assoc 's1 cex))) (next (cdr (assoc 's2 cex))) (inf (cdr (assoc 'inf cex))) (prec 8) (tprev (gstate-t->statet prev)) (prevv (gstate-t->statev prev)) (tnext (gstate-t->statet next)) (nextv (gstate-t->statev next)) (li-path (lenv->left-internal lenv)) (req-path (lenv->req-out lenv)) (ack-path (renv->ack-out renv)) (ri-path (renv->right-internal renv)) (delta (lenv->delta lenv)) (- (cw "-----------------------------------------------------~%")) (- (cw "prev: tprev = ~s0~%" (rational-to-string tprev prec))) (- (show-sig li-path prevv "left-internal" prec)) (- (show-sig req-path prevv "req" prec)) (- (show-sig ack-path prevv "ack" prec)) (- (show-sig ri-path prevv "right-internal" prec)) (- (cw "next: tnext = ~s0~%(inf = ~s1,~% delta = [~s2, ~s3))~%" (rational-to-string tnext prec) (rational-to-string inf prec) (rational-to-string (interval->lo delta) prec) (rational-to-string (interval->hi delta) prec))) (- (show-sig li-path nextv "left-internal" prec)) (- (show-sig req-path nextv "req" prec)) (- (show-sig ack-path nextv "ack" prec)) (- (show-sig ri-path nextv "right-internal" prec)) (- (cw "-----------------------------------------------------~%")) (lstep (lenv-step lenv prev next inf)) (rstep (renv-step renv prev next inf)) (- (cw "lstep = ~x0, rstep=~x1~%" lstep rstep)) (- (cw "-----------------------------------------------------~%")) (- (cw "Testing invariant on next state~%")) (li (cdr (assoc-equal li-path nextv))) (req (cdr (assoc-equal req-path nextv))) (ack (cdr (assoc-equal ack-path nextv))) (ri (cdr (assoc-equal ri-path nextv))) (testbench (make-asp-env-testbench :req req :ack ack :li li :ri ri :delta delta :inf inf)) (inv (invariant-env lenv renv next inf)) (- (cw "~%Testing the whole invariant on next state: ~q0" (if inv 'passed 'failed))) (inv-lenv (invariant-lenv-failed testbench tnext)) (- (cw "Testing invariant on the left env: ~q0" (pretty-print inv-lenv))) (inv-renv (invariant-renv-failed testbench tnext)) (- (cw "Testing invariant on the right env: ~q0" (pretty-print inv-renv))) (inv-interact-env (interact-env-failed testbench)) (- (cw "Testing invariant on the interaction between envs: ~q0" (pretty-print inv-interact-env))) (lb (leftbench testbench)) (rb (rightbench testbench)) (- (cw "li_idle = ~s0~%" (interval-to-string (internal-idle-time lb) prec))) (- (cw "li_ready = ~s0~%" (interval-to-string (internal-next-ready-time lb) prec))) (- (cw "lx_idle = ~s0~%" (interval-to-string (external-idle-time lb) prec))) (- (cw "lx_ready = ~s0~%" (interval-to-string (external-next-ready-time lb) prec))) (- (cw "ri_idle = ~s0~%" (interval-to-string (internal-idle-time rb) prec))) (- (cw "ri_ready = ~s0~%" (interval-to-string (internal-next-ready-time rb) prec))) (- (cw "rx_idle = ~s0~%" (interval-to-string (external-idle-time rb) prec))) (- (cw "rx_ready = ~s0~%" (interval-to-string (external-next-ready-time rb) prec))) (- (cw "-----------------------------------------------------~%")) (- (cw "li-step-oracle: ~q0" (li-step-oracle lenv prev inf))) (- (cw "req-step-oracle: ~q0" (req-step-oracle lenv prev inf))) (- (cw "ri-step-oracle: ~q0" (ri-step-oracle renv prev inf))) (- (cw "ack-step-oracle: ~q0" (ack-step-oracle renv prev inf))) (- (cw "lenv-step-oracle: ~q0" (lenv-step-oracle lenv prev inf))) (- (cw "renv-step-oracle: ~q0" (renv-step-oracle renv prev inf))) (- (cw "prev: ~q0" prev)) (- (cw "renv-lenv-step-oracle: ~q0" (renv-lenv-step-oracle lenv renv prev inf))) (- (cw "lenv-valid: ~q0" (lenv-step lenv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) (- (cw "renv-valid: ~q0" (renv-step renv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) ) nil))
true
;; Copyright (C) 2018, University of British Columbia ;; Written by PI:NAME:<NAME>END_PI (Oct 2018) ;; ;; License: A 3-clause BSD license. ;; See the LICENSE file distributed with this software ;; (in-package "ASP") (include-book "std/util/define" :dir :system) (include-book "tools/bstar" :dir :system) (include-book "centaur/fty/top" :dir :system) ; for defalist, etc. (include-book "rational2str") (define pretty-print (failed-clauses) :guard t (if failed-clauses failed-clauses 'passed)) (define sig-value-to-string ((sv sig-value-p) (prec natp)) :returns (s stringp) (b* (((unless (sig-value-p sv)) "???") ((sig-value sv) sv) (val (coerce (if sv.value "t" "nil") 'list)) (at (coerce " @ " 'list)) (tim (coerce (rational-to-string sv.time prec) 'list))) (coerce (append val at tim) 'string))) (define interval-to-string ((iv interval-p) (prec natp)) :returns (s stringp) (b* (((unless (interval-p iv)) "???") (prec (if (natp prec) prec 4)) (lo (rational-to-string (interval->lo iv) prec)) (hi (rational-to-string (interval->hi iv) prec))) (concatenate 'string "[" lo ", " hi ")"))) (define show-sig ((sig sig-path-p) (st gstate-p) (name stringp) (prec natp)) (b* ((sig (sig-path-fix sig)) (st (gstate-fix st)) (pair (assoc-equal sig st)) ((unless pair) (cw "Sig ~p0 not found!~%" sig)) (v (cdr (assoc-equal sig st)))) (cw " ~s0 = ~x1 @ ~s2~%" name (sig-value->value v) (rational-to-string (sig-value->time v) prec) :fmt-control-alist `((fmt-soft-right-margin . 1000) (fmt-hard-right-margin . 1000))))) (define test ((cex t)) :verify-guards nil (b* ((lenv (cdr (assoc 'lenv cex))) (renv (cdr (assoc 'renv cex))) (prev (cdr (assoc 's1 cex))) (next (cdr (assoc 's2 cex))) (inf (cdr (assoc 'inf cex))) (prec 8) (tprev (gstate-t->statet prev)) (prevv (gstate-t->statev prev)) (tnext (gstate-t->statet next)) (nextv (gstate-t->statev next)) (li-path (lenv->left-internal lenv)) (req-path (lenv->req-out lenv)) (ack-path (renv->ack-out renv)) (ri-path (renv->right-internal renv)) (delta (lenv->delta lenv)) (- (cw "-----------------------------------------------------~%")) (- (cw "prev: tprev = ~s0~%" (rational-to-string tprev prec))) (- (show-sig li-path prevv "left-internal" prec)) (- (show-sig req-path prevv "req" prec)) (- (show-sig ack-path prevv "ack" prec)) (- (show-sig ri-path prevv "right-internal" prec)) (- (cw "next: tnext = ~s0~%(inf = ~s1,~% delta = [~s2, ~s3))~%" (rational-to-string tnext prec) (rational-to-string inf prec) (rational-to-string (interval->lo delta) prec) (rational-to-string (interval->hi delta) prec))) (- (show-sig li-path nextv "left-internal" prec)) (- (show-sig req-path nextv "req" prec)) (- (show-sig ack-path nextv "ack" prec)) (- (show-sig ri-path nextv "right-internal" prec)) (- (cw "-----------------------------------------------------~%")) (lstep (lenv-step lenv prev next inf)) (rstep (renv-step renv prev next inf)) (- (cw "lstep = ~x0, rstep=~x1~%" lstep rstep)) (- (cw "-----------------------------------------------------~%")) (- (cw "Testing invariant on next state~%")) (li (cdr (assoc-equal li-path nextv))) (req (cdr (assoc-equal req-path nextv))) (ack (cdr (assoc-equal ack-path nextv))) (ri (cdr (assoc-equal ri-path nextv))) (testbench (make-asp-env-testbench :req req :ack ack :li li :ri ri :delta delta :inf inf)) (inv (invariant-env lenv renv next inf)) (- (cw "~%Testing the whole invariant on next state: ~q0" (if inv 'passed 'failed))) (inv-lenv (invariant-lenv-failed testbench tnext)) (- (cw "Testing invariant on the left env: ~q0" (pretty-print inv-lenv))) (inv-renv (invariant-renv-failed testbench tnext)) (- (cw "Testing invariant on the right env: ~q0" (pretty-print inv-renv))) (inv-interact-env (interact-env-failed testbench)) (- (cw "Testing invariant on the interaction between envs: ~q0" (pretty-print inv-interact-env))) (lb (leftbench testbench)) (rb (rightbench testbench)) (- (cw "li_idle = ~s0~%" (interval-to-string (internal-idle-time lb) prec))) (- (cw "li_ready = ~s0~%" (interval-to-string (internal-next-ready-time lb) prec))) (- (cw "lx_idle = ~s0~%" (interval-to-string (external-idle-time lb) prec))) (- (cw "lx_ready = ~s0~%" (interval-to-string (external-next-ready-time lb) prec))) (- (cw "ri_idle = ~s0~%" (interval-to-string (internal-idle-time rb) prec))) (- (cw "ri_ready = ~s0~%" (interval-to-string (internal-next-ready-time rb) prec))) (- (cw "rx_idle = ~s0~%" (interval-to-string (external-idle-time rb) prec))) (- (cw "rx_ready = ~s0~%" (interval-to-string (external-next-ready-time rb) prec))) (- (cw "-----------------------------------------------------~%")) (- (cw "li-step-oracle: ~q0" (li-step-oracle lenv prev inf))) (- (cw "req-step-oracle: ~q0" (req-step-oracle lenv prev inf))) (- (cw "ri-step-oracle: ~q0" (ri-step-oracle renv prev inf))) (- (cw "ack-step-oracle: ~q0" (ack-step-oracle renv prev inf))) (- (cw "lenv-step-oracle: ~q0" (lenv-step-oracle lenv prev inf))) (- (cw "renv-step-oracle: ~q0" (renv-step-oracle renv prev inf))) (- (cw "prev: ~q0" prev)) (- (cw "renv-lenv-step-oracle: ~q0" (renv-lenv-step-oracle lenv renv prev inf))) (- (cw "lenv-valid: ~q0" (lenv-step lenv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) (- (cw "renv-valid: ~q0" (renv-step renv prev (maybe-gstate-t-some->val (renv-lenv-step-oracle lenv renv prev inf)) inf))) ) nil))
[ { "context": "art of ABCD\n (c) 2015 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 88, "score": 0.999902069568634, "start": 70, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 113, "score": 0.9998899102210999, "start": 99, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.abcd)\n\n(defgener", "end": 133, "score": 0.9999138712882996, "start": 115, "tag": "EMAIL", "value": "[email protected]" } ]
dependencies.lisp
Shinmera/abcd
6
#| This file is a part of ABCD (c) 2015 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.abcd) (defgeneric c-system-includable-pathnames (system) (:method ((system c-system)) (let ((includes ())) (dolist (header (find-components 'c-header system :test #'typep)) (asdf:operate 'compute-options-op header) (when (getf (component-effective-options header) :includable) (pushnew (uiop:pathname-directory-pathname (asdf:component-pathname header)) includes :test #'equal))) includes))) (defgeneric c-system-library-options (system) (:method ((system c-system)) (assert (or (c-system-shared-library system) (c-system-static-library system))) `(:include-dirs ,(c-system-includable-pathnames system) :library-dirs (,(uiop:pathname-directory-pathname (asdf/system:component-build-pathname system))) :libraries (,(pathname-name (asdf/system:component-build-pathname system)))))) (define-dependency-def-parser :shared-library (definition) definition) (define-dependency-resolver :shared-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant)) (define-dependency-def-parser :static-library (definition) definition) (define-dependency-resolver :static-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant))
72303
#| This file is a part of ABCD (c) 2015 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.abcd) (defgeneric c-system-includable-pathnames (system) (:method ((system c-system)) (let ((includes ())) (dolist (header (find-components 'c-header system :test #'typep)) (asdf:operate 'compute-options-op header) (when (getf (component-effective-options header) :includable) (pushnew (uiop:pathname-directory-pathname (asdf:component-pathname header)) includes :test #'equal))) includes))) (defgeneric c-system-library-options (system) (:method ((system c-system)) (assert (or (c-system-shared-library system) (c-system-static-library system))) `(:include-dirs ,(c-system-includable-pathnames system) :library-dirs (,(uiop:pathname-directory-pathname (asdf/system:component-build-pathname system))) :libraries (,(pathname-name (asdf/system:component-build-pathname system)))))) (define-dependency-def-parser :shared-library (definition) definition) (define-dependency-resolver :shared-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant)) (define-dependency-def-parser :static-library (definition) definition) (define-dependency-resolver :static-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant))
true
#| This file is a part of ABCD (c) 2015 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.abcd) (defgeneric c-system-includable-pathnames (system) (:method ((system c-system)) (let ((includes ())) (dolist (header (find-components 'c-header system :test #'typep)) (asdf:operate 'compute-options-op header) (when (getf (component-effective-options header) :includable) (pushnew (uiop:pathname-directory-pathname (asdf:component-pathname header)) includes :test #'equal))) includes))) (defgeneric c-system-library-options (system) (:method ((system c-system)) (assert (or (c-system-shared-library system) (c-system-static-library system))) `(:include-dirs ,(c-system-includable-pathnames system) :library-dirs (,(uiop:pathname-directory-pathname (asdf/system:component-build-pathname system))) :libraries (,(pathname-name (asdf/system:component-build-pathname system)))))) (define-dependency-def-parser :shared-library (definition) definition) (define-dependency-resolver :shared-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant)) (define-dependency-def-parser :static-library (definition) definition) (define-dependency-resolver :static-library (system dependant &key) (let ((dependant (asdf:find-system dependant T))) (nmerge-options (component-direct-options system) (c-system-library-options dependant)) dependant))
[ { "context": "st-comprehension.lisp\n;;;;\n;;;; Copyright (c) 2015 Robert Smith\n\n(defpackage #:list-comprehensions\n (:nicknames ", "end": 70, "score": 0.9990935921669006, "start": 58, "tag": "NAME", "value": "Robert Smith" } ]
list-comprehension.lisp
stylewarning/lisp-random
56
;;;; list-comprehension.lisp ;;;; ;;;; Copyright (c) 2015 Robert Smith (defpackage #:list-comprehensions (:nicknames #:lc) (:use #:cl) (:export #:lc #:define-lc-clause #:continue)) (in-package #:list-comprehensions) (defmacro with-collector ((var collector) &body body) "Execute BODY with COLLECTOR fbound to a function which will collect its argument to VAR efficiently. VAR will be bound to the list of collected values. Mutating the list VAR or calling COLLECTOR on VAR has undefined behavior." (check-type var symbol) (check-type collector symbol) (let ((tail (gensym "TAIL-")) (new-tail (gensym "NEW-TAIL-")) (value (gensym "VALUE-"))) `(let ((,var nil) (,tail nil)) (flet ((,collector (,value) #+#:sanity-check (unless (eq ,value ,var) (error "Cannot collect the list ~S being collected to." ',var)) (let ((,new-tail (cons ,value nil))) (if (null ,var) (setf ,var ,new-tail) (setf (cdr ,tail) ,new-tail)) (setf ,tail ,new-tail) ;; Return the value. ,value))) ,@body)))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun kw (symb) (intern (symbol-name symb) :keyword))) (defvar *lc-clause-expanders* (make-hash-table :test 'eq)) (defmacro define-lc-clause (name lambda-list &body body) "Define a new list comprehension clause named NAME which takes the arguments as specified by the ordinary lambda list LAMBDA-LIST, executing BODY. BODY should have a form similar to that of a macro: a quasiquoted form representing the expansion of the clause. Within BODY, a local function `CONTINUE' should be called which will expand into the remaining code of the list comprehension." (let ((name (kw name)) (continue (gensym "CONTINUE-")) (clause-arguments (gensym "CLAUSE-ARGUMENTS-"))) `(progn (setf (gethash ,name *lc-clause-expanders*) (lambda (,clause-arguments ,continue) (flet ((continue () (funcall ,continue))) (destructuring-bind ,lambda-list ,clause-arguments ,@body)))) ,name))) (define-lc-clause if (&rest items) `(when (and ,@items) ,(continue))) (define-lc-clause with (var val) `(let ((,var ,val)) ,(continue))) (define-lc-clause in (var seq) `(map nil (lambda (,var) ,(continue)) ,seq)) (define-lc-clause for (var min max) `(loop :for ,var :from ,min :below ,max :do (progn ,(continue)))) (defmacro lc (expr &rest clauses) "Compute the list comprehension of the expression EXPR with the clauses CLAUSES. By default, the following clause types are supported: (IF <item>*) Only includes EXPR if every one of <item> expressions are satisfied. (WITH <var> <val>) Binds the variable <var> to the value <val> in the remaining clauses as well as in EXPR. (FOR <var> <min> <max>) Iterates <var> from the value <min> to below <max>. (IN <var> <seq>) Iterates <var> through each item of the sequence <seq>. New clauses can be defined with the macro `DEFINE-LC-CLAUSE'." (let ((result (gensym "RESULT-")) (collect (gensym "COLLECT-"))) (labels ((process-clauses (clauses) (if (null clauses) `(,collect ,expr) (destructuring-bind (type &rest clause-items) (car clauses) (funcall (gethash (kw type) *lc-clause-expanders*) clause-items (lambda () (process-clauses (cdr clauses)))))))) `(with-collector (,result ,collect) ,(process-clauses clauses) ,result)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun cartesian-product (list1 list2) (lc (list x y) (for x list1) (for y list2))) ;;; CL-USER> (cartesian-product '(1 2 3) '(a b c)) ;;; ((1 A) (1 B) (1 C) (2 A) (2 B) (2 C) (3 A) (3 B) (3 C)) (defun pythagorean-triples (limit) (lc (list x y z) (for x 1 limit) (for y 1 x) (with z^2 (+ (* x x) (* y y))) (with z (isqrt z^2)) (if (= z^2 (* z z))))) ;;; CL-USER> (pythagorean-triples 50) ;;; ((4 3 5) (8 6 10) (12 5 13) (12 9 15) (15 8 17) (16 12 20) ;;; (20 15 25) (21 20 29) (24 7 25) (24 10 26) (24 18 30) ;;; (28 21 35) (30 16 34) (32 24 40) (35 12 37) (36 15 39) ;;; (36 27 45) (40 9 41) (40 30 50) (42 40 58) (44 33 55) ;;; (45 24 51) (45 28 53) (48 14 50) (48 20 52) (48 36 60))
31359
;;;; list-comprehension.lisp ;;;; ;;;; Copyright (c) 2015 <NAME> (defpackage #:list-comprehensions (:nicknames #:lc) (:use #:cl) (:export #:lc #:define-lc-clause #:continue)) (in-package #:list-comprehensions) (defmacro with-collector ((var collector) &body body) "Execute BODY with COLLECTOR fbound to a function which will collect its argument to VAR efficiently. VAR will be bound to the list of collected values. Mutating the list VAR or calling COLLECTOR on VAR has undefined behavior." (check-type var symbol) (check-type collector symbol) (let ((tail (gensym "TAIL-")) (new-tail (gensym "NEW-TAIL-")) (value (gensym "VALUE-"))) `(let ((,var nil) (,tail nil)) (flet ((,collector (,value) #+#:sanity-check (unless (eq ,value ,var) (error "Cannot collect the list ~S being collected to." ',var)) (let ((,new-tail (cons ,value nil))) (if (null ,var) (setf ,var ,new-tail) (setf (cdr ,tail) ,new-tail)) (setf ,tail ,new-tail) ;; Return the value. ,value))) ,@body)))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun kw (symb) (intern (symbol-name symb) :keyword))) (defvar *lc-clause-expanders* (make-hash-table :test 'eq)) (defmacro define-lc-clause (name lambda-list &body body) "Define a new list comprehension clause named NAME which takes the arguments as specified by the ordinary lambda list LAMBDA-LIST, executing BODY. BODY should have a form similar to that of a macro: a quasiquoted form representing the expansion of the clause. Within BODY, a local function `CONTINUE' should be called which will expand into the remaining code of the list comprehension." (let ((name (kw name)) (continue (gensym "CONTINUE-")) (clause-arguments (gensym "CLAUSE-ARGUMENTS-"))) `(progn (setf (gethash ,name *lc-clause-expanders*) (lambda (,clause-arguments ,continue) (flet ((continue () (funcall ,continue))) (destructuring-bind ,lambda-list ,clause-arguments ,@body)))) ,name))) (define-lc-clause if (&rest items) `(when (and ,@items) ,(continue))) (define-lc-clause with (var val) `(let ((,var ,val)) ,(continue))) (define-lc-clause in (var seq) `(map nil (lambda (,var) ,(continue)) ,seq)) (define-lc-clause for (var min max) `(loop :for ,var :from ,min :below ,max :do (progn ,(continue)))) (defmacro lc (expr &rest clauses) "Compute the list comprehension of the expression EXPR with the clauses CLAUSES. By default, the following clause types are supported: (IF <item>*) Only includes EXPR if every one of <item> expressions are satisfied. (WITH <var> <val>) Binds the variable <var> to the value <val> in the remaining clauses as well as in EXPR. (FOR <var> <min> <max>) Iterates <var> from the value <min> to below <max>. (IN <var> <seq>) Iterates <var> through each item of the sequence <seq>. New clauses can be defined with the macro `DEFINE-LC-CLAUSE'." (let ((result (gensym "RESULT-")) (collect (gensym "COLLECT-"))) (labels ((process-clauses (clauses) (if (null clauses) `(,collect ,expr) (destructuring-bind (type &rest clause-items) (car clauses) (funcall (gethash (kw type) *lc-clause-expanders*) clause-items (lambda () (process-clauses (cdr clauses)))))))) `(with-collector (,result ,collect) ,(process-clauses clauses) ,result)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun cartesian-product (list1 list2) (lc (list x y) (for x list1) (for y list2))) ;;; CL-USER> (cartesian-product '(1 2 3) '(a b c)) ;;; ((1 A) (1 B) (1 C) (2 A) (2 B) (2 C) (3 A) (3 B) (3 C)) (defun pythagorean-triples (limit) (lc (list x y z) (for x 1 limit) (for y 1 x) (with z^2 (+ (* x x) (* y y))) (with z (isqrt z^2)) (if (= z^2 (* z z))))) ;;; CL-USER> (pythagorean-triples 50) ;;; ((4 3 5) (8 6 10) (12 5 13) (12 9 15) (15 8 17) (16 12 20) ;;; (20 15 25) (21 20 29) (24 7 25) (24 10 26) (24 18 30) ;;; (28 21 35) (30 16 34) (32 24 40) (35 12 37) (36 15 39) ;;; (36 27 45) (40 9 41) (40 30 50) (42 40 58) (44 33 55) ;;; (45 24 51) (45 28 53) (48 14 50) (48 20 52) (48 36 60))
true
;;;; list-comprehension.lisp ;;;; ;;;; Copyright (c) 2015 PI:NAME:<NAME>END_PI (defpackage #:list-comprehensions (:nicknames #:lc) (:use #:cl) (:export #:lc #:define-lc-clause #:continue)) (in-package #:list-comprehensions) (defmacro with-collector ((var collector) &body body) "Execute BODY with COLLECTOR fbound to a function which will collect its argument to VAR efficiently. VAR will be bound to the list of collected values. Mutating the list VAR or calling COLLECTOR on VAR has undefined behavior." (check-type var symbol) (check-type collector symbol) (let ((tail (gensym "TAIL-")) (new-tail (gensym "NEW-TAIL-")) (value (gensym "VALUE-"))) `(let ((,var nil) (,tail nil)) (flet ((,collector (,value) #+#:sanity-check (unless (eq ,value ,var) (error "Cannot collect the list ~S being collected to." ',var)) (let ((,new-tail (cons ,value nil))) (if (null ,var) (setf ,var ,new-tail) (setf (cdr ,tail) ,new-tail)) (setf ,tail ,new-tail) ;; Return the value. ,value))) ,@body)))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun kw (symb) (intern (symbol-name symb) :keyword))) (defvar *lc-clause-expanders* (make-hash-table :test 'eq)) (defmacro define-lc-clause (name lambda-list &body body) "Define a new list comprehension clause named NAME which takes the arguments as specified by the ordinary lambda list LAMBDA-LIST, executing BODY. BODY should have a form similar to that of a macro: a quasiquoted form representing the expansion of the clause. Within BODY, a local function `CONTINUE' should be called which will expand into the remaining code of the list comprehension." (let ((name (kw name)) (continue (gensym "CONTINUE-")) (clause-arguments (gensym "CLAUSE-ARGUMENTS-"))) `(progn (setf (gethash ,name *lc-clause-expanders*) (lambda (,clause-arguments ,continue) (flet ((continue () (funcall ,continue))) (destructuring-bind ,lambda-list ,clause-arguments ,@body)))) ,name))) (define-lc-clause if (&rest items) `(when (and ,@items) ,(continue))) (define-lc-clause with (var val) `(let ((,var ,val)) ,(continue))) (define-lc-clause in (var seq) `(map nil (lambda (,var) ,(continue)) ,seq)) (define-lc-clause for (var min max) `(loop :for ,var :from ,min :below ,max :do (progn ,(continue)))) (defmacro lc (expr &rest clauses) "Compute the list comprehension of the expression EXPR with the clauses CLAUSES. By default, the following clause types are supported: (IF <item>*) Only includes EXPR if every one of <item> expressions are satisfied. (WITH <var> <val>) Binds the variable <var> to the value <val> in the remaining clauses as well as in EXPR. (FOR <var> <min> <max>) Iterates <var> from the value <min> to below <max>. (IN <var> <seq>) Iterates <var> through each item of the sequence <seq>. New clauses can be defined with the macro `DEFINE-LC-CLAUSE'." (let ((result (gensym "RESULT-")) (collect (gensym "COLLECT-"))) (labels ((process-clauses (clauses) (if (null clauses) `(,collect ,expr) (destructuring-bind (type &rest clause-items) (car clauses) (funcall (gethash (kw type) *lc-clause-expanders*) clause-items (lambda () (process-clauses (cdr clauses)))))))) `(with-collector (,result ,collect) ,(process-clauses clauses) ,result)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Examples ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun cartesian-product (list1 list2) (lc (list x y) (for x list1) (for y list2))) ;;; CL-USER> (cartesian-product '(1 2 3) '(a b c)) ;;; ((1 A) (1 B) (1 C) (2 A) (2 B) (2 C) (3 A) (3 B) (3 C)) (defun pythagorean-triples (limit) (lc (list x y z) (for x 1 limit) (for y 1 x) (with z^2 (+ (* x x) (* y y))) (with z (isqrt z^2)) (if (= z^2 (* z z))))) ;;; CL-USER> (pythagorean-triples 50) ;;; ((4 3 5) (8 6 10) (12 5 13) (12 9 15) (15 8 17) (16 12 20) ;;; (20 15 25) (21 20 29) (24 7 25) (24 10 26) (24 18 30) ;;; (28 21 35) (30 16 34) (32 24 40) (35 12 37) (36 15 39) ;;; (36 27 45) (40 9 41) (40 30 50) (42 40 58) (44 33 55) ;;; (45 24 51) (45 28 53) (48 14 50) (48 20 52) (48 36 60))
[ { "context": "ion \"Correlate pair-generation system\"\n :author \"Alejandro Zamora <[email protected]>\"\n :license \"MIT\"\n :", "end": 137, "score": 0.9999019503593445, "start": 121, "tag": "NAME", "value": "Alejandro Zamora" }, { "context": "r-generation system\"\n :author \"Alejandro Zamora <[email protected]>\"\n :license \"MIT\"\n :version \"0.0.1\"\n :serial ", "end": 163, "score": 0.9999306201934814, "start": 139, "tag": "EMAIL", "value": "[email protected]" } ]
pair-generation.asd
alejandrozf/pair-generation
0
;;;; pair-generation.asd (asdf:defsystem #:pair-generation :description "Correlate pair-generation system" :author "Alejandro Zamora <[email protected]>" :license "MIT" :version "0.0.1" :serial t :components ((:file "package") (:file "pair-generation")))
74691
;;;; pair-generation.asd (asdf:defsystem #:pair-generation :description "Correlate pair-generation system" :author "<NAME> <<EMAIL>>" :license "MIT" :version "0.0.1" :serial t :components ((:file "package") (:file "pair-generation")))
true
;;;; pair-generation.asd (asdf:defsystem #:pair-generation :description "Correlate pair-generation system" :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "MIT" :version "0.0.1" :serial t :components ((:file "package") (:file "pair-generation")))
[ { "context": "of Radiance\n (c) 2016 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 92, "score": 0.9999167323112488, "start": 74, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 117, "score": 0.9998912215232849, "start": 103, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.radiance.core)\n\n", "end": 137, "score": 0.9999240040779114, "start": 119, "tag": "EMAIL", "value": "[email protected]" } ]
migration.lisp
hjudt/radiance
1
#| This file is a part of Radiance (c) 2016 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.radiance.core) (defun encode-version (version) (etypecase version (null NIL) (keyword version) (string (intern version :KEYWORD)) (cons (encode-version (with-output-to-string (out) (princ (first version) out) (dolist (part (rest version)) (etypecase part (integer (format out ".~d" part)) (string (format out "-~:@(~a~)" part))))))))) (defun parse-version (version) (loop for part in (cl-ppcre:split "[.-]" version) collect (or (ignore-errors (parse-integer part)) part))) (defun ensure-parsed-version (version) (etypecase version (null NIL) (cons version) ((or string keyword) (parse-version (string version))))) (defun ensure-versions-comparable (a b) (let* ((a (ensure-parsed-version a)) (b (ensure-parsed-version b)) (al (length a)) (bl (length b))) (cond ((< al bl) (values (append a (make-list (- bl al) :initial-element 0)) b)) ((< bl al) (values a (append b (make-list (- al bl) :initial-element 0)))) (T (values a b))))) (defmethod version-part= ((a integer) (b integer)) (= a b)) (defmethod version-part= ((a integer) (b string)) NIL) (defmethod version-part= ((a string) (b integer)) NIL) (defmethod version-part= ((a string) (b string)) (string= a b)) (defmethod version-part< ((a integer) (b integer)) (< a b)) (defmethod version-part< ((a integer) (b string)) T) (defmethod version-part< ((a string) (b integer)) NIL) (defmethod version-part< ((a string) (b string)) (string< a b)) (defun version= (a b) (cond ((eql a b) T) ((or (null a) (null b)) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts always (version-part= a b)))))) (defun version< (a b) (cond ((eql a b) NIL) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return NIL)))))) (defun version<= (a b) (cond ((eql a b) T) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return T)))))) (defun version-region (versions &key start end) (loop for version in versions when (and (or (not start) (version<= start version)) (or (not end) (version<= version end))) collect version)) (defun version-bounds (versions &key (start NIL start-p) end) (when versions (let* ((versions (version-region versions :start start :end end)) (last (last versions))) (when (and start-p (version< start (first versions))) (push start versions)) (when (and end (version< (car last) end)) (setf (cdr last) (list end))) versions))) (defmethod last-known-system-version ((system asdf:system)) (config :versions (asdf:component-name system))) (defmethod last-known-system-version (system) (last-known-system-version (asdf:find-system system T))) (defmethod (setf last-known-system-version) (version (system asdf:system)) (setf (config :versions (asdf:component-name system)) (encode-version version))) (defmethod (setf last-known-system-version) (version system) (setf (last-known-system-version (asdf:find-system system T)) version)) (defun ensure-system (system-ish &optional parent) (typecase system-ish (asdf:system system-ish) ((or string symbol) (asdf:find-system system-ish T)) (cons (asdf/find-component:resolve-dependency-spec parent system-ish)))) (defgeneric migrate-versions (system from to)) (defmethod ready-dependency-for-migration (dependency system from) (declare (ignore system from)) (handler-bind ((system-has-no-version #'continue)) (migrate dependency T T))) (defmethod ensure-dependencies-ready ((system asdf:system) from) (loop for spec in (append (asdf:system-defsystem-depends-on system) (asdf:system-depends-on system)) for dependency = (ensure-system spec system) do (when (typep dependency 'virtual-module) (ready-dependency-for-migration dependency system from)))) (defmethod migrate-versions :before (system from to) (l:debug :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (ensure-dependencies-ready system from)) (defmethod migrate-versions (system from to)) (defmethod migrate-versions :after (system from to) (setf (last-known-system-version system) to)) (defmacro define-version-migration (system (from to) &body body) (check-type system (or symbol string)) (let ((from (etypecase from ((or null keyword) from) ((or symbol string) (intern (string-upcase from) :keyword)))) (to (etypecase to (keyword to) ((or symbol string) (intern (string-upcase to) :keyword))))) `(defmethod migrate-versions ((,(gensym "SYSTEM") (eql (asdf:find-system ',system))) (,(gensym "FROM") (eql ,from)) (,(gensym "TO") (eql ,to))) ,@body))) (defmethod versions ((system asdf:system)) (sort (remove-duplicates (loop for method in (c2mop:generic-function-methods #'migrate-versions) for (sys from to) = (c2mop:method-specializers method) for matching = (and (null (method-qualifiers method)) (typep sys 'c2mop:eql-specializer) (eql system (c2mop:eql-specializer-object sys))) when (and matching (typep from 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object from) when (and matching (typep to 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object to)) :test #'version=) #'version<)) (defmethod migrate ((system asdf:system) from to) (unless (version= from to) (with-simple-restart (abort "Abort the migration.") (with-simple-restart (force-version "Treat the migration as having been successful.") (assert (version< from to) (from to) 'backwards-migration-not-allowed :from from :to to) (l:info :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (let ((versions (version-bounds (versions system) :start from :end to))) (loop for (from to) on versions while to do (migrate-versions system from to)))) (setf (last-known-system-version system) to)))) (defmethod migrate ((system asdf:system) from (to (eql T))) (let ((version (asdf:component-version system))) (if version (migrate system from version) (cerror "Don't migrate the system and continue." 'system-has-no-version :system system)))) (defmethod migrate ((system asdf:system) (from (eql T)) to) (migrate system (last-known-system-version system) to)) (defmethod migrate ((system symbol) from to) (migrate (asdf:find-system system T) from to)) (defmethod migrate ((system string) from to) (migrate (asdf:find-system system T) from to))
38983
#| This file is a part of Radiance (c) 2016 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.radiance.core) (defun encode-version (version) (etypecase version (null NIL) (keyword version) (string (intern version :KEYWORD)) (cons (encode-version (with-output-to-string (out) (princ (first version) out) (dolist (part (rest version)) (etypecase part (integer (format out ".~d" part)) (string (format out "-~:@(~a~)" part))))))))) (defun parse-version (version) (loop for part in (cl-ppcre:split "[.-]" version) collect (or (ignore-errors (parse-integer part)) part))) (defun ensure-parsed-version (version) (etypecase version (null NIL) (cons version) ((or string keyword) (parse-version (string version))))) (defun ensure-versions-comparable (a b) (let* ((a (ensure-parsed-version a)) (b (ensure-parsed-version b)) (al (length a)) (bl (length b))) (cond ((< al bl) (values (append a (make-list (- bl al) :initial-element 0)) b)) ((< bl al) (values a (append b (make-list (- al bl) :initial-element 0)))) (T (values a b))))) (defmethod version-part= ((a integer) (b integer)) (= a b)) (defmethod version-part= ((a integer) (b string)) NIL) (defmethod version-part= ((a string) (b integer)) NIL) (defmethod version-part= ((a string) (b string)) (string= a b)) (defmethod version-part< ((a integer) (b integer)) (< a b)) (defmethod version-part< ((a integer) (b string)) T) (defmethod version-part< ((a string) (b integer)) NIL) (defmethod version-part< ((a string) (b string)) (string< a b)) (defun version= (a b) (cond ((eql a b) T) ((or (null a) (null b)) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts always (version-part= a b)))))) (defun version< (a b) (cond ((eql a b) NIL) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return NIL)))))) (defun version<= (a b) (cond ((eql a b) T) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return T)))))) (defun version-region (versions &key start end) (loop for version in versions when (and (or (not start) (version<= start version)) (or (not end) (version<= version end))) collect version)) (defun version-bounds (versions &key (start NIL start-p) end) (when versions (let* ((versions (version-region versions :start start :end end)) (last (last versions))) (when (and start-p (version< start (first versions))) (push start versions)) (when (and end (version< (car last) end)) (setf (cdr last) (list end))) versions))) (defmethod last-known-system-version ((system asdf:system)) (config :versions (asdf:component-name system))) (defmethod last-known-system-version (system) (last-known-system-version (asdf:find-system system T))) (defmethod (setf last-known-system-version) (version (system asdf:system)) (setf (config :versions (asdf:component-name system)) (encode-version version))) (defmethod (setf last-known-system-version) (version system) (setf (last-known-system-version (asdf:find-system system T)) version)) (defun ensure-system (system-ish &optional parent) (typecase system-ish (asdf:system system-ish) ((or string symbol) (asdf:find-system system-ish T)) (cons (asdf/find-component:resolve-dependency-spec parent system-ish)))) (defgeneric migrate-versions (system from to)) (defmethod ready-dependency-for-migration (dependency system from) (declare (ignore system from)) (handler-bind ((system-has-no-version #'continue)) (migrate dependency T T))) (defmethod ensure-dependencies-ready ((system asdf:system) from) (loop for spec in (append (asdf:system-defsystem-depends-on system) (asdf:system-depends-on system)) for dependency = (ensure-system spec system) do (when (typep dependency 'virtual-module) (ready-dependency-for-migration dependency system from)))) (defmethod migrate-versions :before (system from to) (l:debug :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (ensure-dependencies-ready system from)) (defmethod migrate-versions (system from to)) (defmethod migrate-versions :after (system from to) (setf (last-known-system-version system) to)) (defmacro define-version-migration (system (from to) &body body) (check-type system (or symbol string)) (let ((from (etypecase from ((or null keyword) from) ((or symbol string) (intern (string-upcase from) :keyword)))) (to (etypecase to (keyword to) ((or symbol string) (intern (string-upcase to) :keyword))))) `(defmethod migrate-versions ((,(gensym "SYSTEM") (eql (asdf:find-system ',system))) (,(gensym "FROM") (eql ,from)) (,(gensym "TO") (eql ,to))) ,@body))) (defmethod versions ((system asdf:system)) (sort (remove-duplicates (loop for method in (c2mop:generic-function-methods #'migrate-versions) for (sys from to) = (c2mop:method-specializers method) for matching = (and (null (method-qualifiers method)) (typep sys 'c2mop:eql-specializer) (eql system (c2mop:eql-specializer-object sys))) when (and matching (typep from 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object from) when (and matching (typep to 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object to)) :test #'version=) #'version<)) (defmethod migrate ((system asdf:system) from to) (unless (version= from to) (with-simple-restart (abort "Abort the migration.") (with-simple-restart (force-version "Treat the migration as having been successful.") (assert (version< from to) (from to) 'backwards-migration-not-allowed :from from :to to) (l:info :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (let ((versions (version-bounds (versions system) :start from :end to))) (loop for (from to) on versions while to do (migrate-versions system from to)))) (setf (last-known-system-version system) to)))) (defmethod migrate ((system asdf:system) from (to (eql T))) (let ((version (asdf:component-version system))) (if version (migrate system from version) (cerror "Don't migrate the system and continue." 'system-has-no-version :system system)))) (defmethod migrate ((system asdf:system) (from (eql T)) to) (migrate system (last-known-system-version system) to)) (defmethod migrate ((system symbol) from to) (migrate (asdf:find-system system T) from to)) (defmethod migrate ((system string) from to) (migrate (asdf:find-system system T) from to))
true
#| This file is a part of Radiance (c) 2016 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.radiance.core) (defun encode-version (version) (etypecase version (null NIL) (keyword version) (string (intern version :KEYWORD)) (cons (encode-version (with-output-to-string (out) (princ (first version) out) (dolist (part (rest version)) (etypecase part (integer (format out ".~d" part)) (string (format out "-~:@(~a~)" part))))))))) (defun parse-version (version) (loop for part in (cl-ppcre:split "[.-]" version) collect (or (ignore-errors (parse-integer part)) part))) (defun ensure-parsed-version (version) (etypecase version (null NIL) (cons version) ((or string keyword) (parse-version (string version))))) (defun ensure-versions-comparable (a b) (let* ((a (ensure-parsed-version a)) (b (ensure-parsed-version b)) (al (length a)) (bl (length b))) (cond ((< al bl) (values (append a (make-list (- bl al) :initial-element 0)) b)) ((< bl al) (values a (append b (make-list (- al bl) :initial-element 0)))) (T (values a b))))) (defmethod version-part= ((a integer) (b integer)) (= a b)) (defmethod version-part= ((a integer) (b string)) NIL) (defmethod version-part= ((a string) (b integer)) NIL) (defmethod version-part= ((a string) (b string)) (string= a b)) (defmethod version-part< ((a integer) (b integer)) (< a b)) (defmethod version-part< ((a integer) (b string)) T) (defmethod version-part< ((a string) (b integer)) NIL) (defmethod version-part< ((a string) (b string)) (string< a b)) (defun version= (a b) (cond ((eql a b) T) ((or (null a) (null b)) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts always (version-part= a b)))))) (defun version< (a b) (cond ((eql a b) NIL) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return NIL)))))) (defun version<= (a b) (cond ((eql a b) T) ((null a) T) ((null b) NIL) (T (multiple-value-bind (a-parts b-parts) (ensure-versions-comparable a b) (loop for a in a-parts for b in b-parts do (cond ((version-part= a b)) ((version-part< a b) (return T)) (T (return NIL))) finally (return T)))))) (defun version-region (versions &key start end) (loop for version in versions when (and (or (not start) (version<= start version)) (or (not end) (version<= version end))) collect version)) (defun version-bounds (versions &key (start NIL start-p) end) (when versions (let* ((versions (version-region versions :start start :end end)) (last (last versions))) (when (and start-p (version< start (first versions))) (push start versions)) (when (and end (version< (car last) end)) (setf (cdr last) (list end))) versions))) (defmethod last-known-system-version ((system asdf:system)) (config :versions (asdf:component-name system))) (defmethod last-known-system-version (system) (last-known-system-version (asdf:find-system system T))) (defmethod (setf last-known-system-version) (version (system asdf:system)) (setf (config :versions (asdf:component-name system)) (encode-version version))) (defmethod (setf last-known-system-version) (version system) (setf (last-known-system-version (asdf:find-system system T)) version)) (defun ensure-system (system-ish &optional parent) (typecase system-ish (asdf:system system-ish) ((or string symbol) (asdf:find-system system-ish T)) (cons (asdf/find-component:resolve-dependency-spec parent system-ish)))) (defgeneric migrate-versions (system from to)) (defmethod ready-dependency-for-migration (dependency system from) (declare (ignore system from)) (handler-bind ((system-has-no-version #'continue)) (migrate dependency T T))) (defmethod ensure-dependencies-ready ((system asdf:system) from) (loop for spec in (append (asdf:system-defsystem-depends-on system) (asdf:system-depends-on system)) for dependency = (ensure-system spec system) do (when (typep dependency 'virtual-module) (ready-dependency-for-migration dependency system from)))) (defmethod migrate-versions :before (system from to) (l:debug :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (ensure-dependencies-ready system from)) (defmethod migrate-versions (system from to)) (defmethod migrate-versions :after (system from to) (setf (last-known-system-version system) to)) (defmacro define-version-migration (system (from to) &body body) (check-type system (or symbol string)) (let ((from (etypecase from ((or null keyword) from) ((or symbol string) (intern (string-upcase from) :keyword)))) (to (etypecase to (keyword to) ((or symbol string) (intern (string-upcase to) :keyword))))) `(defmethod migrate-versions ((,(gensym "SYSTEM") (eql (asdf:find-system ',system))) (,(gensym "FROM") (eql ,from)) (,(gensym "TO") (eql ,to))) ,@body))) (defmethod versions ((system asdf:system)) (sort (remove-duplicates (loop for method in (c2mop:generic-function-methods #'migrate-versions) for (sys from to) = (c2mop:method-specializers method) for matching = (and (null (method-qualifiers method)) (typep sys 'c2mop:eql-specializer) (eql system (c2mop:eql-specializer-object sys))) when (and matching (typep from 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object from) when (and matching (typep to 'c2mop:eql-specializer)) collect (c2mop:eql-specializer-object to)) :test #'version=) #'version<)) (defmethod migrate ((system asdf:system) from to) (unless (version= from to) (with-simple-restart (abort "Abort the migration.") (with-simple-restart (force-version "Treat the migration as having been successful.") (assert (version< from to) (from to) 'backwards-migration-not-allowed :from from :to to) (l:info :radiance.migration "Migrating ~a from ~a to ~a." (asdf:component-name system) (encode-version from) (encode-version to)) (let ((versions (version-bounds (versions system) :start from :end to))) (loop for (from to) on versions while to do (migrate-versions system from to)))) (setf (last-known-system-version system) to)))) (defmethod migrate ((system asdf:system) from (to (eql T))) (let ((version (asdf:component-version system))) (if version (migrate system from version) (cerror "Don't migrate the system and continue." 'system-has-no-version :system system)))) (defmethod migrate ((system asdf:system) (from (eql T)) to) (migrate system (last-known-system-version system) to)) (defmethod migrate ((system symbol) from to) (migrate (asdf:find-system system T) from to)) (defmethod migrate ((system string) from to) (migrate (asdf:find-system system T) from to))
[ { "context": ";; Copyright 2010-2018 Ben Lambert\n\n;; Licensed under the Apache License, Version 2.", "end": 34, "score": 0.9998304843902588, "start": 23, "tag": "NAME", "value": "Ben Lambert" } ]
weights-optimization/printing.lisp
belambert/cl-machine-learning
1
;; Copyright 2010-2018 Ben Lambert ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; http://www.apache.org/licenses/LICENSE-2.0 ;; Unless required by applicable law or agreed to in writing, software ;; distributed under the License is distributed on an "AS IS" BASIS, ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;; See the License for the specific language governing permissions and ;; limitations under the License. (in-package :lm-training) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Graphing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun graph-parameter-sweep (points filename &key (verbose nil) (debug t)) "Plots a single graph of the objective function over the course of the entire optimization." (when (= (length (first points)) 3) (gnuplot:plot-graph points :heatmap :filename (concat filename "-map") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :debug debug :verbose verbose) (gnuplot:plot-graph points :surface :filename (concat filename "-surface") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :z-label "Objective function" :debug debug :verbose verbose) (let ((counter 0)) (setf points (mapcar (lambda (x) (prog1 (list counter (third x)) (incf counter))) points)))) (gnuplot:plot-graph points :2dgraph :filename filename :title "Parameter sweep: time vs. objective function" :x-label "Function evaluation # (approx)" :y-label "Objective function" :debug debug :verbose verbose)) (defun graph-feature-parameter-sweeps (array prefix &key model (min-feature 0) (max-feature most-positive-fixnum) (verbose nil) (debug nil)) "Plot one graph per parameter of the parameter value vs. the objective function." (unless array (format t "Couldn't plot feature parameter sweeps. NIL array.~%") (return-from graph-feature-parameter-sweeps)) (loop for feature from (max 0 min-feature) below (min (length array) max-feature) for points = (elt array feature) for filename = (format nil "~Afeature-~d" prefix feature) for this-feature = (when model (elt (patterns model) feature)) for title = (format nil "Param val vs. obj func for feat #~:D: ~{~A ~}" feature (append (list (pattern-type this-feature)) (pattern-fillers this-feature))) for axis-labels = '("Parameter value" "Objective function") do ;; Print the scatter plot version (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose) ;; Print thumbnail versions... (setf filename (concat filename "-thumb")) (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose :thumbnail t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Training ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun print-non-zero-features (array model) "Given an array of feature weights and a model, print out all the non-zero features in a readable format." (format t "~:D non-zero weight features:~%" (count-if-not 'zerop (parameters model))) (loop for i from 0 below (length array) for value = (elt array i) for feature = (elt (patterns model) i) do (when (/= value 0) (format t " Feature ~8:D Weight=~10,2f, Name: ~A~%" i value (print-pattern feature nil)))) (force-output t)) (defun print-before-and-after-reranking (model nbests &key (prefix "")) "Given a model and some nbest lists, evaluate and print performance before and after reranking." (let* ((before (evaluate-nbest-lists nbests)) (after (evaluate-nbest-lists (rerank-with-model nbests model))) (best (evaluate-nbest-lists (rerank-by-wer nbests))) ;;(delta (struct-subtract-recursive after before)) (delta (struct-subtract after before))) (format t "********** ~A best possible **********~%" prefix) (print-evaluation-statistics best) (format t "********** ~A baseline **********~%" prefix) (print-evaluation-statistics before) (format t "********** ~A with model **********~%" prefix) (print-evaluation-statistics after) (format t "********** ~A delta **********~%" prefix) (print-evaluation-statistics delta))) (defun print-before-and-after-pairwise (model1 model2 pairs &key (prefix "")) "There really isn't a *before* with the pairwise eval... that's already factored in." (let* ((before (pairwise-evaluation model1 pairs)) (after (pairwise-evaluation model2 pairs))) (declare (ignore before)) (format t "********** ~A with model **********~%" prefix) (print-summary-results after)))
43174
;; Copyright 2010-2018 <NAME> ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; http://www.apache.org/licenses/LICENSE-2.0 ;; Unless required by applicable law or agreed to in writing, software ;; distributed under the License is distributed on an "AS IS" BASIS, ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;; See the License for the specific language governing permissions and ;; limitations under the License. (in-package :lm-training) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Graphing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun graph-parameter-sweep (points filename &key (verbose nil) (debug t)) "Plots a single graph of the objective function over the course of the entire optimization." (when (= (length (first points)) 3) (gnuplot:plot-graph points :heatmap :filename (concat filename "-map") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :debug debug :verbose verbose) (gnuplot:plot-graph points :surface :filename (concat filename "-surface") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :z-label "Objective function" :debug debug :verbose verbose) (let ((counter 0)) (setf points (mapcar (lambda (x) (prog1 (list counter (third x)) (incf counter))) points)))) (gnuplot:plot-graph points :2dgraph :filename filename :title "Parameter sweep: time vs. objective function" :x-label "Function evaluation # (approx)" :y-label "Objective function" :debug debug :verbose verbose)) (defun graph-feature-parameter-sweeps (array prefix &key model (min-feature 0) (max-feature most-positive-fixnum) (verbose nil) (debug nil)) "Plot one graph per parameter of the parameter value vs. the objective function." (unless array (format t "Couldn't plot feature parameter sweeps. NIL array.~%") (return-from graph-feature-parameter-sweeps)) (loop for feature from (max 0 min-feature) below (min (length array) max-feature) for points = (elt array feature) for filename = (format nil "~Afeature-~d" prefix feature) for this-feature = (when model (elt (patterns model) feature)) for title = (format nil "Param val vs. obj func for feat #~:D: ~{~A ~}" feature (append (list (pattern-type this-feature)) (pattern-fillers this-feature))) for axis-labels = '("Parameter value" "Objective function") do ;; Print the scatter plot version (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose) ;; Print thumbnail versions... (setf filename (concat filename "-thumb")) (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose :thumbnail t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Training ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun print-non-zero-features (array model) "Given an array of feature weights and a model, print out all the non-zero features in a readable format." (format t "~:D non-zero weight features:~%" (count-if-not 'zerop (parameters model))) (loop for i from 0 below (length array) for value = (elt array i) for feature = (elt (patterns model) i) do (when (/= value 0) (format t " Feature ~8:D Weight=~10,2f, Name: ~A~%" i value (print-pattern feature nil)))) (force-output t)) (defun print-before-and-after-reranking (model nbests &key (prefix "")) "Given a model and some nbest lists, evaluate and print performance before and after reranking." (let* ((before (evaluate-nbest-lists nbests)) (after (evaluate-nbest-lists (rerank-with-model nbests model))) (best (evaluate-nbest-lists (rerank-by-wer nbests))) ;;(delta (struct-subtract-recursive after before)) (delta (struct-subtract after before))) (format t "********** ~A best possible **********~%" prefix) (print-evaluation-statistics best) (format t "********** ~A baseline **********~%" prefix) (print-evaluation-statistics before) (format t "********** ~A with model **********~%" prefix) (print-evaluation-statistics after) (format t "********** ~A delta **********~%" prefix) (print-evaluation-statistics delta))) (defun print-before-and-after-pairwise (model1 model2 pairs &key (prefix "")) "There really isn't a *before* with the pairwise eval... that's already factored in." (let* ((before (pairwise-evaluation model1 pairs)) (after (pairwise-evaluation model2 pairs))) (declare (ignore before)) (format t "********** ~A with model **********~%" prefix) (print-summary-results after)))
true
;; Copyright 2010-2018 PI:NAME:<NAME>END_PI ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; http://www.apache.org/licenses/LICENSE-2.0 ;; Unless required by applicable law or agreed to in writing, software ;; distributed under the License is distributed on an "AS IS" BASIS, ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;; See the License for the specific language governing permissions and ;; limitations under the License. (in-package :lm-training) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Graphing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun graph-parameter-sweep (points filename &key (verbose nil) (debug t)) "Plots a single graph of the objective function over the course of the entire optimization." (when (= (length (first points)) 3) (gnuplot:plot-graph points :heatmap :filename (concat filename "-map") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :debug debug :verbose verbose) (gnuplot:plot-graph points :surface :filename (concat filename "-surface") :title "2d parameter sweep" :legend-labels '("Objective function") :x-label "parameter1" :y-label "parameter2" :z-label "Objective function" :debug debug :verbose verbose) (let ((counter 0)) (setf points (mapcar (lambda (x) (prog1 (list counter (third x)) (incf counter))) points)))) (gnuplot:plot-graph points :2dgraph :filename filename :title "Parameter sweep: time vs. objective function" :x-label "Function evaluation # (approx)" :y-label "Objective function" :debug debug :verbose verbose)) (defun graph-feature-parameter-sweeps (array prefix &key model (min-feature 0) (max-feature most-positive-fixnum) (verbose nil) (debug nil)) "Plot one graph per parameter of the parameter value vs. the objective function." (unless array (format t "Couldn't plot feature parameter sweeps. NIL array.~%") (return-from graph-feature-parameter-sweeps)) (loop for feature from (max 0 min-feature) below (min (length array) max-feature) for points = (elt array feature) for filename = (format nil "~Afeature-~d" prefix feature) for this-feature = (when model (elt (patterns model) feature)) for title = (format nil "Param val vs. obj func for feat #~:D: ~{~A ~}" feature (append (list (pattern-type this-feature)) (pattern-fillers this-feature))) for axis-labels = '("Parameter value" "Objective function") do ;; Print the scatter plot version (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose) ;; Print thumbnail versions... (setf filename (concat filename "-thumb")) (gnuplot:plot-graph points :scatter :filename (concat filename "-scatter") :title title :x-label (first axis-labels) :y-label (second axis-labels) :debug debug :verbose verbose :thumbnail t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;; Training ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun print-non-zero-features (array model) "Given an array of feature weights and a model, print out all the non-zero features in a readable format." (format t "~:D non-zero weight features:~%" (count-if-not 'zerop (parameters model))) (loop for i from 0 below (length array) for value = (elt array i) for feature = (elt (patterns model) i) do (when (/= value 0) (format t " Feature ~8:D Weight=~10,2f, Name: ~A~%" i value (print-pattern feature nil)))) (force-output t)) (defun print-before-and-after-reranking (model nbests &key (prefix "")) "Given a model and some nbest lists, evaluate and print performance before and after reranking." (let* ((before (evaluate-nbest-lists nbests)) (after (evaluate-nbest-lists (rerank-with-model nbests model))) (best (evaluate-nbest-lists (rerank-by-wer nbests))) ;;(delta (struct-subtract-recursive after before)) (delta (struct-subtract after before))) (format t "********** ~A best possible **********~%" prefix) (print-evaluation-statistics best) (format t "********** ~A baseline **********~%" prefix) (print-evaluation-statistics before) (format t "********** ~A with model **********~%" prefix) (print-evaluation-statistics after) (format t "********** ~A delta **********~%" prefix) (print-evaluation-statistics delta))) (defun print-before-and-after-pairwise (model1 model2 pairs &key (prefix "")) "There really isn't a *before* with the pairwise eval... that's already factored in." (let* ((before (pairwise-evaluation model1 pairs)) (after (pairwise-evaluation model2 pairs))) (declare (ignore before)) (format t "********** ~A with model **********~%" prefix) (print-summary-results after)))
[ { "context": "rt of Alloy\n (c) 2019 Shirakumo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n", "end": 89, "score": 0.9999086856842041, "start": 71, "tag": "EMAIL", "value": "[email protected]" }, { "context": "umo http://tymoon.eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirak", "end": 114, "score": 0.9998905658721924, "start": 100, "tag": "NAME", "value": "Nicolas Hafner" }, { "context": ".eu ([email protected])\n Author: Nicolas Hafner <[email protected]>\n|#\n\n(in-package #:org.shirakumo.alloy)\n\n(defclas", "end": 134, "score": 0.9999144673347473, "start": 116, "tag": "EMAIL", "value": "[email protected]" } ]
layouts/clip-view.lisp
Hellseher/alloy
120
#| This file is a part of Alloy (c) 2019 Shirakumo http://tymoon.eu ([email protected]) Author: Nicolas Hafner <[email protected]> |# (in-package #:org.shirakumo.alloy) (defclass clip-view (layout single-container observable) ((offset :initarg :offset :initform (px-point 0 0) :accessor offset) (stretch :initarg :stretch :initform T :accessor stretch) (limit :initarg :limit :initform NIL :accessor limit))) (defmethod suggest-bounds (extent (layout clip-view)) (if (inner layout) (suggest-bounds extent (inner layout)) extent)) (defmethod notice-bounds ((element layout-element) (layout clip-view)) (setf (bounds layout) (bounds layout))) (defun clamp-offset (offset layout) (flet ((clamp (l x u) (min (max l x) u))) (px-point (clamp (min 0 (- (pxw (bounds layout)) (pxw (bounds (inner layout))))) (pxx offset) 0) (clamp (min 0 (- (pxh (bounds layout)) (pxh (bounds (inner layout))))) (pxy offset) 0)))) (defmethod (setf offset) :around ((offset point) (layout clip-view)) (let ((clamped (clamp-offset offset layout))) (unless (and (/= (pxx clamped) (pxx (offset layout))) (/= (pxy clamped) (pxy (offset layout)))) (call-next-method clamped layout)))) (defmethod (setf offset) :after (offset (layout clip-view)) (setf (bounds layout) (bounds layout))) (defmethod (setf bounds) :after (bounds (layout clip-view)) (when (inner layout) (with-unit-parent layout (let ((ideal (suggest-bounds (px-extent (- (pxx bounds) (pxx (offset layout))) (- (pxy bounds) (pxy (offset layout))) (w bounds) (h bounds)) (inner layout)))) (setf (bounds (inner layout)) (px-extent (- (pxx ideal) (max 0 (- (pxw ideal) (pxw bounds)))) (- (pxy ideal) (max 0 (- (pxh ideal) (pxh bounds)))) (cond ((null (stretch layout)) (w ideal)) ((eq :x (limit layout)) (w bounds)) (T (max (pxw ideal) (pxw bounds)))) (cond ((null (stretch layout)) (h ideal)) ((eq :y (limit layout)) (h bounds)) (T (max (pxh ideal) (pxh bounds))))))) ;; Ensure we clamp the offset into valid bounds. ;;(setf (offset layout) (offset layout)) ))) (defmethod handle ((event scroll) (layout clip-view)) (restart-case (call-next-method) (decline () (let ((off (offset layout))) (setf (offset layout) (px-point (+ (* (pxw layout) 0.1 (dx event)) (pxx off)) (+ (* (pxh layout) 0.1 (dy event)) (pxy off)))))))) (defmethod render ((renderer renderer) (layout clip-view)) (when (inner layout) (with-constrained-visibility ((bounds layout) renderer) (render renderer (inner layout))))) (defmethod ensure-visible ((element layout-element) (layout clip-view)) (let* ((view (bounds layout)) (container (bounds (inner layout))) (element (bounds element))) ;; KLUDGE: terrible kludge for Y only for now. (unless (and (<= (pxy view) (pxy element)) (<= (+ (pxy element) (pxh element)) (+ (pxy view) (pxh view)))) (cond ((< (pxy element) (pxy view)) (setf (offset layout) (px-point (pxx (offset layout)) (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view)))))) (T (setf (offset layout) (px-point (pxx (offset layout)) (+ (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view))) (- (pxh view) (pxh element))))))))) (call-next-method))
58930
#| This file is a part of Alloy (c) 2019 Shirakumo http://tymoon.eu (<EMAIL>) Author: <NAME> <<EMAIL>> |# (in-package #:org.shirakumo.alloy) (defclass clip-view (layout single-container observable) ((offset :initarg :offset :initform (px-point 0 0) :accessor offset) (stretch :initarg :stretch :initform T :accessor stretch) (limit :initarg :limit :initform NIL :accessor limit))) (defmethod suggest-bounds (extent (layout clip-view)) (if (inner layout) (suggest-bounds extent (inner layout)) extent)) (defmethod notice-bounds ((element layout-element) (layout clip-view)) (setf (bounds layout) (bounds layout))) (defun clamp-offset (offset layout) (flet ((clamp (l x u) (min (max l x) u))) (px-point (clamp (min 0 (- (pxw (bounds layout)) (pxw (bounds (inner layout))))) (pxx offset) 0) (clamp (min 0 (- (pxh (bounds layout)) (pxh (bounds (inner layout))))) (pxy offset) 0)))) (defmethod (setf offset) :around ((offset point) (layout clip-view)) (let ((clamped (clamp-offset offset layout))) (unless (and (/= (pxx clamped) (pxx (offset layout))) (/= (pxy clamped) (pxy (offset layout)))) (call-next-method clamped layout)))) (defmethod (setf offset) :after (offset (layout clip-view)) (setf (bounds layout) (bounds layout))) (defmethod (setf bounds) :after (bounds (layout clip-view)) (when (inner layout) (with-unit-parent layout (let ((ideal (suggest-bounds (px-extent (- (pxx bounds) (pxx (offset layout))) (- (pxy bounds) (pxy (offset layout))) (w bounds) (h bounds)) (inner layout)))) (setf (bounds (inner layout)) (px-extent (- (pxx ideal) (max 0 (- (pxw ideal) (pxw bounds)))) (- (pxy ideal) (max 0 (- (pxh ideal) (pxh bounds)))) (cond ((null (stretch layout)) (w ideal)) ((eq :x (limit layout)) (w bounds)) (T (max (pxw ideal) (pxw bounds)))) (cond ((null (stretch layout)) (h ideal)) ((eq :y (limit layout)) (h bounds)) (T (max (pxh ideal) (pxh bounds))))))) ;; Ensure we clamp the offset into valid bounds. ;;(setf (offset layout) (offset layout)) ))) (defmethod handle ((event scroll) (layout clip-view)) (restart-case (call-next-method) (decline () (let ((off (offset layout))) (setf (offset layout) (px-point (+ (* (pxw layout) 0.1 (dx event)) (pxx off)) (+ (* (pxh layout) 0.1 (dy event)) (pxy off)))))))) (defmethod render ((renderer renderer) (layout clip-view)) (when (inner layout) (with-constrained-visibility ((bounds layout) renderer) (render renderer (inner layout))))) (defmethod ensure-visible ((element layout-element) (layout clip-view)) (let* ((view (bounds layout)) (container (bounds (inner layout))) (element (bounds element))) ;; KLUDGE: terrible kludge for Y only for now. (unless (and (<= (pxy view) (pxy element)) (<= (+ (pxy element) (pxh element)) (+ (pxy view) (pxh view)))) (cond ((< (pxy element) (pxy view)) (setf (offset layout) (px-point (pxx (offset layout)) (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view)))))) (T (setf (offset layout) (px-point (pxx (offset layout)) (+ (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view))) (- (pxh view) (pxh element))))))))) (call-next-method))
true
#| This file is a part of Alloy (c) 2019 Shirakumo http://tymoon.eu (PI:EMAIL:<EMAIL>END_PI) Author: PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI> |# (in-package #:org.shirakumo.alloy) (defclass clip-view (layout single-container observable) ((offset :initarg :offset :initform (px-point 0 0) :accessor offset) (stretch :initarg :stretch :initform T :accessor stretch) (limit :initarg :limit :initform NIL :accessor limit))) (defmethod suggest-bounds (extent (layout clip-view)) (if (inner layout) (suggest-bounds extent (inner layout)) extent)) (defmethod notice-bounds ((element layout-element) (layout clip-view)) (setf (bounds layout) (bounds layout))) (defun clamp-offset (offset layout) (flet ((clamp (l x u) (min (max l x) u))) (px-point (clamp (min 0 (- (pxw (bounds layout)) (pxw (bounds (inner layout))))) (pxx offset) 0) (clamp (min 0 (- (pxh (bounds layout)) (pxh (bounds (inner layout))))) (pxy offset) 0)))) (defmethod (setf offset) :around ((offset point) (layout clip-view)) (let ((clamped (clamp-offset offset layout))) (unless (and (/= (pxx clamped) (pxx (offset layout))) (/= (pxy clamped) (pxy (offset layout)))) (call-next-method clamped layout)))) (defmethod (setf offset) :after (offset (layout clip-view)) (setf (bounds layout) (bounds layout))) (defmethod (setf bounds) :after (bounds (layout clip-view)) (when (inner layout) (with-unit-parent layout (let ((ideal (suggest-bounds (px-extent (- (pxx bounds) (pxx (offset layout))) (- (pxy bounds) (pxy (offset layout))) (w bounds) (h bounds)) (inner layout)))) (setf (bounds (inner layout)) (px-extent (- (pxx ideal) (max 0 (- (pxw ideal) (pxw bounds)))) (- (pxy ideal) (max 0 (- (pxh ideal) (pxh bounds)))) (cond ((null (stretch layout)) (w ideal)) ((eq :x (limit layout)) (w bounds)) (T (max (pxw ideal) (pxw bounds)))) (cond ((null (stretch layout)) (h ideal)) ((eq :y (limit layout)) (h bounds)) (T (max (pxh ideal) (pxh bounds))))))) ;; Ensure we clamp the offset into valid bounds. ;;(setf (offset layout) (offset layout)) ))) (defmethod handle ((event scroll) (layout clip-view)) (restart-case (call-next-method) (decline () (let ((off (offset layout))) (setf (offset layout) (px-point (+ (* (pxw layout) 0.1 (dx event)) (pxx off)) (+ (* (pxh layout) 0.1 (dy event)) (pxy off)))))))) (defmethod render ((renderer renderer) (layout clip-view)) (when (inner layout) (with-constrained-visibility ((bounds layout) renderer) (render renderer (inner layout))))) (defmethod ensure-visible ((element layout-element) (layout clip-view)) (let* ((view (bounds layout)) (container (bounds (inner layout))) (element (bounds element))) ;; KLUDGE: terrible kludge for Y only for now. (unless (and (<= (pxy view) (pxy element)) (<= (+ (pxy element) (pxh element)) (+ (pxy view) (pxh view)))) (cond ((< (pxy element) (pxy view)) (setf (offset layout) (px-point (pxx (offset layout)) (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view)))))) (T (setf (offset layout) (px-point (pxx (offset layout)) (+ (- (- (pxy element) (pxy container)) (- (pxh container) (pxh view))) (- (pxh view) (pxh element))))))))) (call-next-method))
[ { "context": "nse. See the file books/3BSD-mod.txt.\n;\n; Authors: Limei Gilham\n; Eric Smith ([email protected])\n;\n", "end": 193, "score": 0.9998894333839417, "start": 181, "tag": "NAME", "value": "Limei Gilham" }, { "context": "3BSD-mod.txt.\n;\n; Authors: Limei Gilham\n; Eric Smith ([email protected])\n;\n;;;;;;;;;;;;;;;;;;;;;;", "end": 215, "score": 0.9998519420623779, "start": 205, "tag": "NAME", "value": "Eric Smith" }, { "context": "\n;\n; Authors: Limei Gilham\n; Eric Smith ([email protected])\n;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;", "end": 239, "score": 0.9999328851699829, "start": 217, "tag": "EMAIL", "value": "[email protected]" } ]
books/kestrel/apt/rename-params.lisp
mayankmanj/acl2
0
; Transformation to rename parameters of a function ; ; Copyright (C) 2015-2022 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Authors: Limei Gilham ; Eric Smith ([email protected]) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; STATUS: IN-PROGRESS ;; See tests in rename-params-tests.lisp (include-book "kestrel/terms-light/rename-vars-in-term" :dir :system) (include-book "utilities/deftransformation") (include-book "utilities/function-renamingp") ;(include-book "utilities/maybe-verify-guards2") (include-book "kestrel/std/system/guard-verified-p" :dir :system) (include-book "utilities/names") ; for INCREMENT-NAME-SUFFIX-SAFE (include-book "utilities/make-becomes-theorem") (include-book "utilities/option-parsing") (include-book "utilities/transformation-prologue") (include-book "kestrel/utilities/defun-forms" :dir :system) (include-book "kestrel/utilities/my-get-event" :dir :system) (include-book "kestrel/utilities/doublets2" :dir :system) (include-book "kestrel/utilities/world" :dir :system) (include-book "kestrel/utilities/defining-forms" :dir :system) (include-book "kestrel/alists-light/lookup-eq-safe" :dir :system) (include-book "kestrel/utilities/declares1" :dir :system) ; for substitute-measure-in-declares (include-book "kestrel/utilities/declares" :dir :system) ; for substitute-guard-in-declares (include-book "kestrel/utilities/directed-untranslate-dollar" :dir :system) (include-book "kestrel/utilities/verify-guards-dollar" :dir :system) (include-book "kestrel/terms-light/restore-mv-in-branches" :dir :system) (include-book "kestrel/clause-processors/simplify-after-using-conjunction" :dir :system) (include-book "std/typed-alists/symbol-symbol-alistp" :dir :system) (include-book "misc/install-not-normalized" :dir :system) (local (include-book "kestrel/lists-light/union-equal" :dir :system)) (local (include-book "kestrel/lists-light/len" :dir :system)) (local (in-theory (disable len))) ;; Union together the formals of all the FNS (defun formals-of-fns (fns wrld) (declare (xargs :guard (and (symbol-listp fns) (plist-worldp wrld)))) (if (endp fns) nil (union-eq (fn-formals (first fns) wrld) (formals-of-fns (rest fns) wrld)))) ;; drop these?: (defthm symbolp-of-cdr-assoc-equal-symbol-symbol-alist (implies (and (symbolp x) (symbol-symbol-alistp alist) (assoc-equal (car l) alist)) (symbolp (cdr (assoc-equal x alist))))) (defthm symbol-listp-of-sublis-var-simple-lst (implies (and (symbol-listp l) (symbol-symbol-alistp alist)) (symbol-listp (sublis-var-simple-lst alist l))) :hints (("Goal" :in-theory (enable sublis-var-simple sublis-var-simple-lst)))) (defthm pseudo-termp-of-lookup-equal (implies (and (symbolp x) (symbol-symbol-alistp alist)) (pseudo-termp (lookup-equal x alist))) :hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) ;returns a new defun (defun rename-params-in-defun (fn renaming new-fn fn-event function-renaming rec untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) (fn-definedp fn (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (let* ((wrld (w state)) (body (fn-body fn t wrld)) (ubody (get-body-from-event fn fn-event)) (formals (sublis-var-simple-lst renaming (fn-formals fn wrld))) (declares (get-declares-from-event fn fn-event)) ;TODO: Think about all the kinds of declares that get passed through. (declares (substitute-measure-in-declares declares renaming state)) (declares (substitute-guard-in-declares declares renaming)) (declares (add-verify-guards-nil declares)) ;we will later verify the guards if needed (declares (if rec (replace-xarg-in-declares :hints `(("Goal" :in-theory '() :use (:instance (:termination-theorem ,fn) :extra-bindings-ok ,@(alist-to-doublets renaming)))) declares) declares)) (declares ; cheap way to deal with previous ignorable decls (cons `(declare (ignorable ,@formals)) (remove-declares 'ignorable declares))) (new-body (rename-vars-in-term renaming body renaming)) (new-body (rename-fns new-body function-renaming)) (num-values (num-return-values-of-fn fn wrld)) (new-body (if (<= 2 num-values) (restore-mv-in-branches new-body num-values (strip-cdrs function-renaming) wrld) new-body)) (new-body (if (eq nil untranslate) new-body ;TODO clean up macros at least? clean up mvs too? (if (eq t untranslate) (untranslate new-body nil wrld) (directed-untranslate$ new-body ubody wrld))))) `(defun ,new-fn (,@formals) ,@declares ,new-body))) ;returns the new defuns (defun rename-params-in-defuns (fns renaming fn-event function-renaming untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbol-listp fns) (all-fn-definedp fns (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (if (endp fns) nil (cons (rename-params-in-defun (first fns) renaming (lookup-eq-safe (first fns) function-renaming) ;new name for this fn fn-event function-renaming :mutual untranslate state) (rename-params-in-defuns (rest fns) renaming fn-event function-renaming untranslate state)))) ;; (maybe-verify-guards2 verify-guards ;todo: deprecate maybe-verify-guards2? ;; new-fn ;; `(("Goal" :use ( ;; We instantiate the guard theorem according to ;; ;; the param renaming: ;; (:instance (:guard-theorem ,old-fn nil) ;; :extra-bindings-ok ;; ,@(alist-to-doublets param-renaming)))))) ;; Returns an event. ;; Similar to verify-guards-for-defun, but this one takes a param-renaming. ;; This requires the 'becomes theorems' to already exist. (defun verify-guards-for-rename-params (old-fn new-fn param-renaming function-renaming) (declare (xargs :guard (and (symbolp old-fn) (symbolp new-fn) (symbol-alistp param-renaming) (function-renamingp function-renaming)))) (let ((guard-hints ;;(if (eq :auto guard-hints) `(("Goal" :use (:instance (:guard-theorem ,old-fn :limited) ; matches the :guard-simplify :limited below :extra-bindings-ok ;; account for the renaming: ,@(alist-to-doublets param-renaming)) :do-not '(generalize eliminate-destructors) ;;TODO; Turn off more stuff: ;; we use the becomes lemma(s): :in-theory '(,@(becomes-theorem-names function-renaming) ;; because untranslate can ;; introduce CASE, which will have ;; EQLABLEP guard obligations that ;; may not be in the original ;; function: (:e eqlablep) (:e eqlable-listp) ; not sure whether this is needed, depends on what kinds of CASE untranslate can put in )) ;; This can speed things up greatly. See comments in verify-guards-for-defun: ("goal'" :clause-processor (simplify-after-using-conjunction-clause-processor clause))))) `(verify-guards$ ,new-fn :hints ,guard-hints :guard-simplify :limited ;; avoid simplification based on the current theory ))) ;todo: combine with rename-params-event? (defun rename-params-fn-core (fn new-name param-renaming-alist fn-event verify-guards untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) ;; (symbolp new-name) (var-renamingp param-renaming-alist) (member-eq verify-guards '(t nil :auto)) (fn-definedp fn (w state)) (member-eq untranslate '(t nil :nice))))) (let ((verify-guards (if (eq :auto verify-guards) (guard-verified-p fn (w state)) verify-guards)) (prologue (transformation-prologue fn (w state))) ;puts in install-not-normalized for fn (and its mutually-recursive partners) ) (if (not (fn-recursivep fn state)) ;; we are operating on a single, non-recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event nil nil untranslate state)) ;; TODO: Can we often avoid adding the :verify-guards t? (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) ; no hints to clean up since non-recursive (becomes-theorem (make-becomes-theorem fn new-fn nil t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem)) ) `(encapsulate () ,@prologue (local ,new-defun) ; has :verify-guards nil (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) (if (fn-singly-recursivep fn state) ;;we are operating on a single, recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event (acons fn new-fn nil) :single untranslate state)) ;;TODO: restrict the hints in this case.. (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) (new-defun-to-export (remove-hints-from-defun new-defun-to-export)) (becomes-theorem (make-becomes-theorem fn new-fn :single t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem))) `(encapsulate () ,@prologue (local ,new-defun) (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) ;; we are operating on a mutually recursive nest of functions: (b* ((ctx `(rename-params ,fn)) (fns (fn-recursive-partners fn (w state))) ;; Handle the :new-name arg: (new-name-alist ;this is an alist, but some values may be :auto (elaborate-mut-rec-option2 new-name :new-name fns ctx)) (function-renaming (pick-new-names new-name-alist state)) (new-fn (lookup-eq-safe fn function-renaming)) (new-defuns (rename-params-in-defuns fns param-renaming-alist fn-event function-renaming untranslate state)) (mut-rec `(mutual-recursion ,@new-defuns)) (flag-function-name (pack$ 'flag- fn)) (make-flag-form `(make-flag ,flag-function-name ,fn)) (becomes-theorems (make-becomes-theorems fns function-renaming t ;todo: thread through a thm-enable argument! t state)) (becomes-defthm-flag (make-becomes-defthm-flag flag-function-name becomes-theorems fns function-renaming nil '(theory 'minimal-theory) (w state)))) `(encapsulate () ,@prologue ,mut-rec (local ,make-flag-form) (local ,becomes-defthm-flag) ,@(clean-up-defthms becomes-theorems) ,@(and verify-guards (list (verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming))))))))) ;; Returns (mv erp event state). ;; todo: allow different renamings for mutual recursion (defun rename-params-event (fn param-renaming new-name verify-guards untranslate state) (declare (xargs :stobjs state :guard (and (symbolp fn) (member-eq verify-guards '(t nil :auto)) (member-eq untranslate '(t nil :nice))) :mode :program)) ;because of the call to my-get-event (b* (((when (and (not (symbol-symbol-doubletp param-renaming)) (not (symbol-symbol-doubletsp param-renaming)))) (er hard? 'rename-params-event "The parameter renaming must be either a doublet (list of length 2) of names, or a list of such doublets, but it is ~x0." param-renaming) (mv :bad-input nil state)) ;; Desugar the param-renaming; (param-renaming-doublets (if (null param-renaming) nil (if (consp (first param-renaming)) ; it's already a list of doublets param-renaming ;; Make a single doublet into a singleton list of doublets: (list param-renaming)))) (param-renaming-alist (doublets-to-alist param-renaming-doublets)) (fns (if (fn-mutually-recursivep fn state) (fn-recursive-partners fn (w state)) ;includes fn (list fn))) (existing-formals (formals-of-fns fns (w state))) ((when (not (subsetp-eq (strip-cars param-renaming-alist) existing-formals))) (er hard? 'rename-params "The renaming, ~x0, includes params that are not among the formals, ~x1, of the function(s)." param-renaming-doublets existing-formals) (mv t nil state)) (fn-event (my-get-event fn (w state))) (event (rename-params-fn-core fn new-name param-renaming-alist fn-event verify-guards untranslate state))) (mv nil event state))) (deftransformation rename-params (fn ;the name of a defined function param-renaming ; a doublet or list of doublets ) ((new-name ':auto) (verify-guards ':auto) (untranslate 't) ;todo: make :nice the default? ) :short "Rename one or more parameters in a function." :arg-descriptions ((fn "Function to transform") (param-renaming "A doublet or list of doublets") (new-name "New name to use for the function (if :auto, the transformation generates a name") (verify-guards "Whether to verify guards of the new function(s).") (untranslate "How to untranslate the function body after changing it.")))
5
; Transformation to rename parameters of a function ; ; Copyright (C) 2015-2022 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Authors: <NAME> ; <NAME> (<EMAIL>) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; STATUS: IN-PROGRESS ;; See tests in rename-params-tests.lisp (include-book "kestrel/terms-light/rename-vars-in-term" :dir :system) (include-book "utilities/deftransformation") (include-book "utilities/function-renamingp") ;(include-book "utilities/maybe-verify-guards2") (include-book "kestrel/std/system/guard-verified-p" :dir :system) (include-book "utilities/names") ; for INCREMENT-NAME-SUFFIX-SAFE (include-book "utilities/make-becomes-theorem") (include-book "utilities/option-parsing") (include-book "utilities/transformation-prologue") (include-book "kestrel/utilities/defun-forms" :dir :system) (include-book "kestrel/utilities/my-get-event" :dir :system) (include-book "kestrel/utilities/doublets2" :dir :system) (include-book "kestrel/utilities/world" :dir :system) (include-book "kestrel/utilities/defining-forms" :dir :system) (include-book "kestrel/alists-light/lookup-eq-safe" :dir :system) (include-book "kestrel/utilities/declares1" :dir :system) ; for substitute-measure-in-declares (include-book "kestrel/utilities/declares" :dir :system) ; for substitute-guard-in-declares (include-book "kestrel/utilities/directed-untranslate-dollar" :dir :system) (include-book "kestrel/utilities/verify-guards-dollar" :dir :system) (include-book "kestrel/terms-light/restore-mv-in-branches" :dir :system) (include-book "kestrel/clause-processors/simplify-after-using-conjunction" :dir :system) (include-book "std/typed-alists/symbol-symbol-alistp" :dir :system) (include-book "misc/install-not-normalized" :dir :system) (local (include-book "kestrel/lists-light/union-equal" :dir :system)) (local (include-book "kestrel/lists-light/len" :dir :system)) (local (in-theory (disable len))) ;; Union together the formals of all the FNS (defun formals-of-fns (fns wrld) (declare (xargs :guard (and (symbol-listp fns) (plist-worldp wrld)))) (if (endp fns) nil (union-eq (fn-formals (first fns) wrld) (formals-of-fns (rest fns) wrld)))) ;; drop these?: (defthm symbolp-of-cdr-assoc-equal-symbol-symbol-alist (implies (and (symbolp x) (symbol-symbol-alistp alist) (assoc-equal (car l) alist)) (symbolp (cdr (assoc-equal x alist))))) (defthm symbol-listp-of-sublis-var-simple-lst (implies (and (symbol-listp l) (symbol-symbol-alistp alist)) (symbol-listp (sublis-var-simple-lst alist l))) :hints (("Goal" :in-theory (enable sublis-var-simple sublis-var-simple-lst)))) (defthm pseudo-termp-of-lookup-equal (implies (and (symbolp x) (symbol-symbol-alistp alist)) (pseudo-termp (lookup-equal x alist))) :hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) ;returns a new defun (defun rename-params-in-defun (fn renaming new-fn fn-event function-renaming rec untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) (fn-definedp fn (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (let* ((wrld (w state)) (body (fn-body fn t wrld)) (ubody (get-body-from-event fn fn-event)) (formals (sublis-var-simple-lst renaming (fn-formals fn wrld))) (declares (get-declares-from-event fn fn-event)) ;TODO: Think about all the kinds of declares that get passed through. (declares (substitute-measure-in-declares declares renaming state)) (declares (substitute-guard-in-declares declares renaming)) (declares (add-verify-guards-nil declares)) ;we will later verify the guards if needed (declares (if rec (replace-xarg-in-declares :hints `(("Goal" :in-theory '() :use (:instance (:termination-theorem ,fn) :extra-bindings-ok ,@(alist-to-doublets renaming)))) declares) declares)) (declares ; cheap way to deal with previous ignorable decls (cons `(declare (ignorable ,@formals)) (remove-declares 'ignorable declares))) (new-body (rename-vars-in-term renaming body renaming)) (new-body (rename-fns new-body function-renaming)) (num-values (num-return-values-of-fn fn wrld)) (new-body (if (<= 2 num-values) (restore-mv-in-branches new-body num-values (strip-cdrs function-renaming) wrld) new-body)) (new-body (if (eq nil untranslate) new-body ;TODO clean up macros at least? clean up mvs too? (if (eq t untranslate) (untranslate new-body nil wrld) (directed-untranslate$ new-body ubody wrld))))) `(defun ,new-fn (,@formals) ,@declares ,new-body))) ;returns the new defuns (defun rename-params-in-defuns (fns renaming fn-event function-renaming untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbol-listp fns) (all-fn-definedp fns (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (if (endp fns) nil (cons (rename-params-in-defun (first fns) renaming (lookup-eq-safe (first fns) function-renaming) ;new name for this fn fn-event function-renaming :mutual untranslate state) (rename-params-in-defuns (rest fns) renaming fn-event function-renaming untranslate state)))) ;; (maybe-verify-guards2 verify-guards ;todo: deprecate maybe-verify-guards2? ;; new-fn ;; `(("Goal" :use ( ;; We instantiate the guard theorem according to ;; ;; the param renaming: ;; (:instance (:guard-theorem ,old-fn nil) ;; :extra-bindings-ok ;; ,@(alist-to-doublets param-renaming)))))) ;; Returns an event. ;; Similar to verify-guards-for-defun, but this one takes a param-renaming. ;; This requires the 'becomes theorems' to already exist. (defun verify-guards-for-rename-params (old-fn new-fn param-renaming function-renaming) (declare (xargs :guard (and (symbolp old-fn) (symbolp new-fn) (symbol-alistp param-renaming) (function-renamingp function-renaming)))) (let ((guard-hints ;;(if (eq :auto guard-hints) `(("Goal" :use (:instance (:guard-theorem ,old-fn :limited) ; matches the :guard-simplify :limited below :extra-bindings-ok ;; account for the renaming: ,@(alist-to-doublets param-renaming)) :do-not '(generalize eliminate-destructors) ;;TODO; Turn off more stuff: ;; we use the becomes lemma(s): :in-theory '(,@(becomes-theorem-names function-renaming) ;; because untranslate can ;; introduce CASE, which will have ;; EQLABLEP guard obligations that ;; may not be in the original ;; function: (:e eqlablep) (:e eqlable-listp) ; not sure whether this is needed, depends on what kinds of CASE untranslate can put in )) ;; This can speed things up greatly. See comments in verify-guards-for-defun: ("goal'" :clause-processor (simplify-after-using-conjunction-clause-processor clause))))) `(verify-guards$ ,new-fn :hints ,guard-hints :guard-simplify :limited ;; avoid simplification based on the current theory ))) ;todo: combine with rename-params-event? (defun rename-params-fn-core (fn new-name param-renaming-alist fn-event verify-guards untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) ;; (symbolp new-name) (var-renamingp param-renaming-alist) (member-eq verify-guards '(t nil :auto)) (fn-definedp fn (w state)) (member-eq untranslate '(t nil :nice))))) (let ((verify-guards (if (eq :auto verify-guards) (guard-verified-p fn (w state)) verify-guards)) (prologue (transformation-prologue fn (w state))) ;puts in install-not-normalized for fn (and its mutually-recursive partners) ) (if (not (fn-recursivep fn state)) ;; we are operating on a single, non-recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event nil nil untranslate state)) ;; TODO: Can we often avoid adding the :verify-guards t? (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) ; no hints to clean up since non-recursive (becomes-theorem (make-becomes-theorem fn new-fn nil t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem)) ) `(encapsulate () ,@prologue (local ,new-defun) ; has :verify-guards nil (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) (if (fn-singly-recursivep fn state) ;;we are operating on a single, recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event (acons fn new-fn nil) :single untranslate state)) ;;TODO: restrict the hints in this case.. (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) (new-defun-to-export (remove-hints-from-defun new-defun-to-export)) (becomes-theorem (make-becomes-theorem fn new-fn :single t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem))) `(encapsulate () ,@prologue (local ,new-defun) (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) ;; we are operating on a mutually recursive nest of functions: (b* ((ctx `(rename-params ,fn)) (fns (fn-recursive-partners fn (w state))) ;; Handle the :new-name arg: (new-name-alist ;this is an alist, but some values may be :auto (elaborate-mut-rec-option2 new-name :new-name fns ctx)) (function-renaming (pick-new-names new-name-alist state)) (new-fn (lookup-eq-safe fn function-renaming)) (new-defuns (rename-params-in-defuns fns param-renaming-alist fn-event function-renaming untranslate state)) (mut-rec `(mutual-recursion ,@new-defuns)) (flag-function-name (pack$ 'flag- fn)) (make-flag-form `(make-flag ,flag-function-name ,fn)) (becomes-theorems (make-becomes-theorems fns function-renaming t ;todo: thread through a thm-enable argument! t state)) (becomes-defthm-flag (make-becomes-defthm-flag flag-function-name becomes-theorems fns function-renaming nil '(theory 'minimal-theory) (w state)))) `(encapsulate () ,@prologue ,mut-rec (local ,make-flag-form) (local ,becomes-defthm-flag) ,@(clean-up-defthms becomes-theorems) ,@(and verify-guards (list (verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming))))))))) ;; Returns (mv erp event state). ;; todo: allow different renamings for mutual recursion (defun rename-params-event (fn param-renaming new-name verify-guards untranslate state) (declare (xargs :stobjs state :guard (and (symbolp fn) (member-eq verify-guards '(t nil :auto)) (member-eq untranslate '(t nil :nice))) :mode :program)) ;because of the call to my-get-event (b* (((when (and (not (symbol-symbol-doubletp param-renaming)) (not (symbol-symbol-doubletsp param-renaming)))) (er hard? 'rename-params-event "The parameter renaming must be either a doublet (list of length 2) of names, or a list of such doublets, but it is ~x0." param-renaming) (mv :bad-input nil state)) ;; Desugar the param-renaming; (param-renaming-doublets (if (null param-renaming) nil (if (consp (first param-renaming)) ; it's already a list of doublets param-renaming ;; Make a single doublet into a singleton list of doublets: (list param-renaming)))) (param-renaming-alist (doublets-to-alist param-renaming-doublets)) (fns (if (fn-mutually-recursivep fn state) (fn-recursive-partners fn (w state)) ;includes fn (list fn))) (existing-formals (formals-of-fns fns (w state))) ((when (not (subsetp-eq (strip-cars param-renaming-alist) existing-formals))) (er hard? 'rename-params "The renaming, ~x0, includes params that are not among the formals, ~x1, of the function(s)." param-renaming-doublets existing-formals) (mv t nil state)) (fn-event (my-get-event fn (w state))) (event (rename-params-fn-core fn new-name param-renaming-alist fn-event verify-guards untranslate state))) (mv nil event state))) (deftransformation rename-params (fn ;the name of a defined function param-renaming ; a doublet or list of doublets ) ((new-name ':auto) (verify-guards ':auto) (untranslate 't) ;todo: make :nice the default? ) :short "Rename one or more parameters in a function." :arg-descriptions ((fn "Function to transform") (param-renaming "A doublet or list of doublets") (new-name "New name to use for the function (if :auto, the transformation generates a name") (verify-guards "Whether to verify guards of the new function(s).") (untranslate "How to untranslate the function body after changing it.")))
true
; Transformation to rename parameters of a function ; ; Copyright (C) 2015-2022 Kestrel Institute ; ; License: A 3-clause BSD license. See the file books/3BSD-mod.txt. ; ; Authors: PI:NAME:<NAME>END_PI ; PI:NAME:<NAME>END_PI (PI:EMAIL:<EMAIL>END_PI) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "ACL2") ;; STATUS: IN-PROGRESS ;; See tests in rename-params-tests.lisp (include-book "kestrel/terms-light/rename-vars-in-term" :dir :system) (include-book "utilities/deftransformation") (include-book "utilities/function-renamingp") ;(include-book "utilities/maybe-verify-guards2") (include-book "kestrel/std/system/guard-verified-p" :dir :system) (include-book "utilities/names") ; for INCREMENT-NAME-SUFFIX-SAFE (include-book "utilities/make-becomes-theorem") (include-book "utilities/option-parsing") (include-book "utilities/transformation-prologue") (include-book "kestrel/utilities/defun-forms" :dir :system) (include-book "kestrel/utilities/my-get-event" :dir :system) (include-book "kestrel/utilities/doublets2" :dir :system) (include-book "kestrel/utilities/world" :dir :system) (include-book "kestrel/utilities/defining-forms" :dir :system) (include-book "kestrel/alists-light/lookup-eq-safe" :dir :system) (include-book "kestrel/utilities/declares1" :dir :system) ; for substitute-measure-in-declares (include-book "kestrel/utilities/declares" :dir :system) ; for substitute-guard-in-declares (include-book "kestrel/utilities/directed-untranslate-dollar" :dir :system) (include-book "kestrel/utilities/verify-guards-dollar" :dir :system) (include-book "kestrel/terms-light/restore-mv-in-branches" :dir :system) (include-book "kestrel/clause-processors/simplify-after-using-conjunction" :dir :system) (include-book "std/typed-alists/symbol-symbol-alistp" :dir :system) (include-book "misc/install-not-normalized" :dir :system) (local (include-book "kestrel/lists-light/union-equal" :dir :system)) (local (include-book "kestrel/lists-light/len" :dir :system)) (local (in-theory (disable len))) ;; Union together the formals of all the FNS (defun formals-of-fns (fns wrld) (declare (xargs :guard (and (symbol-listp fns) (plist-worldp wrld)))) (if (endp fns) nil (union-eq (fn-formals (first fns) wrld) (formals-of-fns (rest fns) wrld)))) ;; drop these?: (defthm symbolp-of-cdr-assoc-equal-symbol-symbol-alist (implies (and (symbolp x) (symbol-symbol-alistp alist) (assoc-equal (car l) alist)) (symbolp (cdr (assoc-equal x alist))))) (defthm symbol-listp-of-sublis-var-simple-lst (implies (and (symbol-listp l) (symbol-symbol-alistp alist)) (symbol-listp (sublis-var-simple-lst alist l))) :hints (("Goal" :in-theory (enable sublis-var-simple sublis-var-simple-lst)))) (defthm pseudo-termp-of-lookup-equal (implies (and (symbolp x) (symbol-symbol-alistp alist)) (pseudo-termp (lookup-equal x alist))) :hints (("Goal" :in-theory (enable symbol-symbol-alistp)))) ;returns a new defun (defun rename-params-in-defun (fn renaming new-fn fn-event function-renaming rec untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) (fn-definedp fn (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (let* ((wrld (w state)) (body (fn-body fn t wrld)) (ubody (get-body-from-event fn fn-event)) (formals (sublis-var-simple-lst renaming (fn-formals fn wrld))) (declares (get-declares-from-event fn fn-event)) ;TODO: Think about all the kinds of declares that get passed through. (declares (substitute-measure-in-declares declares renaming state)) (declares (substitute-guard-in-declares declares renaming)) (declares (add-verify-guards-nil declares)) ;we will later verify the guards if needed (declares (if rec (replace-xarg-in-declares :hints `(("Goal" :in-theory '() :use (:instance (:termination-theorem ,fn) :extra-bindings-ok ,@(alist-to-doublets renaming)))) declares) declares)) (declares ; cheap way to deal with previous ignorable decls (cons `(declare (ignorable ,@formals)) (remove-declares 'ignorable declares))) (new-body (rename-vars-in-term renaming body renaming)) (new-body (rename-fns new-body function-renaming)) (num-values (num-return-values-of-fn fn wrld)) (new-body (if (<= 2 num-values) (restore-mv-in-branches new-body num-values (strip-cdrs function-renaming) wrld) new-body)) (new-body (if (eq nil untranslate) new-body ;TODO clean up macros at least? clean up mvs too? (if (eq t untranslate) (untranslate new-body nil wrld) (directed-untranslate$ new-body ubody wrld))))) `(defun ,new-fn (,@formals) ,@declares ,new-body))) ;returns the new defuns (defun rename-params-in-defuns (fns renaming fn-event function-renaming untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbol-listp fns) (all-fn-definedp fns (w state)) (var-renamingp renaming) (function-renamingp function-renaming) (member-eq untranslate '(t nil :nice))))) (if (endp fns) nil (cons (rename-params-in-defun (first fns) renaming (lookup-eq-safe (first fns) function-renaming) ;new name for this fn fn-event function-renaming :mutual untranslate state) (rename-params-in-defuns (rest fns) renaming fn-event function-renaming untranslate state)))) ;; (maybe-verify-guards2 verify-guards ;todo: deprecate maybe-verify-guards2? ;; new-fn ;; `(("Goal" :use ( ;; We instantiate the guard theorem according to ;; ;; the param renaming: ;; (:instance (:guard-theorem ,old-fn nil) ;; :extra-bindings-ok ;; ,@(alist-to-doublets param-renaming)))))) ;; Returns an event. ;; Similar to verify-guards-for-defun, but this one takes a param-renaming. ;; This requires the 'becomes theorems' to already exist. (defun verify-guards-for-rename-params (old-fn new-fn param-renaming function-renaming) (declare (xargs :guard (and (symbolp old-fn) (symbolp new-fn) (symbol-alistp param-renaming) (function-renamingp function-renaming)))) (let ((guard-hints ;;(if (eq :auto guard-hints) `(("Goal" :use (:instance (:guard-theorem ,old-fn :limited) ; matches the :guard-simplify :limited below :extra-bindings-ok ;; account for the renaming: ,@(alist-to-doublets param-renaming)) :do-not '(generalize eliminate-destructors) ;;TODO; Turn off more stuff: ;; we use the becomes lemma(s): :in-theory '(,@(becomes-theorem-names function-renaming) ;; because untranslate can ;; introduce CASE, which will have ;; EQLABLEP guard obligations that ;; may not be in the original ;; function: (:e eqlablep) (:e eqlable-listp) ; not sure whether this is needed, depends on what kinds of CASE untranslate can put in )) ;; This can speed things up greatly. See comments in verify-guards-for-defun: ("goal'" :clause-processor (simplify-after-using-conjunction-clause-processor clause))))) `(verify-guards$ ,new-fn :hints ,guard-hints :guard-simplify :limited ;; avoid simplification based on the current theory ))) ;todo: combine with rename-params-event? (defun rename-params-fn-core (fn new-name param-renaming-alist fn-event verify-guards untranslate state) (declare (xargs :stobjs state :mode :program ;because we call untranslate :guard (and (symbolp fn) ;; (symbolp new-name) (var-renamingp param-renaming-alist) (member-eq verify-guards '(t nil :auto)) (fn-definedp fn (w state)) (member-eq untranslate '(t nil :nice))))) (let ((verify-guards (if (eq :auto verify-guards) (guard-verified-p fn (w state)) verify-guards)) (prologue (transformation-prologue fn (w state))) ;puts in install-not-normalized for fn (and its mutually-recursive partners) ) (if (not (fn-recursivep fn state)) ;; we are operating on a single, non-recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event nil nil untranslate state)) ;; TODO: Can we often avoid adding the :verify-guards t? (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) ; no hints to clean up since non-recursive (becomes-theorem (make-becomes-theorem fn new-fn nil t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem)) ) `(encapsulate () ,@prologue (local ,new-defun) ; has :verify-guards nil (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) (if (fn-singly-recursivep fn state) ;;we are operating on a single, recursive function: (b* ((new-fn (if (eq :auto new-name) (increment-name-suffix-safe fn state) new-name)) (function-renaming (acons fn new-fn nil)) (new-defun (rename-params-in-defun fn param-renaming-alist new-fn fn-event (acons fn new-fn nil) :single untranslate state)) ;;TODO: restrict the hints in this case.. (new-defun-to-export (if verify-guards (add-verify-guards-t-to-defun new-defun) new-defun)) (new-defun-to-export (remove-hints-from-defun new-defun-to-export)) (becomes-theorem (make-becomes-theorem fn new-fn :single t nil '(theory 'minimal-theory) t state)) ;; Remove :hints from the theorem before exporting it: (becomes-theorem-to-export (clean-up-defthm becomes-theorem))) `(encapsulate () ,@prologue (local ,new-defun) (local (install-not-normalized ,new-fn)) (local ,becomes-theorem) ,@(and verify-guards `((local ,(verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming)))) ,new-defun-to-export ,becomes-theorem-to-export)) ;; we are operating on a mutually recursive nest of functions: (b* ((ctx `(rename-params ,fn)) (fns (fn-recursive-partners fn (w state))) ;; Handle the :new-name arg: (new-name-alist ;this is an alist, but some values may be :auto (elaborate-mut-rec-option2 new-name :new-name fns ctx)) (function-renaming (pick-new-names new-name-alist state)) (new-fn (lookup-eq-safe fn function-renaming)) (new-defuns (rename-params-in-defuns fns param-renaming-alist fn-event function-renaming untranslate state)) (mut-rec `(mutual-recursion ,@new-defuns)) (flag-function-name (pack$ 'flag- fn)) (make-flag-form `(make-flag ,flag-function-name ,fn)) (becomes-theorems (make-becomes-theorems fns function-renaming t ;todo: thread through a thm-enable argument! t state)) (becomes-defthm-flag (make-becomes-defthm-flag flag-function-name becomes-theorems fns function-renaming nil '(theory 'minimal-theory) (w state)))) `(encapsulate () ,@prologue ,mut-rec (local ,make-flag-form) (local ,becomes-defthm-flag) ,@(clean-up-defthms becomes-theorems) ,@(and verify-guards (list (verify-guards-for-rename-params fn new-fn param-renaming-alist function-renaming))))))))) ;; Returns (mv erp event state). ;; todo: allow different renamings for mutual recursion (defun rename-params-event (fn param-renaming new-name verify-guards untranslate state) (declare (xargs :stobjs state :guard (and (symbolp fn) (member-eq verify-guards '(t nil :auto)) (member-eq untranslate '(t nil :nice))) :mode :program)) ;because of the call to my-get-event (b* (((when (and (not (symbol-symbol-doubletp param-renaming)) (not (symbol-symbol-doubletsp param-renaming)))) (er hard? 'rename-params-event "The parameter renaming must be either a doublet (list of length 2) of names, or a list of such doublets, but it is ~x0." param-renaming) (mv :bad-input nil state)) ;; Desugar the param-renaming; (param-renaming-doublets (if (null param-renaming) nil (if (consp (first param-renaming)) ; it's already a list of doublets param-renaming ;; Make a single doublet into a singleton list of doublets: (list param-renaming)))) (param-renaming-alist (doublets-to-alist param-renaming-doublets)) (fns (if (fn-mutually-recursivep fn state) (fn-recursive-partners fn (w state)) ;includes fn (list fn))) (existing-formals (formals-of-fns fns (w state))) ((when (not (subsetp-eq (strip-cars param-renaming-alist) existing-formals))) (er hard? 'rename-params "The renaming, ~x0, includes params that are not among the formals, ~x1, of the function(s)." param-renaming-doublets existing-formals) (mv t nil state)) (fn-event (my-get-event fn (w state))) (event (rename-params-fn-core fn new-name param-renaming-alist fn-event verify-guards untranslate state))) (mv nil event state))) (deftransformation rename-params (fn ;the name of a defined function param-renaming ; a doublet or list of doublets ) ((new-name ':auto) (verify-guards ':auto) (untranslate 't) ;todo: make :nice the default? ) :short "Rename one or more parameters in a function." :arg-descriptions ((fn "Function to transform") (param-renaming "A doublet or list of doublets") (new-name "New name to use for the function (if :auto, the transformation generates a name") (verify-guards "Whether to verify guards of the new function(s).") (untranslate "How to untranslate the function body after changing it.")))
[ { "context": "s\"))\n\n(defsystem \"data-flow/protocols\"\n :author \"Mark Cox\"\n :description \"Protocols for the data-flow syst", "end": 151, "score": 0.9997377991676331, "start": 143, "tag": "NAME", "value": "Mark Cox" }, { "context": "ts\")))))\n\n(defsystem \"data-flow/utils\"\n :author \"Mark Cox\"\n :description \"Utilities for the data-flow syst", "end": 504, "score": 0.9997978210449219, "start": 496, "tag": "NAME", "value": "Mark Cox" }, { "context": ")))\n\n(defsystem \"data-flow/containers\"\n :author \"Mark Cox\"\n :description \"Containers for the data-flow sys", "end": 868, "score": 0.9997987151145935, "start": 860, "tag": "NAME", "value": "Mark Cox" }, { "context": ")))\n\n(defsystem \"data-flow/schedulers\"\n :author \"Mark Cox\"\n :description \"Schedulers for the data-flow sys", "end": 1524, "score": 0.9997678399085999, "start": 1516, "tag": "NAME", "value": "Mark Cox" }, { "context": "efsystem \"data-flow/sequential-object\"\n :author \"Mark Cox\"\n :description \"Utilities for linearizing functi", "end": 2211, "score": 0.99983149766922, "start": 2203, "tag": "NAME", "value": "Mark Cox" }, { "context": ")))\n\n(defsystem \"data-flow/components\"\n :author \"Mark Cox\"\n :description \"Component implementations for th", "end": 2877, "score": 0.9998178482055664, "start": 2869, "tag": "NAME", "value": "Mark Cox" }, { "context": "omponent\")))))\n\n(defsystem \"data-flow\"\n :author \"Mark Cox\"\n :description \"A framework for authoring and us", "end": 3432, "score": 0.9998233914375305, "start": 3424, "tag": "NAME", "value": "Mark Cox" }, { "context": "s\n\n(defsystem \"data-flow/tests/common\"\n :author \"Mark Cox\"\n :description \"Common functionality needed for ", "end": 3801, "score": 0.9998151659965515, "start": 3793, "tag": "NAME", "value": "Mark Cox" }, { "context": "defsystem \"data-flow/containers/tests\"\n :author \"Mark Cox\"\n :description \"Tests for the data-flow/containe", "end": 4131, "score": 0.9998373985290527, "start": 4123, "tag": "NAME", "value": "Mark Cox" }, { "context": "defsystem \"data-flow/schedulers/tests\"\n :author \"Mark Cox\"\n :description \"Tests for the data-flow/schedule", "end": 4661, "score": 0.9997859597206116, "start": 4653, "tag": "NAME", "value": "Mark Cox" }, { "context": "em \"data-flow/sequential-object/tests\"\n :author \"Mark Cox\"\n :description \"An abstraction for linearzing op", "end": 5248, "score": 0.9997666478157043, "start": 5240, "tag": "NAME", "value": "Mark Cox" }, { "context": "defsystem \"data-flow/components/tests\"\n :author \"Mark Cox\"\n :description \"Tests for the data-flow/componen", "end": 5665, "score": 0.9997610449790955, "start": 5657, "tag": "NAME", "value": "Mark Cox" }, { "context": "rt\")))))\n\n(defsystem \"data-flow/tests\"\n :author \"Mark Cox\"\n :description \"Tests for the data-flow system.\"", "end": 6191, "score": 0.9996933341026306, "start": 6183, "tag": "NAME", "value": "Mark Cox" } ]
data-flow.asd
markcox80/data-flow
2
(eval-when (:compile-toplevel :load-toplevel :execute) (asdf:load-system "data-flow-features")) (defsystem "data-flow/protocols" :author "Mark Cox" :description "Protocols for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "protocols" :serial t :components ((:file "packages") (:file "protocols") (:file "ports"))))) (defsystem "data-flow/utils" :author "Mark Cox" :description "Utilities for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "utils" :serial t :components ((:file "packages") (:file "sbcl" :if-feature (:and :sbcl data-flow.features:compare-and-set)))))) (defsystem "data-flow/containers" :author "Mark Cox" :description "Containers for the data-flow system." :serial t :depends-on ("data-flow/utils") :components ((:module "containers" :serial t :components ((:file "packages") (:file "protocols") (:file "fifo") (:file "linked-list") (:file "bt-mutex-queue" :if-feature data-flow.features:threads) (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set) (:file "helpers"))))) (defsystem "data-flow/schedulers" :author "Mark Cox" :description "Schedulers for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "schedulers" :serial t :components ((:file "packages") (:file "common") (:file "sequential") (:file "thread-pool-common") (:file "thread-pool-parallel" :if-feature data-flow.features:threads) (:file "thread-pool") (:file "resource"))))) (defsystem "data-flow/sequential-object" :author "Mark Cox" :description "Utilities for linearizing function calls." :serial t :depends-on ("data-flow/containers") :components ((:module "sequential-object" :serial t :components ((:file "packages") (:file "protocols") (:file "single-thread") (:file "parallel") (:file "bt" :if-feature data-flow.features:threads) (:file "cas" :if-feature data-flow.features:compare-and-set) (:file "sequential-object"))))) (defsystem "data-flow/components" :author "Mark Cox" :description "Component implementations for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "components" :serial t :components ((:file "packages") (:file "basic-component") (:file "disconnected-port") (:file "standard-port") (:file "standard-component"))))) (defsystem "data-flow" :author "Mark Cox" :description "A framework for authoring and using components that process data arriving via ports." :depends-on ("data-flow/schedulers" "data-flow/components") :license "Simplified BSD License variant" :version "0.9.0" :in-order-to ((test-op (test-op "data-flow/tests")))) ;;;; Tests (defsystem "data-flow/tests/common" :author "Mark Cox" :description "Common functionality needed for the data-flow/tests system." :depends-on ("fiveam") :serial t :components ((:module "tests" :serial t :components ((:file "packages") (:file "asdf"))))) (defsystem "data-flow/containers/tests" :author "Mark Cox" :description "Tests for the data-flow/containers system." :depends-on ("data-flow/tests/common" "data-flow/containers") :serial t :components ((:module "containers/tests" :serial t :components ((:file "packages") (:file "fifo") (:file "linked-list") (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set))))) (defsystem "data-flow/schedulers/tests" :author "Mark Cox" :description "Tests for the data-flow/schedulers system." :depends-on ("data-flow/tests/common" "data-flow/schedulers") :serial t :components ((:module "schedulers/tests" :serial t :components ((:file "packages") (:file "scheduler") (:file "sequential") (:file "parallel") (:file "resource") (:file "thread-pool"))))) (defsystem "data-flow/sequential-object/tests" :author "Mark Cox" :description "An abstraction for linearzing operations on an object." :depends-on ("data-flow/tests/common" "data-flow/sequential-object") :serial t :components ((:module "sequential-object/tests" :serial t :components ((:file "packages") (:file "sequential-object"))))) (defsystem "data-flow/components/tests" :author "Mark Cox" :description "Tests for the data-flow/components system." :depends-on ("data-flow/tests/common" "data-flow/schedulers/tests" "data-flow/components") :serial t :components ((:module "components/tests" :serial t :components ((:file "packages") (:file "component") (:file "disconnected-port") (:file "standard-port"))))) (defsystem "data-flow/tests" :author "Mark Cox" :description "Tests for the data-flow system." :depends-on ("data-flow/tests/common" "data-flow/containers/tests" "data-flow/schedulers/tests" "data-flow/sequential-object/tests" "data-flow/components/tests"))
72175
(eval-when (:compile-toplevel :load-toplevel :execute) (asdf:load-system "data-flow-features")) (defsystem "data-flow/protocols" :author "<NAME>" :description "Protocols for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "protocols" :serial t :components ((:file "packages") (:file "protocols") (:file "ports"))))) (defsystem "data-flow/utils" :author "<NAME>" :description "Utilities for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "utils" :serial t :components ((:file "packages") (:file "sbcl" :if-feature (:and :sbcl data-flow.features:compare-and-set)))))) (defsystem "data-flow/containers" :author "<NAME>" :description "Containers for the data-flow system." :serial t :depends-on ("data-flow/utils") :components ((:module "containers" :serial t :components ((:file "packages") (:file "protocols") (:file "fifo") (:file "linked-list") (:file "bt-mutex-queue" :if-feature data-flow.features:threads) (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set) (:file "helpers"))))) (defsystem "data-flow/schedulers" :author "<NAME>" :description "Schedulers for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "schedulers" :serial t :components ((:file "packages") (:file "common") (:file "sequential") (:file "thread-pool-common") (:file "thread-pool-parallel" :if-feature data-flow.features:threads) (:file "thread-pool") (:file "resource"))))) (defsystem "data-flow/sequential-object" :author "<NAME>" :description "Utilities for linearizing function calls." :serial t :depends-on ("data-flow/containers") :components ((:module "sequential-object" :serial t :components ((:file "packages") (:file "protocols") (:file "single-thread") (:file "parallel") (:file "bt" :if-feature data-flow.features:threads) (:file "cas" :if-feature data-flow.features:compare-and-set) (:file "sequential-object"))))) (defsystem "data-flow/components" :author "<NAME>" :description "Component implementations for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "components" :serial t :components ((:file "packages") (:file "basic-component") (:file "disconnected-port") (:file "standard-port") (:file "standard-component"))))) (defsystem "data-flow" :author "<NAME>" :description "A framework for authoring and using components that process data arriving via ports." :depends-on ("data-flow/schedulers" "data-flow/components") :license "Simplified BSD License variant" :version "0.9.0" :in-order-to ((test-op (test-op "data-flow/tests")))) ;;;; Tests (defsystem "data-flow/tests/common" :author "<NAME>" :description "Common functionality needed for the data-flow/tests system." :depends-on ("fiveam") :serial t :components ((:module "tests" :serial t :components ((:file "packages") (:file "asdf"))))) (defsystem "data-flow/containers/tests" :author "<NAME>" :description "Tests for the data-flow/containers system." :depends-on ("data-flow/tests/common" "data-flow/containers") :serial t :components ((:module "containers/tests" :serial t :components ((:file "packages") (:file "fifo") (:file "linked-list") (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set))))) (defsystem "data-flow/schedulers/tests" :author "<NAME>" :description "Tests for the data-flow/schedulers system." :depends-on ("data-flow/tests/common" "data-flow/schedulers") :serial t :components ((:module "schedulers/tests" :serial t :components ((:file "packages") (:file "scheduler") (:file "sequential") (:file "parallel") (:file "resource") (:file "thread-pool"))))) (defsystem "data-flow/sequential-object/tests" :author "<NAME>" :description "An abstraction for linearzing operations on an object." :depends-on ("data-flow/tests/common" "data-flow/sequential-object") :serial t :components ((:module "sequential-object/tests" :serial t :components ((:file "packages") (:file "sequential-object"))))) (defsystem "data-flow/components/tests" :author "<NAME>" :description "Tests for the data-flow/components system." :depends-on ("data-flow/tests/common" "data-flow/schedulers/tests" "data-flow/components") :serial t :components ((:module "components/tests" :serial t :components ((:file "packages") (:file "component") (:file "disconnected-port") (:file "standard-port"))))) (defsystem "data-flow/tests" :author "<NAME>" :description "Tests for the data-flow system." :depends-on ("data-flow/tests/common" "data-flow/containers/tests" "data-flow/schedulers/tests" "data-flow/sequential-object/tests" "data-flow/components/tests"))
true
(eval-when (:compile-toplevel :load-toplevel :execute) (asdf:load-system "data-flow-features")) (defsystem "data-flow/protocols" :author "PI:NAME:<NAME>END_PI" :description "Protocols for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "protocols" :serial t :components ((:file "packages") (:file "protocols") (:file "ports"))))) (defsystem "data-flow/utils" :author "PI:NAME:<NAME>END_PI" :description "Utilities for the data-flow system." :depends-on ("alexandria") :serial t :components ((:module "utils" :serial t :components ((:file "packages") (:file "sbcl" :if-feature (:and :sbcl data-flow.features:compare-and-set)))))) (defsystem "data-flow/containers" :author "PI:NAME:<NAME>END_PI" :description "Containers for the data-flow system." :serial t :depends-on ("data-flow/utils") :components ((:module "containers" :serial t :components ((:file "packages") (:file "protocols") (:file "fifo") (:file "linked-list") (:file "bt-mutex-queue" :if-feature data-flow.features:threads) (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set) (:file "helpers"))))) (defsystem "data-flow/schedulers" :author "PI:NAME:<NAME>END_PI" :description "Schedulers for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "schedulers" :serial t :components ((:file "packages") (:file "common") (:file "sequential") (:file "thread-pool-common") (:file "thread-pool-parallel" :if-feature data-flow.features:threads) (:file "thread-pool") (:file "resource"))))) (defsystem "data-flow/sequential-object" :author "PI:NAME:<NAME>END_PI" :description "Utilities for linearizing function calls." :serial t :depends-on ("data-flow/containers") :components ((:module "sequential-object" :serial t :components ((:file "packages") (:file "protocols") (:file "single-thread") (:file "parallel") (:file "bt" :if-feature data-flow.features:threads) (:file "cas" :if-feature data-flow.features:compare-and-set) (:file "sequential-object"))))) (defsystem "data-flow/components" :author "PI:NAME:<NAME>END_PI" :description "Component implementations for the data-flow system." :serial t :depends-on ("data-flow/protocols" "data-flow/containers" "data-flow/sequential-object") :components ((:module "components" :serial t :components ((:file "packages") (:file "basic-component") (:file "disconnected-port") (:file "standard-port") (:file "standard-component"))))) (defsystem "data-flow" :author "PI:NAME:<NAME>END_PI" :description "A framework for authoring and using components that process data arriving via ports." :depends-on ("data-flow/schedulers" "data-flow/components") :license "Simplified BSD License variant" :version "0.9.0" :in-order-to ((test-op (test-op "data-flow/tests")))) ;;;; Tests (defsystem "data-flow/tests/common" :author "PI:NAME:<NAME>END_PI" :description "Common functionality needed for the data-flow/tests system." :depends-on ("fiveam") :serial t :components ((:module "tests" :serial t :components ((:file "packages") (:file "asdf"))))) (defsystem "data-flow/containers/tests" :author "PI:NAME:<NAME>END_PI" :description "Tests for the data-flow/containers system." :depends-on ("data-flow/tests/common" "data-flow/containers") :serial t :components ((:module "containers/tests" :serial t :components ((:file "packages") (:file "fifo") (:file "linked-list") (:file "lock-free-fifo" :if-feature data-flow.features:compare-and-set))))) (defsystem "data-flow/schedulers/tests" :author "PI:NAME:<NAME>END_PI" :description "Tests for the data-flow/schedulers system." :depends-on ("data-flow/tests/common" "data-flow/schedulers") :serial t :components ((:module "schedulers/tests" :serial t :components ((:file "packages") (:file "scheduler") (:file "sequential") (:file "parallel") (:file "resource") (:file "thread-pool"))))) (defsystem "data-flow/sequential-object/tests" :author "PI:NAME:<NAME>END_PI" :description "An abstraction for linearzing operations on an object." :depends-on ("data-flow/tests/common" "data-flow/sequential-object") :serial t :components ((:module "sequential-object/tests" :serial t :components ((:file "packages") (:file "sequential-object"))))) (defsystem "data-flow/components/tests" :author "PI:NAME:<NAME>END_PI" :description "Tests for the data-flow/components system." :depends-on ("data-flow/tests/common" "data-flow/schedulers/tests" "data-flow/components") :serial t :components ((:module "components/tests" :serial t :components ((:file "packages") (:file "component") (:file "disconnected-port") (:file "standard-port"))))) (defsystem "data-flow/tests" :author "PI:NAME:<NAME>END_PI" :description "Tests for the data-flow system." :depends-on ("data-flow/tests/common" "data-flow/containers/tests" "data-flow/schedulers/tests" "data-flow/sequential-object/tests" "data-flow/components/tests"))
[ { "context": "mposed.btrie.system)\n\n(defsystem btrie\n :author \"Peter Hillerström <[email protected]>\"\n :license \"Simpli", "end": 170, "score": 0.9998931884765625, "start": 153, "tag": "NAME", "value": "Peter Hillerström" }, { "context": ")\n\n(defsystem btrie\n :author \"Peter Hillerström <[email protected]>\"\n :license \"Simplified BSD license.\"\n :version", "end": 199, "score": 0.9999284148216248, "start": 172, "tag": "EMAIL", "value": "[email protected]" } ]
btrie.asd
peterhil/btrie
6
(in-package #:cl-user) (defpackage #:nu.composed.btrie.system (:use #:cl #:asdf)) (in-package #:nu.composed.btrie.system) (defsystem btrie :author "Peter Hillerström <[email protected]>" :license "Simplified BSD license." :version "0.2.1" :description "Branch trie - a generic trie implementation with branch widths. * Implementation is generic: keys can be of sequences of any type. * Branch width of a trie node tells how many branches go through that node and can be used to calculate probabilites for different suffixes." :depends-on (:arnesi :split-sequence :lift) :serial t :components ((:file "btrie"))) (defsystem btrie-tests :depends-on (:btrie :lift :metabang-bind) :serial t :components ((:file "tests")))
4090
(in-package #:cl-user) (defpackage #:nu.composed.btrie.system (:use #:cl #:asdf)) (in-package #:nu.composed.btrie.system) (defsystem btrie :author "<NAME> <<EMAIL>>" :license "Simplified BSD license." :version "0.2.1" :description "Branch trie - a generic trie implementation with branch widths. * Implementation is generic: keys can be of sequences of any type. * Branch width of a trie node tells how many branches go through that node and can be used to calculate probabilites for different suffixes." :depends-on (:arnesi :split-sequence :lift) :serial t :components ((:file "btrie"))) (defsystem btrie-tests :depends-on (:btrie :lift :metabang-bind) :serial t :components ((:file "tests")))
true
(in-package #:cl-user) (defpackage #:nu.composed.btrie.system (:use #:cl #:asdf)) (in-package #:nu.composed.btrie.system) (defsystem btrie :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "Simplified BSD license." :version "0.2.1" :description "Branch trie - a generic trie implementation with branch widths. * Implementation is generic: keys can be of sequences of any type. * Branch width of a trie node tells how many branches go through that node and can be used to calculate probabilites for different suffixes." :depends-on (:arnesi :split-sequence :lift) :serial t :components ((:file "btrie"))) (defsystem btrie-tests :depends-on (:btrie :lift :metabang-bind) :serial t :components ((:file "tests")))
[ { "context": "ption \"cl-dot support for cl-digraph\"\n\n :author \"Steve Losh <[email protected]>\"\n :license \"MIT\"\n\n :depen", "end": 101, "score": 0.9998914003372192, "start": 91, "tag": "NAME", "value": "Steve Losh" }, { "context": "t support for cl-digraph\"\n\n :author \"Steve Losh <[email protected]>\"\n :license \"MIT\"\n\n :depends-on (:cl-digraph\n ", "end": 122, "score": 0.9999277591705322, "start": 103, "tag": "EMAIL", "value": "[email protected]" } ]
cl-digraph.dot.asd
sjl/travis-test
22
(asdf:defsystem :cl-digraph.dot :description "cl-dot support for cl-digraph" :author "Steve Losh <[email protected]>" :license "MIT" :depends-on (:cl-digraph :cl-dot) :serial t :components ((:file "package.dot") (:module "src" :serial t :components ((:file "dot")))))
32113
(asdf:defsystem :cl-digraph.dot :description "cl-dot support for cl-digraph" :author "<NAME> <<EMAIL>>" :license "MIT" :depends-on (:cl-digraph :cl-dot) :serial t :components ((:file "package.dot") (:module "src" :serial t :components ((:file "dot")))))
true
(asdf:defsystem :cl-digraph.dot :description "cl-dot support for cl-digraph" :author "PI:NAME:<NAME>END_PI <PI:EMAIL:<EMAIL>END_PI>" :license "MIT" :depends-on (:cl-digraph :cl-dot) :serial t :components ((:file "package.dot") (:module "src" :serial t :components ((:file "dot")))))
[ { "context": "ule for definite integrals of infinite series.\n\n;; Cuong Chau April, 2015\n\n(in-pack", "end": 82, "score": 0.9996924996376038, "start": 72, "tag": "NAME", "value": "Cuong Chau" } ]
books/workshops/2015/chau-kaufmann-hunt/support/int-infinite-sum-2.lisp
mayankmanj/acl2
305
;; Proof of the sum rule for definite integrals of infinite series. ;; Cuong Chau April, 2015 (in-package "ACL2") (include-book "riemann-integral/ftc-1-2") (include-book "utils") (local (include-book "nonstd/nsa/overspill" :dir :system)) (local (include-book "nonstd/integrals/ftc-2" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) ;; ====================================================================== (encapsulate ((low () t) (fi-prime (x i) t) (fi-domain () t)) (local (defun low () 0)) (local (defun fi-prime (x i) (declare (ignore x i)) 0)) (local (defun fi-domain () (interval nil nil))) (defthm inside-interval-p-low (inside-interval-p (low) (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm realp-fi-prime (realp (fi-prime x i)) :rule-classes :type-prescription) (defthm intervalp-fi-domain (interval-p (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm fi-domain-real (implies (inside-interval-p x (fi-domain)) (realp x)) :rule-classes (:forward-chaining)) (defthm fi-domain-non-trivial (or (null (interval-left-endpoint (fi-domain))) (null (interval-right-endpoint (fi-domain))) (< (interval-left-endpoint (fi-domain)) (interval-right-endpoint (fi-domain)))) :rule-classes nil) (defthm fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (fi-prime x i) (fi-prime y i)))) (defun sum-fi-prime (x i) (if (zp i) (fi-prime x 0) (+ (fi-prime x i) (sum-fi-prime x (1- i))))) (defthm i-limited-sum-fi-prime (implies (and (inside-interval-p x (fi-domain)) (natp i) (i-large i)) (i-limited (sum-fi-prime x i)))) (defun-std sum-fi-prime-infinity (x) (if (inside-interval-p x (fi-domain)) (standard-part (sum-fi-prime x (i-large-integer))) 0)) (local (defthm sum-fi-prime-equals-0 (equal (sum-fi-prime x i) 0))) (local (defthm-std sum-fi-prime-infinity-equals-0 (equal (sum-fi-prime-infinity x) 0))) (defthm sum-fi-prime-uniformly-converge (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime x i))))) (defthm-std standardp-fi-prime (implies (and (standardp x) (standardp i)) (standardp (fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-sum-fi-prime (implies (and (standardp x) (standardp i)) (standardp (sum-fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-fi-domain (standardp (fi-domain)) :rule-classes (:rewrite :type-prescription)) (defthm realp-sum-fi-prime (realp (sum-fi-prime x i)) :rule-classes :type-prescription) (defthm sum-fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i)))) ;; ====================================================================== ;; Define the Riemann integral of fi-prime. (defun map-fi-prime (p i) (if (consp p) (cons (fi-prime (car p) i) (map-fi-prime (cdr p) i)) nil)) (defun riemann-fi-prime (p i) (dotprod (deltas p) (map-fi-prime (cdr p) i))) (local (defthm limited-riemann-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-fi-prime))) (defun-std strict-int-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-fi-prime (make-small-partition a b) i)) 0))) (defun int-fi-prime (a b i) (if (<= a b) (strict-int-fi-prime a b i) (- (strict-int-fi-prime b a i)))) (local (defthm fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1)) (fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-fi-prime a b i)))))))) ;; ====================================================================== ;; Define the Riemann integral of sum-fi-prime. (defun map-sum-fi-prime (p i) (if (consp p) (cons (sum-fi-prime (car p) i) (map-sum-fi-prime (cdr p) i)) nil)) (defun riemann-sum-fi-prime (p i) (dotprod (deltas p) (map-sum-fi-prime (cdr p) i))) (local (defthm limited-riemann-sum-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime))) (defun-std strict-int-sum-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime (make-small-partition a b) i)) 0))) (defun int-sum-fi-prime (a b i) (if (<= a b) (strict-int-sum-fi-prime a b i) (- (strict-int-sum-fi-prime b a i)))) (local (defthm sum-fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-sum-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-sum-fi-prime a b i)))))))) ;; ====================================================================== ;; Prove that the integral of the sum equals the sum of the integrals. (defun sum-int-fi-prime (a b i) (if (zp i) (int-fi-prime a b 0) (+ (int-fi-prime a b i) (sum-int-fi-prime a b (1- i))))) (local (defthm sum-int-fi-prime-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (sum-int-fi-prime a x i) (sum-int-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("Goal" :in-theory (disable int-fi-prime)) ("Subgoal *1/3" :use (fi-prime-ftc-1-2 (:instance i-close-plus (x1 (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1))) (x2 (fi-prime x i)) (y1 (/ (- (sum-int-fi-prime a x (1- i)) (sum-int-fi-prime a x1 (1- i))) (- x x1))) (y2 (sum-fi-prime x (1- i)))))) ("Subgoal *1/1" :use (:instance fi-prime-ftc-1-2 (i 0)))))) (local (encapsulate (((i) => *)) (local (defun i () 0)) (defthm natp-i (natp (i)) :rule-classes :type-prescription))) (local (defthm-std standardp-i (standardp (i)) :rule-classes (:rewrite :type-prescription))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-fi-prime (implies (partitionp p) (realp (riemann-fi-prime p i))) :rule-classes :type-prescription)) (defthm-std realp-int-fi-prime (realp (int-fi-prime a b i)) :hints (("Goal" :use ((:instance realp-riemann-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription) (defthm-std realp-sum-int-fi-prime (realp (sum-int-fi-prime a b i)) :hints (("Goal" :in-theory (disable int-fi-prime))) :rule-classes :type-prescription) (local (defthm sum-rule-of-int-sum-fi-prime-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b (i)) (- (sum-int-fi-prime (low) b (i)) (sum-int-fi-prime (low) a (i))))) :hints (("Goal" :by (:functional-instance ftc-2 (rcdfn (lambda (x) (sum-int-fi-prime (low) x (i)))) (rcdfn-prime (lambda (x) (sum-fi-prime x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-sum-fi-prime p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-sum-fi-prime p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-sum-fi-prime a b (i)))) (int-rcdfn-prime (lambda (a b) (int-sum-fi-prime a b (i)))))) ("Subgoal 7" :use (:instance sum-int-fi-prime-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-sum-fi-prime-lemma-2 (equal (sum-int-fi-prime a a i) 0))) (defthm sum-rule-of-int-sum-fi-prime (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b i) (sum-int-fi-prime a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-sum-fi-prime-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i)))))))) ;; ====================================================================== ;; Infinite series. (local (defun diff-sum-small (n x y) (< (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) (/ (1+ n))))) (local (encapsulate () (local (defthm lemma-1 (implies (and (i-close x y) (realp x) (realp y) (standardp a) (realp a) (< 0 a)) (< (abs (- x y)) a)) :hints (("Goal" :in-theory (e/d (i-close) (SMALL-<-NON-SMALL)) :use ((:instance STANDARD-SMALL-IS-ZERO (x a)) (:instance SMALL-<-NON-SMALL (x (- x y)) (y a))))))) (defthm diff-sum-small-on-std-n (implies (and (standardp n) (natp n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (diff-sum-small n x y)) :hints (("Goal" :use (:instance lemma-1 (x (sum-fi-prime x n)) (y (sum-fi-prime y n)) (a (/ (1+ n))))))))) (local (in-theory (disable diff-sum-small))) (local (overspill diff-sum-small (x y))) (local (defthm diff-sum-small-holds-on-i-large (let ((n (diff-sum-small-witness x y))) (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (and (natp n) (i-large n) (implies (and (natp m) (<= m n)) (diff-sum-small m x y))))) :hints (("Goal" :use (:instance diff-sum-small-overspill (x (list x y))))) :rule-classes nil)) (local (encapsulate () (local (defthm lemma-2 (implies (and (natp n) (i-large n)) (i-close (/ (1+ n)) 0)) :hints (("Goal" :in-theory (enable i-close))))) (local (defthm lemma-3 (realp (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) :rule-classes :type-prescription)) (local (defthm lemma-4 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-small) (abs)) :use (:instance close-squeeze (x 0) (y (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) (z (/ (1+ n)))))))) (local (defthm lemma-5 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (sum-fi-prime x n) (sum-fi-prime y n))) :hints (("Goal" :in-theory (enable i-close) :use lemma-4)))) (defthm sum-fi-prime-continuous-overspill (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (<= m n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :in-theory (disable abs) :use (diff-sum-small-holds-on-i-large)))))) (local (defthm sum-fi-prime-uniformly-converge-alt (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i) (i-large j) (natp j)) (i-close (sum-fi-prime x i) (sum-fi-prime x j))) :hints (("Goal" :use (:instance i-close-transitive (x (sum-fi-prime x i)) (y (sum-fi-prime-infinity x)) (z (sum-fi-prime x j))))))) (encapsulate () (local (defthm sum-fi-prime-continuous-lemma (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (< n m) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :use (diff-sum-small-holds-on-i-large (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime x (diff-sum-small-witness x y))) (z (sum-fi-prime y (diff-sum-small-witness x y)))) (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime y (diff-sum-small-witness x y))) (z (sum-fi-prime y m)))))))) (local (defthm not-i-large-is-standardp (implies (natp x) (equal (not (i-large x)) (standardp x))) :hints (("Goal" :in-theory (disable limited-integers-are-standard) :use limited-integers-are-standard)))) (local (defthm sum-fi-prime-continuous-strong (implies (and (natp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i))) :hints (("Goal" :in-theory (disable not-i-large-is-standardp) :use ((:instance not-i-large-is-standardp (x i)) (:instance sum-fi-prime-continuous-overspill (m i)) (:instance sum-fi-prime-continuous-lemma (m i))) :cases ((<= i (diff-sum-small-witness x y)) (< (diff-sum-small-witness x y) i)))))) (defthm sum-fi-prime-infinity-continuous (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime-infinity y))) :hints (("Goal" :use ((:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime x (i-large-integer))) (z (sum-fi-prime y (i-large-integer)))) (:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime y (i-large-integer))) (z (sum-fi-prime-infinity y)))))))) ;; ====================================================================== (local (defun diff-sum-fi-primes (x i) (- (sum-fi-prime-infinity x) (sum-fi-prime x i)))) (local (defthm realp-diff-sum-fi-primes (realp (diff-sum-fi-primes x i)) :rule-classes :type-prescription)) (local (defthm diff-sum-fi-primes-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (diff-sum-fi-primes x i) (diff-sum-fi-primes y i))) :hints (("Goal" :in-theory (disable sum-fi-prime-infinity))))) (local (defthm diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (diff-sum-fi-primes x i) 0)) :hints (("Goal" :in-theory (e/d (i-close) (sum-fi-prime-uniformly-converge)) :use (sum-fi-prime-uniformly-converge))))) ;; ====================================================================== ;; Find max diff-sum-fi-primes. (local (defun find-max-diff-sum-fi-primes-x-n (a max-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (> (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes max-x i)) (find-max-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-max-diff-sum-fi-primes-x-n a max-x (1+ step) n eps i)) max-x))) (local (defthm find-max-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-max-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-max-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-max-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) (local (defthm find-max-diff-sum-fi-primes-is-maximum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes x i) (diff-sum-fi-primes (find-max-diff-sum-fi-primes-x a b i) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-is-maximum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) ;; Find min diff-sum-fi-primes. (local (defun find-min-diff-sum-fi-primes-x-n (a min-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (< (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes min-x i)) (find-min-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-min-diff-sum-fi-primes-x-n a min-x (1+ step) n eps i)) min-x))) (local (defthm find-min-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-min-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-min-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-min-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (defthm find-min-diff-sum-fi-primes-is-minimum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes (find-min-diff-sum-fi-primes-x a b i) i) (diff-sum-fi-primes x i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-is-minimum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (in-theory (disable diff-sum-fi-primes))) ;; ====================================================================== (local (defun map-diff-sum-fi-primes (p i) (if (consp p) (cons (diff-sum-fi-primes (car p) i) (map-diff-sum-fi-primes (cdr p) i)) nil))) (local (defun riemann-diff-sum-fi-primes (p i) (dotprod (deltas p) (map-diff-sum-fi-primes (cdr p) i)))) (local (defun diff-sum-fi-primes-max-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-max-diff-sum-fi-primes-x a b i) (if (< b a) (find-max-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-above (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (riemann-diff-sum-fi-primes p i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-above (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-max-x diff-sum-fi-primes-max-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-max-x))) (local (defun diff-sum-fi-primes-min-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-min-diff-sum-fi-primes-x a b i) (if (< b a) (find-min-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-below (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))) (riemann-diff-sum-fi-primes p i))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-below (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-min-x diff-sum-fi-primes-min-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-min-x))) ;; Define the upper bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-upper-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-upper-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-upper-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-upper-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-upper-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-max-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i)) (y2 0)))))) ;; Define the lower bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-lower-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-lower-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-lower-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-min-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i)) (y2 0)))))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-upper-bound (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes-upper-bound a b i))) :hints (("Goal" :in-theory (disable riemann-diff-sum-fi-primes-lower-bound riemann-diff-sum-fi-primes-upper-bound) :use (:instance i-close-transitive (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y 0) (z (riemann-diff-sum-fi-primes-upper-bound a b i))))))) (local (defthm strict-int-diff-sum-fi-primes-bounded (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (<= (riemann-diff-sum-fi-primes (make-small-partition a b) i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :use ((:instance riemann-diff-sum-fi-primes-bounded-below (p (make-small-partition a b))) (:instance riemann-diff-sum-fi-primes-bounded-above (p (make-small-partition a b))) (:instance car-make-small-partition) (:instance car-last-make-small-partition) (:instance partitionp-make-small-partition)) :in-theory (disable car-make-small-partition car-last-make-small-partition partitionp-make-small-partition))) :rule-classes :linear)) (local (in-theory (disable riemann-diff-sum-fi-primes-upper-bound riemann-diff-sum-fi-primes-lower-bound))) ;; ====================================================================== ;; Define the Riemann integral of diff-sum-fi-primes. (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-diff-sum-fi-primes (implies (partitionp p) (realp (riemann-diff-sum-fi-primes p i))) :rule-classes :type-prescription))) (local (defthm limited-riemann-diff-sum-fi-primes-small-partition (implies (and (standardp i) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-diff-sum-fi-primes (make-small-partition a b) i))) :hints (("Goal" :use ((:instance standards-are-limited (x (riemann-diff-sum-fi-primes-upper-bound a b i))) (:instance standards-are-limited (x (riemann-diff-sum-fi-primes-lower-bound a b i))) (:instance limited-squeeze (a (riemann-diff-sum-fi-primes-lower-bound a b i)) (b (riemann-diff-sum-fi-primes-upper-bound a b i)) (x (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b)))) :in-theory (disable limited-squeeze standards-are-limited standards-are-limited-forward riemann-diff-sum-fi-primes))))) (local (in-theory (disable riemann-diff-sum-fi-primes))) (local (defun-std strict-int-diff-sum-fi-primes (a b i) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-diff-sum-fi-primes (make-small-partition a b) i)) 0))) (local (defun int-diff-sum-fi-primes (a b i) (if (<= a b) (strict-int-diff-sum-fi-primes a b i) (- (strict-int-diff-sum-fi-primes b a i))))) ;; ====================================================================== (local (defthm-std int-diff-sum-fi-primes-bounded-1 (implies (and (<= a b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :expand ((riemann-diff-sum-fi-primes-lower-bound a a i) (riemann-diff-sum-fi-primes-upper-bound a a i)) :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (y (riemann-diff-sum-fi-primes-upper-bound a b i)))))) :rule-classes :linear)) (local (defthm-std int-diff-sum-fi-primes-bounded-2 (implies (and (< b a) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (- (riemann-diff-sum-fi-primes-upper-bound b a i)) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (- (riemann-diff-sum-fi-primes-lower-bound b a i))))) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a))) (:instance strict-int-diff-sum-fi-primes-bounded (a b) (b a)) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (- (riemann-diff-sum-fi-primes (make-small-partition b a) i)))) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes (make-small-partition b a) i))) (y (- (riemann-diff-sum-fi-primes-lower-bound b a i))))))) :rule-classes :linear)) (local (defthm-std realp-int-diff-sum-fi-primes (realp (int-diff-sum-fi-primes a b i)) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (encapsulate () (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-1 (implies (and (<= a b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (int-diff-sum-fi-primes a b i)) (z (riemann-diff-sum-fi-primes-upper-bound a b i)))))))) (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-2 (implies (and (< b a) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (int-diff-sum-fi-primes a b i)) (z (- (riemann-diff-sum-fi-primes-lower-bound b a i)))) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-lower-bound b a i)) (y2 0)) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-upper-bound b a i)) (y2 0))))))) (defthm int-diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :cases ((<= a b) (< b a)) :use ((:instance int-diff-sum-fi-primes-approaches-0-lemma-1) (:instance int-diff-sum-fi-primes-approaches-0-lemma-2))))))) ;; ====================================================================== (defun map-sum-fi-prime-infinity (p) (if (consp p) (cons (sum-fi-prime-infinity (car p)) (map-sum-fi-prime-infinity (cdr p))) nil)) (defun riemann-sum-fi-prime-infinity (p) (dotprod (deltas p) (map-sum-fi-prime-infinity (cdr p)))) (local (defthm limited-riemann-sum-fi-prime-infinity-small-partition (implies (and (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime-infinity (make-small-partition a b)))) :hints (("Goal" :use (:functional-instance limited-riemann-rcfn-small-partition (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity))) ("Subgoal 3" :use sum-fi-prime-infinity-continuous) ("Subgoal 2" :use fi-domain-non-trivial)))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime-infinity))) (defun-std strict-int-sum-fi-prime-infinity (a b) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime-infinity (make-small-partition a b))) 0))) (defun int-sum-fi-prime-infinity (a b) (if (<= a b) (strict-int-sum-fi-prime-infinity a b) (- (strict-int-sum-fi-prime-infinity b a)))) (local (defthm sum-fi-prime-infinity-ftc-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1)) (sum-fi-prime-infinity x))) :hints (("goal" :by (:functional-instance ftc-1 (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity) (strict-int-rcfn strict-int-sum-fi-prime-infinity) (int-rcfn int-sum-fi-prime-infinity)))))) ;; ====================================================================== (local (defun diff-int-sum-fi-primes (a b i) (- (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i)))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-sum-fi-prime (implies (partitionp p) (realp (riemann-sum-fi-prime p i))) :rule-classes :type-prescription) (defthm realp-riemann-sum-fi-prime-infinity (implies (partitionp p) (realp (riemann-sum-fi-prime-infinity p))) :rule-classes :type-prescription)) (local (defthm-std realp-diff-int-sum-fi-primes (realp (diff-int-sum-fi-primes a b i)) :hints (("Goal" :in-theory (disable riemann-sum-fi-prime-infinity riemann-sum-fi-prime) :use ((:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition b a))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (defthm diff-int-sum-fi-primes-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (diff-int-sum-fi-primes a x i) (diff-int-sum-fi-primes a x1 i)) (- x x1)) (diff-sum-fi-primes x i))) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes) (sum-fi-prime-infinity sum-fi-prime int-sum-fi-prime-infinity int-sum-fi-prime)) :use (sum-fi-prime-infinity-ftc-1 sum-fi-prime-ftc-1-2 (:instance i-close-times (x -1) (y1 (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1))) (y2 (sum-fi-prime x i))) (:instance i-close-plus (x1 (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1))) (x2 (sum-fi-prime-infinity x)) (y1 (- (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)))) (y2 (- (sum-fi-prime x i))))))))) (local (defthm sum-rule-of-int-diff-sum-fi-primes-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b (i)) (- (diff-int-sum-fi-primes (low) b (i)) (diff-int-sum-fi-primes (low) a (i))))) :hints (("Goal" :in-theory (enable riemann-diff-sum-fi-primes) :by (:functional-instance ftc-2 (rcdfn (lambda (x) (diff-int-sum-fi-primes (low) x (i)))) (rcdfn-prime (lambda (x) (diff-sum-fi-primes x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-diff-sum-fi-primes p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-diff-sum-fi-primes p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-diff-sum-fi-primes a b (i)))) (int-rcdfn-prime (lambda (a b) (int-diff-sum-fi-primes a b (i)))))) ("Subgoal 7" :use (:instance diff-int-sum-fi-primes-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-diff-sum-fi-primes-lemma-2 (equal (diff-int-sum-fi-primes a a i) 0))) (local (defthm sum-rule-of-int-diff-sum-fi-primes (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b i) (diff-int-sum-fi-primes a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-diff-sum-fi-primes-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i))))))))) ;; ====================================================================== (local (defthm int-sum-fi-prime-infinity-lemma-1 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i))) :hints (("Goal" :in-theory (enable i-close) :use int-diff-sum-fi-primes-approaches-0)))) (defthm-std standardp-int-sum-fi-prime-infinity (implies (and (standardp a) (standardp b)) (standardp (int-sum-fi-prime-infinity a b))) :rule-classes (:rewrite :type-prescription)) (encapsulate () (local (in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime))) (local (defthm limited-int-sum-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (int-sum-fi-prime a b i))) :hints (("Goal" :use ((:instance standards-are-limited (x (int-sum-fi-prime-infinity a b))) (:instance i-close-limited (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b i)))))))) (defun-std int-sum-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (int-sum-fi-prime a b (i-large-integer))) 0)) (local (defthm limited-sum-int-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (sum-int-fi-prime a b i))) :hints (("Goal" :in-theory (disable sum-rule-of-int-sum-fi-prime) :use sum-rule-of-int-sum-fi-prime)))) (defun-std sum-int-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (sum-int-fi-prime a b (i-large-integer))) 0))) (defthm-std int-sum-fi-prime-infinity-lemma-2 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (int-sum-fi-prime-with-large-index a b))) :hints (("Goal" :in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime) :use (int-sum-fi-prime-infinity-lemma-1 (:instance close-x-y->same-standard-part (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b (i-large-integer)))))))) (defthm-std sum-rule-of-int-sum-fi-prime-infinity (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (sum-int-fi-prime-with-large-index a b))))
93566
;; Proof of the sum rule for definite integrals of infinite series. ;; <NAME> April, 2015 (in-package "ACL2") (include-book "riemann-integral/ftc-1-2") (include-book "utils") (local (include-book "nonstd/nsa/overspill" :dir :system)) (local (include-book "nonstd/integrals/ftc-2" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) ;; ====================================================================== (encapsulate ((low () t) (fi-prime (x i) t) (fi-domain () t)) (local (defun low () 0)) (local (defun fi-prime (x i) (declare (ignore x i)) 0)) (local (defun fi-domain () (interval nil nil))) (defthm inside-interval-p-low (inside-interval-p (low) (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm realp-fi-prime (realp (fi-prime x i)) :rule-classes :type-prescription) (defthm intervalp-fi-domain (interval-p (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm fi-domain-real (implies (inside-interval-p x (fi-domain)) (realp x)) :rule-classes (:forward-chaining)) (defthm fi-domain-non-trivial (or (null (interval-left-endpoint (fi-domain))) (null (interval-right-endpoint (fi-domain))) (< (interval-left-endpoint (fi-domain)) (interval-right-endpoint (fi-domain)))) :rule-classes nil) (defthm fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (fi-prime x i) (fi-prime y i)))) (defun sum-fi-prime (x i) (if (zp i) (fi-prime x 0) (+ (fi-prime x i) (sum-fi-prime x (1- i))))) (defthm i-limited-sum-fi-prime (implies (and (inside-interval-p x (fi-domain)) (natp i) (i-large i)) (i-limited (sum-fi-prime x i)))) (defun-std sum-fi-prime-infinity (x) (if (inside-interval-p x (fi-domain)) (standard-part (sum-fi-prime x (i-large-integer))) 0)) (local (defthm sum-fi-prime-equals-0 (equal (sum-fi-prime x i) 0))) (local (defthm-std sum-fi-prime-infinity-equals-0 (equal (sum-fi-prime-infinity x) 0))) (defthm sum-fi-prime-uniformly-converge (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime x i))))) (defthm-std standardp-fi-prime (implies (and (standardp x) (standardp i)) (standardp (fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-sum-fi-prime (implies (and (standardp x) (standardp i)) (standardp (sum-fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-fi-domain (standardp (fi-domain)) :rule-classes (:rewrite :type-prescription)) (defthm realp-sum-fi-prime (realp (sum-fi-prime x i)) :rule-classes :type-prescription) (defthm sum-fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i)))) ;; ====================================================================== ;; Define the Riemann integral of fi-prime. (defun map-fi-prime (p i) (if (consp p) (cons (fi-prime (car p) i) (map-fi-prime (cdr p) i)) nil)) (defun riemann-fi-prime (p i) (dotprod (deltas p) (map-fi-prime (cdr p) i))) (local (defthm limited-riemann-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-fi-prime))) (defun-std strict-int-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-fi-prime (make-small-partition a b) i)) 0))) (defun int-fi-prime (a b i) (if (<= a b) (strict-int-fi-prime a b i) (- (strict-int-fi-prime b a i)))) (local (defthm fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1)) (fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-fi-prime a b i)))))))) ;; ====================================================================== ;; Define the Riemann integral of sum-fi-prime. (defun map-sum-fi-prime (p i) (if (consp p) (cons (sum-fi-prime (car p) i) (map-sum-fi-prime (cdr p) i)) nil)) (defun riemann-sum-fi-prime (p i) (dotprod (deltas p) (map-sum-fi-prime (cdr p) i))) (local (defthm limited-riemann-sum-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime))) (defun-std strict-int-sum-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime (make-small-partition a b) i)) 0))) (defun int-sum-fi-prime (a b i) (if (<= a b) (strict-int-sum-fi-prime a b i) (- (strict-int-sum-fi-prime b a i)))) (local (defthm sum-fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-sum-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-sum-fi-prime a b i)))))))) ;; ====================================================================== ;; Prove that the integral of the sum equals the sum of the integrals. (defun sum-int-fi-prime (a b i) (if (zp i) (int-fi-prime a b 0) (+ (int-fi-prime a b i) (sum-int-fi-prime a b (1- i))))) (local (defthm sum-int-fi-prime-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (sum-int-fi-prime a x i) (sum-int-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("Goal" :in-theory (disable int-fi-prime)) ("Subgoal *1/3" :use (fi-prime-ftc-1-2 (:instance i-close-plus (x1 (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1))) (x2 (fi-prime x i)) (y1 (/ (- (sum-int-fi-prime a x (1- i)) (sum-int-fi-prime a x1 (1- i))) (- x x1))) (y2 (sum-fi-prime x (1- i)))))) ("Subgoal *1/1" :use (:instance fi-prime-ftc-1-2 (i 0)))))) (local (encapsulate (((i) => *)) (local (defun i () 0)) (defthm natp-i (natp (i)) :rule-classes :type-prescription))) (local (defthm-std standardp-i (standardp (i)) :rule-classes (:rewrite :type-prescription))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-fi-prime (implies (partitionp p) (realp (riemann-fi-prime p i))) :rule-classes :type-prescription)) (defthm-std realp-int-fi-prime (realp (int-fi-prime a b i)) :hints (("Goal" :use ((:instance realp-riemann-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription) (defthm-std realp-sum-int-fi-prime (realp (sum-int-fi-prime a b i)) :hints (("Goal" :in-theory (disable int-fi-prime))) :rule-classes :type-prescription) (local (defthm sum-rule-of-int-sum-fi-prime-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b (i)) (- (sum-int-fi-prime (low) b (i)) (sum-int-fi-prime (low) a (i))))) :hints (("Goal" :by (:functional-instance ftc-2 (rcdfn (lambda (x) (sum-int-fi-prime (low) x (i)))) (rcdfn-prime (lambda (x) (sum-fi-prime x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-sum-fi-prime p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-sum-fi-prime p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-sum-fi-prime a b (i)))) (int-rcdfn-prime (lambda (a b) (int-sum-fi-prime a b (i)))))) ("Subgoal 7" :use (:instance sum-int-fi-prime-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-sum-fi-prime-lemma-2 (equal (sum-int-fi-prime a a i) 0))) (defthm sum-rule-of-int-sum-fi-prime (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b i) (sum-int-fi-prime a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-sum-fi-prime-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i)))))))) ;; ====================================================================== ;; Infinite series. (local (defun diff-sum-small (n x y) (< (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) (/ (1+ n))))) (local (encapsulate () (local (defthm lemma-1 (implies (and (i-close x y) (realp x) (realp y) (standardp a) (realp a) (< 0 a)) (< (abs (- x y)) a)) :hints (("Goal" :in-theory (e/d (i-close) (SMALL-<-NON-SMALL)) :use ((:instance STANDARD-SMALL-IS-ZERO (x a)) (:instance SMALL-<-NON-SMALL (x (- x y)) (y a))))))) (defthm diff-sum-small-on-std-n (implies (and (standardp n) (natp n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (diff-sum-small n x y)) :hints (("Goal" :use (:instance lemma-1 (x (sum-fi-prime x n)) (y (sum-fi-prime y n)) (a (/ (1+ n))))))))) (local (in-theory (disable diff-sum-small))) (local (overspill diff-sum-small (x y))) (local (defthm diff-sum-small-holds-on-i-large (let ((n (diff-sum-small-witness x y))) (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (and (natp n) (i-large n) (implies (and (natp m) (<= m n)) (diff-sum-small m x y))))) :hints (("Goal" :use (:instance diff-sum-small-overspill (x (list x y))))) :rule-classes nil)) (local (encapsulate () (local (defthm lemma-2 (implies (and (natp n) (i-large n)) (i-close (/ (1+ n)) 0)) :hints (("Goal" :in-theory (enable i-close))))) (local (defthm lemma-3 (realp (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) :rule-classes :type-prescription)) (local (defthm lemma-4 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-small) (abs)) :use (:instance close-squeeze (x 0) (y (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) (z (/ (1+ n)))))))) (local (defthm lemma-5 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (sum-fi-prime x n) (sum-fi-prime y n))) :hints (("Goal" :in-theory (enable i-close) :use lemma-4)))) (defthm sum-fi-prime-continuous-overspill (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (<= m n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :in-theory (disable abs) :use (diff-sum-small-holds-on-i-large)))))) (local (defthm sum-fi-prime-uniformly-converge-alt (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i) (i-large j) (natp j)) (i-close (sum-fi-prime x i) (sum-fi-prime x j))) :hints (("Goal" :use (:instance i-close-transitive (x (sum-fi-prime x i)) (y (sum-fi-prime-infinity x)) (z (sum-fi-prime x j))))))) (encapsulate () (local (defthm sum-fi-prime-continuous-lemma (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (< n m) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :use (diff-sum-small-holds-on-i-large (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime x (diff-sum-small-witness x y))) (z (sum-fi-prime y (diff-sum-small-witness x y)))) (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime y (diff-sum-small-witness x y))) (z (sum-fi-prime y m)))))))) (local (defthm not-i-large-is-standardp (implies (natp x) (equal (not (i-large x)) (standardp x))) :hints (("Goal" :in-theory (disable limited-integers-are-standard) :use limited-integers-are-standard)))) (local (defthm sum-fi-prime-continuous-strong (implies (and (natp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i))) :hints (("Goal" :in-theory (disable not-i-large-is-standardp) :use ((:instance not-i-large-is-standardp (x i)) (:instance sum-fi-prime-continuous-overspill (m i)) (:instance sum-fi-prime-continuous-lemma (m i))) :cases ((<= i (diff-sum-small-witness x y)) (< (diff-sum-small-witness x y) i)))))) (defthm sum-fi-prime-infinity-continuous (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime-infinity y))) :hints (("Goal" :use ((:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime x (i-large-integer))) (z (sum-fi-prime y (i-large-integer)))) (:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime y (i-large-integer))) (z (sum-fi-prime-infinity y)))))))) ;; ====================================================================== (local (defun diff-sum-fi-primes (x i) (- (sum-fi-prime-infinity x) (sum-fi-prime x i)))) (local (defthm realp-diff-sum-fi-primes (realp (diff-sum-fi-primes x i)) :rule-classes :type-prescription)) (local (defthm diff-sum-fi-primes-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (diff-sum-fi-primes x i) (diff-sum-fi-primes y i))) :hints (("Goal" :in-theory (disable sum-fi-prime-infinity))))) (local (defthm diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (diff-sum-fi-primes x i) 0)) :hints (("Goal" :in-theory (e/d (i-close) (sum-fi-prime-uniformly-converge)) :use (sum-fi-prime-uniformly-converge))))) ;; ====================================================================== ;; Find max diff-sum-fi-primes. (local (defun find-max-diff-sum-fi-primes-x-n (a max-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (> (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes max-x i)) (find-max-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-max-diff-sum-fi-primes-x-n a max-x (1+ step) n eps i)) max-x))) (local (defthm find-max-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-max-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-max-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-max-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) (local (defthm find-max-diff-sum-fi-primes-is-maximum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes x i) (diff-sum-fi-primes (find-max-diff-sum-fi-primes-x a b i) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-is-maximum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) ;; Find min diff-sum-fi-primes. (local (defun find-min-diff-sum-fi-primes-x-n (a min-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (< (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes min-x i)) (find-min-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-min-diff-sum-fi-primes-x-n a min-x (1+ step) n eps i)) min-x))) (local (defthm find-min-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-min-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-min-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-min-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (defthm find-min-diff-sum-fi-primes-is-minimum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes (find-min-diff-sum-fi-primes-x a b i) i) (diff-sum-fi-primes x i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-is-minimum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (in-theory (disable diff-sum-fi-primes))) ;; ====================================================================== (local (defun map-diff-sum-fi-primes (p i) (if (consp p) (cons (diff-sum-fi-primes (car p) i) (map-diff-sum-fi-primes (cdr p) i)) nil))) (local (defun riemann-diff-sum-fi-primes (p i) (dotprod (deltas p) (map-diff-sum-fi-primes (cdr p) i)))) (local (defun diff-sum-fi-primes-max-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-max-diff-sum-fi-primes-x a b i) (if (< b a) (find-max-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-above (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (riemann-diff-sum-fi-primes p i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-above (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-max-x diff-sum-fi-primes-max-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-max-x))) (local (defun diff-sum-fi-primes-min-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-min-diff-sum-fi-primes-x a b i) (if (< b a) (find-min-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-below (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))) (riemann-diff-sum-fi-primes p i))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-below (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-min-x diff-sum-fi-primes-min-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-min-x))) ;; Define the upper bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-upper-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-upper-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-upper-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-upper-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-upper-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-max-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i)) (y2 0)))))) ;; Define the lower bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-lower-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-lower-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-lower-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-min-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i)) (y2 0)))))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-upper-bound (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes-upper-bound a b i))) :hints (("Goal" :in-theory (disable riemann-diff-sum-fi-primes-lower-bound riemann-diff-sum-fi-primes-upper-bound) :use (:instance i-close-transitive (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y 0) (z (riemann-diff-sum-fi-primes-upper-bound a b i))))))) (local (defthm strict-int-diff-sum-fi-primes-bounded (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (<= (riemann-diff-sum-fi-primes (make-small-partition a b) i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :use ((:instance riemann-diff-sum-fi-primes-bounded-below (p (make-small-partition a b))) (:instance riemann-diff-sum-fi-primes-bounded-above (p (make-small-partition a b))) (:instance car-make-small-partition) (:instance car-last-make-small-partition) (:instance partitionp-make-small-partition)) :in-theory (disable car-make-small-partition car-last-make-small-partition partitionp-make-small-partition))) :rule-classes :linear)) (local (in-theory (disable riemann-diff-sum-fi-primes-upper-bound riemann-diff-sum-fi-primes-lower-bound))) ;; ====================================================================== ;; Define the Riemann integral of diff-sum-fi-primes. (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-diff-sum-fi-primes (implies (partitionp p) (realp (riemann-diff-sum-fi-primes p i))) :rule-classes :type-prescription))) (local (defthm limited-riemann-diff-sum-fi-primes-small-partition (implies (and (standardp i) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-diff-sum-fi-primes (make-small-partition a b) i))) :hints (("Goal" :use ((:instance standards-are-limited (x (riemann-diff-sum-fi-primes-upper-bound a b i))) (:instance standards-are-limited (x (riemann-diff-sum-fi-primes-lower-bound a b i))) (:instance limited-squeeze (a (riemann-diff-sum-fi-primes-lower-bound a b i)) (b (riemann-diff-sum-fi-primes-upper-bound a b i)) (x (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b)))) :in-theory (disable limited-squeeze standards-are-limited standards-are-limited-forward riemann-diff-sum-fi-primes))))) (local (in-theory (disable riemann-diff-sum-fi-primes))) (local (defun-std strict-int-diff-sum-fi-primes (a b i) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-diff-sum-fi-primes (make-small-partition a b) i)) 0))) (local (defun int-diff-sum-fi-primes (a b i) (if (<= a b) (strict-int-diff-sum-fi-primes a b i) (- (strict-int-diff-sum-fi-primes b a i))))) ;; ====================================================================== (local (defthm-std int-diff-sum-fi-primes-bounded-1 (implies (and (<= a b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :expand ((riemann-diff-sum-fi-primes-lower-bound a a i) (riemann-diff-sum-fi-primes-upper-bound a a i)) :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (y (riemann-diff-sum-fi-primes-upper-bound a b i)))))) :rule-classes :linear)) (local (defthm-std int-diff-sum-fi-primes-bounded-2 (implies (and (< b a) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (- (riemann-diff-sum-fi-primes-upper-bound b a i)) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (- (riemann-diff-sum-fi-primes-lower-bound b a i))))) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a))) (:instance strict-int-diff-sum-fi-primes-bounded (a b) (b a)) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (- (riemann-diff-sum-fi-primes (make-small-partition b a) i)))) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes (make-small-partition b a) i))) (y (- (riemann-diff-sum-fi-primes-lower-bound b a i))))))) :rule-classes :linear)) (local (defthm-std realp-int-diff-sum-fi-primes (realp (int-diff-sum-fi-primes a b i)) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (encapsulate () (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-1 (implies (and (<= a b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (int-diff-sum-fi-primes a b i)) (z (riemann-diff-sum-fi-primes-upper-bound a b i)))))))) (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-2 (implies (and (< b a) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (int-diff-sum-fi-primes a b i)) (z (- (riemann-diff-sum-fi-primes-lower-bound b a i)))) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-lower-bound b a i)) (y2 0)) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-upper-bound b a i)) (y2 0))))))) (defthm int-diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :cases ((<= a b) (< b a)) :use ((:instance int-diff-sum-fi-primes-approaches-0-lemma-1) (:instance int-diff-sum-fi-primes-approaches-0-lemma-2))))))) ;; ====================================================================== (defun map-sum-fi-prime-infinity (p) (if (consp p) (cons (sum-fi-prime-infinity (car p)) (map-sum-fi-prime-infinity (cdr p))) nil)) (defun riemann-sum-fi-prime-infinity (p) (dotprod (deltas p) (map-sum-fi-prime-infinity (cdr p)))) (local (defthm limited-riemann-sum-fi-prime-infinity-small-partition (implies (and (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime-infinity (make-small-partition a b)))) :hints (("Goal" :use (:functional-instance limited-riemann-rcfn-small-partition (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity))) ("Subgoal 3" :use sum-fi-prime-infinity-continuous) ("Subgoal 2" :use fi-domain-non-trivial)))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime-infinity))) (defun-std strict-int-sum-fi-prime-infinity (a b) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime-infinity (make-small-partition a b))) 0))) (defun int-sum-fi-prime-infinity (a b) (if (<= a b) (strict-int-sum-fi-prime-infinity a b) (- (strict-int-sum-fi-prime-infinity b a)))) (local (defthm sum-fi-prime-infinity-ftc-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1)) (sum-fi-prime-infinity x))) :hints (("goal" :by (:functional-instance ftc-1 (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity) (strict-int-rcfn strict-int-sum-fi-prime-infinity) (int-rcfn int-sum-fi-prime-infinity)))))) ;; ====================================================================== (local (defun diff-int-sum-fi-primes (a b i) (- (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i)))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-sum-fi-prime (implies (partitionp p) (realp (riemann-sum-fi-prime p i))) :rule-classes :type-prescription) (defthm realp-riemann-sum-fi-prime-infinity (implies (partitionp p) (realp (riemann-sum-fi-prime-infinity p))) :rule-classes :type-prescription)) (local (defthm-std realp-diff-int-sum-fi-primes (realp (diff-int-sum-fi-primes a b i)) :hints (("Goal" :in-theory (disable riemann-sum-fi-prime-infinity riemann-sum-fi-prime) :use ((:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition b a))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (defthm diff-int-sum-fi-primes-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (diff-int-sum-fi-primes a x i) (diff-int-sum-fi-primes a x1 i)) (- x x1)) (diff-sum-fi-primes x i))) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes) (sum-fi-prime-infinity sum-fi-prime int-sum-fi-prime-infinity int-sum-fi-prime)) :use (sum-fi-prime-infinity-ftc-1 sum-fi-prime-ftc-1-2 (:instance i-close-times (x -1) (y1 (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1))) (y2 (sum-fi-prime x i))) (:instance i-close-plus (x1 (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1))) (x2 (sum-fi-prime-infinity x)) (y1 (- (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)))) (y2 (- (sum-fi-prime x i))))))))) (local (defthm sum-rule-of-int-diff-sum-fi-primes-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b (i)) (- (diff-int-sum-fi-primes (low) b (i)) (diff-int-sum-fi-primes (low) a (i))))) :hints (("Goal" :in-theory (enable riemann-diff-sum-fi-primes) :by (:functional-instance ftc-2 (rcdfn (lambda (x) (diff-int-sum-fi-primes (low) x (i)))) (rcdfn-prime (lambda (x) (diff-sum-fi-primes x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-diff-sum-fi-primes p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-diff-sum-fi-primes p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-diff-sum-fi-primes a b (i)))) (int-rcdfn-prime (lambda (a b) (int-diff-sum-fi-primes a b (i)))))) ("Subgoal 7" :use (:instance diff-int-sum-fi-primes-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-diff-sum-fi-primes-lemma-2 (equal (diff-int-sum-fi-primes a a i) 0))) (local (defthm sum-rule-of-int-diff-sum-fi-primes (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b i) (diff-int-sum-fi-primes a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-diff-sum-fi-primes-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i))))))))) ;; ====================================================================== (local (defthm int-sum-fi-prime-infinity-lemma-1 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i))) :hints (("Goal" :in-theory (enable i-close) :use int-diff-sum-fi-primes-approaches-0)))) (defthm-std standardp-int-sum-fi-prime-infinity (implies (and (standardp a) (standardp b)) (standardp (int-sum-fi-prime-infinity a b))) :rule-classes (:rewrite :type-prescription)) (encapsulate () (local (in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime))) (local (defthm limited-int-sum-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (int-sum-fi-prime a b i))) :hints (("Goal" :use ((:instance standards-are-limited (x (int-sum-fi-prime-infinity a b))) (:instance i-close-limited (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b i)))))))) (defun-std int-sum-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (int-sum-fi-prime a b (i-large-integer))) 0)) (local (defthm limited-sum-int-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (sum-int-fi-prime a b i))) :hints (("Goal" :in-theory (disable sum-rule-of-int-sum-fi-prime) :use sum-rule-of-int-sum-fi-prime)))) (defun-std sum-int-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (sum-int-fi-prime a b (i-large-integer))) 0))) (defthm-std int-sum-fi-prime-infinity-lemma-2 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (int-sum-fi-prime-with-large-index a b))) :hints (("Goal" :in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime) :use (int-sum-fi-prime-infinity-lemma-1 (:instance close-x-y->same-standard-part (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b (i-large-integer)))))))) (defthm-std sum-rule-of-int-sum-fi-prime-infinity (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (sum-int-fi-prime-with-large-index a b))))
true
;; Proof of the sum rule for definite integrals of infinite series. ;; PI:NAME:<NAME>END_PI April, 2015 (in-package "ACL2") (include-book "riemann-integral/ftc-1-2") (include-book "utils") (local (include-book "nonstd/nsa/overspill" :dir :system)) (local (include-book "nonstd/integrals/ftc-2" :dir :system)) (local (include-book "arithmetic/top" :dir :system)) ;; ====================================================================== (encapsulate ((low () t) (fi-prime (x i) t) (fi-domain () t)) (local (defun low () 0)) (local (defun fi-prime (x i) (declare (ignore x i)) 0)) (local (defun fi-domain () (interval nil nil))) (defthm inside-interval-p-low (inside-interval-p (low) (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm realp-fi-prime (realp (fi-prime x i)) :rule-classes :type-prescription) (defthm intervalp-fi-domain (interval-p (fi-domain)) :rule-classes (:type-prescription :rewrite)) (defthm fi-domain-real (implies (inside-interval-p x (fi-domain)) (realp x)) :rule-classes (:forward-chaining)) (defthm fi-domain-non-trivial (or (null (interval-left-endpoint (fi-domain))) (null (interval-right-endpoint (fi-domain))) (< (interval-left-endpoint (fi-domain)) (interval-right-endpoint (fi-domain)))) :rule-classes nil) (defthm fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (fi-prime x i) (fi-prime y i)))) (defun sum-fi-prime (x i) (if (zp i) (fi-prime x 0) (+ (fi-prime x i) (sum-fi-prime x (1- i))))) (defthm i-limited-sum-fi-prime (implies (and (inside-interval-p x (fi-domain)) (natp i) (i-large i)) (i-limited (sum-fi-prime x i)))) (defun-std sum-fi-prime-infinity (x) (if (inside-interval-p x (fi-domain)) (standard-part (sum-fi-prime x (i-large-integer))) 0)) (local (defthm sum-fi-prime-equals-0 (equal (sum-fi-prime x i) 0))) (local (defthm-std sum-fi-prime-infinity-equals-0 (equal (sum-fi-prime-infinity x) 0))) (defthm sum-fi-prime-uniformly-converge (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime x i))))) (defthm-std standardp-fi-prime (implies (and (standardp x) (standardp i)) (standardp (fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-sum-fi-prime (implies (and (standardp x) (standardp i)) (standardp (sum-fi-prime x i))) :rule-classes (:rewrite :type-prescription)) (defthm-std standardp-fi-domain (standardp (fi-domain)) :rule-classes (:rewrite :type-prescription)) (defthm realp-sum-fi-prime (realp (sum-fi-prime x i)) :rule-classes :type-prescription) (defthm sum-fi-prime-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i)))) ;; ====================================================================== ;; Define the Riemann integral of fi-prime. (defun map-fi-prime (p i) (if (consp p) (cons (fi-prime (car p) i) (map-fi-prime (cdr p) i)) nil)) (defun riemann-fi-prime (p i) (dotprod (deltas p) (map-fi-prime (cdr p) i))) (local (defthm limited-riemann-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-fi-prime))) (defun-std strict-int-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-fi-prime (make-small-partition a b) i)) 0))) (defun int-fi-prime (a b i) (if (<= a b) (strict-int-fi-prime a b i) (- (strict-int-fi-prime b a i)))) (local (defthm fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1)) (fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-fi-prime a b i)))))))) ;; ====================================================================== ;; Define the Riemann integral of sum-fi-prime. (defun map-sum-fi-prime (p i) (if (consp p) (cons (sum-fi-prime (car p) i) (map-sum-fi-prime (cdr p) i)) nil)) (defun riemann-sum-fi-prime (p i) (dotprod (deltas p) (map-sum-fi-prime (cdr p) i))) (local (defthm limited-riemann-sum-fi-prime-small-partition (implies (and (standardp i) (realp a) (standardp a) (realp b) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime (make-small-partition a b) i))) :hints (("Goal" :by (:functional-instance limited-riemann-rcfn-2-small-partition (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))))) ("Subgoal 2" :use (fi-domain-non-trivial))))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime))) (defun-std strict-int-sum-fi-prime (a b i) (if (and (realp a) (realp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime (make-small-partition a b) i)) 0))) (defun int-sum-fi-prime (a b i) (if (<= a b) (strict-int-sum-fi-prime a b i) (- (strict-int-sum-fi-prime b a i)))) (local (defthm sum-fi-prime-ftc-1-2 (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("goal" :by (:functional-instance ftc-1-2 (rcfn-2 (lambda (x i) (sum-fi-prime x i))) (rcfn-2-domain fi-domain) (map-rcfn-2 (lambda (p i) (map-sum-fi-prime p i))) (riemann-rcfn-2 (lambda (p i) (riemann-sum-fi-prime p i))) (strict-int-rcfn-2 (lambda (a b i) (strict-int-sum-fi-prime a b i))) (int-rcfn-2 (lambda (a b i) (int-sum-fi-prime a b i)))))))) ;; ====================================================================== ;; Prove that the integral of the sum equals the sum of the integrals. (defun sum-int-fi-prime (a b i) (if (zp i) (int-fi-prime a b 0) (+ (int-fi-prime a b i) (sum-int-fi-prime a b (1- i))))) (local (defthm sum-int-fi-prime-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (sum-int-fi-prime a x i) (sum-int-fi-prime a x1 i)) (- x x1)) (sum-fi-prime x i))) :hints (("Goal" :in-theory (disable int-fi-prime)) ("Subgoal *1/3" :use (fi-prime-ftc-1-2 (:instance i-close-plus (x1 (/ (- (int-fi-prime a x i) (int-fi-prime a x1 i)) (- x x1))) (x2 (fi-prime x i)) (y1 (/ (- (sum-int-fi-prime a x (1- i)) (sum-int-fi-prime a x1 (1- i))) (- x x1))) (y2 (sum-fi-prime x (1- i)))))) ("Subgoal *1/1" :use (:instance fi-prime-ftc-1-2 (i 0)))))) (local (encapsulate (((i) => *)) (local (defun i () 0)) (defthm natp-i (natp (i)) :rule-classes :type-prescription))) (local (defthm-std standardp-i (standardp (i)) :rule-classes (:rewrite :type-prescription))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-fi-prime (implies (partitionp p) (realp (riemann-fi-prime p i))) :rule-classes :type-prescription)) (defthm-std realp-int-fi-prime (realp (int-fi-prime a b i)) :hints (("Goal" :use ((:instance realp-riemann-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription) (defthm-std realp-sum-int-fi-prime (realp (sum-int-fi-prime a b i)) :hints (("Goal" :in-theory (disable int-fi-prime))) :rule-classes :type-prescription) (local (defthm sum-rule-of-int-sum-fi-prime-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b (i)) (- (sum-int-fi-prime (low) b (i)) (sum-int-fi-prime (low) a (i))))) :hints (("Goal" :by (:functional-instance ftc-2 (rcdfn (lambda (x) (sum-int-fi-prime (low) x (i)))) (rcdfn-prime (lambda (x) (sum-fi-prime x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-sum-fi-prime p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-sum-fi-prime p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-sum-fi-prime a b (i)))) (int-rcdfn-prime (lambda (a b) (int-sum-fi-prime a b (i)))))) ("Subgoal 7" :use (:instance sum-int-fi-prime-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-sum-fi-prime-lemma-2 (equal (sum-int-fi-prime a a i) 0))) (defthm sum-rule-of-int-sum-fi-prime (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime a b i) (sum-int-fi-prime a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-sum-fi-prime-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i)))))))) ;; ====================================================================== ;; Infinite series. (local (defun diff-sum-small (n x y) (< (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) (/ (1+ n))))) (local (encapsulate () (local (defthm lemma-1 (implies (and (i-close x y) (realp x) (realp y) (standardp a) (realp a) (< 0 a)) (< (abs (- x y)) a)) :hints (("Goal" :in-theory (e/d (i-close) (SMALL-<-NON-SMALL)) :use ((:instance STANDARD-SMALL-IS-ZERO (x a)) (:instance SMALL-<-NON-SMALL (x (- x y)) (y a))))))) (defthm diff-sum-small-on-std-n (implies (and (standardp n) (natp n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (diff-sum-small n x y)) :hints (("Goal" :use (:instance lemma-1 (x (sum-fi-prime x n)) (y (sum-fi-prime y n)) (a (/ (1+ n))))))))) (local (in-theory (disable diff-sum-small))) (local (overspill diff-sum-small (x y))) (local (defthm diff-sum-small-holds-on-i-large (let ((n (diff-sum-small-witness x y))) (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (and (natp n) (i-large n) (implies (and (natp m) (<= m n)) (diff-sum-small m x y))))) :hints (("Goal" :use (:instance diff-sum-small-overspill (x (list x y))))) :rule-classes nil)) (local (encapsulate () (local (defthm lemma-2 (implies (and (natp n) (i-large n)) (i-close (/ (1+ n)) 0)) :hints (("Goal" :in-theory (enable i-close))))) (local (defthm lemma-3 (realp (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) :rule-classes :type-prescription)) (local (defthm lemma-4 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (abs (- (sum-fi-prime x n) (sum-fi-prime y n))) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-small) (abs)) :use (:instance close-squeeze (x 0) (y (abs (- (sum-fi-prime x n) (sum-fi-prime y n)))) (z (/ (1+ n)))))))) (local (defthm lemma-5 (implies (and (natp n) (i-large n) (diff-sum-small n x y)) (i-close (sum-fi-prime x n) (sum-fi-prime y n))) :hints (("Goal" :in-theory (enable i-close) :use lemma-4)))) (defthm sum-fi-prime-continuous-overspill (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (<= m n) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :in-theory (disable abs) :use (diff-sum-small-holds-on-i-large)))))) (local (defthm sum-fi-prime-uniformly-converge-alt (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i) (i-large j) (natp j)) (i-close (sum-fi-prime x i) (sum-fi-prime x j))) :hints (("Goal" :use (:instance i-close-transitive (x (sum-fi-prime x i)) (y (sum-fi-prime-infinity x)) (z (sum-fi-prime x j))))))) (encapsulate () (local (defthm sum-fi-prime-continuous-lemma (let ((n (diff-sum-small-witness x y))) (implies (and (i-large m) (natp m) (< n m) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x m) (sum-fi-prime y m)))) :hints (("Goal" :use (diff-sum-small-holds-on-i-large (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime x (diff-sum-small-witness x y))) (z (sum-fi-prime y (diff-sum-small-witness x y)))) (:instance i-close-transitive (x (sum-fi-prime x m)) (y (sum-fi-prime y (diff-sum-small-witness x y))) (z (sum-fi-prime y m)))))))) (local (defthm not-i-large-is-standardp (implies (natp x) (equal (not (i-large x)) (standardp x))) :hints (("Goal" :in-theory (disable limited-integers-are-standard) :use limited-integers-are-standard)))) (local (defthm sum-fi-prime-continuous-strong (implies (and (natp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime x i) (sum-fi-prime y i))) :hints (("Goal" :in-theory (disable not-i-large-is-standardp) :use ((:instance not-i-large-is-standardp (x i)) (:instance sum-fi-prime-continuous-overspill (m i)) (:instance sum-fi-prime-continuous-lemma (m i))) :cases ((<= i (diff-sum-small-witness x y)) (< (diff-sum-small-witness x y) i)))))) (defthm sum-fi-prime-infinity-continuous (implies (and (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (sum-fi-prime-infinity x) (sum-fi-prime-infinity y))) :hints (("Goal" :use ((:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime x (i-large-integer))) (z (sum-fi-prime y (i-large-integer)))) (:instance i-close-transitive (x (sum-fi-prime-infinity x)) (y (sum-fi-prime y (i-large-integer))) (z (sum-fi-prime-infinity y)))))))) ;; ====================================================================== (local (defun diff-sum-fi-primes (x i) (- (sum-fi-prime-infinity x) (sum-fi-prime x i)))) (local (defthm realp-diff-sum-fi-primes (realp (diff-sum-fi-primes x i)) :rule-classes :type-prescription)) (local (defthm diff-sum-fi-primes-continuous (implies (and (standardp i) (standardp x) (inside-interval-p x (fi-domain)) (inside-interval-p y (fi-domain)) (i-close x y)) (i-close (diff-sum-fi-primes x i) (diff-sum-fi-primes y i))) :hints (("Goal" :in-theory (disable sum-fi-prime-infinity))))) (local (defthm diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p x (fi-domain)) (i-large i) (natp i)) (i-close (diff-sum-fi-primes x i) 0)) :hints (("Goal" :in-theory (e/d (i-close) (sum-fi-prime-uniformly-converge)) :use (sum-fi-prime-uniformly-converge))))) ;; ====================================================================== ;; Find max diff-sum-fi-primes. (local (defun find-max-diff-sum-fi-primes-x-n (a max-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (> (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes max-x i)) (find-max-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-max-diff-sum-fi-primes-x-n a max-x (1+ step) n eps i)) max-x))) (local (defthm find-max-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-max-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-max-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-max-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-max-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) (local (defthm find-max-diff-sum-fi-primes-is-maximum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes x i) (diff-sum-fi-primes (find-max-diff-sum-fi-primes-x a b i) i))) :hints (("Goal" :by (:functional-instance find-max-rcfn-2-is-maximum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x)))))) ;; Find min diff-sum-fi-primes. (local (defun find-min-diff-sum-fi-primes-x-n (a min-x step n eps i) (declare (xargs :measure (nfix (1+ (- n step))))) (if (and (integerp step) (integerp n) (<= step n) (realp a) (realp eps) (< 0 eps)) (if (< (diff-sum-fi-primes (+ a (* step eps)) i) (diff-sum-fi-primes min-x i)) (find-min-diff-sum-fi-primes-x-n a (+ a (* step eps)) (1+ step) n eps i) (find-min-diff-sum-fi-primes-x-n a min-x (1+ step) n eps i)) min-x))) (local (defthm find-min-diff-sum-fi-primes-x-n-limited (implies (and (realp a) (i-limited a) (realp b) (i-limited b) (< a b)) (i-limited (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (+ (- (* (/ (i-large-integer)) a)) (* (/ (i-large-integer)) b)) i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-n-limited (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n))) ("Subgoal 3" :use (:instance diff-sum-fi-primes-continuous (i arg))) ("Subgoal 2" :use fi-domain-non-trivial)))) (local (defun-std find-min-diff-sum-fi-primes-x (a b i) (if (and (realp a) (realp b) (< a b)) (standard-part (find-min-diff-sum-fi-primes-x-n a a 0 (i-large-integer) (/ (- b a) (i-large-integer)) i)) 0))) (local (defthm find-min-diff-sum-fi-primes-x-inside-interval (implies (and (inside-interval-p a interval) (inside-interval-p b interval) (< a b)) (inside-interval-p (find-min-diff-sum-fi-primes-x a b i) interval)) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-x-inside-interval (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (defthm find-min-diff-sum-fi-primes-is-minimum (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (realp x) (<= a x) (<= x b) (< a b)) (<= (diff-sum-fi-primes (find-min-diff-sum-fi-primes-x a b i) i) (diff-sum-fi-primes x i))) :hints (("Goal" :by (:functional-instance find-min-rcfn-2-is-minimum (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x)))))) (local (in-theory (disable diff-sum-fi-primes))) ;; ====================================================================== (local (defun map-diff-sum-fi-primes (p i) (if (consp p) (cons (diff-sum-fi-primes (car p) i) (map-diff-sum-fi-primes (cdr p) i)) nil))) (local (defun riemann-diff-sum-fi-primes (p i) (dotprod (deltas p) (map-diff-sum-fi-primes (cdr p) i)))) (local (defun diff-sum-fi-primes-max-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-max-diff-sum-fi-primes-x a b i) (if (< b a) (find-max-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-above (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (riemann-diff-sum-fi-primes p i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-above (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-max-rcfn-2-x-n find-max-diff-sum-fi-primes-x-n) (find-max-rcfn-2-x find-max-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-max-x diff-sum-fi-primes-max-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-max-x))) (local (defun diff-sum-fi-primes-min-x (a b i) (if (and (realp a) (realp b)) (if (< a b) (find-min-diff-sum-fi-primes-x a b i) (if (< b a) (find-min-diff-sum-fi-primes-x b a i) b)) b))) (local (defthm riemann-diff-sum-fi-primes-bounded-below (implies (and (partitionp p) (inside-interval-p (car p) (fi-domain)) (inside-interval-p (car (last p)) (fi-domain))) (<= (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x (car p) (car (last p)) i) i) (- (car (last p)) (car p))) (riemann-diff-sum-fi-primes p i))) :hints (("Goal" :by (:functional-instance riemann-rcfn-2-bounded-below (rcfn-2 diff-sum-fi-primes) (rcfn-2-domain fi-domain) (find-min-rcfn-2-x-n find-min-diff-sum-fi-primes-x-n) (find-min-rcfn-2-x find-min-diff-sum-fi-primes-x) (map-rcfn-2 map-diff-sum-fi-primes) (riemann-rcfn-2 riemann-diff-sum-fi-primes) (rcfn-2-min-x diff-sum-fi-primes-min-x)))) :rule-classes :linear)) (local (in-theory (disable diff-sum-fi-primes-min-x))) ;; Define the upper bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-upper-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-upper-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-upper-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-upper-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-upper-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-upper-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-max-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-max-x a b i) i)) (y2 0)))))) ;; Define the lower bound function of riemann-diff-sum-fi-primes. (local (defun riemann-diff-sum-fi-primes-lower-bound (a b i) (* (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i) (- b a)))) (local (defthm realp-riemann-diff-sum-fi-primes-lower-bound (implies (and (realp a) (realp b)) (realp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes :type-prescription)) (local (defthm-std standardp-riemann-diff-sum-fi-primes-lower-bound (implies (and (standardp i) (standardp a) (standardp b)) (standardp (riemann-diff-sum-fi-primes-lower-bound a b i))) :rule-classes (:rewrite :type-prescription))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) 0)) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes-min-x) (DISTRIBUTIVITY)) :use (:instance i-close-times (x (- b a)) (y1 (diff-sum-fi-primes (diff-sum-fi-primes-min-x a b i) i)) (y2 0)))))) (local (defthm riemann-diff-sum-fi-primes-lower-bound-approaches-upper-bound (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes-upper-bound a b i))) :hints (("Goal" :in-theory (disable riemann-diff-sum-fi-primes-lower-bound riemann-diff-sum-fi-primes-upper-bound) :use (:instance i-close-transitive (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y 0) (z (riemann-diff-sum-fi-primes-upper-bound a b i))))))) (local (defthm strict-int-diff-sum-fi-primes-bounded (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (<= (riemann-diff-sum-fi-primes (make-small-partition a b) i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :use ((:instance riemann-diff-sum-fi-primes-bounded-below (p (make-small-partition a b))) (:instance riemann-diff-sum-fi-primes-bounded-above (p (make-small-partition a b))) (:instance car-make-small-partition) (:instance car-last-make-small-partition) (:instance partitionp-make-small-partition)) :in-theory (disable car-make-small-partition car-last-make-small-partition partitionp-make-small-partition))) :rule-classes :linear)) (local (in-theory (disable riemann-diff-sum-fi-primes-upper-bound riemann-diff-sum-fi-primes-lower-bound))) ;; ====================================================================== ;; Define the Riemann integral of diff-sum-fi-primes. (local (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-diff-sum-fi-primes (implies (partitionp p) (realp (riemann-diff-sum-fi-primes p i))) :rule-classes :type-prescription))) (local (defthm limited-riemann-diff-sum-fi-primes-small-partition (implies (and (standardp i) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-diff-sum-fi-primes (make-small-partition a b) i))) :hints (("Goal" :use ((:instance standards-are-limited (x (riemann-diff-sum-fi-primes-upper-bound a b i))) (:instance standards-are-limited (x (riemann-diff-sum-fi-primes-lower-bound a b i))) (:instance limited-squeeze (a (riemann-diff-sum-fi-primes-lower-bound a b i)) (b (riemann-diff-sum-fi-primes-upper-bound a b i)) (x (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b)))) :in-theory (disable limited-squeeze standards-are-limited standards-are-limited-forward riemann-diff-sum-fi-primes))))) (local (in-theory (disable riemann-diff-sum-fi-primes))) (local (defun-std strict-int-diff-sum-fi-primes (a b i) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-diff-sum-fi-primes (make-small-partition a b) i)) 0))) (local (defun int-diff-sum-fi-primes (a b i) (if (<= a b) (strict-int-diff-sum-fi-primes a b i) (- (strict-int-diff-sum-fi-primes b a i))))) ;; ====================================================================== (local (defthm-std int-diff-sum-fi-primes-bounded-1 (implies (and (<= a b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (riemann-diff-sum-fi-primes-lower-bound a b i) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (riemann-diff-sum-fi-primes-upper-bound a b i)))) :hints (("Goal" :expand ((riemann-diff-sum-fi-primes-lower-bound a a i) (riemann-diff-sum-fi-primes-upper-bound a a i)) :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance strict-int-diff-sum-fi-primes-bounded) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (riemann-diff-sum-fi-primes (make-small-partition a b) i))) (:instance STANDARD-PART-<= (x (riemann-diff-sum-fi-primes (make-small-partition a b) i)) (y (riemann-diff-sum-fi-primes-upper-bound a b i)))))) :rule-classes :linear)) (local (defthm-std int-diff-sum-fi-primes-bounded-2 (implies (and (< b a) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (and (<= (- (riemann-diff-sum-fi-primes-upper-bound b a i)) (int-diff-sum-fi-primes a b i)) (<= (int-diff-sum-fi-primes a b i) (- (riemann-diff-sum-fi-primes-lower-bound b a i))))) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a))) (:instance strict-int-diff-sum-fi-primes-bounded (a b) (b a)) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (- (riemann-diff-sum-fi-primes (make-small-partition b a) i)))) (:instance STANDARD-PART-<= (x (- (riemann-diff-sum-fi-primes (make-small-partition b a) i))) (y (- (riemann-diff-sum-fi-primes-lower-bound b a i))))))) :rule-classes :linear)) (local (defthm-std realp-int-diff-sum-fi-primes (realp (int-diff-sum-fi-primes a b i)) :hints (("Goal" :use ((:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition a b))) (:instance realp-riemann-diff-sum-fi-primes (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (encapsulate () (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-1 (implies (and (<= a b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (riemann-diff-sum-fi-primes-lower-bound a b i)) (y (int-diff-sum-fi-primes a b i)) (z (riemann-diff-sum-fi-primes-upper-bound a b i)))))))) (local (defthm int-diff-sum-fi-primes-approaches-0-lemma-2 (implies (and (< b a) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :in-theory (disable int-diff-sum-fi-primes) :use ((:instance close-squeeze (x (- (riemann-diff-sum-fi-primes-upper-bound b a i))) (y (int-diff-sum-fi-primes a b i)) (z (- (riemann-diff-sum-fi-primes-lower-bound b a i)))) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-lower-bound b a i)) (y2 0)) (:instance i-close-times (x -1) (y1 (riemann-diff-sum-fi-primes-upper-bound b a i)) (y2 0))))))) (defthm int-diff-sum-fi-primes-approaches-0 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-diff-sum-fi-primes a b i) 0)) :hints (("Goal" :cases ((<= a b) (< b a)) :use ((:instance int-diff-sum-fi-primes-approaches-0-lemma-1) (:instance int-diff-sum-fi-primes-approaches-0-lemma-2))))))) ;; ====================================================================== (defun map-sum-fi-prime-infinity (p) (if (consp p) (cons (sum-fi-prime-infinity (car p)) (map-sum-fi-prime-infinity (cdr p))) nil)) (defun riemann-sum-fi-prime-infinity (p) (dotprod (deltas p) (map-sum-fi-prime-infinity (cdr p)))) (local (defthm limited-riemann-sum-fi-prime-infinity-small-partition (implies (and (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (i-limited (riemann-sum-fi-prime-infinity (make-small-partition a b)))) :hints (("Goal" :use (:functional-instance limited-riemann-rcfn-small-partition (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity))) ("Subgoal 3" :use sum-fi-prime-infinity-continuous) ("Subgoal 2" :use fi-domain-non-trivial)))) (encapsulate () (local (in-theory (disable riemann-sum-fi-prime-infinity))) (defun-std strict-int-sum-fi-prime-infinity (a b) (if (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (< a b)) (standard-part (riemann-sum-fi-prime-infinity (make-small-partition a b))) 0))) (defun int-sum-fi-prime-infinity (a b) (if (<= a b) (strict-int-sum-fi-prime-infinity a b) (- (strict-int-sum-fi-prime-infinity b a)))) (local (defthm sum-fi-prime-infinity-ftc-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1)) (sum-fi-prime-infinity x))) :hints (("goal" :by (:functional-instance ftc-1 (rcfn sum-fi-prime-infinity) (rcfn-domain fi-domain) (map-rcfn map-sum-fi-prime-infinity) (riemann-rcfn riemann-sum-fi-prime-infinity) (strict-int-rcfn strict-int-sum-fi-prime-infinity) (int-rcfn int-sum-fi-prime-infinity)))))) ;; ====================================================================== (local (defun diff-int-sum-fi-primes (a b i) (- (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i)))) (encapsulate () (local (include-book "arithmetic-5/top" :dir :system)) (defthm realp-riemann-sum-fi-prime (implies (partitionp p) (realp (riemann-sum-fi-prime p i))) :rule-classes :type-prescription) (defthm realp-riemann-sum-fi-prime-infinity (implies (partitionp p) (realp (riemann-sum-fi-prime-infinity p))) :rule-classes :type-prescription)) (local (defthm-std realp-diff-int-sum-fi-primes (realp (diff-int-sum-fi-primes a b i)) :hints (("Goal" :in-theory (disable riemann-sum-fi-prime-infinity riemann-sum-fi-prime) :use ((:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime-infinity (p (make-small-partition b a))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition a b))) (:instance realp-riemann-sum-fi-prime (p (make-small-partition b a)))))) :rule-classes :type-prescription)) (local (defthm diff-int-sum-fi-primes-derivative (implies (and (standardp i) (inside-interval-p a (fi-domain)) (inside-interval-p x (fi-domain)) (inside-interval-p x1 (fi-domain)) (standardp x) (i-close x x1) (not (equal x x1))) (i-close (/ (- (diff-int-sum-fi-primes a x i) (diff-int-sum-fi-primes a x1 i)) (- x x1)) (diff-sum-fi-primes x i))) :hints (("Goal" :in-theory (e/d (diff-sum-fi-primes) (sum-fi-prime-infinity sum-fi-prime int-sum-fi-prime-infinity int-sum-fi-prime)) :use (sum-fi-prime-infinity-ftc-1 sum-fi-prime-ftc-1-2 (:instance i-close-times (x -1) (y1 (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1))) (y2 (sum-fi-prime x i))) (:instance i-close-plus (x1 (/ (- (int-sum-fi-prime-infinity a x) (int-sum-fi-prime-infinity a x1)) (- x x1))) (x2 (sum-fi-prime-infinity x)) (y1 (- (/ (- (int-sum-fi-prime a x i) (int-sum-fi-prime a x1 i)) (- x x1)))) (y2 (- (sum-fi-prime x i))))))))) (local (defthm sum-rule-of-int-diff-sum-fi-primes-lemma-1 (implies (and (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b (i)) (- (diff-int-sum-fi-primes (low) b (i)) (diff-int-sum-fi-primes (low) a (i))))) :hints (("Goal" :in-theory (enable riemann-diff-sum-fi-primes) :by (:functional-instance ftc-2 (rcdfn (lambda (x) (diff-int-sum-fi-primes (low) x (i)))) (rcdfn-prime (lambda (x) (diff-sum-fi-primes x (i)))) (rcdfn-domain fi-domain) (map-rcdfn-prime (lambda (p) (map-diff-sum-fi-primes p (i)))) (riemann-rcdfn-prime (lambda (p) (riemann-diff-sum-fi-primes p (i)))) (strict-int-rcdfn-prime (lambda (a b) (strict-int-diff-sum-fi-primes a b (i)))) (int-rcdfn-prime (lambda (a b) (int-diff-sum-fi-primes a b (i)))))) ("Subgoal 7" :use (:instance diff-int-sum-fi-primes-derivative (a (low)) (i (i)))) ("Subgoal 6" :use fi-domain-non-trivial)))) (local (defthm-std sum-rule-of-int-diff-sum-fi-primes-lemma-2 (equal (diff-int-sum-fi-primes a a i) 0))) (local (defthm sum-rule-of-int-diff-sum-fi-primes (implies (and (natp i) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-diff-sum-fi-primes a b i) (diff-int-sum-fi-primes a b i))) :hints (("Goal" :use (:functional-instance sum-rule-of-int-diff-sum-fi-primes-lemma-1 (low (lambda () (if (inside-interval-p a (fi-domain)) a (low)))) (i (lambda () (if (natp i) i (i))))))))) ;; ====================================================================== (local (defthm int-sum-fi-prime-infinity-lemma-1 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (standardp a) (standardp b) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-close (int-sum-fi-prime-infinity a b) (int-sum-fi-prime a b i))) :hints (("Goal" :in-theory (enable i-close) :use int-diff-sum-fi-primes-approaches-0)))) (defthm-std standardp-int-sum-fi-prime-infinity (implies (and (standardp a) (standardp b)) (standardp (int-sum-fi-prime-infinity a b))) :rule-classes (:rewrite :type-prescription)) (encapsulate () (local (in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime))) (local (defthm limited-int-sum-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (int-sum-fi-prime a b i))) :hints (("Goal" :use ((:instance standards-are-limited (x (int-sum-fi-prime-infinity a b))) (:instance i-close-limited (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b i)))))))) (defun-std int-sum-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (int-sum-fi-prime a b (i-large-integer))) 0)) (local (defthm limited-sum-int-fi-prime-with-large-index (implies (and (standardp a) (standardp b) ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain)) (i-large i) (natp i)) (i-limited (sum-int-fi-prime a b i))) :hints (("Goal" :in-theory (disable sum-rule-of-int-sum-fi-prime) :use sum-rule-of-int-sum-fi-prime)))) (defun-std sum-int-fi-prime-with-large-index (a b) (if (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (standard-part (sum-int-fi-prime a b (i-large-integer))) 0))) (defthm-std int-sum-fi-prime-infinity-lemma-2 (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (int-sum-fi-prime-with-large-index a b))) :hints (("Goal" :in-theory (disable int-sum-fi-prime-infinity int-sum-fi-prime sum-rule-of-int-sum-fi-prime) :use (int-sum-fi-prime-infinity-lemma-1 (:instance close-x-y->same-standard-part (x (int-sum-fi-prime-infinity a b)) (y (int-sum-fi-prime a b (i-large-integer)))))))) (defthm-std sum-rule-of-int-sum-fi-prime-infinity (implies (and ;;(interval-left-inclusive-p (fi-domain)) ;;(interval-right-inclusive-p (fi-domain)) (inside-interval-p a (fi-domain)) (inside-interval-p b (fi-domain))) (equal (int-sum-fi-prime-infinity a b) (sum-int-fi-prime-with-large-index a b))))