feat: inductive command
cc @Kha
This commit is contained in:
parent
98d8520158
commit
8a2dd414ff
4 changed files with 58 additions and 4 deletions
|
|
@ -439,15 +439,12 @@ adaptReader (fun (ctx : Term.Context) => { ctx with levelNames := allUserLevelNa
|
|||
| Except.ok levelParams => do
|
||||
indTypes ← replaceIndFVarsWithConsts views indFVars levelParams numParams indTypes;
|
||||
let indTypes := applyInferMod views numParams indTypes;
|
||||
traceIndTypes indTypes;
|
||||
pure $ Declaration.inductDecl levelParams numParams indTypes isUnsafe
|
||||
|
||||
def elabInductiveCore (views : Array InductiveView) : CommandElabM Unit := do
|
||||
let view0 := views.get! 0;
|
||||
decl ← runTermElabM view0.declName $ fun vars => mkInductiveDecl vars views;
|
||||
-- TODO register decl
|
||||
pure ()
|
||||
|
||||
addDecl view0.ref decl
|
||||
|
||||
end Command
|
||||
end Elab
|
||||
|
|
|
|||
|
|
@ -106,3 +106,13 @@ inductive T1 : Nat → Type
|
|||
|
||||
inductive T1 : Nat → Type
|
||||
| z1 : Nat -- unexpected constructor resulting type
|
||||
|
||||
|
||||
-- Test13
|
||||
|
||||
inductive A (α : Type u) (β : Type v)
|
||||
| nil {}
|
||||
| protected cons : α → β → A → A
|
||||
|
||||
open A
|
||||
#check cons -- unknown `cons`, it is protected
|
||||
|
|
|
|||
|
|
@ -26,3 +26,5 @@ inductive1.lean:105:0: error: unexpected constructor resulting type, type expect
|
|||
T1
|
||||
inductive1.lean:108:0: error: unexpected constructor resulting type
|
||||
Nat
|
||||
inductive1.lean:118:7: error: unknown identifier 'cons'
|
||||
(sorryAx ?m_1) : ?m_1
|
||||
|
|
|
|||
45
tests/lean/run/inductive1.lean
Normal file
45
tests/lean/run/inductive1.lean
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
new_frontend
|
||||
|
||||
inductive L1.{u} (α : Type u)
|
||||
| nil
|
||||
| cons : α → L1 → L1
|
||||
|
||||
#check L1
|
||||
#check @L1.cons
|
||||
|
||||
inductive L2.{u} (α : Type u)
|
||||
| nil
|
||||
| cons (head : α) (tail : L2)
|
||||
|
||||
#check @L2.cons
|
||||
|
||||
universes u v
|
||||
variable (α : Type u)
|
||||
|
||||
inductive A (β : Type v)
|
||||
| nil {}
|
||||
| protected cons : α → β → A → A
|
||||
|
||||
#check @A.cons
|
||||
#check A.nil Nat Bool
|
||||
|
||||
mutual
|
||||
inductive isEven : Nat → Prop
|
||||
| z : isEven 0
|
||||
| s (n : Nat) : isOdd n → isEven (n+1)
|
||||
|
||||
inductive isOdd : Nat → Prop
|
||||
| s (n : Nat) : isEven n → isOdd (n+1)
|
||||
end
|
||||
|
||||
#check isEven
|
||||
#check isOdd.s
|
||||
#check @isEven.rec
|
||||
|
||||
inductive V (α : Type _) : Nat → Type _
|
||||
| nil : V 0
|
||||
| cons {n : Nat} : α → V n → V (n+1)
|
||||
|
||||
#check @V.nil
|
||||
#check @V.cons
|
||||
#check @V.rec
|
||||
Loading…
Add table
Reference in a new issue