-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndSig.lean
More file actions
30 lines (26 loc) · 789 Bytes
/
IndSig.lean
File metadata and controls
30 lines (26 loc) · 789 Bytes
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
import Mathlib.Logic.Equiv.Defs
class Inductive (α : Type u) (F : Type u → Type v) [Functor F] where
fold (x : F α) : α
recursor {τ} (f : F τ → τ) (a : α) : τ
rec_fold f x : @recursor τ f (fold x) = f (recursor f <$> x)
instance : Inductive Nat Option where
fold
| none => .zero
| some n => .succ n
recursor f := Nat.rec (f none) λ _ t => f <| some t
rec_fold _
| none => rfl
| some _ => rfl
instance : Functor (Option <| α × ·) where
map f
| none => none
| some (a, x) => some (a, f x)
noncomputable
instance : Inductive (List α) (Option <| α × ·) where
fold
| none => .nil
| some (a, l) => .cons a l
recursor f := List.rec (f none) λ a _ t => f <| some (a, t)
rec_fold _
| none => rfl
| some _ => rfl