2015-04-04 04:20:19 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2015 Floris van Doorn. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Module: init.hit
|
|
|
|
Authors: Floris van Doorn
|
|
|
|
|
|
|
|
Declaration of the primitive hits in Lean
|
|
|
|
-/
|
|
|
|
|
|
|
|
prelude
|
|
|
|
|
|
|
|
import .trunc
|
|
|
|
|
|
|
|
open is_trunc eq
|
|
|
|
|
2015-04-07 01:01:08 +00:00
|
|
|
/-
|
2015-04-10 01:45:18 +00:00
|
|
|
We take two higher inductive types (hits) as primitive notions in Lean. We define all other hits
|
|
|
|
in terms of these two hits. The hits which are primitive are
|
2015-04-07 01:01:08 +00:00
|
|
|
- n-truncation
|
2015-04-11 00:33:33 +00:00
|
|
|
- type quotients (non-truncated quotients)
|
2015-04-07 01:01:08 +00:00
|
|
|
For each of the hits we add the following constants:
|
|
|
|
- the type formation
|
|
|
|
- the term and path constructors
|
|
|
|
- the dependent recursor
|
2015-04-19 21:56:24 +00:00
|
|
|
We add the computation rule for point constructors judgmentally to the kernel of Lean.
|
|
|
|
The computation rules for the path constructors are added (propositionally) as axioms
|
2015-04-07 01:01:08 +00:00
|
|
|
|
|
|
|
In this file we only define the dependent recursor. For the nondependent recursor and all other
|
2015-04-19 21:56:24 +00:00
|
|
|
uses of these hits, see the folder ../hit/
|
2015-04-07 01:01:08 +00:00
|
|
|
-/
|
|
|
|
|
2015-04-04 04:20:19 +00:00
|
|
|
constant trunc.{u} (n : trunc_index) (A : Type.{u}) : Type.{u}
|
|
|
|
|
|
|
|
namespace trunc
|
|
|
|
constant tr {n : trunc_index} {A : Type} (a : A) : trunc n A
|
|
|
|
constant is_trunc_trunc (n : trunc_index) (A : Type) : is_trunc n (trunc n A)
|
|
|
|
|
|
|
|
attribute is_trunc_trunc [instance]
|
|
|
|
|
2015-04-23 22:27:56 +00:00
|
|
|
protected constant rec {n : trunc_index} {A : Type} {P : trunc n A → Type}
|
2015-04-04 04:20:19 +00:00
|
|
|
[Pt : Πaa, is_trunc n (P aa)] (H : Πa, P (tr a)) : Πaa, P aa
|
|
|
|
|
2015-04-07 01:01:08 +00:00
|
|
|
protected definition rec_on [reducible] {n : trunc_index} {A : Type} {P : trunc n A → Type}
|
|
|
|
(aa : trunc n A) [Pt : Πaa, is_trunc n (P aa)] (H : Πa, P (tr a)) : P aa :=
|
2015-04-04 04:20:19 +00:00
|
|
|
trunc.rec H aa
|
|
|
|
end trunc
|
|
|
|
|
2015-04-11 00:33:33 +00:00
|
|
|
constant type_quotient.{u v} {A : Type.{u}} (R : A → A → Type.{v}) : Type.{max u v}
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-11 00:33:33 +00:00
|
|
|
namespace type_quotient
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-11 00:33:33 +00:00
|
|
|
constant class_of {A : Type} (R : A → A → Type) (a : A) : type_quotient R
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-27 21:34:55 +00:00
|
|
|
constant eq_of_rel {A : Type} (R : A → A → Type) {a a' : A} (H : R a a')
|
2015-04-11 00:33:33 +00:00
|
|
|
: class_of R a = class_of R a'
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-23 22:27:56 +00:00
|
|
|
protected constant rec {A : Type} {R : A → A → Type} {P : type_quotient R → Type}
|
2015-05-01 03:23:12 +00:00
|
|
|
(Pc : Π(a : A), P (class_of R a)) (Pp : Π⦃a a' : A⦄ (H : R a a'), eq_of_rel R H ▸ Pc a = Pc a')
|
2015-04-11 00:33:33 +00:00
|
|
|
(x : type_quotient R) : P x
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-11 00:33:33 +00:00
|
|
|
protected definition rec_on [reducible] {A : Type} {R : A → A → Type} {P : type_quotient R → Type}
|
|
|
|
(x : type_quotient R) (Pc : Π(a : A), P (class_of R a))
|
2015-05-01 03:23:12 +00:00
|
|
|
(Pp : Π⦃a a' : A⦄ (H : R a a'), eq_of_rel R H ▸ Pc a = Pc a') : P x :=
|
2015-05-19 05:35:18 +00:00
|
|
|
type_quotient.rec Pc Pp x
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-23 22:27:56 +00:00
|
|
|
end type_quotient
|
|
|
|
|
|
|
|
init_hits -- Initialize builtin computational rules for trunc and type_quotient
|
|
|
|
|
|
|
|
namespace trunc
|
|
|
|
definition rec_tr [reducible] {n : trunc_index} {A : Type} {P : trunc n A → Type}
|
|
|
|
[Pt : Πaa, is_trunc n (P aa)] (H : Πa, P (tr a)) (a : A) : trunc.rec H (tr a) = H a :=
|
|
|
|
idp
|
|
|
|
end trunc
|
|
|
|
|
|
|
|
namespace type_quotient
|
2015-04-11 00:33:33 +00:00
|
|
|
definition rec_class_of {A : Type} {R : A → A → Type} {P : type_quotient R → Type}
|
2015-05-01 03:23:12 +00:00
|
|
|
(Pc : Π(a : A), P (class_of R a)) (Pp : Π⦃a a' : A⦄ (H : R a a'), eq_of_rel R H ▸ Pc a = Pc a')
|
2015-04-23 22:27:56 +00:00
|
|
|
(a : A) : type_quotient.rec Pc Pp (class_of R a) = Pc a :=
|
|
|
|
idp
|
2015-04-04 04:20:19 +00:00
|
|
|
|
2015-04-11 00:33:33 +00:00
|
|
|
constant rec_eq_of_rel {A : Type} {R : A → A → Type} {P : type_quotient R → Type}
|
2015-05-01 03:23:12 +00:00
|
|
|
(Pc : Π(a : A), P (class_of R a)) (Pp : Π⦃a a' : A⦄ (H : R a a'), eq_of_rel R H ▸ Pc a = Pc a')
|
2015-04-27 21:34:55 +00:00
|
|
|
{a a' : A} (H : R a a') : apd (type_quotient.rec Pc Pp) (eq_of_rel R H) = Pp H
|
2015-04-11 00:33:33 +00:00
|
|
|
end type_quotient
|
2015-05-07 20:35:14 +00:00
|
|
|
|
|
|
|
attribute type_quotient.class_of trunc.tr [constructor]
|
|
|
|
attribute type_quotient.rec trunc.rec [unfold-c 6]
|
|
|
|
attribute type_quotient.rec_on trunc.rec_on [unfold-c 4]
|