[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-82030-en":3,"doc-seo-82030-105":31,"detail-sidebar-cat-0-en-105":93},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":21,"is_downloadable":21,"audit_status":21,"page_count":22,"language":23,"language_code":24,"site_id":25,"html_lang":24,"table_of_contents":26,"faqs":27,"seo_title":28,"seo_description":14,"update_tm":29,"read_time":30},82030,7971461740886,"Theodore","https://ap-avatar.wpscdn.com/davatar_3d24733baf745e90a7e4bdd5f77d97b2",8,"Research & Report","Potential Functions as Types: A Synthetic Modal Formulation of Amortized Cost","Amortized analysis is unified through a dependent type-theoretic framework that connects two classical viewpoints: a physicist’s potential-function view and a banker’s credit-resource view. The work presents fracture and gluing results showing each type contains a fusion of abstraction and potential functions, enforcing conservation of abstraction and cost modularly. It introduces credit/debit operators and a graded substructural dependent type theory (Giralf) semantically interpreted as a sub-language of Calf, plus an inference algorithm that translates a limited class of Calf programs into Giralf for automated cost verification.","arXiv :2607 .08547v2 [ cs .PL] 10 Jul 2026  \nPotential Functions as Types  \nA Synthetic Modal Formulation of Amortized Cost  \nHARRISON GRODIN, ETHAN CHU, and RUNMING LI, Carnegie Mellon University, USA JAN HOFFMANN and ROBERT HARPER, Carnegie Mellon University, USA  \nAmortized analysis can be framed from the physicist’s view, amenable to manual verification in dependent type theory using potential functions, and the banker’s view, amenable to automated inference in substructural type theory using type-level credit annotations. In this work, we synthesize these perspectives in Calf, a dependent type theory for cost verification. From the physicist’s view, we present a fracture and gluing theorem that renders every type as containing a fusion of an abstraction function and a potential function. By construction, every program between two such types must preserve abstraction, to facilitate modularity of behavior, and conserve potential, to facilitate modularity of cost. Incorporating the banker’s view, we synthetically construct type operators for credits and debits. We then define Giralf, a graded substructural dependent type theory for programming with credits and debits, which is semantically interpreted as a sub-language of Calf. Finally, we adapt an inference algorithm to transform a limited class of Calf programs into Giralf counterparts, automating the cost analysis of common algorithms in Calf.  \nAdditional Key Words and Phrases: abstract data type, abstraction, abstraction function, amortized analysis, algorithm analysis, call-by-push-value, cost analysis, data structure, dependent type theory, information flow, modal type theory, modularity, phase distinction, proof assistants, resource analysis, verification  \n1 Introduction  \nAmortized analysis, pioneered by Sleator and Tarjan [1985], is a technique for analyzing the cost of a sequence of operations on an ephemeral data structure. Since its inception, there have been two compatible perspectives ofthe method—the physicist’s view and the banker’s view.  \nIn the physicist’s view, a potential function Φ : 􀀭 → C assigns potential (i.e., future cost) to each data structure of a type 􀀭 , where C is a type representing cost (commonly the natural numbers) . Then, for an operation 􀀵 : 􀀭 → 􀀭 with a true cost 􀀲 ⊤ : 􀀭 → C and an imagined amortized cost 􀀲 abs : 􀀭 → C, one proves a principle tantamount to the conservation of energy:  \n􀀲 ⊤ (􀁇) + Φ(􀀵 (􀁇)) ≤ Φ (􀁇) + 􀀲 abs (􀁇) . (1)  \nIterating this inequality (traditionally via a telescoping sum) ensures that the true cost of a sequence of operations is upper-bounded by the sum of the amortized costs and the initial potential. Because it requires a proof of Eq. (1), which could rely on arbitrarily complex facts and invariants of the data, the physicist’s view is well-suited for manual verification in dependent type theory [Grodin and Harper 2024; Niu et al. 2022] and higher-order logic [Nipkow and Brinkop 2019] .  \nIn the banker’s view, cost is viewed as a coin-like resource—called a credit—that can be saved within a data structure. Credits can be spent later to offset the cost of an expensive operation; if all true costs are offset by credits, the amortized cost of a sequence of operations is simply the number of credits stored within the input data. Due to their status as a resource, credits must be treated substructurally: although credits may be wasted, they may not be duplicated. In many common algorithms and data structures, it is possible to attach the requisite credits to a data structure automatically, placing a credit in exactly the locations where cost will later be incurred. Thus, the banker’s view is well-suited for substructural logics and type theories [Atkey 2011; Mével et al. 2019] as well as automated inference [Hoffmann and Jost 2022; Hofmann and Jost 2003] .  \nFrom either perspective, amortization is fundamentally about modularity. Amortized analysis does not affect the implementation details or the true cost of data","cbCaieRI7lohyNRy","https://ap.wps.com/l/cbCaieRI7lohyNRy","pdf",702496,7,1,28,"English","en",105,"# Introduction\n## Two perspectives on amortized analysis\n## Modularity via cost interfaces and ghost resources\n## The proposed unification approach\n## Building blocks: Calf and phase distinction","[{\"question\":\"What are the two main perspectives on amortized analysis used in the document?\",\"answer\":\"The document contrasts the physicist’s view based on potential functions with the banker’s view based on credits as a coin-like resource. Both perspectives model how future cost is accounted for during sequences of operations.\"},{\"question\":\"How does the approach preserve modularity when verifying amortized cost?\",\"answer\":\"It treats abstraction and potential conservatively through type structure: types encode an abstraction function fusion and programs carry proofs of conservation. A synthetic phase distinction provides a stable model for client verification and isolates where costs occur.\"},{\"question\":\"What is Giralf, and how is it related to Calf?\",\"answer\":\"Giralf is a graded substructural dependent type theory for programming with credits and debits. It is defined so that its semantics form a sub-language of Calf, enabling cost reasoning within the same dependent-type framework.\"}]","Potential Functions as Types: A Synthetic Modal Formulation of Amortized Cost | PDF",1784177685,71,{"code":4,"msg":32,"data":33},"ok",{"site_id":25,"language":24,"slug":34,"title":13,"keywords":35,"description":14,"schema_data":36,"social_meta":88,"head_meta":90,"extra_data":92,"updated_unix":29},"potential-functions-as-types-a-synthetic-modal-formulation-of-amortized-cost","",{"@graph":37,"@context":87},[38,55,70],{"@type":39,"itemListElement":40},"BreadcrumbList",[41,45,49,52],{"item":42,"name":43,"@type":44,"position":21},"https://docshare.wps.com","Home","ListItem",{"item":46,"name":47,"@type":44,"position":48},"https://docshare.wps.com/document/","Document",2,{"item":50,"name":12,"@type":44,"position":51},"https://docshare.wps.com/document/research-report/",3,{"item":53,"name":13,"@type":44,"position":54},"https://docshare.wps.com/document/potential-functions-as-types-a-synthetic-modal-formulation-of-amortized-cost/82030/",4,{"url":53,"name":13,"@type":56,"author":57,"headline":13,"publisher":59,"fileFormat":62,"inLanguage":24,"description":14,"dateModified":63,"datePublished":64,"encodingFormat":62,"isAccessibleForFree":65,"interactionStatistic":66},"DigitalDocument",{"name":9,"@type":58},"Person",{"url":42,"name":60,"@type":61},"DocShare","Organization","application/pdf","2026-07-30","2026-07-16",true,{"@type":67,"interactionType":68,"userInteractionCount":20},"InteractionCounter",{"@type":69},"ViewAction",{"@type":71,"mainEntity":72},"FAQPage",[73,79,83],{"name":74,"@type":75,"acceptedAnswer":76},"What are the two main perspectives on amortized analysis used in the document?","Question",{"text":77,"@type":78},"The document contrasts the physicist’s view based on potential functions with the banker’s view based on credits as a coin-like resource. Both perspectives model how future cost is accounted for during sequences of operations.","Answer",{"name":80,"@type":75,"acceptedAnswer":81},"How does the approach preserve modularity when verifying amortized cost?",{"text":82,"@type":78},"It treats abstraction and potential conservatively through type structure: types encode an abstraction function fusion and programs carry proofs of conservation. A synthetic phase distinction provides a stable model for client verification and isolates where costs occur.",{"name":84,"@type":75,"acceptedAnswer":85},"What is Giralf, and how is it related to Calf?",{"text":86,"@type":78},"Giralf is a graded substructural dependent type theory for programming with credits and debits. It is defined so that its semantics form a sub-language of Calf, enabling cost reasoning within the same dependent-type framework.","https://schema.org",{"og:url":53,"og:type":89,"og:title":13,"og:site_name":60,"og:description":14},"article",{"robots":91,"canonical":53},"index,follow",{"doc_id":7,"site_id":25},{"code":4,"msg":5,"data":94},[95,99,103,107,112,117,121,124,129,132,136],{"id":21,"doc_module":4,"doc_module_name":47,"category_name":96,"show_sort_weight":97,"slug":98},"Story & Novel",90,"story-novel",{"id":48,"doc_module":4,"doc_module_name":47,"category_name":100,"show_sort_weight":101,"slug":102},"Literature",80,"literature",{"id":54,"doc_module":4,"doc_module_name":47,"category_name":104,"show_sort_weight":105,"slug":106},"Exam",70,"exam",{"id":108,"doc_module":4,"doc_module_name":47,"category_name":109,"show_sort_weight":110,"slug":111},5,"Comic",60,"comic",{"id":113,"doc_module":4,"doc_module_name":47,"category_name":114,"show_sort_weight":115,"slug":116},6,"Technology",50,"technology",{"id":20,"doc_module":4,"doc_module_name":47,"category_name":118,"show_sort_weight":119,"slug":120},"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":47,"category_name":12,"show_sort_weight":122,"slug":123},30,"research-report",{"id":125,"doc_module":4,"doc_module_name":47,"category_name":126,"show_sort_weight":127,"slug":128},9,"Religion & Spirituality",20,"religion-spirituality",{"id":127,"doc_module":4,"doc_module_name":47,"category_name":130,"show_sort_weight":127,"slug":131},"World Cup","world-cup",{"id":133,"doc_module":4,"doc_module_name":47,"category_name":134,"show_sort_weight":133,"slug":135},10,"Lifestyle","lifestyle",{"id":137,"doc_module":4,"doc_module_name":47,"category_name":138,"show_sort_weight":108,"slug":139},19,"General","general"]