lean2/tests/lean/run/541b.lean
Leonardo de Moura c5fb3ec6d0 fix(library/definitional/equations): fixes #541
This commit allows recursive applications to have less or more arguments
than the equation left-hand-side.
We add two tests
   - 541a.lean  recursive call with more arguments
   - 542b.lean  recursive call with less arguments
2015-05-10 20:37:44 -07:00

43 lines
1.2 KiB
Text

import data.list
inductive typ : Type :=
| nat : typ
| arr : typ → typ → typ
inductive const : Type :=
| z | s
inductive exp : Type :=
| var : nat → exp
| cnst : const → exp
| lam : nat → typ → exp → exp
| ap : exp → exp → exp
open exp
inductive is_val : exp → Prop :=
| vcnst : Π c, is_val (cnst c)
| vlam : Π x t e, is_val (lam x t e)
| vcnst_ap : Π {e} c, is_val e → is_val (ap (cnst c) e)
inductive step : exp → exp → Prop :=
infix `➤`:50 := step
| stepl : Π {e1 e1'} e2, e1 ➤ e1' → ap e1 e2 ➤ ap e1' e2
| stepr : Π {e1 e2 e2'}, is_val e1 → e2 ➤ e2' → ap e1 e2 ➤ ap e1 e2'
| subst : Π {x e1 e1' e2} t, is_val e2 → ap (lam x t e1) e2 ➤ e1'
infix `➤`:50 := step
open is_val
open step
theorem nostep : ∀ {e} e', is_val e → e ➤ e' → false
| nostep e' (vcnst c) Hsteps := by cases Hsteps
| nostep e' (vlam x t e) Hsteps := by cases Hsteps
| nostep (ap e' e) (@vcnst_ap e c Hval) (stepl e Hbad) :=
have Hvalc : is_val (cnst c), from vcnst c,
have IH : not (cnst c ➤ e'), from nostep e' Hvalc,
absurd Hbad IH
| nostep (ap (cnst c) e') (@vcnst_ap e c Hvale) (stepr Hvalc Hbad) :=
have IH : not (e ➤ e'), from nostep e' Hvale,
absurd Hbad IH