On k-colored Lambda Terms and their Skeletons

Similar documents
On Type-holding and type-repelling lambda-term skeletons, with applications to all-term and random-term generation of simply-typed closed lambda terms

Question 1 TELE4353. Question 1, cnt d. What is CDMA? Direct Sequence Spread Spectrum System Model. What is direct sequence CDMA?

stanchion paper roll mandrel base FIGURE P3-12 ramp

(CATALYST GROUP) B"sic Electric"l Engineering

CHAPTER 2 LITERATURE STUDY

Algorithms for Memory Hierarchies Lecture 14

FFH and MCFH Spread-Spectrum Wireless Sensor Network Systems Based on the Generalized Approach to Signal Processing

Kirchhoff s Rules. Kirchhoff s Laws. Kirchhoff s Rules. Kirchhoff s Laws. Practice. Understanding SPH4UW. Kirchhoff s Voltage Rule (KVR):

Throughput Performance of Quantized Proportional Fair Scheduling with Adaptive Modulation and Coding

MATH 118 PROBLEM SET 6

First Round Solutions Grades 4, 5, and 6

Polar Coordinates. July 30, 2014

University of North Carolina-Charlotte Department of Electrical and Computer Engineering ECGR 4143/5195 Electrical Machinery Fall 2009

Topic 20: Huffman Coding

MAXIMUM FLOWS IN FUZZY NETWORKS WITH FUNNEL-SHAPED NODES

Abacaba-Dabacaba! by Michael Naylor Western Washington University

MEASURE THE CHARACTERISTIC CURVES RELEVANT TO AN NPN TRANSISTOR

Math 116 Calculus II

Synchronous Machine Parameter Measurement

Lecture 20. Intro to line integrals. Dan Nichols MATH 233, Spring 2018 University of Massachusetts.

EE Controls Lab #2: Implementing State-Transition Logic on a PLC

Example. Check that the Jacobian of the transformation to spherical coordinates is

Domination and Independence on Square Chessboard

Benders Decomposition for Capacity Expansion Planning with Network Constraints and Uncertain Demand: the Spanish Case

Module 9. DC Machines. Version 2 EE IIT, Kharagpur

9.4. ; 65. A family of curves has polar equations. ; 66. The astronomer Giovanni Cassini ( ) studied the family of curves with polar equations

LECTURE 9: QUADRATIC RESIDUES AND THE LAW OF QUADRATIC RECIPROCITY

i INDEX PANEL DOOR TECHNICAL DATA

Exercise 1-1. The Sine Wave EXERCISE OBJECTIVE DISCUSSION OUTLINE. Relationship between a rotating phasor and a sine wave DISCUSSION

Dataflow Language Model. DataFlow Models. Applications of Dataflow. Dataflow Languages. Kahn process networks. A Kahn Process (1)

Application Note. Differential Amplifier

On the Description of Communications Between Software Components with UML

ECE 274 Digital Logic. Digital Design. Datapath Components Shifters, Comparators, Counters, Multipliers Digital Design

Sequential Logic (2) Synchronous vs Asynchronous Sequential Circuit. Clock Signal. Synchronous Sequential Circuits. FSM Overview 9/10/12

Synchronous Machine Parameter Measurement

Synchronous Generator Line Synchronization

Experiment 3: Non-Ideal Operational Amplifiers

Experiment 8 Series DC Motor (II)

Homework #1 due Monday at 6pm. White drop box in Student Lounge on the second floor of Cory. Tuesday labs cancelled next week

CS 135: Computer Architecture I. Boolean Algebra. Basic Logic Gates

Lab 8. Speed Control of a D.C. motor. The Motor Drive

Electronic Circuits I - Tutorial 03 Diode Applications I

Energy Harvesting Two-Way Channels With Decoding and Processing Costs

On lambda-term skeletons, with applications to all-term and random-term generation of simply-typed closed lambda terms

10.4 AREAS AND LENGTHS IN POLAR COORDINATES

Understanding Basic Analog Ideal Op Amps

Math Circles Finite Automata Question Sheet 3 (Solutions)

Hawk 3 H335 and H345 3½ Digit and 4½ Digit Advanced Digital Controller OPERATOR S MANUAL

Realizing Site Permutations

Student Book SERIES. Patterns and Algebra. Name

RIGHT-ANGLED TRIANGULAR PATCH RESONATOR AND FILTER WITH FRACTAL HOLE

PB-735 HD DP. Industrial Line. Automatic punch and bind machine for books and calendars

Vector Calculus. 1 Line Integrals

The Math Learning Center PO Box 12929, Salem, Oregon Math Learning Center

Student Book SERIES. Fractions. Name

ISSCC 2006 / SESSION 21 / ADVANCED CLOCKING, LOGIC AND SIGNALING TECHNIQUES / 21.5

Diffraction and Interference. 6.1 Diffraction. Diffraction grating. Diffraction grating. Question. Use of a diffraction grating in a spectrometer

Congruences for Stirling Numbers of the Second Kind Modulo 5

Experiment 3: Non-Ideal Operational Amplifiers

Seven Sisters. Visit for video tutorials

Regular languages can be expressed as regular expressions.

Secret Key Generation and Agreement in UWB Communication Channels

NONCLASSICAL CONSTRUCTIONS II

Geometric quantities for polar curves

(1) Primary Trigonometric Ratios (SOH CAH TOA): Given a right triangle OPQ with acute angle, we have the following trig ratios: ADJ

The Discussion of this exercise covers the following points:

Spiral Tilings with C-curves

BUBBLE BOBBLE 1 o C r t n o s l 2 t e G t g n i a t S r d e t 3 a B s c i Pl y a 4 a G m S e r c e n e 5 in r Sco g 6 ms e It 7 a P s s o w d r

Compared to generators DC MOTORS. Back e.m.f. Back e.m.f. Example. Example. The construction of a d.c. motor is the same as a d.c. generator.

Improving the Active Power Filter Performance with a Prediction Based Reference Generation

b = and their properties: b 1 b 2 b 3 a b is perpendicular to both a and 1 b = x = x 0 + at y = y 0 + bt z = z 0 + ct ; y = y 0 )

Understanding The HA2500 Horizontal Output Load Test

DESIGN OF CONTINUOUS LAG COMPENSATORS

Make Your Math Super Powered

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Study on SLT calibration method of 2-port waveguide DUT

Section 2.2 PWM converter driven DC motor drives

Information-Coupled Turbo Codes for LTE Systems

Series. Teacher. Numbers

Chapter 2 Literature Review

Experiment 3: The research of Thevenin theorem

Direct Current Circuits. Chapter Outline Electromotive Force 28.2 Resistors in Series and in Parallel 28.3 Kirchhoff s Rules 28.

Efficient and Resilient Key Discovery based on Pseudo-Random Key Pre-Deployment

How to Build Wealth Like Warren Buffett.

Exponential-Hyperbolic Model for Actual Operating Conditions of Three Phase Arc Furnaces

Section 16.3 Double Integrals over General Regions

HYDAC KineSys Controls for Hydraulic Presses

Samantha s Strategies page 1 of 2

Direct AC Generation from Solar Cell Arrays

A Development of Earthing-Resistance-Estimation Instrument

Convolutional Networks. Lecture slides for Chapter 9 of Deep Learning Ian Goodfellow

Digital Design. Chapter 1: Introduction

Algebra Practice. Dr. Barbara Sandall, Ed.D., and Travis Olson, M.S.

Lecture 16: Four Quadrant operation of DC Drive (or) TYPE E Four Quadrant chopper Fed Drive: Operation

Three-Phase Synchronous Machines The synchronous machine can be used to operate as: 1. Synchronous motors 2. Synchronous generators (Alternator)

A COMPARISON OF CIRCUIT IMPLEMENTATIONS FROM A SECURITY PERSPECTIVE

Redundancy Data Elimination Scheme Based on Stitching Technique in Image Senor Networks

THE TRADEOFF BETWEEN DIVERSITY GAIN AND INTERFERENCE SUPPRESSION VIA BEAMFORMING IN

A Stochastic Geometry Approach to the Modeling of DSRC for Vehicular Safety Communication

Y9.ET1.3 Implementation of Secure Energy Management against Cyber/physical Attacks for FREEDM System

Transcription:

On k-coored Lmbd Terms nd their Skeetons Pu Tru Uniersity of North Texs PADL 2018 Reserch supported by NSF grnt 1423324 Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 1 / 45

Oeriew this tk is bout n ppiction of ogic progrmming to the modeing of combintori properties of mbd terms mbd terms in de Bruijn nottion re Motzkin trees (so ced binry-unry trees) with indices t their ees counting up on the pth to the root the steps to their mbd binder s generiztion of ffine mbd terms, we introduce k-coored mbd terms obtined by being their mbd nodes with counts of the ribes they bind we study properties of the skeetons of k-coored mbd terms, the Motzkin trees obtined by ersing the de Bruijn indices being their ees we focus on the (difficut) cse of simpy-typed cosed k-coored mbd terms for which new combintori genertion gorithm is gien nd some interesting retions between mxim cooring, size of type expressions nd typbiity re expored Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 2 / 45

Outine 1 Lmbd terms nd their tree skeetons 2 Function equtions, dt types, nd -term genertors : in one, with DCGs 3 Mking mbd terms (somewht) more coorfu 4 Motzkin skeetons for cosed, ffine nd iner terms 5 K-coored cosed mbd terms 6 K-coored mbd terms nd type inference 7 A two-stge genertion gorithm for typbe nd untypbe skeetons 8 Questions? the pper is orgnized s iterte Proog progrm - our code is ibe t: http://www.cse.unt.edu/~tru/reserch/2017/pd18.pro Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 3 / 45

Lmbd terms nd their tree skeetons Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 4 / 45

Cosed mbd terms nd their Motzkin-trees skeetons Motzkin tree (so ced binry-unry tree) is rooted ordered tree buit from binry nodes, unry nodes nd ef nodes the set of Motzkin trees cn be seen s the free gebr generted by the constructors /0, /1 nd /2 mbd terms in de Bruijn form: the free gebr generted by the constructors /1, nd /2 nd ees beed with ntur numbers wrpped with the constructor /1 mbd term in de Bruijn form is cosed if for ech of its de Bruijn indices it exists mbd binder to which it points, on the pth to the root of the tree representing the term they re counted by sequence A135501 in OEIS skeeton of mbd term: the Motzkin tree obtined by ersing the bes t its ees we c Motzkin tree cosbe if it is the skeeton of t est one cosed mbd term Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 5 / 45

Some Cosbe nd Uncosbe Motzkin Skeetons ) 3 cosbe skeetons b) 3 uncosbe skeetons Figure: Cosbe s. uncosbe skeetons of size 7 Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 6 / 45

Function equtions, dt types, nd -term genertors : in one, with DCGs Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 7 / 45

Function equtions, dt types, nd -term genertors : in one, with DCGs the retionship between gebric function equtions nd unmbiguous CF-grmmrs is we known (see e.g., Fjoet s book) Proog preprocesses CF-grmmr nottion from Definite Cuse Grmmrs nottion to ctu code we cn design direct trnstion to them from gebric function equtions BTW, unmbiguous CF-grmmrs so describe dt dt types (e.g., Hske s dt decrtions)! The set of Motzkin trees M(z) foows the gebric function eqution M(z) = z + zm(z) + zm 2 (z). Trnsting to Proog s Definite Cuse Grmmr nottion (with, stnding for conjunction nd ; for disjunction) we obtin: m --> z ; z,m ; z,m,m. % we cn think here tht z consumes 1 size unit Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 8 / 45

A size definition: ech constructor costs s much s its rity Proposition The set of terms of size n for the size definition {ppiction=2, mbd=1, ribe=0} is equ to the set of terms of size n + 1 for the size definition {ppiction=1, mbd=1, ribe=1}. true, gien tht the number of ees in Motzkin tree is the number of binry nodes + 1 the term (((0),(0))) wi he size 3 = 1 + 2 with our definition, which corresponds to size 4 = 1 + 1 + 1 + 1 using the size definition for sequence A135501 our size definition is impemented s (SX,X):-succ(X,SX). % for /1 constructors -->,. % for /2 constructors with Proog s DCG nottion controing the consumption of size units from N to 0 Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 9 / 45

Cosbe nd uncosbe Motzkin skeetons cosbe skeeton: Motzkin tree tht is the skeeton of t est one cosed mbd term cn such skeeton predetermine if it cn be decorted to cosed mbd term? YES, nd there re sighty more uncosbe Motzkin trees thn cosbe ones s size grows: cosbe: 0,1,1,2,5,11,26,65,163,417,1086,2858,7599,20391,55127,150028,410719,... uncosbe: 1,0,1,2,4,10,25,62,160,418,1102,2940,7912,21444,58507,160544,442748,... Wht hppens to them symptoticy? pper with Oiier Bodini) 1 5 re cosbe (see LOPSTR 17 how we do it: we need is DCG grmmr describing them! Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 10 / 45

A CF grmmr for cosbe skeetons Proposition A Motzkin tree is skeeton of cosed mbd term if nd ony if it exists t est one mbd binder on ech pth from the ef to the root. t est one mbd (/1 constructor) on ech pth Motzkin trees beow the /1 constructor contin ony /2 brnches nd ees ssuming motske/3 genertes Motzkin trees i.e., by decorting m/2 cosbe(n,x):-cosbe(x,n,0). cosbe((z))-->,motske(z). % /2 nd ees ony cosbe((x,y))-->,cosbe(x),cosbe(y). Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 11 / 45

Mking mbd terms (somewht) more coorfu Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 12 / 45

Mking mbd terms (somewht) more coorfu our mbd terms in de Bruijn form: s the free gebr generted by the constructors /1, r/1 nd /2 with ees beed with ntur numbers (nd seen s wrpped with the constructor /1 when conenient) we spit mbd constructors into 2 csses: binding mbds, /1 tht re reched by t est one de Bruijn index free mbds, r/1, tht re not reched by ny de Bruijn index ex: λ x.λ y.λ z.(y (x x)) is written s ((r(((0),((1),(1))))) free mbd terms wi he no sy on terms being cosed, but they wi impct on which cosed terms re simpy typed 2-coored Motzkin trees: the free gebr generted by the constructors /0, /1, r/1 nd /2 2-coored Motzkin skeeton of mbd term: the tree obtined by ersing the de Bruijn indices being their ees Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 13 / 45

A bijection between 2-coored Motzkin skeetons nd non-empty binry trees binry trees: the free gebr generted by e/0 nd c/2 bijections between the Ctn fmiy of combintori objects nd 2-coored Motzkin trees : they exist but they inoe rtifici constructs (e.g., depth first serch on rose-trees, indirect definition of the mpping) reson to find new one! In Proog we need one retion for f nd f 1 : ct_mot(c(e,e),). ct_mot(c(x,e),(a)):-x=c(_,_),ct_mot(x,a). ct_mot(c(e,y),r(b)):-y=c(_,_),ct_mot(y,b). ct_mot(c(x,y),(a,b)):-x=c(_,_),y=c(_,_), ct_mot(x,a), ct_mot(y,b). one cn incude the empty tree e by n rithmetiztion mechnism tht defines successor nd predecessor (e.g., our PPDP 15 pper) Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 14 / 45

The 2-Motzkin to non-empty binry trees bijection t work two twinned trees of size 4 c c c e e e c e c e e r two twinned trees size 10 c c c c c e c e e e c c c e e e c c e e e e e r r r r r Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 15 / 45

Motzkin skeetons for cosed, ffine nd iner terms Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 16 / 45

Generting 2-coored Motzkin skeetons Motzkin skeetons of mbd terms: we erse the de Bruijn indices t ees size of constructors is their rity =2, =1, r=1, =0 in fct, this size definition mtches the size of their hep representtion generte the spits of the size N into 2*A+L+R where A=size of /2 etc. define predictes to consume size units s needed: Dec(c(SL,R,A),c(L,R,A)):-succ(L,SL). rdec(c(l,sr,a),c(l,r,a)):-succ(r,sr). Dec(c(L,R,SA),c(L,R,A)):-succ(A,SA). Proposition If Motzkin tree is skeeton of cosed mbd term then it exists t est one mbd binder on ech pth from the ef to the root. Thus L A + 1. The number of ees is A + 1 gien A ppiction nodes. Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 17 / 45

Generting cosed ffine terms flm(n,t):-sum_to(n,hi,lo),hs_enough_mbds(hi),flinlm(t,[],hi,lo) hs_enough_mbds(c(l,_,a)):-succ(a,l). % L=A+1 flinlm((x),[x])-->[]. flinlm((x,a),vs)-->dec,flinlm(a,[x Vs]). flinlm(r(a),vs)-->rdec,flinlm(a,vs). flinlm((a,b),vs)-->dec,{subset_nd_compement_of(vs,as,bs)}, flinlm(a,as), % mbd cnnot go flinlm(b,bs). % to both brnches!!! subset_nd_compement_of([],[],[]). subset_nd_compement_of([x Xs],NewYs,NewZs):- subset_nd_compement_of(xs,ys,zs), pce_eement(x,ys,zs,newys,newzs). pce_eement(x,ys,zs,[x Ys],Zs). pce_eement(x,ys,zs,ys,[x Zs]). Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 18 / 45

Liner terms, skeetons of ffine nd iner terms inlm(n,t):-n mod 3=:=1, sum_to(n,hi,lo),hs_no_unused(hi), flinlm(t,[],hi,lo). hs_no_unused(c(l,0,a)):-succ(a,l). % 0 r/1 constructors! Proposition If Motzkin tree with n binry nodes is skeeton of iner mbd term, then it hs excty n + 1 unry nodes, with one on ech pth from the root to its n + 1 ees. ffine: 0,1,2,3,9,30,81,242,838,2799,9365,33616,122937,449698 iner: 0,1,0,0,5,0,0,60,0,0,1105,0,0,27120,0,0,828250 Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 19 / 45

K-coored cosed mbd terms Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 20 / 45

K-coored cosed mbd terms: ffine terms ++ ntur generiztion of ffine terms: ech mbd cn bind t most k ribe occurrences k-coored mbd terms: sme s BCK(p) terms - with k = p + 1 we, for p>1 they re shoud ctuy be ced BCKW(p)) s the W combintor is needed when mbd binds t est two ribe occurrences... Bodini nd Gittenberger: cosed formu with bout 100+ mth symbos for BCK(2) Proposition Gener mbd terms re computtiony equient to 3-coored mbd terms (i.e., BCK(2) terms). Proof. Conert mbd term to S,K combintors. S nd K use t most two ribes for ech mbd: S = λ f.λ g.λ x.(f x)(g x), K = λ x.λ y.x. Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 21 / 45

Generting k-coored cosed mbd terms kcooredcosed(n,x):-kcooredcosed(x,[],n,0). kcooredcosed((i),vs)-->{nth0(i,vs,v),inc_r(v)}. kcooredcosed((k,a),vs)-->, % <= the K-coored mbd binder kcooredcosed(a,[v Vs]), {cose_r(v,k)}. kcooredcosed((a,b),vs)-->, kcooredcosed(a,vs), kcooredcosed(b,vs). inc_r(x):-r(x),!,x=s(_). % count new ribe under the binder inc_r(s(x)):-inc_r(x). cose_r(x,k):-r(x),!,k=0. % cose nd conert to ints cose_r(s(x),sk):-cose_r(x,k),succ(k,sk). Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 22 / 45

Exmpes of k-coored cosed mbd terms 3-coored mbd terms of size 3, exhibiting coors 0,1,2.?- kcooredcosed(3,x). X = (0, (0, (1, (0)))) ; X = (0, (1, (0, (1)))) ; X = (1, (0, (0, (2)))) ; X = (2, ((0), (0))). in cosed term with n ppiction nodes, the counts of k-coored mbds must sum up to n + 1 we cn generte binry tree nd then decorte it with mbds stisfying this constrint the constrint hods for cosed subterms, recursiey cn this mechnism reduce the mount of bcktrcking nd cceerte term genertion? Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 23 / 45

K-coored mbd terms nd type inference Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 24 / 45

Simpy-typed mbd terms: the chenges I The study of the combintori properties of simpy-typed mbd terms is notoriousy hrd. The two most striking fcts tht one might notice when inferring types re: non-monotonicity, s crossing mbd increses the size of the type, whie crossing n ppiction node trims it down greement i unifiction (with occurs check) between the types of ech ribe under mbd Interestingy, to our best knowedge, no SAT or ASP gorithms exist in the iterture tht ttck the combined type inference nd combintori genertion probem for mbd terms, most ikey becuse of the compexity of emuting unifiction-with-occurs-check steps in proposition ogic. Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 25 / 45

Simpy-typed mbd terms: the chenges II the symptoticy nishing density of simpy-typed mbd terms in the set of cosed terms een more drmtic in the cse of their norm forms this mkes their -term nd rndom-term genertion incresingy difficut with size s for simpy typed terms, no nytic method is known for estimting the probbiities describing Botzmnn smping, one needs to fiter through the set of cosed mbd terms or norm forms unti typbe term is found it is incresingy computtiony expensie s their density decreses with size bsic combintori properties ike counts for terms of gien size he been obtined so fr ony by generting terms Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 26 / 45

Type inference for k-coored terms simpytypedcoored(n,x,t):-simpytypedcoored(x,t,[],n,0). simpytypedcoored((x),t,vss)-->{ member(vs:t0,vss), unify_with_occurs_check(t,t0), ddtobinder(vs,x) }. simpytypedcoored((vs,a),s->t,vss)-->, simpytypedcoored(a,t,[vs:s Vss]), {cosebinder(vs)}. simpytypedcoored((a,b),t,vss)-->, simpytypedcoored(a,(s->t),vss), simpytypedcoored(b,s,vss). ddtobinder(ps,p):-r(ps),!,ps=[p _]. ddtobinder([_ Ps],P):-ddToBinder(Ps,P). cosebinder(xs):-ppend(xs,[],_),!. Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 27 / 45

How mny simpy typed terms re 2-coored (i.e., ffine)? simpy typed cosed terms s. ffine cosed terms (og. sce) 10 6 10 4 10 2 10 0 simpy typed cosed terms ffine cosed terms 0 2 4 6 8 10 12 14 size Figure: Simpy typed cosed terms nd ffine cosed terms by incresing sizes Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 28 / 45

Are coors growing proportion to the og of their type-sizes? 8 g. coors nd type sizes 6 4 g. coors g. type sizes 2 0 5 10 15 term size Figure: Growth of coors nd type sizes Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 29 / 45

most coorfu term: reches the mximum number of coors 80 60 40 mx coors mx type size 20 0 0 5 10 15 term size Figure: Coors of most coorfu term s. its mximum type size Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 30 / 45

Does most coorfu term rech mx type size? 80 60 type size 40 mx coorfu type mx type 20 0 0 5 10 15 term size Figure: Lrgest type size of most coorfu term s. rgest type size Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 31 / 45

A two-stge genertion gorithm for typbe nd untypbe skeetons Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 32 / 45

Typbe nd untypbe Motzkin skeetons typbe Motzkin tree is one for which it exists simpy-typed cosed term hing it s its skeeton untypbe Motzkin tree is one for which no simpy-typed cosed term exists hing it s its skeeton to efficienty generte these skeetons we wi spit the genertion of mbd terms in two stges the first stge wi generte the unifiction equtions tht need to be soed for type inference s we s the redy to be fied out mbd trees it is conenient to ctuy generte on the fy the code to be executed in the second stge the second stge wi just use Proog s metc to ctite this code Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 33 / 45

Generting the executbe eqution set we generte redy to run conjunction of unifiction constrints geneqs(n,x,t,eqs):-geneqs(x,t,[],eqs,true,n,0). geneqs((i),v,[v0 Vs],Es1,Es2)-->{dd_eq(Vs,V0,V,I,Es1,Es2)}. geneqs((a),(s->t),vs,es1,es2)-->,geneqs(a,t,[s Vs],Es1,Es2). geneqs((a,b),t,vs,es1,es3)-->, geneqs(a,(s->t),vs,es1,es2), geneqs(b,s,vs,es2,es3). % soe this eqution s it cn either succeed once, or fi dd_eq([],v0,v,0,es,es):-unify_with_occurs_check(v0,v). % <== dd_eq([v1 Vs],V0,V,I,(e([V0,V1 Vs],V,0,I),Es),Es). e(i,vs,v):-e(vs,v,0,i). e([v0 _],V,N,N):-unify_with_occurs_check(V0,V). e([_ Vs],V,N1,N3):-succ(N1,N2),e(Vs,V,N2,N3). Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 34 / 45

Efficient genertion of typbe nd untypbe skeetons we soe the equtions for 2-coored terms to oid bcktrcking Motzkin trees: 1,1,2,4,9,21,51,127,323,835,2188 Type eqution trees: 0,1,1,1,5, 9,17, 55,122,289, 828 we cn generte efficienty typebe nd untypbe skeetons untypbe: Eqs he no soution (their negtion succeeds) typbe: Eqs he t est one soution (no need to compute ) untypbeske(n,ske):-geneqs(n,x,_,eqs),not(eqs),tomotske(x,ske). typbeske(n,ske):-geneqs(n,x,_,eqs),once(eqs),tomotske(x,ske). Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 35 / 45

3 typbe nd 3 untypbe Motzkin trees Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 36 / 45

Growth of the number of skeetons is simir on og-sce 10 6 skeeton counts (og. sce) 10 4 10 2 typbe skeetons untypbe skeetons 10 0 0 5 10 15 20 skeeton size Figure: typbe s. untypbe skeetons up to size 20 Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 37 / 45

Counts of typbe nd untypbe Motzkin skeetons term size typbe skeetons untypbe skeetons 0 0 0 1 1 0 2 1 0 3 1 0 4 5 0 5 9 0 6 17 4 7 55 0 8 122 12 9 289 51 10 828 56 11 2037 275 12 5239 867 13 14578 1736 14 37942 5988 15 101307 17697 16 281041 43583 17 755726 134546 18 2062288 390872 19 5745200 1045248 20 15768207 3102275 Figure: Number of typbe nd untypbe skeetons Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 38 / 45

Growth rtes of typbe nd untypbe skeetons 5 4 skeeton growth rtes 3 2 typbe skeetons untypbe skeetons 1 0 6 8 10 12 14 16 18 20 skeeton size Figure: The simir growth rtes of typbe nd untypbe skeetons Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 39 / 45

Motzkin trees s. their subset of typbe skeetons 10 6 Motzkin trees nd typbe skeetons (og. sce) 10 5 10 4 10 3 10 2 10 1 Motzkin trees typbe skeetons 10 0 0 5 10 15 size Figure: Counts for Motzkin trees nd typbe skeetons for incresing term sizes Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 40 / 45

Counts of simpy typed cosed terms s. their skeetons simpy typed cosed terms nd their skeetons (og. sce) 10 8 10 6 10 4 10 2 10 0 simpy typed cosed terms typbe skeetons 0 5 10 15 size Figure: Counts of simpy typed cosed terms nd their skeetons by incresing sizes Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 41 / 45

Some reserch questions for future work I As coors bstrct numbers of occurrences of gien binder, whie the ength of the mbd chins in de Bruijn nottion bstrcts wy the number of prmeters of gien function, how do the distributions of these two compementry spects of mbd terms interct? Wht interesting empiric retions exists between coors of mbd terms nd typbiity? Wht retions exist between coors nd the compexity of type expressions? Wht re the best theoretic modes tht rete properties of k-coored simpy-typed terms nd their skeetons to properties of their type expressions? Cn n empiric study of retions between trees representing simpy typed mbd terms, their skeetons nd their types ree interesting properties of the mutipe underying formisms rnging from computtions to proofs in the impiction frgment of intuitionistic ogic? Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 42 / 45

Some reserch questions for future work II Wht re the typic properties (size, coors, etc.) of the mbd expressions generted during compition of ctu function progrms? Cn we, by controing the retie weight of the coors fine-tune -term nd rndom term genertors to refect the distributions obsered for mbd terms used s intermedite code in compiers for function nguges? Do bijections between simper fmiies of combintori objects, mbd terms in de Bruijn nottion, their norm forms nd their skeetons proide mens for generting ery rge rndom mbd terms whie owing to seectiey fine-tune the distribution of their constructors? Cn such bijections hep pushing further the size of rndom simpy typed terms nd norm forms generted i new sequenti nd pre gorithms? Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 43 / 45

Concusions we he deised bstrction mechnisms tht forget properties of the difficut css of simpy-typed cosed mbd terms to ree equience csses tht re ikey to be esier to grsp with nytic toos some of our findings: bijection between 2-coored terms nd binry trees simpe gorithm for generting ffine nd iner terms efficient genertion of typbe nd untypbe skeetons, with potenti uses s emms in dynmic progrmming gorithms k-coored terms re ikey to be usbe to fine-tune rndom genertors to more cosey mtch coor-distributions of mbd terms representing re progrms the toos used: nguge s simpe s (mosty) Horn Cuse Proog cn hnde eegnty combintori genertion probems when the synergy between sound unifiction, bcktrcking nd DCGs is put t work! Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 44 / 45

Questions? Pu Tru ( Uniersity of North Texs ) On k-coored Lmbd Terms nd their Skeetons PADL 2018 45 / 45