lean4-htt/tests/lean/run/new_inductive.lean
Leonardo de Moura 90a79a0b06 chore: remove command universes
Now, `universe` may declare many universes. The goal is to make it
consistent with the `variable` command
2021-06-29 17:01:07 -07:00

81 lines
2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

universe u v
inductive myList (α : Type u)
| nil : myList α
| cons : α → myList α → myList α
inductive myPair (α : Type u) (β : Type v)
| mk : α → β → myPair α β
mutual
variable (α : Type u) (m : α → Type v)
inductive bla : Nat → Type (max u v)
| mk₁ (n : Nat) : α → boo n → bla (n+1)
| mk₂ (a : α) : m a → String → bla 0
inductive boo : Nat → Type (max u v)
| mk₃ (n : Nat) : bla n → bla (n+1) → boo (n+2)
end
#print bla
inductive Term (α : Type) (β : Type)
| var : α → bla (Term α β) (fun _ => Term α β) 10 → Term α β
| foo (p : Nat → myPair (Term α β) (myList $ Term α β)) (n : β) : myList (myList $ Term α β) → Term α β
#print Term
#print Term.below
#check @Term.casesOn
#print Term.noConfusionType
#print Term.noConfusion
inductive arrow (α β : Type)
| mk (s : Nat → myPair α β) : arrow α β
mutual
inductive tst1
| mk : (arrow (myPair tst2 Bool) tst2) → tst1
inductive tst2
| mk : tst1 → tst2
end
#check @tst1.casesOn
#check @tst2.casesOn
#check @tst1.recOn
namespace test
inductive Rbnode (α : Type u)
| leaf : Rbnode α
| redNode (lchild : Rbnode α) (val : α) (rchild : Rbnode α) : Rbnode α
| blackNode (lchild : Rbnode α) (val : α) (rchild : Rbnode α) : Rbnode α
#reduce sizeOf <| Rbnode.redNode Rbnode.leaf 10 Rbnode.leaf
#check @Rbnode.brecOn
namespace Rbnode
variable {α : Type u}
constant insert (lt : αα → Prop) [DecidableRel lt] (t : Rbnode α) (x : α) : Rbnode α := Rbnode.leaf
inductive WellFormed (lt : αα → Prop) : Rbnode α → Prop
| leafWff : WellFormed lt leaf
| insertWff {n n' : Rbnode α} {x : α} (s : DecidableRel lt) : WellFormed lt n → n' = insert lt n x → WellFormed lt n'
end Rbnode
def Rbtree (α : Type u) (lt : αα → Prop) : Type u :=
{t : Rbnode α // t.WellFormed lt }
inductive Trie
| Empty : Trie
| mk : Char → Rbnode (myPair Char Trie) → Trie
#print Trie.rec
#print Trie.noConfusion
end test
inductive Foo
| mk : List Foo → Foo
#check Foo