lean4-htt/tests/lean/run/662.lean
Leonardo de Moura f36fca875c feag(frontends/lean): explicit delimiters in declaration parameters
Comment from parser.h

This commit makes sure that all declaration parameters must be surrounded with some kind of bracket. (e.g., '()', '{}', '[]').
The goal is to avoid counter-intuitive declarations such as:

              example p : false := trivial
              def main proof : false := trivial

which would be parsed as

              example (p : false) : _ := trivial

              def main (proof : false) : _ := trivial

where `_` in both cases is elaborated into `true`. This issue was raised by @gebner in the slack channel.

Remark: we still want implicit delimiters for lambda/pi expressions. That is, we want to write

               fun x : t, s
           or
               fun x, s

instead of

               fun (x : t), s
2017-09-15 10:07:09 -07:00

38 lines
1.1 KiB
Text

open nat
inductive type : Type
| Nat : type
| Func : type → type → type
open type
section var
variable {var : type → Type}
inductive term : type → Type
| Var : ∀ {t}, var t → term t
| Const : nat → term Nat
| Plus : term Nat → term Nat → term Nat
| Abs : ∀ {dom ran}, (var dom → term ran) → term (Func dom ran)
| App : ∀ {dom ran}, term (Func dom ran) → term dom → term ran
| Let : ∀ {t1 t2}, term t1 → (var t1 → term t2) → term t2
end var
open term
definition Term (t) := Π (var : type → Type), @term var t
open unit
definition count_vars : Π {t : type}, @term (λ x, unit) t -> nat
| A (Var x) := 1
| Nat (Const x) := 0
| Nat (Plus e1 e2) := count_vars e1 + count_vars e2
| (Func A B) (Abs e1) := count_vars (e1 star)
| B (@App ._ A .(B) e1 e2) := count_vars e1 + count_vars e2
| B (@Let ._ A .(B) e1 e2) := count_vars e1 + count_vars (e2 star)
definition var (t : type) : @term (λ x, unit) t :=
Var star
example : count_vars (App (App (var (Func Nat (Func Nat Nat))) (var Nat)) (var Nat)) = 3 :=
rfl