-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMutualInd.lean
64 lines (57 loc) · 1.54 KB
/
MutualInd.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
set_option autoImplicit false
set_option pp.fieldNotation false
inductive Term : Type where
| 𝒰 : Nat → Term
open Term
inductive Ctxt : Type where
| nil : Ctxt
| cons : Ctxt → Term → Ctxt
notation:50 "⬝" => Ctxt.nil
infixl:50 "∷" => Ctxt.cons
inductive Eqv : Term → Term → Prop where
| trans {a b c} :
Eqv a b →
Eqv b c →
---------
Eqv a c
| 𝒰 {a b} :
a = b →
----------------
Eqv (𝒰 a) (𝒰 b)
infix:40 (priority := 1001) "≈" => Eqv
mutual
inductive Wf : Ctxt → Prop where
| nil : Wf (⬝)
| cons {Γ A k} :
Wf Γ →
Wt Γ A (𝒰 k) →
--------------
Wf (Γ ∷ A)
inductive Wt : Ctxt → Term → Term → Prop where
| 𝒰 {Γ j k} :
j < k →
-----------------
Wt Γ (𝒰 j) (𝒰 k)
| conv {Γ A B a k} :
A ≈ B →
Wt Γ a A →
Wt Γ B (𝒰 k) →
--------------
Wt Γ a B
end
notation:40 "⊢" Γ:40 => Wf Γ
notation:40 Γ:41 "⊢" a:41 "∶" A:41 => Wt Γ a A
theorem wt𝒰Inv {Γ j A 𝒰'} : Γ ⊢ A ∶ 𝒰' → A = 𝒰 j → ∃ k, 𝒰 k ≈ 𝒰' := by
intro h e; subst e
-- induction h
/- 'induction' tactic does not support mutually inductive types,
the eliminator 'Wt.rec' has multiple motives -/
cases h with
| 𝒰 lt => exact ⟨_, Eqv.𝒰 rfl⟩
| conv e₁ h _ =>
let ⟨_, e₂⟩ := wt𝒰Inv h rfl
exact ⟨_, Eqv.trans e₂ e₁⟩
-- termination_by structural h => h
/- failed to infer structural recursion:
Cannot use parameter h:
unknown constant 'Wt.brecOn' -/