{"id":19151386,"url":"https://github.com/tezos/optimal_stack","last_synced_at":"2025-07-10T20:36:27.168Z","repository":{"id":109373702,"uuid":"107523671","full_name":"tezos/optimal_stack","owner":"tezos","description":"Compiler for stack manipulation in Michelson","archived":false,"fork":false,"pushed_at":"2018-12-19T17:17:18.000Z","size":5,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T05:28:22.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tezos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-19T09:07:12.000Z","updated_at":"2023-11-01T19:27:26.000Z","dependencies_parsed_at":"2023-03-07T10:00:21.640Z","dependency_job_id":null,"html_url":"https://github.com/tezos/optimal_stack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tezos/optimal_stack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tezos%2Foptimal_stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tezos%2Foptimal_stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tezos%2Foptimal_stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tezos%2Foptimal_stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tezos","download_url":"https://codeload.github.com/tezos/optimal_stack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tezos%2Foptimal_stack/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264652984,"owners_count":23644366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:14:36.315Z","updated_at":"2025-07-10T20:36:27.149Z","avatar_url":"https://github.com/tezos.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# optimal_stack\n\nI don't think the heap implementation is mine, but I don't remember\nwhere it's from. Let me know if you find it so I can put the right license.\n\n\n\n\nCompiler for stack manipulation in Michelson\n\nA lot of operations in Michelson are stack manipulation operations that \ndecompose structures on the stack and recompose them. This is a compiler\nthat calculates the optimal sequence of stack operations to achieve\na given result using A\\*.\n\nThis could be used as a light compilation pass for a JUMBLE macro\nthat would work like this:\n\nJUMBLE (a,b):c:(d,(e,f)) =\u003e (a,f):(c,d)\n\nWould turn a stack of the form on the left into a stack of the form\non the right. a,b,c,d,e,f are symbolic variables.\n\nCurrently, this compiler is quite slow because it attempts to find\nthe *optimal* solution. Here are ways in which it could be made practical\n\n1. Instead of searching for an optimal solution among the graph\nof all stack manipulations, start from a known admissible solution\nand refine it using a set of rewriting rules.\n\n2. Speed up the seach by\n - introducing more theorems about minimal costs in order to improve the A\\* heuristic\n - adding pseudo-instructions with known costs in order to help guide the search\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftezos%2Foptimal_stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftezos%2Foptimal_stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftezos%2Foptimal_stack/lists"}