Skip to content

Commit

Permalink
notation & some delaborators & minor renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
forked-from-1kasper committed Nov 9, 2023
1 parent 14636a1 commit f4c870c
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 118 deletions.
4 changes: 2 additions & 2 deletions GroundZero/Algebra/EilenbergMacLane.lean
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace K1
noncomputable def (G : Group) : Group :=
@Group.intro (Ω¹(K1 G)) (grpd _ _) KΩ.mul KΩ.inv KΩ.one
(λ _ _ _, Id.inv (Id.assoc _ _ _))
Id.reflLeft Id.reflRight Id.invComp
Id.lid Id.rid Id.invComp

noncomputable def homomorphism : Group.Hom G (KΩ G) :=
Group.mkhomo loop loop.mul
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace K1
transitivity; apply ap (· ⬝ loop x); apply loop.mul;
transitivity; symmetry; apply Id.assoc;
transitivity; apply ap; apply ap (· ⬝ loop x); apply loop.inv;
transitivity; apply ap; apply Id.invComp; apply Id.reflRight };
transitivity; apply ap; apply Id.invComp; apply Id.rid };
{ apply zeroEqvSet.forward; apply piRespectsNType 0;
intro; apply zeroEqvSet.left; apply grpd };
{ apply oneEqvGroupoid.forward;
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Algebra/Group/Z.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GroundZero.Algebra

noncomputable def : Group :=
Group.intro (Circle.isGroupoid Circle.base Circle.base) Id.trans Id.inv Id.refl
(λ a b c, (Id.assoc a b c)⁻¹) Id.reflLeft Id.reflRight Id.invComp
(λ a b c, (Id.assoc a b c)⁻¹) Id.lid Id.rid Id.invComp

noncomputable def ZΩ.abelian : ZΩ.isCommutative := Circle.comm

Expand Down
8 changes: 4 additions & 4 deletions GroundZero/Algebra/Ring.lean
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,19 @@ hott def field.mulRightInv (T : Prering) [field T] {x : T.carrier}
(p : T.isproper x) : x * x⁻¹ = 1 :=
ap Sigma.fst (Tˣ.mulRightInv ⟨x, p⟩)

class lid (T : Prering) [ring T] (φ : T⁺.subgroup) :=
class Lid (T : Prering) [ring T] (φ : T⁺.subgroup) :=
(ideal : Π r i, i ∈ φ.set → T.ψ r i ∈ φ.set)

class rid (T : Prering) [ring T] (φ : T⁺.subgroup) :=
class Rid (T : Prering) [ring T] (φ : T⁺.subgroup) :=
(ideal : Π i r, i ∈ φ.set → T.ψ i r ∈ φ.set)

class ideal (T : Prering) [ring T] (φ : T⁺.subgroup) :=
(left : Π r i, i ∈ φ.set → T.ψ r i ∈ φ.set)
(right : Π i r, i ∈ φ.set → T.ψ i r ∈ φ.set)

instance ideal.auto (T : Prering) [ring T]
(φ : T⁺.subgroup) [lid T φ] [rid T φ] : ideal T φ :=
lid.ideal, rid.ideal⟩
(φ : T⁺.subgroup) [Lid T φ] [Rid T φ] : ideal T φ :=
Lid.ideal, Rid.ideal⟩

namespace Ring
variable (T : Prering) [ring T] (φ : T⁺.subgroup) [ideal T φ]
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Exercises/Chap2.lean
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ begin induction p; reflexivity end

hott def transportSquare {A : Type u} {B : A → Type v} {f g : Π x, B x} (H : f ~ g) {x y : A} (p : x = y) :
ap (transport B p) (H x) ⬝ apd g p = apd f p ⬝ H y :=
begin induction p; transitivity; apply Id.reflRight; apply Equiv.idmap end
begin induction p; transitivity; apply Id.rid; apply Equiv.idmap end
4 changes: 2 additions & 2 deletions GroundZero/Exercises/Chap4.lean
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace «4.3»
apply ap (·⁻¹⁻¹); symmetry; apply e.2.2.2;
apply ap (_ ⬝ · ⬝ _); apply Equiv.mapOverComp };
{ intro p; induction p; transitivity; apply ap (· ⬝ _);
apply Id.reflRight; apply Id.invComp }
apply Id.rid; apply Id.invComp }
end

hott lemma embdOfQinv : qinv f → isEmbedding f :=
Expand Down Expand Up @@ -222,7 +222,7 @@ namespace «4.4»
apply transport (@Sigma _ · ≃ _); apply Theorems.funext;
intro e; symmetry; apply ap (fib idfun);
transitivity; apply Equiv.transportOverContrMap;
transitivity; apply Id.reflRight; apply ap (ap g); apply Id.invInv;
transitivity; apply Id.rid; apply ap (ap g); apply Id.invInv;
apply Equiv.trans; apply Sigma.respectsEquiv;
{ intro; apply Equiv.trans; apply Sigma.hmtpyInvEqv;
apply Structures.contrEquivUnit.{_, 0}; apply singl.contr };
Expand Down
94 changes: 47 additions & 47 deletions GroundZero/HITs/Circle.lean

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions GroundZero/HITs/Interval.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Interval
recfalse) (φ true) (H _ _)

hott def contrLeft : Π i, i₀ = i :=
Interval.ind (idp i₀) seg (begin apply pathoverFromTrans; apply Id.reflLeft end)
Interval.ind (idp i₀) seg (begin apply pathoverFromTrans; apply Id.lid end)

hott def contrRight : Π i, i₁ = i :=
Interval.ind seg⁻¹ (idp i₁) (begin apply pathoverFromTrans; apply Id.invComp end)
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace Interval
apply recβrule end
... = seg⁻¹ ⬝ seg :
begin apply ap (· ⬝ seg);
apply Id.reflRight end
apply Id.rid end
... = idp i₁ : by apply Id.invComp)

hott def negNeg' (x : I) : neg (neg x) = x :=
Expand All @@ -124,7 +124,7 @@ namespace Interval
reflexivity; reflexivity; change _ = _;
transitivity; apply Equiv.transportOverHmtpy;
transitivity; apply ap (· ⬝ ap p seg);
transitivity; apply Id.reflRight;
transitivity; apply Id.rid;
transitivity; apply Id.mapInv; apply ap;
apply recβrule; apply Id.invComp
end
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/HITs/Merely.lean
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace Merely
glue⁻¹ ⬝ ap incl (ap (Generalized.dep A n) p) ⬝ glue = ap incl p :=
begin
induction p; transitivity; { symmetry; apply Id.assoc };
apply Equiv.rewriteComp; symmetry; apply Id.reflRight
apply Equiv.rewriteComp; symmetry; apply Id.rid
end

hott def congOverPath {A : Type u} {n : ℕ} {a b : Generalized.rep A n}
Expand Down
14 changes: 7 additions & 7 deletions GroundZero/HITs/Quotient.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ open GroundZero
namespace GroundZero.HITs
universe u v w u' v'

hott def Quot {A : Type u} (R : A → A → propset.{v}) := ∥Graph (λ x y, (R x y).1)∥₀
hott def Quot {A : Type u} (R : A → A → Prop v) := ∥Graph (λ x y, (R x y).1)∥₀

hott def Quot.elem {A : Type u} {R : A → A → propset.{v}} : A → Quot R :=
hott def Quot.elem {A : Type u} {R : A → A → Prop v} : A → Quot R :=
Trunc.elem ∘ Graph.elem

hott def Quot.sound {A : Type u} {R : A → A → propset.{v}} {a b : A} :
hott def Quot.sound {A : Type u} {R : A → A → Prop v} {a b : A} :
(R a b).1 → @Id (Quot R) (Quot.elem a) (Quot.elem b) :=
begin intro H; apply ap Trunc.elem; apply Graph.line; assumption end

noncomputable hott def Quot.set {A : Type u} {R : A → A → propset.{v}} : hset (Quot R) :=
noncomputable hott def Quot.set {A : Type u} {R : A → A → Prop v} : hset (Quot R) :=
zeroEqvSet.forward (Trunc.uniq 0)

hott def Quot.ind {A : Type u} {R : A → A → propset.{u'}} {π : Quot R → Type v}
hott def Quot.ind {A : Type u} {R : A → A → Prop u'} {π : Quot R → Type v}
(elemπ : Π x, π (Quot.elem x))
(lineπ : Π x y H, elemπ x =[Quot.sound H] elemπ y)
(set : Π x, hset (π x)) : Π x, π x :=
Expand All @@ -37,11 +37,11 @@ end

attribute [eliminator] Quot.ind

hott def Quot.rec {A : Type u} {R : A → A → propset.{u'}} {B : Type v}
hott def Quot.rec {A : Type u} {R : A → A → Prop u'} {B : Type v}
(elemπ : A → B) (lineπ : Π x y, (R x y).fst → elemπ x = elemπ y) (set : hset B) : Quot R → B :=
@Quot.ind A R (λ _, B) elemπ (λ x y H, Equiv.pathoverOfEq (Quot.sound H) (lineπ x y H)) (λ _, set)

hott def Quot.lift₂ {A : Type u} {R₁ : A → A → propset.{u'}} {B : Type v} {R₂ : B → B → propset.{v'}}
hott def Quot.lift₂ {A : Type u} {R₁ : A → A → Prop u'} {B : Type v} {R₂ : B → B → Prop v'}
{γ : Type w} (R₁refl : Π x, (R₁ x x).fst) (R₂refl : Π x, (R₂ x x).fst) (f : A → B → γ)
(h : hset γ) (p : Π a₁ a₂ b₁ b₂, (R₁ a₁ b₁).fst → (R₂ a₂ b₂).fst → f a₁ a₂ = f b₁ b₂) : Quot R₁ → Quot R₂ → γ :=
begin
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/HITs/Reals.lean
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace Reals
induction n using Nat.casesOn; apply Id.invComp;
{ transitivity; symmetry; apply Id.assoc;
transitivity; apply ap; apply Id.invComp;
apply Id.reflRight }
apply Id.rid }
end)⟩

hott def dist : Π (u v : R), u = v :=
Expand Down
6 changes: 6 additions & 0 deletions GroundZero/Meta/Notation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ open Lean.PrettyPrinter.Delaborator

namespace GroundZero.Meta.Notation

open Lean in def delabCustomSort (t₀ : Delab) (t : Syntax.Level → Delab) : Delab :=
whenPPOption Lean.getPPNotation do {
let ε ← SubExpr.getExpr; let n := ε.constLevels!.get! 0;
if n.isZero then t₀ else t (n.quote max_prec)
}

@[app_unexpander Nat.succ]
def natSuccUnexpander : Lean.PrettyPrinter.Unexpander
| `($_ $n) => `($n + 1)
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Modal/Disc.lean
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ begin
transitivity; apply Id.ap (· ⬝ _); apply Id.assoc;
transitivity; symmetry; apply Id.assoc;
transitivity; apply Id.ap; apply Id.invComp;
transitivity; apply Id.reflRight; apply bimap;
transitivity; apply Id.rid; apply bimap;
{ transitivity; apply Id.ap; apply Id.mapInv; apply Id.invInv };
{ apply Id.invInv } }
end
Expand Down
42 changes: 27 additions & 15 deletions GroundZero/Structures.lean
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,31 @@ namespace Structures
hott def isLoop {A : Type u} {a : A} (p : a = a) := ¬(p = idp a)

hott def prop (A : Type u) := Π (a b : A), a = b
hott def hset (A : Type u) := Π (a b : A) (p q : a = b), p = q

hott def groupoid (A : Type u) :=
Π (a b : A) (p q : a = b) (A B : p = q), A = B

hott def propset := Σ (A : Type u), prop A
hott def hsetset := Σ (A : Type u), hset A

macro (priority := high) "Prop" : term => `(propset)
macro (priority := high) "Prop" n:level : term => `(propset.{$n})
macro (priority := high) "Prop" n:(ppSpace level:max) : term => `(propset.{$n})

hott def hset (A : Type u) := Π (a b : A) (p q : a = b), p = q
hott def Ens := Σ A, hset A
macro "Set" : term => `(hsetset)
macro "Set" n:(ppSpace level:max) : term => `(hsetset.{$n})

hott def groupoid (A : Type u) :=
Π (a b : A) (p q : a = b) (A B : p = q), A = B
section
open Lean Lean.PrettyPrinter.Delaborator

@[delab app.GroundZero.Structures.propset]
def delabPropSet : Delab :=
Meta.Notation.delabCustomSort `(Prop) (λ n, `(Prop $n))

@[delab app.GroundZero.Structures.hsetset]
def delabHSetSet : Delab :=
Meta.Notation.delabCustomSort `(Set) (λ n, `(Set $n))
end

hott def dec (A : Type u) := A + ¬A

Expand Down Expand Up @@ -413,7 +427,7 @@ begin
apply Types.Id.transCancelLeft (f a a (ρ a));
transitivity; symmetry; apply Types.Equiv.transportComposition;
transitivity; apply Types.Equiv.liftedHapply (R a); apply Types.Equiv.apd (f a) p;
transitivity; apply ap (f a a) (h _ _ _ (ρ a)); symmetry; apply Types.Id.reflRight
transitivity; apply ap (f a a) (h _ _ _ (ρ a)); symmetry; apply Types.Id.rid
end

hott def doubleNegEq {A : Type u} (h : Π (x y : A), ¬¬(x = y) → x = y) : hset A :=
Expand Down Expand Up @@ -448,8 +462,6 @@ end
hott corollary boolIsSet : hset 𝟐 :=
Hedberg boolDecEq



section
open GroundZero.Types.Not (univ)
open GroundZero.Types.Coproduct
Expand Down Expand Up @@ -583,7 +595,7 @@ namespace Theorems
begin
induction p; symmetry; transitivity; apply Types.Equiv.transportOverHmtpy;
transitivity; apply ap (· ⬝ ap (λ (h : A → B), h a) (funext q));
apply Id.reflRight; transitivity; symmetry; apply mapFunctoriality (λ (h : A → B), h a);
apply Id.rid; transitivity; symmetry; apply mapFunctoriality (λ (h : A → B), h a);
transitivity; apply ap; apply Id.invComp; reflexivity
end

Expand Down Expand Up @@ -700,7 +712,7 @@ hott def Finite := iter 𝟏 𝟎
@[match_pattern] def Finite.succ {n : ℕ} : Finite n → Finite (n + 1) := Sum.inl

open Structures (prop propset)
hott def hrel (A : Type u) := A → A → propset.{v}
hott def hrel (A : Type u) := A → A → Prop v

def LEMinf := Π (A : Type u), A + ¬A
macro "LEM∞" : term => `(LEMinf)
Expand Down Expand Up @@ -758,7 +770,7 @@ begin
apply Theorems.funext; intro;
apply (R _ _).2 };
{ intros f g;
apply Theorems.funext; intro;
apply Theorems.funext; intro;
apply Theorems.funext; intro;
apply Theorems.funext; intro;
apply Theorems.funext; intro;
Expand Down Expand Up @@ -883,14 +895,14 @@ namespace Types.Id
α^p = conjugateΩ (apd idp p) (apΩ (transport (λ x, x = x) p) α) :=
begin induction p; symmetry; apply idmapΩ end

hott def higherTransportIdfun {A : Type u} {a : A} (ε : idp a = idp a) :
hott lemma transportAbelian {A : Type u} {a : A} (ε : idp a = idp a) :
transport (λ x, x = x) ε ~ λ x, x :=
λ _, transportInvCompComp _ _ ⬝ cancelHigherConjLeft _ _

hott def abelianΩ {A : Type u} {a : A} (p : idp a = idp a) :
hott theorem abelianΩ {A : Type u} {a : A} (p : idp a = idp a) :
Π (n : ℕ) (α : Ω[n + 1](a = a, idp a)), α^p = α
| Nat.zero, _ => higherTransportIdfun _ _
| Nat.succ n, _ => conjugateSuccΩ _ _ _ ⬝ ap (conjugateΩ (apd idp p)) (apWithHomotopyΩ (higherTransportIdfun _) _ _) ⬝
| Nat.zero, _ => transportAbelian _ _
| Nat.succ n, _ => conjugateSuccΩ _ _ _ ⬝ ap (conjugateΩ (apd idp p)) (apWithHomotopyΩ (transportAbelian _) _ _) ⬝
(conjugateTransΩ _ _ (n + 1) _)⁻¹ ⬝ abelianΩ _ _ _ ⬝ idmapΩ _ _

hott def comApΩ {A : Type u} {B : Type v} {C : Type w} (f : B → C) (g : A → B) {a : A} :
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Theorems/Classical.lean
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ axiom choice {A : Type u} (B : A → Type v) (η : Π x, B x → Type w) :
∥(Σ (φ : Π x, B x), Π x, η x (φ x))∥

noncomputable hott def choiceOfRel {A : Type u} {B : Type v}
(R : A → B → propset.{w}) (H : hset A) (G : hset B) :
(R : A → B → Prop w) (H : hset A) (G : hset B) :
(Π x, ∥(Σ y, (R x y).fst)∥) → ∥(Σ (φ : A → B), Π x, (R x (φ x)).fst)∥ :=
begin
apply @choice A (λ _, B) (λ x y, (R x y).1);
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Theorems/Equiv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ begin
{ transitivity; apply transportOverPi; apply Theorems.funext; intro;
transitivity; apply transportOverPi; apply Theorems.funext; intro;
transitivity; apply transportOverContrMap;
transitivity; apply Id.reflRight;
transitivity; apply Id.rid;
transitivity; apply Id.mapInv;
transitivity; apply ap Id.inv;
transitivity; apply mapToHapply₄;
Expand Down
2 changes: 1 addition & 1 deletion GroundZero/Theorems/Hopf.lean
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace Real
begin
fapply Suspension.ind; reflexivity; apply Suspension.merid true;
intro (b : 𝟐); apply Id.trans; apply Equiv.transportOverHmtpy;
transitivity; apply ap (· ⬝ _); transitivity; apply Id.reflRight;
transitivity; apply ap (· ⬝ _); transitivity; apply Id.rid;
transitivity; apply Id.mapInv; apply ap; transitivity; apply Equiv.mapOverComp;
apply ap (ap map); apply Suspension.recβrule; induction b;
{ transitivity; apply ap (· ⬝ _); transitivity; apply ap; apply Sigma.mapFstOverProd;
Expand Down
4 changes: 2 additions & 2 deletions GroundZero/Types/Ens.lean
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ begin
{ intro; apply propIsSet; apply s.2 }
end

hott def predicate (A : Type u) := A → propset.{v}
hott def predicate (A : Type u) := A → Prop v

hott def Ens.eqvPredicate {A : Type u} : Ens A ≃ predicate A :=
begin
Expand All @@ -112,4 +112,4 @@ hott def Ens.singletonInh {A : Type u} (H : Structures.hset A) (x : A) : Ens.inh
HITs.Merely.elem ⟨x, Id.refl⟩

end Types
end GroundZero
end GroundZero
Loading

0 comments on commit f4c870c

Please sign in to comment.