Higher-order abstract syntax

In computer science, higher-order abstract syntax (abbreviated HOAS) is a technique for the representation of abstract syntax trees for languages with variable binders.

Relation to first-order abstract syntax

An abstract syntax is abstract because it is represented by mathematical objects that have certain structure by their very nature. For instance, in first-order abstract syntax (FOAS) trees, as commonly used in compilers, the tree structure implies the subexpression relation, meaning that no parentheses are required to disambiguate programs (as they are, in the concrete syntax). HOAS exposes additional structure: the relationship between variables and their binding sites. In FOAS representations, a variable is typically represented with an identifier, with the relation between binding site and use being indicated by using the same identifier. With HOAS, there is no name for the variable; each use of the variable refers directly to the binding site.

There are a number of reasons why this technique is useful. First, it makes the binding structure of a program explicit: just as there is no need to explain operator precedence in a FOAS representation, there is no need to have the rules of binding and scope at hand to interpret a HOAS representation. Second, programs that are alpha-equivalent (differing only in the names of bound variables) have identical representations in HOAS, which can make equivalence checking more efficient.

Implementation

One mathematical object that could be used to implement HOAS is a graph where variables are associated with their binding sites via edges. Another popular way to implement HOAS (in, for example, compilers) is with de Bruijn indices.

Use in logic programming

The first programming language which directly supported λ-bindings in syntax was the higher-order logic programming language λProlog.[1] The paper that introduced the term HOAS [2] used λProlog code to illustrate it. Unfortunately, when one transfers the term HOAS from the logic programming to the functional programming setting, that term implies the identification of bindings in syntax with functions over expressions. In this latter setting, HOAS has a different and problematic sense. The term λ-tree syntax has been introduced to refer specifically to the style of representation available in the logic programming setting.[3][4] While different in detail, the treatment of bindings in λProlog is similar to their treatment in logical frameworks, elaborated in the next section.

Use in logical frameworks

In the domain of logical frameworks, the term higher-order abstract syntax is usually used to refer to a specific representation that uses the binders of the meta-language to encode the binding structure of the object language.

For instance, the logical framework LF has a λ-construct, which has arrow (→) type. As an example, consider we wanted to formalize a very primitive language with untyped expressions, a built-in set of variables, and a let construct (let <var> = <exp> in <exp'>), which allows to bind variables var with definition exp in expressions exp'. In Twelf syntax, we could do as follows:

 exp : type.
 var : type.
 v : var -> exp.
 let : var -> exp -> exp -> exp.

Here, exp is the type of all expressions and var the type of all built-in variables (implemented perhaps as natural numbers, which is not shown). The constant v acts as a casting function and witnesses the fact that variables are expressions. Finally, the constant let represents let constructs of the form let <var> = <exp> in <exp>: it accepts a variable, an expression (being bound by the variable), and another expression (that the variable is bound within).

The canonical HOAS representation of the same object language would be:

 exp : type.
 let : exp -> (exp -> exp) -> exp.

In this representation, object level variables do not appear explicitly. The constant let takes an expression (that is being bound) and a meta-level function expexp (the body of the let). This function is the higher-order part: an expression with a free variable is represented as an expression with holes that are filled in by the meta-level function when applied. As a concrete example, we would construct the object level expression

 let x = 1 + 2
 in x + 3

(assuming the natural constructors for numbers and addition) using the HOAS signature above as

 let (plus 1 2) ([y] plus y 3)

where [y] e is Twelf's syntax for the function .

This specific representation has advantages beyond the ones above: for one, by reusing the meta-level notion of binding, the encoding enjoys properties such as type-preserving substitution without the need to define/prove them. In this way using HOAS can drastically reduce the amount of boilerplate code having to do with binding in an encoding.

Higher-order abstract syntax is generally only applicable when object language variables can be understood as variables in the mathematical sense (that is, as stand-ins for arbitrary members of some domain). This is often, but not always, the case: for instance, there are no advantages to be gained from a HOAS encoding of dynamic scope as it appears in some dialects of Lisp because dynamically scoped variables do not act like mathematical variables.

See also

References

  1. ^ Dale Miller; Gopalan Nadathur (1987). A Logic Programming Approach to Manipulating Formulas and Programs (PDF). IEEE Symposium on Logic Programming. pp. 379–388.
  2. ^ Frank Pfenning, Conal Elliott (1988). Higher-order abstract syntax (PDF). Proceedings of the ACM SIGPLAN PLDI '88. pp. 199–208. doi:10.1145/53990.54010. ISBN 0-89791-269-1.
  3. ^ Dale Miller (2000). Abstract Syntax for Variable Binders: An Overview (PDF). Computational Logic - {CL} 2000. pp. 239–253. Archived from the original (PDF) on 2006-12-02.
  4. ^ Miller, Dale (October 2019). "Mechanized metatheory revisited" (PDF). Journal of Automated Reasoning. 63 (3): 625–665. doi:10.1007/s10817-018-9483-3. S2CID 254605065.

Further reading

Read other articles:

Titular character of The Adventures of Tom Sawyer by Mark Twain This article is about the literary character. For the book, see The Adventures of Tom Sawyer. For other uses, see Tom Sawyer (disambiguation). Fictional character Tom Sawyer1876 illustration by True WilliamsFirst appearanceThe Adventures of Tom SawyerLast appearanceTom Sawyer, DetectiveCreated byMark TwainIn-universe informationFamilyAunt Polly (aunt) Sally Phelps (aunt) Mary (cousin) Sid (younger half-brother) Thomas Sawyer (/ˈ...

 

KrašТип шоколадна компаніяdГалузь Харчова промисловістьЗасновано 1911Штаб-квартира Загреб, ХорватіяПродукція Цукерки, вафлі, печиво та ін. кондитерські виробиkras.hr (рос.) НагородиCity of Zagreb Awardd (1982)  Kraš у Вікісховищі Kraš (Краш) — хорватська компанія, що спеціалізується на виро

 

American educator and politician Jo Anna DossettMember of the Oklahoma Senatefrom the 35th districtIncumbentAssumed office January 11, 2021Preceded byGary Stanislawski Personal detailsBornOwasso, Oklahoma, U.S.Political partyDemocraticSpouseChris BarberRelationsJ.J. Dossett (brother)Children2EducationWilliam Jewell College (BA)Oklahoma State University–Stillwater (MA) Jo Anna Dossett is an American educator and politician serving as a member of the Oklahoma Senate from the 35th district...

SiksakuburAlbum studio karya SiksakuburDirilis27 April 2014 (2014-04-27)StudioEC3 StudioGenreDeath MetalDurasi51:55LabelPodium MusicProduserAndre TirandaBaken NainggolanKronologi Siksakubur St. Kristo(2012 (2012)) Siksakubur(2014) Mazmur:187(2016 (2016)) Siksakubur atau Self-titled (judul alternatif VII) adalah album studio ketujuh oleh band death metal Siksakubur, rilis tanggal 27 April 2014 melalui bendera Podium Music, label independen yang didirikan oleh band Siksakubur...

 

Pierre MéchainPierre MéchainLahir(1744-08-16)16 Agustus 1744LaonMeninggal20 September 1804(1804-09-20) (umur 60)Castellón de la Plana, SpanyolKebangsaanPrancisDikenal atasBenda langit jauhKometMeterKarier ilmiahBidangAstronomiInstitusiObservatorium Paris Pierre François André Méchain (16 Agustus 1744 – 20 September 1804) adalah seorang astronom dan pengukur Prancis, bersama dengan Charles Messier, menjari penyumbang utama penelitian awal mengenai benda langit jauh d...

 

For the 1999 No Mercy professional wrestling event held in the United Kingdom, see No Mercy (UK). World Wrestling Federation pay-per-view event No MercyPromotional poster featuring MankindPromotionWorld Wrestling FederationDateOctober 17, 1999CityCleveland, OhioVenueGund ArenaAttendance18,742[1]Pay-per-view chronology ← PreviousRebellion Next →Survivor Series No Mercy chronology ← Previous1999 (UK) Next →2000 The 1999 No Mercy held in the United States was ...

Abide WeekendFounded2013FounderDave PickettLocation Canterbury, KentArea served United KingdomVolunteers 50Websitewww.abideweekend.co.uk Abide Weekend is an annual Christian youth conference based in Canterbury, Kent.[1] It is hosted by a collaboration of three Christian charities: Scripture Union, Urban Saints (formerly 'Crusaders') and Change Youth. History In 2013 Dave Pickett, then director of Kent-based charity 'Change Youth',[2] began a new venture to bring youth groups ...

 

Australian high school Hornsby Girls' High SchoolHornsby Girls' High SchoolLocationHornsby, Sydney, New South WalesAustraliaCoordinates33°42′23″S 151°6′5″E / 33.70639°S 151.10139°E / -33.70639; 151.10139InformationTypeGovernment-funded single-sex selective secondary day schoolMottoFaith with FortitudeEstablished1930 (1930)PrincipalJustin BriggsGenderGirlsEnrolment730CampusSuburbanColour(s)Fawn and navy blue   Websitehornsbygir-h.schools.nsw.g...

 

Kampanye melawan Dong ZhuoBagian dari Tiga KerajaanTanggalFebruari 190 - 191LokasiHenan, CinaHasil Tidak dapat disimpulkan;Dong Zhuo mundur ke barat, koalisi dibubarkanPihak terlibat Koalisi Guandong Dong ZhuoTokoh dan pemimpin Yuan Shao Dong ZhuoKekuatan 100.000+[1] Tidak diketahui Kampanye melawan Dong Zhuo (董卓討伐戰) pada tahun 190 dilancarkan oleh koalisi pejabat regional yang berusaha mengakhiri pengaruh Dong Zhuo di lingkungan kerajaan Dinasti Han di Cina. Dengan Yuan Sha...

1899 short story by Charles W. Chesnutt The Passing of Grandison was first collected in The Wife of His Youth and Other Stories of the Color Line (1899). The Passing of Grandison is a short story written by Charles W. Chesnutt and published in the collection The Wife of His Youth and Other Stories of the Color-Line (1899).[1] The story takes place in the United States in the early 1850s,[2] at the time of anti-slavery sentiment and the abolitionist movement in the Northern Uni...

 

Consonant letter of the Korean Hangul alphabet Sieut redirects here. For the commune in Romania, see Șieuț. siotHangulKorean nameRevised RomanizationSiotMcCune–ReischauerSiot Siot (character: ㅅ; Korean: 시옷, siot, North Korean: 시읏, sieut) is a consonant of the Korean alphabet.[1] The Unicode for ㅅ is U+3145. Siot indicates an [s] sound like in the English word staff, but at the end of a syllable it denotes a [t] sound. Before [i], semivowels (lik...

 

German dialect of South Australia This article is about the German dialect. For other uses, see Barossa (disambiguation). Barossa GermanBarossadeutsch, Barossa-DeutschGerman text in the Gruenberg Lutheran church at Moculta.RegionBarossa Valley, South AustraliaEthnicityGerman AustraliansLanguage familyIndo-European GermanicWest GermanicHigh GermanCentral GermanBarossa GermanWriting systemGerman alphabetLanguage codesISO 639-3–IETFde-u-sd-ausa Barossa German (German: Barossadeutsch or Barossa...

Active complex volcano in Nicaragua Masaya VolcanoView of the craterHighest pointElevation635 m (2,083 ft)[1]Coordinates11°58′58″N 86°9′43″W / 11.98278°N 86.16194°W / 11.98278; -86.16194GeographyLocationMasaya, NicaraguaParent rangeCentral American Volcanic BeltGeologyAge of rock~9,000 yearsMountain typeCalderaVolcanic arc/beltCentral American Volcanic BeltLast eruption2015–present Masaya (Spanish: Volcán Masaya) is a caldera locat...

 

British rabbi For the American lawyer, see Jeremy B. Rosen. This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article may need to be rewritten to comply with Wikipedia's quality standards. You can help. The talk page may contain suggestions. (March 2022) The topic of this article may not meet Wikipedia's general notability guideline. Please help to demonstrate the notability of the top...

 

この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?: ウィーン体制 – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL(2012年2月) ウィーン体制下(1815年)のヨーロッパ ウィ...

Division 1 1899-1900 Competizione Campionato belga di calcio Sport Calcio Edizione 5ª Organizzatore UBSSA Date dal 1º novembre 1899al 6 maggio 1900 Luogo  Belgio Partecipanti 10 Risultati Vincitore Racing Club de Bruxelles(2º titolo) Statistiche Miglior marcatore Charles Atkinson Cronologia della competizione 1898-1899 1900-1901 Manuale La Division 1 1899-1900 è stata la quinta edizione della massima serie del campionato belga di calcio disputata tra il 1º novembre 1899...

 

Challenger Banque Nationale 2010Doppio Sport Tennis Vincitori Kaden Hensel Adam Hubble Finalisti Scott Lipsky David Martin Punteggio 7–6(5), 3–6, [11–9] Tornei Singolare Singolare   Doppio Doppio Voce principale: Challenger Banque Nationale 2010. Il doppio del Challenger Banque Nationale 2010 è stato un torneo di tennis facente parte dell'ATP Challenger Tour 2010. Kaden Hensel e Adam Hubble hanno battuto in finale 7–6(5), 3–6, [11–9] Scott Lipsky e David Martin. Indice 1 Tes...

 

Central Bedfordshire CouncilTypeTypeUnitary authority HistoryFounded1 April 2009Preceded byBedfordshire County Council District councils Mid Bedfordshire District Council South Bedfordshire District Council LeadershipChairGareth Mackey, Independent since 25 May 2023 LeaderAdam Zerny, Independent since 25 May 2023 Chief ExecutiveMarcel Coiffait since November 2020[1] StructureSeats63 councillorsPolitical groups Administration (28)   Independent (28) Other parties (35)...

Agostino Li Vecchi Li Vecchi nel 2003 alla Pallacanestro Messina Nazionalità  Italia Altezza 204 cm Peso 100 kg Pallacanestro Ruolo Allenatore (ex ala) Termine carriera 2017 - giocatore Carriera Squadre di club 1989-1997 Viola R. Calabria99 (323)1997-2000 Barcellona38 (618)2000-2003 Pallalcesto Udine76 (669)2003-2004 Pall. Messina43 (599)2004 FuturVirtus4 (17)2004 Virtus Bologna12 (83)2004-2005 Pall. Treviso1 (0)2005 A. Costa Imola12 (179)2005-20...

 

  لمعانٍ أخرى، طالع مصر (توضيح).   مصر جمهورية مصر العربية مصرعلم مصر مصرشعار جمهورية مصر العربية موقع مصر في شمال شرق أفريقيا وجنوب غرب آسيا الشعار الوطنيمصر أمّ الدنيا  النشيد: بلادي، بلادي، بلادي الأرض والسكان إحداثيات 27°N 29°E / 27°N 29°E / 27; 29  [1]...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!