A

Computational

Approach

to

Reflective

Meta-Reasoning

about

Languages

with

Bindings

We

present

a

foundation

for

a

computational

meta-theory

of

languages

with

bindings

implemented

in

a

computer-aided

formal

reasoning

environment

Our

theory

provides

the

ability

to

reason

abstractly

about

operators

languages

open-ended

languages

classes

of

languages

etc.

The

theory

is

based

on

the

ideas

of

higher-order

abstract

syntax

with

an

appropriate

induction

principle

parameterized

over

the

language

-LRB-

i.e.

a

set

of

operators

-RRB-

being

used

In

our

approach

both

the

bound

and

free

variables

are

treated

uniformly

and

this

uniform

treatment

extends

naturally

to

variable-length

bindings

The

implementation

is

reflective

namely

there

is

a

natural

mapping

between

the

meta-language

of

the

theorem-prover

and

the

object

language

of

our

theory

The

object

language

substitution

operation

is

mapped

to

the

meta-language

substitution

and

does

not

need

to

be

defined

recursively

Our

approach

does

not

require

designing

a

custom

type

theory

in

this

paper

we

describe

the

implementation

of

this

foundational

theory

within

a

general-purpose

type

theory

This

work

is

fully

implemented

in

the

MetaPRL

theorem

prover

using

the

pre-existing

NuPRL-like

Martin-L

of-style

computational

type

theory

Based

on

this

implementation

we

lay

out

an

outline

for

a

framework

for

programming

language

experimentation

and

exploration

as

well

as

a

general

reflective

reasoning

framework

This

paper

also

includes

a

short

survey

of

the

existing

approaches

to

syntactic

reflection

D.

-LSB-

Programming

Languages

-RSB-

Formal

Definitions

and

Theory

Syntax

F.

-LSB-

Mathematical

Logic

and

Formal

Languages

-RSB-

Formal

Languages-Operations

on

languages

Languages

Theory

Verification

An

extended

version

of

this

paper

is

available

as

Caltech

Technical

Report

CaltechCSTR

-LSB-

-RSB-

Permission

to

make

digital

or

hard

copies

of

all

or

part

of

this

work

for

personal

or

classroom

use

is

granted

without

fee

provided

that

copies

are

not

made

or

distributed

for

profit

or

commercial

advantage

and

that

copies

bear

this

notice

and

the

full

citation

on

the

first

page

To

copy

otherwise

to

republish

to

post

on

servers

or

to

redistribute

to

lists

requires

prior

specific

permission

and/or

a

fee

MERLIN

September

Tallinn

Estonia

Copyright

c

ACM

Reflection

Very

generally

reflection

is

the

ability

of

a

system

to

be

self-aware

in

some

way

More

specifically

by

reflection

we

mean

the

property

of

a

computational

or

formal

system

to

be

able

to

access

and

internalize

some

of

its

own

properties

There

are

many

areas

of

computer

science

where

reflection

plays

or

should

play

a

major

role

When

exploring

properties

of

programming

languages

-LRB-

and

other

languages

-RRB-

one

often

realizes

that

languages

have

at

least

two

kinds

of

properties

semantic

properties

that

have

to

do

with

the

meaning

of

what

the

language

's

constructs

express

and

syntactic

properties

of

the

language

itself

Suppose

for

example

that

we

are

exploring

some

language

that

contains

arithmetic

operations

And

in

particular

in

this

language

one

can

write

polynomials

like

x

In

this

case

the

number

of

roots

of

a

polynomial

is

a

semantic

property

since

it

has

to

do

with

the

valuation

of

the

polynomial

On

the

other

hand

the

degree

of

a

polynomial

could

be

considered

an

example

of

a

syntactic

property

since

the

most

natural

way

to

define

it

is

as

a

property

of

the

expression

that

represents

that

polynomial

Of

course

syntactic

properties

often

have

semantic

consequences

which

is

what

makes

them

especially

important

In

this

example

the

number

of

roots

of

a

polynomial

is

bounded

by

its

degree

Another

area

where

reflection

plays

an

important

role

is

run-time

code

generation

in

most

cases

a

language

that

supports

run-time

code

generation

is

essentially

reflective

as

it

is

capable

of

manipulating

its

own

syntax

In

order

to

reason

about

run-time

code

generation

and

to

express

its

semantics

and

properties

it

is

natural

to

use

a

reasoning

system

that

is

reflective

as

well

There

are

many

different

flavors

of

reflection

The

syntactic

reflection

we

have

seen

in

the

examples

above

which

is

the

ability

of

a

system

to

internalize

its

own

syntax

is

just

one

of

these

many

flavors

Another

very

important

kind

of

reflection

is

logical

reflection

which

is

the

ability

of

a

reasoning

system

or

logic

to

internalize

and

reason

about

its

own

logical

properties

A

good

example

of

a

logical

reflection

is

reasoning

about

knowledge

since

the

result

of

reasoning

about

knowledge

is

knowledge

itself

the

logic

of

knowledge

is

naturally

reflective

-LSB-

-RSB-

In

most

cases

it

is

natural

for

reflection

to

be

iterated

In

the

case

of

syntactic

reflection

we

might

care

not

only

about

the

syntax

of

our

language

but

also

about

the

syntax

used

for

expressing

the

syntax

the

syntax

for

expressing

the

syntax

for

expressing

the

syntax

and

so

forth

In

the

case

of

the

logic

of

knowledge

it

is

natural

to

have

iterations

of

the

form

I

know

that

he

knows

that

I

know

When

a

formal

system

is

used

to

reason

about

properties

of

programming

languages

iterated

reflection

magnifies

the

power

of

the

system

making

it

more

natural

to

reason

not

just

about

individual

languages

but

also

about

classes

of

languages

language

schemas

and

so

on

More

generally

reflection

adds

a

lot

of

additional

power

to

a

formal

reasoning

system

-LSB-

-RSB-

In

particular

it

is

well-known

-LSB-

G

-RSB-

that

reflection

allows

a

super-exponential

reduction

in

the

size

of

certain

proofs

In

addition

reflection

could

be

a

very

useful

mechanism

for

implementing

proof

search

algorithms

-LSB-

-RSB-

See

also

-LSB-

-RSB-

for

a

survey

of

reflection

in

theorem

proving

Uniform

Reflection

Framework

For

each

of

the

examples

in

the

previous

section

there

are

many

ad-hoc

ways

of

achieving

the

specific

benefits

of

a

specific

flavor

of

reflection

This

work

aims

at

creating

a

unifying

reflective

framework

that

would

allow

achieving

most

of

these

benefits

in

a

uniform

manner

without

having

to

reinvent

and

re-implement

the

basic

reflective

methodology

every

time

We

believe

that

such

a

framework

will

increase

the

power

of

the

formal

reasoning

tools

and

it

may

also

become

an

invaluable

tool

for

exploring

the

properties

of

novel

programming

languages

for

analyzing

run-time

code

generation

and

for

formalizing

logics

of

knowledge

This

paper

establishes

a

foundation

for

the

development

of

this

framework

a

new

approach

to

reflective

meta-reasoning

about

languages

with

bindings

We

present

a

theory

of

syntax

that

in

a

natural

way

provides

both

a

higher-order

abstract

syntax

-LRB-

HOAS

-RRB-

approach

to

bindings

and

a

de

Bruijn-style

approach

to

bindings

with

easy

and

natural

translation

between

the

two

provides

a

uniform

HOAS-style

approach

to

both

bound

and

free

variables

that

extends

naturally

to

variable-length

vectors

of

binders

permits

meta-reasoning

about

languages

in

particular

the

operators

languages

open-ended

languages

classes

of

languages

etc.

are

all

first-class

objects

that

can

be

reasoned

about

both

abstractly

and

concretely

comes

with

a

natural

induction

principle

for

syntax

that

can

be

parameterized

by

the

language

being

used

provides

a

natural

mapping

between

the

object

syntax

and

meta-syntax

that

is

free

of

exotic

terms

and

allows

mapping

the

object-level

substitution

operation

directly

to

the

meta-level

one

-LRB-

i.e.

reduction

-RRB-

is

fully

derived

in

a

pre-existing

type

theory

in

a

theorem

prover

is

designed

to

serve

as

a

foundation

for

a

general

reflective

reasoning

framework

in

a

theorem

prover

is

designed

to

serve

as

a

foundation

for

a

programming

language

experimentation

framework

The

paper

is

structured

as

follows

Our

work

inherits

a

large

number

of

ideas

from

previous

efforts

and

we

start

in

Section

with

a

brief

survey

of

existing

techniques

for

formal

reasoning

about

syntax

Next

in

Section

we

outline

our

approach

to

reasoning

about

syntax

and

in

Section

we

present

a

formal

account

of

our

theory

based

on

a

Martin-L

of

style

computational

type

theory

-LSB-

CAB

HAB

-RSB-

and

the

implementation

of

that

account

in

the

MetaPRL

theorem

prover

-LSB-

HNC

HNK

HAB

-RSB-

Then

in

Section

we

outline

our

plan

for

building

a

uniform

reflection

framework

based

on

the

syntactic

reflection

Finally

in

Section

we

resume

the

discussion

of

related

work

that

was

started

in

Section

Notation

and

Terminology

We

believe

that

our

approach

to

reasoning

about

syntax

is

fairly

general

and

does

not

rely

on

any

special

features

of

the

theorem

prover

we

use

However

since

we

implement

this

theory

in

MetaPRL

we

introduce

some

basic

knowledge

about

MetaPRL

terms

A

MetaPRL

term

consists

of

An

operator

name

-LRB-

like

sum

-RRB-

which

is

a

unique

name

indicating

the

logic

and

component

of

a

term

A

list

of

parameters

representing

constant

values

and

A

set

of

subterms

with

possible

variable

bindings

We

use

the

following

syntax

to

describe

terms

based

on

the

NuPRL

definition

-LSB-

-RSB-

opname

operator

name

-LSB-

p

p

n

-RSB-

parameters

-LCB-

v

t

v

m

t

m

-RCB-

subt

er

ms

In

addition

MetaPRL

has

a

meta-syntax

somewhat

similar

to

the

higher-order

abstract

syntax

presented

in

Pfenning

and

Elliott

-LSB-

-RSB-

MetaPRL

uses

the

second-order

variables

in

the

style

of

Huet

and

Lang

-LSB-

-RSB-

to

describe

term

schemas

For

example

x.V

-LSB-

x

-RSB-

where

V

is

a

second-order

variable

of

arity

is

a

schema

that

stands

for

an

arbitrary

term

whose

top-level

operator

is

This

meta-syntax

requires

that

every

time

a

binding

occurrence

is

explicitly

specified

in

a

schema

all

corresponding

bound

occurrences

have

to

be

specified

as

well

This

requirement

makes

it

very

easy

to

specify

free

variable

restrictions

for

example

x.V

where

V

is

a

second-order

meta-variable

of

arity

is

a

schema

that

stands

for

an

arbitrary

term

whose

top-level

operator

is

and

whose

body

does

not

have

any

free

occurrences

of

the

variable

bound

by

that

In

particular

the

schema

x.V

matches

the

term

y.

but

not

the

term

x.x.

In

addition

this

meta-language

allows

specifying

certain

term

transformations

including

implicit

substitution

specifications

For

example

a

beta

reduction

transformation

may

be

specified

using

the

following

schema

-LRB-

x.V

-LSB-

x

-RSB-

-RRB-

V

V

-LSB-

V

-RSB-

Here

the

substitution

of

V

for

x

in

V

is

specified

implicitly

Throughout

this

paper

we

will

use

this

second-order

notation

to

denote

arbitrary

terms

namely

unless

stated

otherwise

when

we

write

x.t

-LSB-

x

-RSB-

we

mean

an

arbitrary

term

of

this

form

not

a

term

containing

a

concrete

second-order

variable

named

t

As

in

LF

-LSB-

-RSB-

we

assume

that

object

level

variables

-LRB-

i.e.

the

variables

of

the

language

whose

syntax

we

are

expressing

-RRB-

are

directly

mapped

to

meta-theory

variables

-LRB-

i.e.

the

variable

of

the

language

that

we

use

to

express

the

syntax

-RRB-

Similarly

we

assume

that

the

object-level

binding

structure

is

mapped

to

the

meta-level

binding

structure

In

other

words

the

object-level

notion

of

the

binding/bound

occurrence

is

a

subset

of

that

in

the

metalanguage

We

also

consider

equal

terms

both

on

the

object

level

and

on

the

meta-level

to

be

identical

and

we

assume

that

substitution

avoids

capture

by

renaming

The

sequent

schema

language

we

use

-LSB-

-RSB-

contains

a

number

of

more

advanced

features

in

addition

to

those

outlined

here

However

for

the

purposes

of

this

presentation

the

basic

features

outlined

above

are

sufficient

In

G

odel

used

reflection

to

prove

his

famous

incompleteness

theorem

-LSB-

G

-RSB-

To

express

arithmetic

in

arithmetic

itself

he

assigned

a

unique

number

-LRB-

a

G

odel

number

-RRB-

to

each

arithmetic

formula

A

G

odel

number

of

a

formula

is

essentially

a

numeric

code

of

a

string

of

symbols

used

to

represent

that

formula

A

modern

version

of

the

G

odel

's

approach

was

used

by

Aitken

et

al.

-LSB-

-RSB-

to

implement

reflection

in

the

NuPRL

theorem

prover

-LSB-

CAB

ACE

-RSB-

A

large

part

of

this

effort

was

essentially

a

reimplementation

of

the

core

of

the

NuPRL

prover

inside

NuPRL

's

logical

theory

In

G

odel

's

approach

and

its

variations

-LRB-

including

Aitken

's

one

-RRB-

a

general

mechanism

that

could

be

used

for

formalizing

one

logical

theory

in

another

is

applied

to

formalizing

a

logical

theory

in

itself

This

can

be

very

convenient

for

reasoning

about

reflection

but

for

our

purposes

it

turns

out

to

be

extremely

impractical

First

when

formalizing

a

theory

in

itself

using

generic

means

the

identity

between

the

theory

being

formalized

and

the

one

in

which

the

formalization

happens

becomes

very

obfuscated

which

makes

it

almost

impossible

to

relate

the

reflected

theory

back

to

the

original

one

Second

when

one

has

a

theorem

proving

system

that

already

implements

the

logical

theory

in

question

creating

a

completely

new

implementation

of

this

logical

theory

inside

itself

is

a

very

tedious

redundant

effort

Another

practical

disadvantage

of

the

G

odel

numbers

approach

is

that

it

tends

to

blow

up

the

size

of

the

formulas

and

iterated

reflection

would

cause

the

blow-up

to

be

iterated

as

well

making

it

exponential

or

worse

A

much

more

practical

approach

is

being

used

in

some

programming

languages

such

as

Lisp

and

Scheme

There

the

common

solution

is

for

the

implementation

to

expose

its

internal

syntax

representation

to

user-level

code

by

the

quote

constructor

-LRB-

where

quote

-LRB-

t

-RRB-

prevents

the

evaluation

of

the

expression

t

-RRB-

The

problems

outlined

above

are

solved

instantly

by

this

approach

there

is

no

blow-up

there

is

no

repetition

of

structure

definitions

there

is

even

no

need

for

verifying

that

the

reflected

part

is

equivalent

to

the

original

implementation

since

they

are

identical

Most

Scheme

implementations

take

this

even

further

the

eval

function

is

the

internal

function

for

evaluating

a

Scheme

expression

which

is

exposed

to

the

user-level

Smith

-LSB-

-RSB-

showed

how

this

approach

can

achieve

an

infinite

tower

of

processors

A

similar

language

with

the

quotation

and

antiquotation

operators

was

introduced

in

-LSB-

-RSB-

This

approach

however

violates

the

congruence

property

with

respect

to

computation

if

two

terms

are

computationally

equal

then

one

can

be

substituted

for

the

other

in

any

context

For

instance

although

is

equal

to

the

expressions

and

are

syntactically

different

thus

we

can

not

substitute

by

in

the

expression

quote

-LRB-

-RRB-

The

congruence

property

is

essential

in

many

logical

reasoning

systems

including

the

NuPRL

system

mentioned

above

and

the

MetaPRL

system

-LSB-

HNC

HNK

HAB

-RSB-

that

our

group

uses

A

possible

way

to

expose

the

internal

syntax

without

violating

the

congruence

property

is

to

use

the

so-called

quoted

or

shifted

operators

-LSB-

-RSB-

rather

than

quoting

the

whole

expression

at

once

For

any

operator

op

in

the

original

language

we

add

the

quoted

operator

-LRB-

denoted

as

op

-RRB-

to

represent

a

term

built

with

the

operator

op

For

example

if

the

original

language

contains

the

constant

-LRB-

which

presumably

represents

the

number

-RRB-

then

in

the

reflected

language

would

stand

for

the

term

that

denotes

the

expression

Generally

the

quoted

operator

has

the

same

arity

as

the

original

operator

but

it

is

defined

on

syntactic

terms

rather

than

on

semantic

objects

For

instance

while

is

a

binary

operator

on

numbers

is

a

binary

operator

on

terms

Namely

if

t

and

t

are

syntactic

terms

that

stand

for

expressions

e

and

e

respectively

then

t

t

is

a

new

syntactic

term

that

stands

for

the

expression

e

e

Thus

the

quotation

of

the

expression

would

be

In

general

the

well-formedness

-LRB-

typing

-RRB-

rule

for

a

quoted

operator

is

the

following

t

Term

t

n

Term

op

-LCB-

t

t

n

-RCB-

Term

-LRB-

-RRB-

where

Term

is

a

type

of

terms

Note

that

quotations

can

be

iterated

arbitrarily

many

times

allowing

us

to

quote

quoted

terms

For

instance

stands

for

the

term

that

denotes

the

term

that

denotes

the

numeral

Problems

arise

when

quoting

expressions

that

contain

binding

variables

For

example

what

is

the

quotation

of

x.x

There

are

several

possible

ways

of

answering

this

question

A

commonly

used

approach

-LSB-

-RSB-

in

logical

frameworks

such

as

Elf

-LSB-

-RSB-

LF

-LSB-

-RSB-

and

Isabelle

-LSB-

-RSB-

is

to

construct

an

object

logic

with

a

concrete

operator

that

has

a

type

like

-LRB-

Term

Term

-RRB-

Term

or

-LRB-

Var

Term

-RRB-

Term

In

this

approach

the

quoted

x.x

might

look

like

-LRB-x.x-RRB-

and

the

quoted

x.

might

look

like

-LRB-

x.

-RRB-

Note

that

in

these

examples

the

quoted

terms

have

to

make

use

of

both

the

syntactic

-LRB-

i.e.

quoted

-RRB-

operator

and

the

semantic

operator

Exotic

Terms

ive

implementations

of

the

above

approach

suffer

from

the

well-known

problem

of

exotic

terms

-LSB-

-RSB-

The

issue

is

that

in

general

we

can

not

allow

applying

the

operator

to

an

arbitrary

function

that

maps

terms

to

terms

-LRB-

or

variables

to

terms

-RRB-

and

expect

the

result

of

such

an

application

to

be

a

proper

reflected

term

Consider

for

example

the

following

term

-LRB-

x.

if

x

then

else

-RRB-

It

is

relatively

easy

to

see

that

it

is

not

a

real

syntactic

term

and

can

not

be

obtained

by

quoting

an

actual

term

-LRB-

For

comparison

consider

-LRB-

x.

if

x

then

else

-RRB-

which

is

a

quotation

of

x.

if

x

then

else

-RRB-

How

can

one

ensure

that

e

denotes

a

real

term

and

not

an

exotic

one

That

is

is

it

equal

to

a

result

of

quoting

an

actual

term

of

the

object

language

One

possibility

is

to

require

e

to

be

a

substitution

function

in

other

words

it

has

to

be

equal

to

an

expression

of

the

form

x.t

-LSB-

x

-RSB-

where

t

is

composed

entirely

of

term

constructors

-LRB-

i.e.

quoted

operators

-RRB-

and

x

while

using

destructors

-LRB-

such

as

case

analysis

the

if

operator

used

in

the

example

above

etc

-RRB-

is

prohibited

There

are

a

number

of

approaches

to

enforcing

the

above

restriction

One

of

them

is

the

usage

of

logical

frameworks

with

restricted

function

spaces

-LSB-

-RSB-

where

terms

may

only

contain

constructors

Another

is

to

first

formalize

the

larger

type

that

does

include

exotic

terms

and

then

to

define

recursively

a

predicate

describing

the

validity

or

well-formedness

of

a

term

-LSB-

-RSB-

thus

removing

the

exotic

terms

from

consideration

Yet

another

approach

is

to

create

a

specialized

type

theory

that

combines

the

idea

of

restricted

function

spaces

with

a

modal

type

operator

-LSB-

-RSB-

There

the

case

analysis

is

disallowed

on

objects

of

pure

type

T

but

is

allowed

on

objects

of

a

special

type

T

This

allows

expressing

both

the

restricted

function

space

T

T

and

the

unrestricted

one

-LRB-

T

-RRB-

T

within

a

single

type

theory

Another

way

of

regarding

the

problem

of

exotic

terms

is

that

it

is

caused

by

the

attempt

to

give

a

semantic

definition

to

a

primarily

syntactic

property

A

more

syntax-oriented

approach

was

used

by

Barzilay

et

al.

-LSB-

-RSB-

In

Barzilay

's

approach

the

quoted

version

of

an

operator

that

introduces

a

binding

has

the

same

shape

-LRB-

i.e.

the

number

of

subterms

and

the

binding

structure

-RRB-

as

the

original

one

and

the

variables

-LRB-

both

the

binding

and

the

bound

occurrences

-RRB-

are

unaffected

by

the

quotation

For

instance

the

quotation

of

x.x

is

just

x.x.

The

advantages

of

this

approach

include

This

approach

is

simple

and

clear

Quoted

terms

have

the

same

structure

as

original

ones

inheriting

a

lot

of

properties

of

the

object

syntax

In

all

the

above

approaches

the

equivalence

relation

for

quoted

terms

is

inherited

for

free

For

example

x.x

and

y.y

are

automatically

considered

to

be

the

same

term

Substitution

is

also

easy

we

do

not

need

to

re-implement

the

substitution

that

renames

binding

variables

to

avoid

the

capture

of

free

variables

we

can

use

the

substitution

of

the

original

language

instead

To

prune

exotic

terms

Barzilay

says

that

x.t

-LSB-

x

-RSB-

is

a

valid

term

when

x.t

-LSB-

x

-RSB-

is

a

substitution

function

He

demonstrates

that

it

is

possible

to

formalize

this

notion

in

a

purely

syntactical

fashion

In

this

setting

the

general

well-formedness

rule

for

quoted

terms

with

bindings

is

the

following

is

subst

k

-LCB-

x

x

k

t

-LSB-

x

-RSB-

-RCB-

is

subst

l

-LCB-

z

z

l

s

-LSB-

z

-RSB-

-RCB-

op

-LCB-

x

x

k

t

-LSB-

x

-RSB-

z

z

l

s

-LSB-

z

-RSB-

-RCB-

Term

-LRB-

-RRB-

where

is

subst

n

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

is

the

proposition

that

t

is

a

substitution

function

over

variables

x

x

n

-LRB-

in

other

words

it

is

a

syntactic

version

of

the

Valid

predicate

of

-LSB-

-RSB-

-RRB-

This

proposition

is

defined

syntactically

by

the

following

two

rules

is

subst

n

-LCB-

x

x

n

x

i

-RCB-

and

is

subst

n

k

-LCB-

x

x

n

y

y

k

t

-LSB-

x

y

-RSB-

-RCB-

is

subst

n

l

-LCB-

x

x

n

z

z

l

s

-LSB-

x

z

-RSB-

-RCB-

-RCB-

is

subst

n

-LCB-

x

x

n

op

-LCB-

y

y

k

t

-LSB-

x

y

-RSB-

z

z

l

s

-LSB-

x

z

-RSB-

-RCB-

-RCB-

In

this

approach

the

is

subst

n

-LCB-

-RCB-

and

operators

are

essentially

untyped

-LRB-

in

NuPRL

type

theory

the

computational

properties

of

untyped

terms

are

at

the

core

of

the

semantics

types

are

added

on

top

of

the

untyped

computational

system

-RRB-

Recursive

Definition

and

Structural

Induction

Principle

A

difficulty

shared

by

both

the

straightforward

implementations

of

the

-LRB-

Term

Term

-RRB-

Term

approach

and

by

the

Barzilay

's

one

is

the

problem

of

recursively

defining

the

Term

type

We

want

to

define

the

Term

type

as

the

smallest

set

satisfying

rules

-LRB-

-RRB-

and

-LRB-

-RRB-

Note

however

that

unlike

rule

-LRB-

-RRB-

rule

-LRB-

-RRB-

is

not

monotonic

in

the

sense

that

is

subst

k

-LCB-

x

x

k

t

-LSB-

x

-RSB-

-RCB-

depends

non-monotonically

on

the

Term

type

For

example

to

say

whether

x.t

-LSB-

x

-RSB-

is

a

term

we

should

check

whether

t

is

a

substitution

function

over

x

It

means

at

least

that

for

every

x

in

Term

t

-LSB-

x

-RSB-

should

be

in

Term

as

well

Thus

we

need

to

define

the

whole

type

Term

before

using

-LRB-

-RRB-

which

produces

a

logical

circle

Moreover

since

has

type

-LRB-

Term

Term

-RRB-

Term

it

is

hard

to

formulate

the

structural

induction

principle

for

terms

built

with

the

term

constructor

Variable-Length

Lists

of

Binders

In

Barzilay

's

approach

for

each

number

n

is

subst

n

-LCB-

-RCB-

is

considered

to

be

a

separate

operator

there

is

no

way

to

quantify

over

n

and

there

is

no

way

to

express

variable-length

lists

of

binders

This

issue

of

expressing

the

unbounded-length

lists

of

binders

is

common

to

some

of

the

other

approaches

as

well

Meta-Reasoning

Another

difficulty

that

is

especially

apparent

in

Barzilay

's

approach

is

that

it

only

allows

reasoning

about

concrete

operators

in

concrete

languages

This

approach

does

not

provide

the

ability

to

reason

about

operators

abstractly

in

particular

there

is

no

way

to

state

and

prove

meta-theorems

that

quantify

over

operators

or

languages

much

less

classes

of

languages

Although

it

is

possible

to

solve

the

problems

outlined

in

the

previous

Section

-LRB-

and

we

will

return

to

the

discussion

of

some

of

those

solutions

in

Section

-RRB-

our

desire

is

to

avoid

these

difficulties

from

the

start

We

propose

a

natural

model

of

reflection

that

manages

to

work

around

those

difficulties

We

will

show

how

to

give

a

simple

recursive

definition

of

terms

with

binding

variables

which

does

not

allow

the

construction

of

exotic

terms

and

does

allow

structural

induction

on

terms

In

this

Section

we

provide

a

conceptual

overview

of

our

approach

details

are

given

in

Section

Bound

Terms

One

of

the

key

ideas

of

our

approach

is

how

we

deal

with

terms

containing

free

variables

We

extend

to

free

variables

the

principle

that

variable

names

do

not

really

matter

In

fact

we

model

free

variables

as

bindings

that

can

be

arbitrarily

renamed

Namely

we

will

write

bterm

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

for

a

term

t

over

variables

x

x

n

For

example

instead

of

term

xy

we

will

use

the

term

bterm

-LCB-

x

y.xy

-RCB-

when

it

is

considered

over

variables

x

and

y

and

bterm

-LCB-

x

y

z.xy

-RCB-

when

it

is

considered

over

variables

x

y

and

z.

Free

occurrences

of

x

i

in

t

-LSB-

x

-RSB-

are

considered

bound

in

bterm

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

and

two

equal

bterm

-LCB-

-RCB-

expressions

-LRB-

bterms

-RRB-

are

considered

to

be

identical

Not

every

bterm

is

necessarily

well-formed

We

will

define

the

type

of

terms

in

such

a

way

as

to

eliminate

exotic

terms

Consider

for

example

a

definition

of

lambda-terms

E

XAMPLE

We

can

define

a

set

of

reflected

lambda-terms

as

the

smallest

set

such

that

bterm

-LCB-

x

x

n

x

i

-RCB-

where

i

n

is

a

lambda-term

-LRB-

a

variable

-RRB-

if

bterm

x

x

n

x

n

t

-LSB-

x

-RSB-

is

a

lambda-term

then

bterm

x

x

n

x

n

t

-LSB-

x

-RSB-

is

also

a

lambda-term

-LRB-

an

abstraction

-RRB-

if

bterm

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

and

bterm

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

are

lambda-terms

then

bterm

-LCB-

x

x

n

apply

-LCB-

t

-LSB-

x

-RSB-

t

-LSB-

x

-RSB-

-RCB-

-RCB-

is

also

a

lambda-term

-LRB-

an

application

-RRB-

In

a

way

bterms

could

be

understood

as

an

explicit

coding

for

Barzilay

's

substitution

functions

And

indeed

some

of

the

basic

definitions

are

quite

similar

The

notion

of

bterms

is

also

very

similar

to

that

of

local

variable

contexts

-LSB-

-RSB-

Terminology

Before

we

proceed

further

we

need

to

define

some

terminology

D

EFINITION

We

change

the

notion

of

subterm

so

that

the

subterms

of

a

bterm

are

also

bterms

For

example

the

immediate

subterms

of

bterm

-LCB-

x

y.x

y

-RCB-

are

bterm

-LCB-

x

y.x

-RCB-

and

bterm

-LCB-

x

y.y

-RCB-

the

immediate

subterm

of

bterm

-LCB-

x

y.x

-RCB-

is

bterm

-LCB-

x

y.x

-RCB-

D

EFINITION

We

call

the

number

of

outer

binders

in

a

bterm

expression

its

binding

depth

Namely

the

binding

depth

of

the

bterm

bterm

-LCB-

x

x

n

t

-LSB-

x

-RSB-

-RCB-

is

n.

D

EFINITION

Throughout

the

rest

of

the

paper

we

use

the

notion

of

operator

shape

The

shape

of

an

operator

is

a

list

of

natural

numbers

each

stating

how

many

new

binders

the

operator

introduces

on

the

corresponding

subterm

The

length

of

the

shape

list

is

therefore

the

arity

of

the

operator

For

example

the

shape

of

the

operator

is

-LSB-

-RSB-

and

the

shape

of

the

operator

is

-LSB-

-RSB-

The

mapping

from

operators

to

shapes

is

also

sometimes

called

a

binding

signature

of

a

language

-LSB-

-RSB-

D

EFINITION

Let

op

be

an

operator

with

shape

-LSB-

d

d

N

-RSB-

and

let

btl

be

a

list

of

bterms

-LSB-

b

b

M

-RSB-

We

say

that

btl

is

compatible

with

op

at

depth

n

when

N

M

the

binding

depth

of

bterm

b

j

is

n

d

j

for

each

j

N

Abstract

Operators

Expressions

of

the

form

bterm

-LCB-

x.op

-LCB-

-RCB-

-RCB-

can

only

be

used

to

express

syntax

with

concrete

operators

In

other

words

each

expression

of

this

form

contains

a

specific

constant

operator

op

However

we

would

like

to

reason

about

operators

abstractly

in

particular

we

want

to

make

it

possible

to

have

variables

of

the

type

Op

that

can

be

quantified

over

and

used

in

the

same

manner

as

operator

constants

In

order

to

address

this

we

use

explicit

term

constructors

in

addition

to

bterm

-LCB-

x.op

-LCB-

-RCB-

-RCB-

constants

The

expression

mk

bterm

-LCB-

n

op

btl

-RCB-

where

op

is

some

encoding

of

the

quoted

operator

op

stands

for

a

bterm

with

binding

depth

n

operator

op

and

subterms

btl

Namely

mk

bterm

-LCB-

n

op

bterm

-LCB-

x

x

n

y

t

-LSB-

x

y

-RSB-

-RCB-

bterm

-LCB-

x

x

n

y

k

t

k

-LSB-

x

y

k

-RSB-

-RCB-

-RCB-

is

bterm

-LCB-

x

x

n

op

-LCB-

y

t

-LSB-

x

y

-RSB-

y

k

t

k

-LSB-

x

y

k

-RSB-

-RCB-

-RCB-

Here

is

the

empty

list

and

is

the

list

cons

operator

and

therefore

the

expression

b

b

n

represents

the

concrete

list

-LSB-

b

b

n

-RSB-

Note

that

if

we

know

the

shape

of

the

operator

op

and

we

know

that

the

mk

bterm

expression

is

well-formed

-LRB-

or

more

specifically

if

we

know

that

btl

is

compatible

with

op

at

depth

n

-RRB-

then

it

would

normally

be

possible

to

deduce

the

value

of

n

-LRB-

since

n

is

the

difference

between

the

binding

depth

of

any

element

of

the

list

btl

and

the

corresponding

element

of

the

shape

-LRB-

op

-RRB-

list

-RRB-

There

are

two

reasons

however

for

supplying

n

explicitly

When

btl

is

empty

-LRB-

in

other

words

when

the

arity

of

op

is

-RRB-

the

value

of

n

can

not

be

deduced

this

way

and

still

needs

to

be

supplied

somehow

One

could

consider

operators

to

be

a

special

case

but

this

results

in

a

significant

loss

of

uniformity

When

we

do

not

know

whether

an

mk

bterm

expression

is

necessarily

well-formed

-LRB-

and

as

we

will

see

it

is

often

useful

to

allow

this

to

happen

-RRB-

then

a

lot

of

definitions

and

proofs

are

greatly

simplified

when

the

binding

depth

of

mk

bterm

expressions

is

explicitly

specified

Using

the

mk

bterm

constructor

and

a

few

other

similar

constructors

that

will

be

introduced

later

it

becomes

easy

to

reason

abstractly

about

operators

Indeed

the

second

argument

to

mk

bterm

can

now

be

an

arbitrary

expression

not

just

a

constant

This

has

a

cost

of

making

certain

definitions

slightly

more

complicated

For

example

the

notion

of

compatible

with

op

at

depth

n

now

becomes

an

important

part

of

the

theory

and

will

need

to

be

explicitly

formalized

However

this

is

a

small

price

to

pay

for

the

ability

to

reason

abstractly

about

operators

which

easily

extends

to

reasoning

abstractly

about

languages

classes

of

languages

and

so

forth

Inductively

Defining

the

Type

of

Well-Formed

Bterms

There

are

two

equivalent

approaches

to

inductively

defining

the

general

type

-LRB-

set

-RRB-

of

all

well-formed

bterms

The

first

one

follows

the

same

idea

as

in

Example

bterm

-LCB-

x

x

n

x

i

-RCB-

is

a

well-formed

bterm

for

i

n

mk

bterm

-LCB-

n

op

btl

-RCB-

is

a

well-formed

bterm

when

op

is

a

well-formed

quoted

operator

and

btl

is

a

list

of

well-formed

bterms

that

is

compatible

with

op

at

some

depth

n

If

we

denote

bterm

-LCB-

x

x

l

y

z

z

r

y

-RCB-

as

var

-LCB-

l

r

-RCB-

we

can

restate

the

base

case

of

the

above

definition

as

var

-LCB-

l

r

-RCB-

where

l

and

r

are

arbitrary

natural

numbers

is

a

well-formed

bterm

Once

we

do

this

it

becomes

apparent

that

the

above

definition

has

a

lot

of

similarities

with

de

Bruijn-style

indexing

of

variables

-LSB-

-RSB-

Indeed

one

might

call

the

numbers

l

and

r

the

left

and

right

indices

of

the

variable

var

-LCB-

l

r

-RCB-

It

is

possible

to

provide

an

alternate

definition

that

is

closer

to

pure

HOAS

bnd

-LCB-

x

t

-LSB-

x

-RSB-

-RCB-

where

t

is

a

well-formed

substitution

function

is

a

well-formed

bterm

-LRB-

the

bnd

operation

increases

the

binding

depth

of

t

by

one

by

adding

x

to

the

beginning

of

the

list

of

t

's

outer

binders

-RRB-

mk

term

-LCB-

op

btl

-RCB-

where

op

is

a

well-formed

quoted

operator

and

btl

is

a

list

of

well-formed

bterms

that

is

compatible

with

op

at

depth

is

a

well-formed

bterm

-LRB-

of

binding

depth

-RRB-

Other

than

better

capturing

the

idea

of

HOAS

the

latter

definition

also

makes

it

easier

to

express

the

reflective

correspondence

between

the

meta-syntax

-LRB-

the

syntax

used

to

express

the

theory

of

syntax

namely

the

one

that

includes

the

operators

mk

bterm

bnd

etc.

-RRB-

and

the

meta-meta-syntax

-LRB-

the

syntax

that

is

used

to

express

the

theory

of

syntax

and

the

underlying

theory

in

other

words

the

syntax

that

includes

the

second-order

notations

-RRB-

Namely

provided

that

we

define

the

subst

-LCB-

bt

t

-RCB-

operation

to

compute

the

result

of

substituting

a

closed

term

t

for

the

first

outer

binder

of

the

bterm

bt

we

can

state

that

subst

-LCB-

bnd

-LCB-

x

t

-LSB-

x

-RSB-

-RCB-

t

-RCB-

t

-LSB-

t

-RSB-

-LRB-

-RRB-

-LRB-

where

t

and

t

are

literal

second-order

variables

-RRB-

In

other

words

we

can

state

that

the

substitution

operator

subst

and

the

implicit

second-order

substitution

in

the

meta-meta

language

are

equivalent

The

downside

of

the

alternate

definition

is

that

it

requires

defining

the

notion

of

being

a

substitution

function

Our

Approach

In

our

work

we

try

to

combine

the

advantages

of

both

approaches

outlined

above

In

the

next

Section

we

present

a

theory

that

includes

both

the

HOAS-style

operations

-LRB-

bnd

mk

term

-RRB-

and

the

de

Bruijn-style

ones

-LRB-

var

mk

bterm

-RRB-

Our

theory

also

allows

deriving

the

equivalence

-LRB-

-RRB-

In

our

theory

the

definition

of

the

basic

syntactic

operations

is

based

on

the

HOAS-style

operators

however

the

recursive

definition

of

the

type

of

well-formed

syntax

is

based

on

the

de

Bruijn-style

operations

Our

theory

includes

also

support

for

variable-length

lists

of

binders

In

this

Section

we

describe

how

the

foundations

of

our

theory

are

formally

defined

and

derived

in

the

NuPRL-style

Computational

Type

Theory

in

the

MetaPRL

Theorem

Prover

For

brevity

we

will

present

a

slightly

simplified

version

of

our

implementation

full

details

are

available

in

the

extended

version

of

this

paper

-LSB-

Appendix

-RSB-

Computations

and

Types

In

our

work

we

make

heavy

usage

of

the

fact

that

our

type

theory

allows

us

to

define

computations

without

stating

upfront

-LRB-

or

even

knowing

-RRB-

what

the

relevant

types

are

In

NuPRL-style

type

ries

-LRB-

which

some

even

dubbed

untyped

type

theory

-RRB-

one

may

define

arbitrary

recursive

functions

-LRB-

even

potentially

nonterminating

ones

-RRB-

Only

when

proving

that

such

function

belongs

to

a

particular

type

one

may

have

to

prove

termination

See

-LSB-

-RSB-

for

a

semantics

that

justifies

this

approach

The

formal

definition

of

the

syntax

of

terms

consists

of

two

parts

The

definition

of

untyped

term

constructors

and

term

operations

which

includes

both

HOAS-style

operations

and

de

Bruijn-style

operations

As

it

turns

out

we

can

establish

most

of

the

reduction

properties

without

explicitly

giving

types

to

all

the

operations

The

definition

of

the

type

of

terms

We

will

define

the

type

of

terms

as

the

type

that

contains

all

terms

that

can

be

legitimately

constructed

by

the

term

constructors

HOAS

Constructors

At

the

core

of

our

term

syntax

definition

are

two

basic

HOAS-style

constructors

bnd

-LCB-

x

t

-LSB-

x

-RSB-

-RCB-

is

meant

to

represent

a

term

with

a

free

variable

x

The

intended

semantics

-LRB-

which

will

not

become

explicit

until

later

-RRB-

is

that

bnd

-LCB-

x.t

-LSB-

x

-RSB-

-RCB-

will

only

be

considered

well-formed

when

t

is

a

substitution

function

Internally

bnd

-LCB-

x.t

-LSB-

x

-RSB-

-RCB-

is

implemented

simply

as

the

pair

x.t

-LSB-

x

-RSB-

This

definition

is

truly

internal

and

is

used

only

to

prove

the

properties

of

the

two

destructors

presented

below

it

is

never

used

outside

of

this

Section

-LRB-

Section

-RRB-

mk

term

-LCB-

op

ts

-RCB-

pairs

op

with

ts

The

intended

usage

of

this

operation

-LRB-

which

again

will

only

become

explicit

later

-RRB-

is

that

it

represents

a

closed

term

-LRB-

i.e.

a

bterm

of

binding

depth

-RRB-

with

operator

op

and

subterms

ts

It

will

be

considered

well-formed

when

op

is

an

operator

and

ts

is

a

list

of

terms

that

is

compatible

with

op

at

depth

For

example

mk

term

-LCB-

bnd

-LCB-

x.x

-RCB-

-RCB-

is

x.x.

Internally

mk

term

-LCB-

op

ts

-RCB-

is

implemented

as

the

nested

pair

op

ts

Again

this

definition

is

never

used

outside

of

this

Section

We

also

implement

two

destructors

subst

-LCB-

bt

t

-RCB-

is

meant

to

represent

the

result

of

substituting

term

t

for

the

first

variable

of

the

bterm

bt

Internally

subst

-LCB-

bt

t

-RCB-

is

defined

simply

as

an

application

-LRB-

bt

-RRB-

t

-LRB-

where

bt

is

the

second

element

of

the

pair

bt

-RRB-

We

derive

the

following

property

of

this

substitution

operation

subst

-LCB-

bnd

-LCB-

x.t

-LSB-

x

-RSB-

-RCB-

t

-RCB-

t

-LSB-

t

-RSB-

where

is

the

computational

equality

relation

and

t

and

t

may

be

absolutely

arbitrary

even

ill-typed

This

derivation

is

the

only

place

where

the

internal

definition

of

subst

-LCB-

bt

t

-RCB-

is

used

Note

that

the

above

equality

is

exactly

the

reflective

property

of

substitution

-LRB-

-RRB-

that

was

one

of

the

design

goals

for

our

theory

weak

dest

-LCB-

bt

bcase

op

ts.mkt

case

-LSB-

op

ts

-RSB-

-RCB-

is

designed

to

provide

a

way

to

find

out

whether

bt

is

a

bnd

-LCB-

-RCB-

or

a

mk

term

-LCB-

op

ts

-RCB-

In

NuPRL-style

type

theories

the

computational

equality

relation

-LRB-

which

is

also

sometimes

called

squiggle

equality

and

is

sometimes

denoted

as

or

-RRB-

is

the

finest-grained

equality

relation

in

the

theory

When

a

b

is

true

a

may

be

replaced

with

b

in

an

arbitrary

context

Examples

of

computational

equality

include

beta-reduction

x.a

-LSB-

x

-RSB-

b

a

-LSB-

b

-RSB-

arithmetical

equalities

-LRB-

-RRB-

and

definitional

equality

-LRB-

an

abstraction

is

considered

to

be

computationally

equal

to

its

definition

-RRB-

and

to

extract

the

op

and

ts

in

the

latter

case

In

the

rest

of

this

paper

we

will

use

the

pretty-printed

form

for

weak

dest

match

bt

with

bnd

-LCB-

-RCB-

bcase

mk

term

-LCB-

op

ts

-RCB-

mkt

case

-LSB-

op

ts

-RSB-

Internally

it

is

defined

as

if

bt

then

bcase

else

mkt

case

-LSB-

bt

bt

-RSB-

From

this

internal

definition

we

derive

the

following

properties

of

weak

dest

match

bnd

-LCB-

x.t

-LSB-

x

-RSB-

-RCB-

with

bnd

-LCB-

-RCB-

bcase

mk

term

-LCB-

op

ts

-RCB-

mkt

case

-LSB-

op

ts

-RSB-

bcase

match

mk

term

-LCB-

op

ts

-RCB-

with

bnd

-LCB-

-RCB-

bcase

mk

term

-LCB-

o

t

-RCB-

mkt

case

-LSB-

o

t

-RSB-

mkt

case

-LSB-

op

ts

-RSB-

Vector

HOAS

Operations

As

we

have

mentioned

at

the

end

of

Section

some

approaches

to

reasoning

about

syntax

make

it

hard

or

even

impossible

to

express

arbitrary-length

lists

of

binders

In

our

approach

we

address

this

challenge

by

allowing

operators

where

a

single

binding

in

the

metalanguage

stands

for

a

list

of

object-level

bindings

In

particular

we

allow

representing

bnd

-LCB-

x

bnd

-LCB-

x

bnd

-LCB-

x

n

t

-LSB-

x

x

n

-RSB-

-RCB-

-RCB-

-RCB-

as

vbnd

-LCB-

n

x

t

-LSB-

nth

-LCB-

x

-RCB-

nth

-LCB-

n

x

-RCB-

-RSB-

-RCB-

where

nth

-LCB-

i

l

-RCB-

is

the

i

th

element

of

the

list

l

function

We

define

the

following

vector-style

operations

vbnd

-LCB-

n

x

t

-LSB-

x

-RSB-

-RCB-

represents

a

telescope

of

nested

bnd

operations

It

is

defined

by

induction

on

the

natural

number

n

as

follows

vbnd

-LCB-

x.t

-LSB-

x

-RSB-

-RCB-

t

-LSB-

-RSB-

vbnd

-LCB-

n

x.t

-LSB-

x

-RSB-

-RCB-

bnd

-LCB-

v.vbnd

-LCB-

n

x

t

-LSB-

v

x

-RSB-

-RCB-

-RCB-

We

also

introduce

vbnd

-LCB-

n

t

-RCB-

as

a

simplified

notation

for

vbnd

-LCB-

n

x

t

-RCB-

when

t

does

not

have

free

occurrences

of

x.

vsubst

-LCB-

bt

ts

-RCB-

is

a

vector

substitution

operation

that

is

meant

to

represent

the

result

of

simultaneous

substitution

of

the

terms

in

the

ts

list

for

the

first

ts

variables

of

the

bterm

bt

-LRB-

here

l

is

the

length

of

the

list

l

-RRB-

vsubst

-LCB-

bt

ts

-RCB-

is

defined

by

induction

on

the

list

ts

as

follows

vsubst

-LCB-

bt

-RCB-

bt

vsubst

-LCB-

bt

t

ts

-RCB-

vsubst

-LCB-

subst

-LCB-

bt

t

-RCB-

ts

-RCB-

Below

are

some

of

the

derived

properties

of

these

operations

bnd

-LCB-

v.t

-LSB-

v

-RSB-

-RCB-

vbnd

-LCB-

hd

-LRB-

v

-RRB-

-RCB-

-LRB-

-RRB-

m

n

N.

vbnd

-LCB-

m

n

x

t

-LSB-

x

-RSB-

-RCB-

vbnd

-LCB-

m

y.vbnd

-LCB-

n

z.t

-LSB-

y

@z

-RSB-

-RCB-

-RCB-

-LRB-

-RRB-

l

List

-LRB-

vsubst

-LCB-

vbnd

-LCB-

l

v.t

-LSB-

v

-RSB-

-RCB-

l

-RCB-

t

-LSB-

l

-RSB-

-RRB-

-LRB-

-RRB-

l

List.n

N.

-LRB-

n

l

-RRB-

-LRB-

vsubst

-LCB-

vbnd

-LCB-

n

v.t

-LSB-

v

-RSB-

-RCB-

l

-RCB-

vbnd

-LCB-

n

l

v.bt

-LSB-

l

@v

-RSB-

-RCB-

-RRB-

-LRB-

-RRB-

n

N.

vbnd

-LCB-

n

l.vsubst

-LCB-

vbnd

-LCB-

n

v.t

-LSB-

v

-RSB-

-RCB-

l

-RCB-

-RCB-

vbnd

-LCB-

n

l.t

-LSB-

l

-RSB-

-RCB-

-LRB-

-RRB-

where

hd

is

the

list

head

operation

is

the

list

append

operation

List

is

the

type

of

arbitrary

lists

-LRB-

the

elements

of

a

list

do

not

have

to

belong

to

any

particular

type

-RRB-

N

is

the

type

of

natural

numbers

and

all

the

variables

that

are

not

explicitly

constrained

to

a

specific

type

stand

for

arbitrary

expressions

Our

presentation

of

the

inductive

definitions

is

slightly

simplified

by

omitting

some

minor

technical

details

See

-LSB-

Appendix

-RSB-

for

complete

details

Equivalence

-LRB-

-RRB-

allows

the

merging

and

splitting

of

vector

bnd

operations

Equivalence

-LRB-

-RRB-

is

a

vector

variant

of

equivalence

-LRB-

-RRB-

Equivalence

-LRB-

-RRB-

is

very

similar

to

equivalence

-LRB-

-RRB-

applied

in

the

vbnd

-LCB-

n

l.

-RCB-

context

except

that

-LRB-

-RRB-

does

not

require

l

to

be

a

member

of

any

special

type

De

Bruijn-style

Operations

Based

on

the

HOAS

constructors

defined

in

the

previous

two

sections

we

define

two

de

Bruijn-style

constructors

var

-LCB-

i

j

-RCB-

is

defined

as

vbnd

-LCB-

i

bnd

-LCB-

v.vbnd

-LCB-

j

v

-RCB-

-RCB-

-RCB-

It

is

easy

to

see

that

this

definition

indeed

corresponds

to

the

informal

bterm

-LCB-

x

x

l

y

z

z

r

y

-RCB-

definition

given

in

Section

mk

bterm

-LCB-

n

op

ts

-RCB-

is

meant

to

compute

a

bterm

of

binding

depth

n

with

operator

op

and

with

ts

as

its

subterms

This

operation

is

defined

by

induction

on

natural

number

n

as

follows

mk

bterm

-LCB-

op

ts

-RCB-

mk

term

-LCB-

op

ts

-RCB-

mk

bterm

-LCB-

n

op

ts

-RCB-

bnd

-LCB-

v.mk

bterm

-LCB-

n

op

map

t.subst

-LCB-

t

v

-RCB-

ts

-RCB-

-RCB-

Note

that

if

ts

is

a

list

of

bnd

expressions

-LRB-

which

is

the

intended

usage

of

the

mk

bterm

operation

-RRB-

then

the

bnd

-LCB-

v.

map

t.subst

-LCB-

t

v

-RCB-

ts

-RCB-

has

the

effect

of

stripping

the

outer

bnd

from

each

of

the

members

of

the

ts

list

and

moving

them

into

a

single

merged

bnd

on

the

outside

We

also

define

a

number

of

de

Bruijn-style

destructors

i.e.

operations

that

compute

various

de

Bruijn-style

characteristics

of

a

bterm

Since

the

var

and

mk

bterm

constructors

are

defined

in

terms

of

the

HOAS

constructors

the

destructors

have

to

be

defined

in

terms

of

HOAS

operations

as

well

Because

of

this

these

definitions

are

often

far

from

straightforward

It

is

important

to

emphasize

that

the

tricky

definitions

that

we

use

here

are

only

needed

to

establish

the

basic

properties

of

the

operations

we

defined

Once

the

basic

theory

is

complete

we

can

raise

the

level

of

abstraction

and

no

usage

of

this

theory

will

ever

require

using

any

of

these

definitions

being

aware

of

these

definitions

or

performing

similar

tricks

again

bdepth

-LCB-

t

-RCB-

computes

the

binding

depth

of

term

t

It

is

defined

recursively

using

the

Y

combinator

as

Y

f.b.match

b

with

bnd

-LCB-

-RCB-

f

subst

-LCB-

b

mk

term

-LCB-

-RCB-

-RCB-

mk

term

-LCB-

-RCB-

t

In

effect

this

recursive

function

strips

the

outer

binders

from

a

bterm

one

by

one

using

substitution

-LRB-

note

that

here

we

can

use

an

arbitrary

mk

bterm

expression

as

a

second

argument

for

the

substitution

function

the

arguments

to

mk

bterm

do

not

have

to

have

the

correct

type

-RRB-

and

counts

the

number

of

times

it

needs

to

do

this

before

the

outermost

mk

bterm

is

exposed

We

derive

the

following

properties

of

bdepth

l

r

N.

bdepth

-LCB-

var

-LCB-

l

r

-RCB-

-RCB-

-LRB-

l

r

-RRB-

n

N.

bdepth

-LCB-

mk

bterm

-LCB-

n

op

ts

-RCB-

-RCB-

n

Note

that

the

latter

equivalence

only

requires

n

to

have

the

correct

type

while

op

and

ts

may

be

arbitrary

Since

the

bdepth

operator

is

needed

for

defining

the

type

of

Term

of

well-formed

bterms

at

this

point

we

would

not

have

been

able

to

express

what

the

correct

type

for

ts

would

be

left

-LCB-

t

-RCB-

is

designed

to

compute

the

left

index

of

a

var

expression

It

is

defined

as

Y

f.b.l.

match

b

with

bnd

-LCB-

-RCB-

f

subst

-LCB-

b

mk

term

-LCB-

l

-RCB-

-RCB-

-LRB-

l

-RRB-

mk

term

l

l

t

In

effect

this

recursive

function

substitutes

mk

term

-LCB-

-RCB-

for

the

first

binding

of

t

mk

term

-LCB-

-RCB-

for

the

second

one

mk

term

-LCB-

-RCB-

for

the

next

one

and

so

forth

Once

all

the

binders

are

stripped

and

a

mk

term

-LCB-

l

-RCB-

is

exposed

l

is

the

index

we

were

looking

for

Note

that

here

we

intentionally

supply

mk

term

with

an

argument

of

a

wrong

type

-LRB-

N

instead

of

Op

-RRB-

we

could

have

avoided

this

but

then

the

definition

would

have

been

significantly

more

complicated

As

expected

we

derive

that

l

r

N.

-LRB-

left

-LCB-

var

-LCB-

l

r

-RCB-

-RCB-

l

-RRB-

right

-LCB-

t

-RCB-

computes

the

right

index

of

a

var

expression

It

is

trivial

to

define

in

terms

of

the

previous

two

operators

right

-LCB-

t

-RCB-

bdepth

-LCB-

t

-RCB-

left

-LCB-

t

-RCB-

get

op

-LCB-

t

op

-RCB-

is

an

operation

such

that

n

N.

get

op

mk

bterm

-LCB-

n

op

ts

-RCB-

op

op

l

r

N.

-LRB-

get

op

-LCB-

var

-LCB-

i

j

-RCB-

op

-RCB-

op

Its

definition

is

similar

to

that

of

left

-LCB-

-RCB-

subterms

-LCB-

t

-RCB-

is

designed

to

recover

the

last

argument

of

a

mk

bterm

expression

The

definition

is

rather

technical

and

complicated

so

we

omit

it

see

-LSB-

Appendix

C

-RSB-

for

details

The

main

property

of

the

subterms

operation

that

we

derive

is

n

N.btl

List

subterms

-LCB-

mk

bterm

-LCB-

n

op

btl

-RCB-

-RCB-

map

b.vbnd

-LCB-

n

v.vsubst

-LCB-

b

v

-RCB-

-RCB-

btl

The

right-hand

side

of

this

equivalence

is

not

quite

the

plain

btl

that

one

might

have

hoped

to

see

here

However

when

btl

is

a

list

of

bterms

with

binding

depths

at

least

n

which

is

necessarily

the

case

for

any

well-formed

mk

bterm

-LCB-

n

op

btl

-RCB-

equivalence

-LRB-

-RRB-

would

allow

simplifying

this

right-hand

side

to

the

desired

btl

Operators

For

this

basic

theory

the

exact

representation

details

for

operators

are

not

essential

and

we

define

the

type

of

operators

Op

abstractly

We

only

require

that

operators

have

decidable

equality

and

that

there

exist

a

function

of

the

type

Op

N

List

that

computes

operators

shapes

Using

this

shape

function

and

the

bdepth

function

from

Section

it

is

trivial

to

formalize

the

ts

is

compatible

with

op

at

depth

n

predicate

of

Definition

We

denote

this

predicate

as

shape

compat

-LCB-

n

op

ts

-RCB-

and

define

it

as

shape

-LCB-

op

-RCB-

btl

i

btl

bdepth

-LCB-

nth

-LCB-

btl

i

-RCB-

-RCB-

n

nth

-LCB-

shape

-LCB-

op

-RCB-

i

-RCB-

The

Type

of

Terms

In

this

section

we

will

define

the

type

of

terms

-LRB-

i.e.

well-formed

bterms

-RRB-

Term

as

the

type

of

all

terms

that

can

be

constructed

by

the

de

Bruijn

constructors

from

Section

That

is

the

Term

type

contains

all

expressions

of

the

forms

var

-LCB-

i

j

-RCB-

for

all

natural

numbers

i

j

or

mk

bterm

-LCB-

n

op

ts

-RCB-

for

any

natural

number

n

operator

op

and

list

of

terms

ts

that

is

compatible

with

op

at

depth

n

The

Term

type

is

defined

as

a

fixpoint

of

the

following

function

from

types

to

types

Iter

-LRB-

X

-RRB-

Image

-LRB-

dom

-LRB-

X

-RRB-

x

mk

-LRB-

x

-RRB-

-RRB-

where

Image

is

a

type

constructor

such

that

Image

-LRB-

T

x.

f

-LSB-

x

-RSB-

-RRB-

is

the

type

of

all

the

f

-LSB-

t

-RSB-

for

t

T

-LRB-

for

it

to

be

well-formed

T

must

be

a

well-formed

type

and

f

must

not

have

any

free

variables

except

for

x

-RRB-

dom

-LRB-

X

-RRB-

is

a

type

defined

as

-LRB-

N

N

-RRB-

n

N

op

Op

-LCB-

ts

X

List

shape

compat

-LCB-

n

op

ts

-RCB-

-RCB-

and

mk

-LRB-

x

-RRB-

-LRB-

where

x

is

presumably

a

member

of

the

type

dom

-LRB-

X

-RRB-

-RRB-

is

defined

as

match

x

with

inl

-LRB-

i

j

-RRB-

var

-LCB-

i

j

-RCB-

inr

-LRB-

n

op

ts

-RRB-

mk

bterm

-LCB-

n

op

ts

-RCB-

The

fixpoint

of

Iter

is

reached

by

defining

Term

Void

-LRB-

an

empty

type

-RRB-

Term

n

Iter

-LRB-

Term

n

-RRB-

Term

n

N

Term

n

We

derive

the

intended

introduction

rules

for

the

Term

type

i

N

j

N

var

-LCB-

i

j

-RCB-

Term

and

n

N

op

Op

ts

Term

List

shape

compat

-LCB-

n

op

ts

-RCB-

mk

bterm

-LCB-

n

op

ts

-RCB-

Term

Also

the

structural

induction

principle

is

derived

for

the

Term

type

Namely

we

show

that

to

prove

that

some

property

P

-LSB-

t

-RSB-

holds

for

any

term

t

it

is

sufficient

to

prove

-LRB-

Base

case

-RRB-

P

holds

for

all

variables

that

is

P

-LSB-

var

-LCB-

i

j

-RCB-

-RSB-

holds

for

all

natural

numbers

i

and

j

-LRB-

Induction

step

-RRB-

P

-LSB-

mk

bterm

-LCB-

n

op

ts

-RCB-

-RSB-

is

true

for

any

natural

number

n

any

operator

op

and

any

list

of

terms

ts

that

is

compatible

with

op

at

depth

n

provided

P

-LSB-

t

-RSB-

is

true

for

any

element

t

of

the

list

ts

Note

that

the

type

of

terms

over

n

variables

-LRB-

where

n

corresponds

to

closed

terms

-RRB-

may

be

trivially

defined

using

the

Term

type

and

the

subset

type

constructor

-LCB-

t

Term

bdepth

-LCB-

t

-RCB-

n

-RCB-

In

Sections

and

we

have

presented

a

basic

theory

of

syntax

that

is

fully

implemented

in

a

theorem

prover

As

we

mentioned

in

the

introduction

the

approach

is

both

natural

and

expressive

and

provides

a

foundation

for

reflective

reasoning

about

classes

of

languages

and

logics

However

we

consider

this

theory

to

be

only

the

first

step

towards

building

a

user-accessible

uniform

reflection

framework

and

a

user-accessible

uniform

framework

for

programming

language

reasoning

and

experimentation

where

tasks

similar

to

the

ones

presented

in

the

P

OPL

M

ARK

challenge

-LSB-

ABF

-RSB-

can

be

performed

easily

and

naturally

In

this

section

we

provide

an

outline

of

our

plans

for

building

such

frameworks

on

top

of

the

basic

syntactic

theory

Higher-Level

User

Interface

One

obvious

shortcoming

of

the

theory

presented

in

Sections

and

is

that

it

provides

only

the

basic

low-level

operations

such

as

bnd

var

subterms

etc.

It

presents

a

very

low-level

account

of

syntax

in

a

way

that

would

often

fail

to

abstract

away

the

details

irrelevant

to

the

user

To

address

this

problem

we

are

planning

to

provide

user

interface

functionality

capable

of

mapping

the

high-level

concepts

to

the

low-level

ones

In

particular

we

are

going

to

provide

an

interface

that

would

allow

instantiating

general

theorems

to

specific

collections

of

operators

and

specific

languages

Thus

the

user

will

be

able

to

write

something

like

reflect

language

-LSB-

x.

apply

-LCB-

-RCB-

-RSB-

and

the

system

will

create

all

the

components

outlined

in

Example

It

will

create

a

definition

for

the

type

Language

-LSB-

x.

apply

-LCB-

-RCB-

-RSB-

of

reflected

lambda-terms

-LRB-

where

Language

-LSB-

l

-RSB-

is

a

general

definition

of

a

language

over

a

list

of

operators

l

-RRB-

It

will

state

and

derive

the

introduction

rules

for

this

type

It

will

state

and

derive

the

elimination

rule

for

this

type

-LRB-

the

induction

principle

-RRB-

Moreover

we

are

planning

to

support

even

more

complicated

language

declarations

such

as

t

int

t

t

e

v

x

t.e

-LSB-

x

-RSB-

apply

-LCB-

e

e

-RCB-

that

would

cause

the

system

to

create

mutually

recursive

type

definitions

and

appropriate

rules

Finally

we

are

also

planning

to

support

pattern

bindings

that

are

needed

for

a

natural

encoding

of

ML-like

pattern

matching

-LRB-

such

as

the

one

sketched

in

the

P

OPL

M

ARK

challenge

-LSB-

ABF

-RSB-

-RRB-

As

far

as

the

underlying

theory

goes

we

believe

that

the

mechanisms

very

similar

to

the

vector

bindings

presented

in

Section

will

be

sufficient

here

Dereferencing

Quoted

Terms

As

in

Barzilay

's

work

the

quoted

operator

approach

makes

it

easy

to

define

the

unquoting

-LRB-

or

dereferencing

-RRB-

operator

-LSB-

-LSB-

-RSB-

-RSB-

unq

If

t

is

a

syntactic

term

then

-LSB-

-LSB-

t

-RSB-

-RSB-

unq

is

the

value

represented

by

t

By

definition

-LSB-

-LSB-

op

-LCB-

t

t

n

-RCB-

-RSB-

-RSB-

unq

op

-LCB-

-LSB-

-LSB-

t

-RSB-

-RSB-

unq

-LSB-

-LSB-

t

n

-RSB-

-RSB-

unq

-RCB-

For

instance

-LSB-

-LSB-

-RSB-

-RSB-

unq

is

-LRB-

i.e.

-RRB-

In

order

to

define

unquoting

on

terms

with

bindings

we

need

to

introduce

the

guard

operation

such

that

-LSB-

-LSB-

t

-RSB-

-RSB-

unq

is

t

for

an

arbitrary

expression

t

Then

-LSB-

-LSB-

-RSB-

-RSB-

unq

can

be

defined

as

follows

-LSB-

-LSB-

op

-LCB-

x

x

k

t

-LSB-

x

x

k

-RSB-

z

z

l

s

-LSB-

z

z

l

-RSB-

-RCB-

-RSB-

-RSB-

unq

op

-LCB-

x

x

k

-LSB-

-LSB-

t

-LSB-

x

x

k

-RSB-

-RSB-

-RSB-

unq

z

z

l

-LSB-

-LSB-

s

-LSB-

z

z

l

-RSB-

-RSB-

-RSB-

unq

-RCB-

For

example

-LSB-

-LSB-

x.

x

-RSB-

-RSB-

unq

x.

-LSB-

-LSB-

x

-RSB-

-RSB-

unq

x.

-LSB-

-LSB-

-RSB-

-RSB-

unq

-LSB-

-LSB-

x

-RSB-

-RSB-

unq

x.

x

The

unquote

operation

establishes

the

identity

between

the

original

syntax

and

the

reflected

syntax

making

it

a

true

reflection

Note

that

the

type

theory

-LRB-

which

ensures

in

particular

that

only

terminating

functions

may

be

shown

to

belong

to

a

function

type

-RRB-

would

keep

the

-LSB-

-LSB-

-RSB-

-RSB-

unq

operation

from

introducing

logical

paradox

es

This

is

obviously

not

a

proper

argument

While

a

proper

argument

can

be

made

here

it

is

outside

of

the

scope

of

this

particular

paper

Also

since

the

notion

of

the

quoted

operators

is

fully

open-ended

each

new

language

added

to

the

system

will

automatically

get

to

use

the

-LSB-

-LSB-

-RSB-

-RSB-

unq

operation

for

all

its

newly

introduced

operators

Logical

Reflection

After

defining

syntactic

reflection

it

is

easy

to

define

logical

reflection

If

we

consider

the

proof

system

open-ended

then

the

logical

reflection

is

trivial

when

P

is

a

quotation

of

a

proposition

we

can

regard

-LSB-

-LSB-

P

-RSB-

-RSB-

unq

as

meaning

P

is

true

The

normal

modal

rules

for

the

-LSB-

-LSB-

-RSB-

-RSB-

unq

modality

are

trivially

derivable

For

example

modus

ponens

-LSB-

-LSB-

P

Q

-RSB-

-RSB-

unq

-LSB-

-LSB-

P

-RSB-

-RSB-

unq

-LSB-

-LSB-

Q

-RSB-

-RSB-

unq

is

trivially

true

because

if

we

evaluate

the

first

-LSB-

-LSB-

-RSB-

-RSB-

unq

-LRB-

remember

-LSB-

-LSB-

P

Q

-RSB-

-RSB-

unq

-LSB-

-LSB-

P

-RSB-

-RSB-

unq

-LSB-

-LSB-

Q

-RSB-

-RSB-

unq

by

definition

of

-LSB-

-LSB-

-RSB-

-RSB-

unq

-RRB-

we

get

an

obvious

tautology

-LRB-

-LSB-

-LSB-

P

-RSB-

-RSB-

unq

-LSB-

-LSB-

Q

-RSB-

-RSB-

unq

-RRB-

-LSB-

-LSB-

P

-RSB-

-RSB-

unq

-LSB-

-LSB-

Q

-RSB-

-RSB-

unq

In

order

to

consider

a

closed

proof

system

-LRB-

in

other

words

if

we

want

to

be

able

to

do

induction

over

derivations

-RRB-

we

would

need

to

define

a

provability

predicate

for

that

system

We

are

planning

to

provide

user

interface

functionality

that

would

allow

users

to

describe

a

set

of

proof

rules

and

the

system

would

generate

appropriate

proof

predicate

definitions

and

derive

appropriate

rules

-LRB-

in

a

style

similar

to

the

one

outlined

in

Section

for

the

case

of

language

descriptions

-RRB-

In

Section

we

have

already

discussed

a

number

of

approaches

that

we

consider

ourselves

inheriting

from

Here

we

would

like

to

revisit

some

of

them

and

mention

a

few

other

related

efforts

Our

work

has

a

lot

in

common

with

the

HOAS

implemented

in

Coq

by

Despeyroux

and

Hirschowitz

-LSB-

-RSB-

In

both

cases

the

more

general

space

of

terms

-LRB-

that

include

the

exotic

ones

-RRB-

is

later

restricted

in

a

recursive

manner

In

both

cases

the

higher-order

analogs

of

first-order

de

Bruijn

operators

are

defined

and

used

as

a

part

of

the

well-formedness

specification

for

the

terms

Despeyroux

and

Hirschowitz

use

functions

over

infinite

lists

of

variables

to

define

open

terms

which

is

similar

to

our

vector

bindings

There

are

a

number

of

significant

differences

as

well

Our

approach

is

sufficiently

syntactical

which

allows

eliminating

all

exotic

terms

even

those

that

are

extensionally

equal

to

the

well-formed

ones

while

the

more

semantic

approach

of

-LSB-

-RSB-

has

to

accept

such

exotic

terms

-LRB-

their

solution

to

this

problem

is

to

consider

an

object

term

to

be

represented

by

the

whole

equivalence

class

of

extensionally

equal

terms

-RRB-

more

generally

while

-LSB-

-RSB-

states

that

this

problem

of

extensionality

is

recurrent

all

over

our

work

most

of

our

lemmas

establish

identity

and

not

just

equality

thus

avoiding

most

of

the

issues

of

extensional

equality

In

our

implementation

the

substitution

on

object

terms

is

mapped

directly

to

reduction

while

Despeyroux

et

al.

-LSB-

-RSB-

have

to

define

it

recursively

In

addition

we

provide

a

uniform

approach

to

both

free

and

bound

variables

that

naturally

extends

to

variable-length

vector

bindings

While

our

approach

is

quite

different

from

the

modal

calculus

one

-LSB-

-RSB-

there

are

some

similarities

in

the

intuition

behind

it

Despeyroux

et

al.

-LSB-

-RSB-

says

Intuitively

we

interpret

B

as

the

type

of

closed

objects

of

type

B

We

can

iterate

or

distinguish

cases

over

closed

objects

since

all

constructors

are

statically

known

and

can

be

provided

for

The

intuition

behind

our

approach

is

in

part

based

on

the

canonical

model

of

the

NuPRL

type

theory

-LSB-

-RSB-

where

each

type

is

mapped

to

an

equivalence

relations

over

the

closed

terms

of

that

type

Gordon

and

Melham

-LSB-

-RSB-

define

the

type

of

terms

as

a

quotient

of

the

type

of

terms

with

concrete

binding

variables

over

equivalence

Michael

Norrish

-LSB-

-RSB-

builds

upon

this

work

by

replacing

certain

variable

freshness

requirements

with

variable

swapping

This

approach

has

a

number

of

attractive

properties

however

we

believe

that

the

level

of

abstraction

provided

by

the

HOAS-style

approaches

makes

the

HOAS

style

more

convenient

and

accessible

Ambler

Crole

and

Momigliano

-LSB-

-RSB-

have

combined

the

HOAS

with

the

induction

principle

using

an

approach

which

in

some

sense

is

opposite

to

ours

Namely

they

define

the

HOAS

operators

on

top

of

the

de

Bruijn

definition

of

terms

using

higher

order

pattern

matching

In

a

later

work

-LSB-

-RSB-

they

have

de-scribed

the

notion

of

terms-in-infinite-context

which

is

quite

similar

to

our

approach

to

vector

binding

While

our

vector

bindings

presented

in

Section

are

finite

length

the

exact

same

approach

would

work

for

the

infinite-length

vectors

as

well

The

authors

are

grateful

to

Eli

Barzilay

whose

ideas

were

an

inspiration

for

some

of

the

work

that

lead

to

this

paper

We

are

also

grateful

for

his

comments

on

an

early

draft

of

this

paper

We

are

grateful

to

the

anonymous

reviewers

for

their

very

thorough

and

fair

feedback

and

many

helpful

suggestions

-LSB-

-RSB-

Eric

Aaron

and

Stuart

Allen

Justifying

calculational

logic

by

a

conventional

metalinguistic

semantics

Technical

Report

Cornell

University

Ithaca

New

York

September

-LSB-

ABF

-RSB-

Brian

E.

Aydemir

Aaron

Bohannon

Matthew

Fairbairn

J.

Nathan

Foster

Benjamin

C.

Pierce

Peter

Sewell

Dimitrios

Vytiniotis

Geoffrey

Washburn

Stephanie

Weirich

and

Steve

Zdancewic

Mechanized

metatheory

for

the

masses

The

POPLmark

challenge

Available

from

-LSB-

-RSB-

William

Aitken

and

Robert

L.

Constable

Reflecting

on

NuPRL

Lessons

Technical

report

Cornell

University

Computer

Science

Department

Ithaca

NY

-LSB-

ACE

-RSB-

Stuart

Allen

Robert

Constable

Richard

Eaton

Christoph

Kreitz

and

Lori

Lorigo

The

NuPRL

open

logical

environment

In

David

McAllester

editor

Proceedings

of

the

t

h

International

Conference

on

Automated

Deduction

volume

of

Lecture

Notes

in

Artificial

Intelligence

pages

Springer

Verlag

-LSB-

-RSB-

Stuart

F.

Allen

Robert

L.

Constable

Douglas

J.

Howe

and

William

Aitken

The

semantics

of

reflected

proof

In

Proceedings

of

the

t

h

Symposium

on

Logic

in

Computer

Science

pages

IEEE

Computer

Society

Press

June

-LSB-

-RSB-

Simon

Ambler

Roy

L.

Crole

and

Alberto

Momigliano

Combining

higher

order

abstract

syntax

with

tactical

theorem

proving

and

-LRB-

co

-RRB-

induction

In

TPHOLs

Proceedings

of

the

International

Conference

on

Theorem

Proving

in

Higher

Order

Logics

pages

London

UK

Springer-Verlag

-LSB-

-RSB-

S.

J.

Ambler

R.

L.

Crole

and

Alberto

Momigliano

A

definitional

approach

to

primitive

recursion

over

higher

order

abstract

syntax

In

Proceedings

of

the

workshop

on

Mechanized

reasoning

about

languages

with

variable

binding

pages

ACM

Press

-LSB-

-RSB-

William

Aitken

Robert

L.

Constable

and

Judith

Underwood

Metalogical

Frameworks

II

Using

reflected

decision

procedures

Journal

of

Automated

Reasoning

-LRB-

-RRB-

-LSB-

-RSB-

Stuart

F.

Allen

A

Non-type-theoretic

Definition

of

Martin-L

of

's

Types

In

D.

Gries

editor

Proceedings

of

the

nd

IEEE

Symposium

on

Logic

in

Computer

Science

pages

IEEE

Computer

Society

Press

June

-LSB-

-RSB-

Stuart

F.

Allen

A

Non-Type-Theoretic

Semantics

for

Type-Theoretic

Language

PhD

thesis

Cornell

University

-LSB-

-RSB-

Sergei

Artemov

On

explicit

reflection

in

theorem

proving

and

formal

verification

In

Ganzinger

-LSB-

-RSB-

pages

-LSB-

-RSB-

Sergei

Artemov

Evidence-based

common

knowledge

Technical

Report

CUNY

Ph.D.

Program

in

Computer

Science

Technical

Reports

November

-LSB-

-RSB-

Eli

Barzilay

and

Stuart

Allen

Reflecting

higher-order

abstract

syntax

in

NuPRL

In

Victor

A.

Carre

no

C

ezar

A.

Mu

noz

and

Sophi`ene

Tahar

editors

Theorem

Proving

in

Higher

Order

Logics

Track

B

Proceedings

of

the

t

h

International

Conference

on

Theorem

Proving

in

Higher

Order

Logics

-LRB-

TPHOLs

-RRB-

Hampton

VA

August

pages

National

Aeronautics

and

Space

Administration

-LSB-

-RSB-

Eli

Barzilay

Stuart

Allen

and

Robert

Constable

Practical

reflection

in

NuPRL

Short

paper

presented

at

Annual

IEEE

Symposium

on

Logic

in

Computer

Science

June

Ottawa

Canada

-LSB-

-RSB-

Eli

Barzilay

Quotation

and

reflection

in

NuPRL

and

Scheme

Technical

Report

Cornell

University

Ithaca

New

York

January

-LSB-

-RSB-

Eli

Barzilay

Implementing

Reflection

in

NuPRL

PhD

thesis

Cornell

University

In

preparation

-LSB-

CAB

-RSB-

Robert

L.

Constable

Stuart

F.

Allen

H.

M.

Bromley

W.

R.

Cleaveland

J.

F.

Cremer

R.

W.

Harper

Douglas

J.

Howe

T.

B.

Knoblock

N.

P.

Mendler

P.

Panangaden

James

T.

Sasaki

and

Scott

F.

Smith

Implementing

Mathematics

with

the

NuPRL

Proof

Development

System

Prentice-Hall

NJ

-LSB-

-RSB-

Lu

is

Crus-Filipe

and

Freek

Weidijk

Hierarchical

reflection

In

Slind

et

al.

-LSB-

-RSB-

pages

-LSB-

-RSB-

Robert

L.

Constable

Using

reflection

to

explain

and

enhance

type

theory

In

Helmut

Schwichtenberg

editor

Proof

and

Computation

volume

of

NATO

Advanced

Study

Institute

International

Summer

School

held

in

Marktoberdorf

Germany

July

NATO

Series

F

pages

Springer

Berlin

-LSB-

-RSB-

N.

G.

de

Bruijn

Lambda

calculus

notation

with

nameless

dummies

a

tool

for

automatic

formula

manipulation

with

application

to

the

Church-Rosser

theorem

Indagaciones

Mathematische

This

also

appeared

in

the

Proceedings

of

the

Koninklijke

Nederlandse

Akademie

van

Wetenschappen

Amsterdam

series

A

No.

-LSB-

-RSB-

Jo

elle

Despeyroux

Amy

Felty

and

Andr

e

Hirschowitz

Higher-order

abstract

syntax

in

Coq

In

M.

Dezani-Ciancaglini

and

G.

Plotkin

editors

Proceedings

of

the

International

Conference

on

Typed

Lambda

Calculus

and

its

Applications

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

April

Also

appears

as

INRIA

research

report

-LSB-

-RSB-

Jo

elle

Despeyroux

and

Andr

e

Hirschowitz

Higher-order

abstract

syntax

with

induction

in

Coq

In

LPAR

Proceedings

of

the

International

Conference

on

Logic

Programming

and

Automated

Reasoning

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

Also

appears

as

INRIA

research

report

-LSB-

-RSB-

James

Davis

and

Daniel

Huttenlocher

Shared

annotations

for

cooperative

learning

In

Proceedings

of

the

ACM

Conference

on

Computer

Supported

Cooperative

Learning

September

-LSB-

-RSB-

Jo

elle

Despeyroux

and

Pierre

Leleu

A

modal

lambda

calculus

with

iteration

and

case

constructs

In

T.

Altenkirch

W.

Naraschewski

and

B.

Reus

editors

Types

for

Proofs

and

Programs

International

Workshop

TYPES

Kloster

Irsee

Germany

March

volume

of

Lecture

Notes

in

Computer

Science

pages

-LSB-

-RSB-

Jo

elle

Despeyroux

and

Pierre

Leleu

Recursion

over

objects

of

functional

type

Mathematical

Structures

in

Computer

Science

-LRB-

-RRB-

-LSB-

-RSB-

Jo

elle

Despeyroux

Frank

Pfenning

and

Carsten

Sch

urmann

Primitive

recursion

for

higher

order

abstract

syntax

In

R.

Hindley

editor

Proceedings

of

the

Third

International

Conference

on

Typed

Lambda

Calculus

and

Applications

-LRB-

TLCA

-RRB-

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

April

An

extended

version

is

available

as

Technical

Report

Carnegie

Mellon

University

-LSB-

-RSB-

Andrzej

Ehrenfeucht

and

Jan

Mycielski

Abbreviating

proofs

by

adding

new

axioms

Bulletin

of

the

American

Mathematical

Society

-LSB-

F

-RSB-

Solomon

Feferman

et

al.

editors

Kurt

G

odel

Collected

Works

volume

Oxford

University

Press

Oxford

Clarendon

Press

New

York

-LSB-

-RSB-

Marcelo

Fiore

Gordon

Plotkin

and

Daniele

Turi

Abstract

syntax

and

variable

binding

In

Proceedings

of

t

h

IEEE

Symposium

on

Logic

in

Computer

Science

pages

IEEE

Computer

Society

Press

-LSB-

-RSB-

Harald

Ganzinger

editor

Proceedings

of

the

t

h

International

Conference

on

Automated

Deduction

volume

of

Lecture

Notes

in

Artificial

Intelligence

Berlin

July

Trento

Italy

-LSB-

-RSB-

A.

D.

Gordon

and

T.

Melham

Five

axioms

of

alpha-conversion

In

J.

von

Wright

J.

Grundy

and

J.

Harrison

editors

Theorem

Proving

in

Higher

Order

Logics

International

Conference

Turku

Finland

August

Proceedings

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

-LSB-

-RSB-

Jim

Grundy

Tom

Melham

and

John

O'Leary

A

reflective

functional

language

for

hardware

design

and

theorem

proving

Technical

Report

Oxford

Univerity

Computing

Laboratory

-LSB-

G

-RSB-

Kurt

G

odel

Uber

formal

unentscheidbare

s

atze

der

principia

mathematica

und

verwandter

systeme

I.

Monatshefte

f

ur

Mathematik

und

Physik

English

version

in

-LSB-

-RSB-

-LSB-

G

-RSB-

K.

G

odel

Uber

die

L

ange

von

beweisen

Ergebnisse

eines

mathematischen

Kolloquiums

English

translation

in

-LSB-

F

-RSB-

pages

-LSB-

-RSB-

F.

Giunchiglia

and

A.

Smaill

Reflection

in

constructive

and

non-constructive

automated

reasoning

In

H.

Abramson

and

M.

H.

Rogers

editors

Meta-Programming

in

Logic

Programming

pages

MIT

Press

Cambridge

Mass.

-LSB-

-RSB-

H.

Geuvers

F.

Wiedijk

and

J.

Zwanenburg

Equational

reasoning

via

partial

reflection

In

J.

Harrison

and

M.

Aagaard

editors

Theorem

Proving

in

Higher

Order

Logics

t

h

International

Conference

TPHOLs

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

-LSB-

HAB

-RSB-

Jason

J.

Hickey

Brian

Aydemir

Yegor

Bryukhov

Alexei

Kopylov

Aleksey

Nogin

and

Xin

Yu

A

listing

of

MetaPRL

theories

-LSB-

-RSB-

J.

Harrison

Metatheory

and

reflection

in

theorem

proving

A

survey

and

critique

Technical

Report

SRI

International

Cambridge

Computer

Science

Research

Centre

Millers

Yard

Cambridge

UK

February

-LSB-

-RSB-

Robert

Harper

Furio

Honsell

and

Gordon

Plotkin

A

framework

for

defining

logics

Journal

of

the

Association

for

Computing

Machinery

-LRB-

-RRB-

January

A

revised

and

expanded

verion

of

paper

-LSB-

-RSB-

Jason

J.

Hickey

NuPRL-Light

An

implementation

framework

for

higher-order

logics

In

William

McCune

editor

Proceedings

of

the

t

h

International

Conference

on

Automated

Deduction

volume

of

Lecture

Notes

in

Artificial

Intelligence

pages

Springer

July

An

extended

version

of

the

paper

can

be

found

at

nl/default.html

-LSB-

-RSB-

Jason

J.

Hickey

Fault-tolerant

distributed

theorem

proving

In

Ganzinger

-LSB-

-RSB-

pages

-LSB-

-RSB-

Jason

J.

Hickey

The

MetaPRL

Logical

Programming

Environment

PhD

thesis

Cornell

University

Ithaca

NY

January

-LSB-

-RSB-

G

erard

P.

Huet

and

Bernard

Lang

Proving

and

applying

program

transformations

expressed

with

second-order

patterns

Acta

Informatica

-LSB-

HNC

-RSB-

Jason

Hickey

Aleksey

Nogin

Robert

L.

Constable

Brian

E.

Aydemir

Eli

Barzilay

Yegor

Bryukhov

Richard

Eaton

Adam

Granicz

Alexei

Kopylov

Christoph

Kreitz

Vladimir

N.

Krupski

Lori

Lorigo

Stephan

Schmitt

Carl

Witty

and

Xin

Yu

MetaPRL

A

modular

logical

environment

In

David

Basin

and

Burkhart

Wolff

editors

Proceedings

of

the

t

h

International

Conference

on

Theorem

Proving

in

Higher

Order

Logics

-LRB-

TPHOLs

-RRB-

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

-LSB-

HNK

-RSB-

Jason

J.

Hickey

Aleksey

Nogin

Alexei

Kopylov

et

al.

MetaPRL

home

page

-LSB-

-RSB-

Andrzej

Mostowski

Sentences

undecidable

in

formalized

arithmetic

an

exposition

of

the

theory

of

Kurt

G

odel

Amsterdam

North-Holland

-LSB-

-RSB-

Aleksey

Nogin

and

Jason

Hickey

Sequent

schema

for

derived

rules

In

Victor

A.

Carre

no

C

ezar

A.

Mu

noz

and

Sophi`ene

Tahar

editors

Proceedings

of

the

t

h

International

Conference

on

Theorem

Proving

in

Higher

Order

Logics

-LRB-

TPHOLs

-RRB-

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

-LSB-

-RSB-

Aleksey

Nogin

Alexei

Kopylov

Xin

Yu

and

Jason

Hickey

A

computational

approach

to

reflective

meta-reasoning

about

languages

with

bindings

Technical

Report

CaltechCSTR

California

Institure

of

Technology

Available

at

CaltechCSTR

-LSB-

-RSB-

Michael

Norrish

Recursive

function

definition

for

types

with

binders

In

Slind

et

al.

-LSB-

-RSB-

pages

-LSB-

-RSB-

R.

Parikh

Existence

and

feasibility

in

arithmetic

The

Journal

of

Symbolic

Logic

-LSB-

-RSB-

Lawrence

C.

Paulson

Isabelle

A

Generic

Theorem

Prover

volume

of

Lecture

Notes

in

Computer

Science

Springer-Verlag

New

York

-LSB-

-RSB-

Frank

Pfenning

and

Conal

Elliott

Higher-order

abstract

syntax

In

Proceedings

of

the

ACM

SIGPLAN

Conference

on

Programming

Language

Design

and

Implementation

-LRB-

PLDI

-RRB-

volume

-LRB-

-RRB-

of

SIGPLAN

Notices

pages

Atlanta

Georgia

June

ACM

Press

-LSB-

-RSB-

Frank

Pfenning

Elf

a

language

for

logic

definition

and

verified

metaprogramming

In

Proceedings

of

the

t

h

IEEE

Symposium

on

Logic

in

Computer

Science

pages

Asilomar

Conference

Center

Pacific

Grove

California

June

IEEE

Computer

Society

Press

-LSB-

-RSB-

Gordon

Plotkin

An

illative

theory

of

relations

In

R.

Cooper

K.

Mukai

and

J.

Perry

editors

Situation

Theory

and

Its

Applications

Volume

number

in

CSLI

Lecture

Notes

pages

Centre

for

the

Study

of

Language

and

Information

-LSB-

-RSB-

L.

Paulson

and

T.

Nipkow

Isabelle

tutorial

and

user

's

manual

Technical

report

University

of

Cambridge

Computing

Laboratory

-LSB-

-RSB-

Konrad

Slind

Annette

Bunker

and

Ganesh

Gopalakrishnan

editors

Proceedings

of

the

t

h

International

Conference

on

Theorem

Proving

in

Higher

Order

Logics

-LRB-

TPHOLs

-RRB-

volume

of

Lecture

Notes

in

Computer

Science

Springer-Verlag

-LSB-

-RSB-

Carsten

Sch

urmann

Recursion

for

higher-order

encodings

In

L.

Fribourg

editor

Computer

Science

Logic

Proceedings

of

the

t

h

Annual

Conference

of

the

EACSL

volume

of

Lecture

Notes

in

Computer

Science

pages

Springer-Verlag

-LSB-

-RSB-

B.C.

Smith

Reflection

and

semantics

in

Lisp

Principles

of

Programming

Languages

pages

-LSB-

-RSB-

J.

van

Heijenoort

editor

From

Frege

to

G

odel

A

Source

Book

in

Mathematical

Logic

Harvard

University

Press

Cambridge

MA

metaprl theorem prover
theory of syntax
uniform reflection framework
runtime code generation
nuprl
languages with bindings
reflection
theorem prover
reflective reasoning
programming language
formal languages
type theory
metaprl
substitution
recursive definition

nuprl-like martin-lof-style computational type theory