Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New Design #8

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6645022
Draft the doc for new design
utensil Jul 12, 2020
27edad5
Add inspirations.lean
utensil Jul 12, 2020
f692a3e
Add operatrors.lean
utensil Jul 12, 2020
1ef4437
Add defs.lean
utensil Jul 12, 2020
456a95e
Fix typos found in review
utensil Jul 13, 2020
a9c56f7
Change universe symbols
utensil Jul 13, 2020
62cbbeb
Trying stop using old structure
utensil Jul 14, 2020
604ef0f
Experiment with bundled definitions
utensil Jul 14, 2020
56ba0af
Merge branch 'master' of https://github.com/pygae/lean-ga into utensi…
utensil Jul 14, 2020
5f8d3eb
Breakthrough: worked out stating theorems under variables
utensil Jul 15, 2020
a727f31
Update related inspirations.lean
utensil Jul 18, 2020
f7f09d6
Ignore local experiments
utensil Jul 18, 2020
8371f5d
Further explore unbundled v.s. (semi-)bundled
utensil Jul 18, 2020
f465714
Add equiv to inspirations
utensil Jul 18, 2020
487738a
Cl(V,Q) is a N-filtered algebra
utensil Jul 18, 2020
699cd14
Relation with Grassmann-Cayley Algebra
utensil Jul 21, 2020
d377450
leanproject up
utensil Jul 21, 2020
a388fbd
group, proof_demo, and unbundled GA for the talk
utensil Jul 28, 2020
724220b
Alternate proof formulation, maybe more readable? (#10)
eric-wieser Jul 29, 2020
8538cfc
General clean up and improve the proof doc
utensil Jul 29, 2020
948c9b4
Add bundled quadratic_form
utensil Jul 29, 2020
2a2c83a
Add unbundled_range
eric-wieser Jul 29, 2020
2f2dff1
Rewrite to calc
utensil Jul 29, 2020
1efb817
Merge branch 'master' of https://github.com/pygae/lean-ga into utensi…
utensil Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.olean
/_target
/leanpkg.path
src/geometric_algebra/experiment/
168 changes: 168 additions & 0 deletions docs/misc/new_design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Rethinking the Design of Mathematical Theory Development in Lean

It turns out that we must have a design template in mind in order to carry on further designing of GA in Lean. This document will address this issue.

## Key Insight from Euclidean Geometry

Taking a step back, let's go back to geometry and look at https://github.com/vaibhavkarve/leanteach2020/blob/master/src/euclid.lean .

What's a point? How do we tell this concept to the computer? Do we draw a point? Or do we went to analytic geometry and give it a coordinate? It turns out we don't need to do either, the former is infeasible and the latter is the worst idea in formalizing.

```lean
constant Point : Type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I have a pointXY structure, and I want to apply the theorems about Point to it?

Copy link
Member Author

@utensil utensil Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph discusses how to do abstract reasoning without ever coming back to the concrete world. There was supposed to be a paragraph about what if we need to link back to the concrete world then that's where type classes come in. And I should also discuss using class v.s. structure (1:1 v.s. 1:n) as pointed out by Kevin Buzzard.

```

How about a line? Same.

```lean
constant Line : Type
```

How about the relations between points and lines?

```lean
constant lies_on : Point → Line → Prop
constant between : Point → Point → Point → Prop -- (between a b c) means "b is in between a and c"
constant congruent {A : Type} : A → A → Prop
constant distance : Point → Point → ℝ
```

How about axioms?

```lean
axiom distance_not_neg {p1 p2 : Point} : 0 ≤ distance p1 p2
axiom distance_pos {p1 p2 : Point} : p1 ≠ p2 ↔ 0 < distance p1 p2
```

And this keeps on and on. Then we have a lot of lemmas and theorems and we still don't need to know what exactly a point is, we don't even need to know how to compute a distance.

That's it. We don't need concrete types or computibility to reason about them. The semantic can end with their names and we don't need to know more underneath.

This is the key insight one must have before formalizing a piece of mathematics.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add structure v.s. class here

## Compatibility with mathlib

A geometric product "contains" an inner product and an exterior product (or wedge product).

They're established mathematic. There's already inner product space in mathlib and there would definitely be Grassmann Algebra in mathlib one day. And obviously we can't escape the general Clifford Algebra too.

We must maintain compatibility with them, at least don't conflict with their existence.

It's not a duplication. The development of mathlib is driven by professional mathematitians, they struggle for math generity but we're working at an abstraction level close to applications.

We want to stand on such shoulders but we want good capsulation so that we don't want to worry about more abstract concepts and some too general cases. This would definitely leak, it might not be obvious in definitions but it would be very clear when you're proving something. For example, you have to deal with lattice and finsupp when proving things about linear algebra, and that should not be.

## Operators

We start with has_* that have absolutely no axioms with them, they don't have any properties and any behaviors. It's almost just a name. And we associate notations with them.

Just like in https://github.com/leanprover-community/lean/blob/master/library/init/core.lean#L321

```lean
class has_mul (α : Type u) := (mul : α → α → α)
```

we could just:

```lean
class has_wedge (α : Type u) := (wedge : α → α → α)
class has_inner (α : Type u) := (inner : α → α → α)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_inner assumes the result is real. It could be a more concrete instance of the general has_dot we have.

```

The latter presumably is already in mathlib and has a lot of structures and properties associated with it. We'll deal with that later.

As for geometric product, I'm thinking about the following short name instead of `geomprod`, `gp` etc.:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that gmul doesn't scale well, Scalar Product can't be smul because it's used by has_scalar which would be in our inheritance hierarchy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we have geometric_algebra.has_scalar_product.smul to distinguish from has_scalar.smul? Or do namespaces not work well here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old structure is flat, so no matter where smul comes from, as long as it's in our inheritance hierarchy, it conflicts.

Better avoid it anyway.


```lean
class has_gmul (α : Type u) := (gmul : α → α → α)
```

## Notations

Now we assoc notations with them:

```lean
-- \circ
infix ∘ := has_gmul.gmul
-- \wedge
infix ∧ := has_wedge.wedge
-- \cdot
infix ⋅ := has_inner.inner
```

We'll always use `local` notations waiting for to be `open_locale`ed. I expect conflicts with notations in mathlib and using this to avoid the conflicts as long as possible.

> TODO: describe how to use them even when there's a confliction.

## Defining without defining

There're really millions of products defined in GA and they're based on the geometric product. But the definition might not be the most efficient one or the most intuitive one.

So instead of using `def`, we should make these products just a product with a `Prop` asserting that they're equal to the definition based on gp and let the implementation prove it when intantiate the instance.

```lean
class has_ga_wedge (α : Type u) extends has_wedge :=
(defeq : ∀ a b : α, a ∧ b = (a ∘ b - b ∘ a) / 2)
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't happen yet.


The above ignore the fact this only works on vectors instead of multivectors.

So the true story is that we should define `has_sym_mul` and `has_asym_mul` first.

## The complication with mul

mul group diamond

C wrong

## ga extends has_gmul

## ga vs mv

## the standard template

import universe open variables

class with parameter

bundle

prio

marker forgetful_to

directory structure

## defs and lemmas

contains no lemma except for ... see groups/defs.lean

recover the usual for demo but never use them

## R V are not G0 G1

## G is vector space

## linear map

no `:G` or `coe`

## vector_contractible

non-metric

quadratic form?

functional?

induced topology

## attr

## universal algebra

## what to inherit and forget?

## Clifford and Grassmann

## graded comes later
61 changes: 46 additions & 15 deletions docs/misc/related.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@ Related References
GA & Lean related
--------------------

### Lean/Mathlib Src

- [init/core](https://github.com/leanprover/lean/blob/master/library/init/core.lean)
- [data/complex/basic](https://github.com/leanprover-community/mathlib/blob/master/src/data/complex/basic.lean)
- [data/matrix/basic](https://github.com/leanprover-community/mathlib/blob/master/src/data/matrix/basic.lean)
- [geometry/euclidean](https://github.com/leanprover-community/mathlib/blob/master/src/geometry/euclidean.lean)
- https://github.com/jsm28/bmo2-2020-lean/
- [geometry/manifold/real_instances](https://github.com/leanprover-community/mathlib/blob/master/src/geometry/manifold/real_instances.lean)
- [analysis/convex/cone](https://github.com/leanprover-community/mathlib/blob/master/src/analysis/convex/cone.lean)
- [analysis/normed_space/real_inner_product](https://github.com/leanprover-community/mathlib/blob/master/src/analysis/normed_space/real_inner_product.lean)
- [doc](https://leanprover-community.github.io/mathlib_docs/analysis/normed_space/real_inner_product.html#inner_product_space)

### Lean/Mathlib PRs

- [`feat(data/quaternion): define quaternions and prove some basic properties #2339`](https://github.com/leanprover-community/mathlib/pull/2339/)
- [refactor(algebra/module): change module into an abbreviation for semimodule #2848](https://github.com/leanprover-community/mathlib/pull/2848)
- [feat(algebra/add_torsor): torsors of additive group actions #2720](https://github.com/leanprover-community/mathlib/pull/2720/files)

### Inspiring Lean Code

- [Formalizing Euclid's Axioms](https://github.com/vaibhavkarve/leanteach2020/blob/master/src/euclid.lean)
- [commutative differential graded algebras](https://gist.github.com/kbuzzard/f5ee35457c5d257ceec58c66d7da0c38)
- [free module](https://gist.github.com/sflicht/53bdcdb1e3536e668736f7b4eb63cd79)
- [Huber_pair](https://github.com/leanprover-community/lean-perfectoid-spaces/blob/master/src/Huber_pair.lean#L72)
- https://github.com/jsm28/bmo2-2020-lean/
- https://github.com/GeoCoq/GeoCoq/tree/master/Highschool (in Coq)

### Lean/Mathlib Doc

Expand Down Expand Up @@ -63,6 +51,7 @@ GA & Lean related
- https://github.com/leanprover/vscode-lean/blob/master/translations.json
- https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts
- https://en.wikipedia.org/wiki/List_of_mathematical_symbols_by_subject
- [Unicode characters and corresponding LaTeX math mode commands](http://milde.users.sourceforge.net/LUCR/Math/unimathsymbols.pdf)


### Tactics
Expand Down Expand Up @@ -114,6 +103,46 @@ with Clifford Algebras](https://macau.uni-kiel.de/servlets/MCRFileNodeServlet/di
- [Chris Doran's Geometric Algebra Haskell Package](https://github.com/ga/haskell)
- http://geometry.mrao.cam.ac.uk/2016/10/geometric-algebra-2016/
- http://math.uga.edu/~pete/quadraticforms.pdf
- [Comparing Complex Numbers to Clifford Algebra](https://www.av8n.com/physics/complex-clifford.pdf)
- [Euclidean Geometry and Geometric Algebra](http://geometry.mrao.cam.ac.uk/2020/06/euclidean-geometry-and-geometric-algebra/)

Related Math Concepts
------------------------

- [Free module](https://en.wikipedia.org/wiki/Free_module)
- [Free algebra](https://en.wikipedia.org/wiki/Free_algebra)
- [Universal algebra](https://en.wikipedia.org/wiki/Universal_algebra)
- [Sedenion](https://en.wikipedia.org/wiki/Sedenion)
- [Alternative algebra](https://en.wikipedia.org/wiki/Alternative_algebra)
- [Metric signature](https://en.wikipedia.org/wiki/Metric_signature)
- [Complete lattice](https://en.wikipedia.org/wiki/Complete_lattice)
- [Filters](https://en.wikipedia.org/wiki/Filter_(mathematics))
- [Topology in mathlib](https://www.imo.universite-paris-saclay.fr/~pmassot/topology.pdf)
- [examples of fields](https://planetmath.org/examplesoffields)
- [differential forms on simplices](https://ncatlab.org/nlab/show/differential+forms+on+simplices)
- [Differential graded algebras](https://stacks.math.columbia.edu/tag/061U)

> A [Clifford algebra](https://en.wikipedia.org/wiki/Clifford_algebra) is an algebra generated by a vector space with a quadratic form, and is a unital associative algebra(a K-algebra(K is called the base field of Clifford algebra)), and satisfy a [universal property](https://en.wikipedia.org/wiki/Universal_property).
> Let Q:V→k denote a quadratic form on a vector space V over a field k. The Clifford algebra Cl(V,Q) is defined as T(V)/I_Q where T(V) is the tensor algebra of V and I_Q is the two-sided ideal generated by all elements of the form v⊗v−Q(v) for all v∈V.
> Cl(V,Q) is the exterior algebra ∧V when Q=0.
> Clifford algebra is also a quantization of the exterior algebra.
> To create a Clifford algebra, all one needs to do is specify a quadratic form.
> Cl(V,Q) is a N-[filtered algebra](https://en.wikipedia.org/wiki/Filtered_algebra), Z/2Z-[graded algebra](https://en.wikipedia.org/wiki/Graded_ring#Graded_algebra), the associated graded algebra to the filtration is the exterior algebra
> quantization map q: ∧(V)→Cl(V)
> Clifford algebras may be thought of as quantizations (cf. quantum group) of the exterior algebra, in the same way that the [Weyl algebra](https://en.wikipedia.org/wiki/Weyl_algebra) is a quantization of the symmetric algebra.
> Weyl algebras and Clifford algebras admit a further structure of a [*-algebra](https://en.wikipedia.org/wiki/*-algebra), and can be unified as even and odd terms of a superalgebra, as discussed in CCR and CAR algebras.

- [Clifford Algebras in Sage manual](https://doc.sagemath.org/html/en/reference/algebras/sage/algebras/clifford_algebra.html)
- [Clifford Algebras as Filtered Algebras](http://www-math.mit.edu/~dav/cliffordfilt.pdf)
- [MATH 651: Lie Algebras - Lecture 8 - Universal Enveloping Algebras and Related Concepts, II](https://www.math.upenn.edu/~brweber/Courses/2013/Math651/Notes/L8_UEnvAlgII.pdf)
- [PG course on Spin Geometry - Lecture 1: Clifford algebras: basic notions](https://empg.maths.ed.ac.uk/Activities/Spin/Lecture1.pdf)
- [MAT 1120HF Lie groups and Clifford algebras - CHAPTER 2 Clifford algebras](http://www.math.toronto.edu/mein/teaching/LieClifford/cl2.pdf)
- [Topics in Representation Theory: Clifford Algebras](http://www.math.columbia.edu/~woit/notes17.pdf)
- [Clifford algebras and Lie theory](https://link.springer.com/chapter/10.1007%2F978-3-642-36216-3_2)

- [Geometric Algebra FAQ](https://staff.science.uva.nl/l.dorst/clifford/faq.html)
- Q11. HOW IS IT DIFFERENT FROM CLIFFORD ALGEBRA?
- Q12. HOW IS IT DIFFERENT FROM GRASSMANN-CAYLEY ALGEBRA?

Lean related
------------------
Expand Down Expand Up @@ -182,4 +211,6 @@ Theorem Prover/Type theory related
- [Comparison of Two Theorem Provers: Isabelle/HOL and Coq](https://arxiv.org/abs/1808.09701)
- [A Survey of Languages for Formalizing Mathematics](https://arxiv.org/abs/2005.12876)
- [Category theory for scientists](https://arxiv.org/abs/1302.6946)
- [Rethinking set theory](https://arxiv.org/abs/1212.6543)
- [Rethinking set theory](https://arxiv.org/abs/1212.6543)
- [Lean versus Coq: The cultural chasm](https://artagnon.com/articles/leancoq)
- [Equality of mathematical structures](https://www.cs.bham.ac.uk/~mhe/.talks/xii-pcc.pdf)
4 changes: 2 additions & 2 deletions leanpkg.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "lean-ga"
version = "0.1"
lean_version = "leanprover-community/lean:3.16.5"
lean_version = "leanprover-community/lean:3.17.1"
path = "src"

[dependencies]
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "e803c851d221764eb3ec8bf010e4ed300a32b113"}
mathlib = {git = "https://github.com/leanprover-community/mathlib", rev = "0322d8927d4cdc401a33743ab84e497e85916886"}
97 changes: 97 additions & 0 deletions src/geometric_algebra/generic/bundled_defs.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/-
Copyright (c) 2020 lean-ga Team. All rights reserved.
Released under MIT license as described in the file LICENRE.
Authors: Utensil Rong
-/
import ring_theory.algebra
import linear_algebra.quadratic_form
import tactic
import tactic.lint

-- import geometric_algebra.generic.operators

universes u₀ u₁ u₂

section prio
-- set_option default_priority 200 -- see Note [default priority]
set_option default_priority 100

/--
-/
@[ancestor algebra]
class semi_geometric_algebra
(R : Type u₀) [field R]
(G : Type u₂) [ring G]
extends algebra R G
:=
(V : Type u₁)
[V_acg : add_comm_group V]
[V_vs : vector_space R V]

/--
-/
class weak_geometric_algebra
(R : Type u₀) [field R]
(G : Type u₂) [ring G]
extends semi_geometric_algebra R G
:=
(fᵣ : R →+* G := algebra_map R G)
(fᵥ : V →ₗ[R] G)
-- this is the weaker form of the contraction rule for vectors
(vector_contract' : ∀ v, ∃ r, fᵥ v * fᵥ v = fᵣ r )

/--
-/
class geometric_algebra
(R : Type u₀) [field R]
(G : Type u₂) [ring G]
extends weak_geometric_algebra R G
:=
(q : quadratic_form R V)
(vector_contract : ∀ v, fᵥ v * fᵥ v = fᵣ (q v) )

end prio

-- #print geometric_algebra

namespace geometric_algebra

variables {R : Type u₀} [field R]
-- variables {V : Type u₁} [add_comm_group V] [vector_space R V]
variables {G : Type u₂} [ring G]
variables [geometric_algebra R G]
variables (g : geometric_algebra R G)

namespace trivial

lemma assoc : ∀ A B C : G, (A * B) * C = A * (B * C) := mul_assoc

lemma left_distrib : ∀ A B C : G, A * (B + C) = (A * B) + (A * C) := mul_add

lemma right_distrib : ∀ A B C : G, (A + B) * C = (A * C) + (B * C) := add_mul

end trivial

-- def half : G := fᵣ V (2⁻¹ : R)

-- local notation ` ½[` T `]` := geometric_algebra.fᵣ (2⁻¹ : T)

-- def symm_prod (A B : G) : G := ½[R] * (A * B + B * A)

-- #check symm_prod

-- instance : inhabited (geometric_algebra R V G) := ⟨0⟩

-- @[simp] lemma to_fun_eq_coe : fᵥ.to_fun = ⇑fᵥ := rfl

-- #check ∀ v : g.V, fᵥ v

-- /-
-- Symmetrised product of two vectors must be a scalar
-- -/
-- lemma vec_symm_prod_is_scalar:
-- ∀ (u v : V), ∃ k : R, (fᵥ u) * (fᵥ u) = fᵣ k :=

end geometric_algebra

#lint
Loading