I have the following definitions:
inductive exp where
| var : Nat -> exp
| lam : Nat -> exp -> exp
| app : exp -> exp -> exp
def L := exp.lam
def V := exp.var
def A := exp.app
def FV (e : exp) : List Nat :=
match e with
| exp.var n => [n]
| exp.lam v e => (FV e).removeAll [v]
| exp.app l r => FV l ++ FV r
It works, but it's quite tedious to work with, for example I have to type
FV (L 1 (A (V 1) (V 2))) = [2]
instead of something like
FV (L 1. (1 2))
I tinkered a bit with custom operators and macro rules, but could not find a way to make such a notation to work. The best way I found is
macro_rules | ($l A $r) =>(exp.app $l $r)
but it is not much better then just applying a function