state
stringlengths 0
159k
| srcUpToTactic
stringlengths 387
167k
| nextTactic
stringlengths 3
9k
| declUpToTactic
stringlengths 22
11.5k
| declId
stringlengths 38
95
| decl
stringlengths 16
1.89k
| file_tag
stringlengths 17
73
|
---|---|---|---|---|---|---|
⊢ ∀ (x : Γ'),
x ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by | intro | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
x✝ : Γ'
⊢ x✝ ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; | cases_type* Γ' Bool | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case blank
⊢ blank ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case bit.false
⊢ bit false ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case bit.true
⊢ bit true ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case bra
⊢ bra ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case ket
⊢ ket ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
case comma
⊢ comma ∈
{ val := {blank, bit true, bit false, bra, ket, comma},
nodup := (_ : Multiset.Nodup {blank, bit true, bit false, bra, ket, comma}) } | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | decide | instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> | Mathlib.Computability.Encoding.67_0.rxHMk1LMmv2SbJ8 | instance Γ'.fintype : Fintype Γ' | Mathlib_Computability_Encoding |
⊢ ∀ (n : PosNum), decodePosNum (encodePosNum n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
| intro n | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
| Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
n : PosNum
⊢ decodePosNum (encodePosNum n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
| induction' n with m hm m hm | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
| Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case one
⊢ decodePosNum (encodePosNum PosNum.one) = PosNum.one | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | unfold encodePosNum decodePosNum | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case bit1
m : PosNum
hm : decodePosNum (encodePosNum m) = m
⊢ decodePosNum (encodePosNum (PosNum.bit1 m)) = PosNum.bit1 m | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | unfold encodePosNum decodePosNum | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case bit0
m : PosNum
hm : decodePosNum (encodePosNum m) = m
⊢ decodePosNum (encodePosNum (PosNum.bit0 m)) = PosNum.bit0 m | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | unfold encodePosNum decodePosNum | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case one
⊢ (if [] = [] then PosNum.one else PosNum.bit1 (decodePosNum [])) = PosNum.one | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· | rfl | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case bit1
m : PosNum
hm : decodePosNum (encodePosNum m) = m
⊢ (if encodePosNum m = [] then PosNum.one else PosNum.bit1 (decodePosNum (encodePosNum m))) = PosNum.bit1 m | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· | rw [hm] | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case bit1
m : PosNum
hm : decodePosNum (encodePosNum m) = m
⊢ (if encodePosNum m = [] then PosNum.one else PosNum.bit1 m) = PosNum.bit1 m | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
| exact if_neg (encodePosNum_nonempty m) | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
| Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
case bit0
m : PosNum
hm : decodePosNum (encodePosNum m) = m
⊢ PosNum.bit0 (decodePosNum (encodePosNum m)) = PosNum.bit0 m | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· | exact congr_arg PosNum.bit0 hm | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· | Mathlib.Computability.Encoding.133_0.rxHMk1LMmv2SbJ8 | theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n | Mathlib_Computability_Encoding |
⊢ ∀ (n : Num), decodeNum (encodeNum n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
| intro n | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
| Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
n : Num
⊢ decodeNum (encodeNum n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
| cases' n with n | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
| Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case zero
⊢ decodeNum (encodeNum Num.zero) = Num.zero | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> | unfold encodeNum decodeNum | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> | Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case pos
n : PosNum
⊢ decodeNum (encodeNum (Num.pos n)) = Num.pos n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> | unfold encodeNum decodeNum | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> | Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case zero
⊢ (if
(match Num.zero with
| Num.zero => []
| Num.pos n => encodePosNum n) =
[] then
Num.zero
else
↑(decodePosNum
(match Num.zero with
| Num.zero => []
| Num.pos n => encodePosNum n))) =
Num.zero | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· | rfl | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· | Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case pos
n : PosNum
⊢ (if
(match Num.pos n with
| Num.zero => []
| Num.pos n => encodePosNum n) =
[] then
Num.zero
else
↑(decodePosNum
(match Num.pos n with
| Num.zero => []
| Num.pos n => encodePosNum n))) =
Num.pos n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
| rw [decode_encodePosNum n] | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
| Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case pos
n : PosNum
⊢ (if
(match Num.pos n with
| Num.zero => []
| Num.pos n => encodePosNum n) =
[] then
Num.zero
else ↑n) =
Num.pos n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
| rw [PosNum.cast_to_num] | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
| Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
case pos
n : PosNum
⊢ (if
(match Num.pos n with
| Num.zero => []
| Num.pos n => encodePosNum n) =
[] then
Num.zero
else Num.pos n) =
Num.pos n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
| exact if_neg (encodePosNum_nonempty n) | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
| Mathlib.Computability.Encoding.142_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n | Mathlib_Computability_Encoding |
⊢ ∀ (n : ℕ), decodeNat (encodeNat n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
| intro n | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
| Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
n : ℕ
⊢ decodeNat (encodeNat n) = n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
| conv_rhs => rw [← Num.to_of_nat n] | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
| Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
n : ℕ
| n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | rw [← Num.to_of_nat n] | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
n : ℕ
| n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | rw [← Num.to_of_nat n] | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
n : ℕ
| n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | rw [← Num.to_of_nat n] | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => | Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
n : ℕ
⊢ decodeNat (encodeNat n) = ↑↑n | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
| exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n) | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
| Mathlib.Computability.Encoding.151_0.rxHMk1LMmv2SbJ8 | theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n | Mathlib_Computability_Encoding |
x : ℕ
⊢ decodeNat (List.map sectionΓ'Bool ((fun x => List.map inclusionBoolΓ' (encodeNat x)) x)) = x | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
| rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat] | /-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
| Mathlib.Computability.Encoding.170_0.rxHMk1LMmv2SbJ8 | /-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ | Mathlib_Computability_Encoding |
α : Type u
e : Encoding α
inst✝ : Encodable e.Γ
⊢ #α ≤ ℵ₀ | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat]
#align computability.encoding_nat_Γ' Computability.encodingNatΓ'
/-- A binary fin_encoding of ℕ in Γ'. -/
def finEncodingNatΓ' : FinEncoding ℕ :=
⟨encodingNatΓ', Γ'.fintype⟩
#align computability.fin_encoding_nat_Γ' Computability.finEncodingNatΓ'
/-- A unary encoding function of ℕ in bool. -/
def unaryEncodeNat : Nat → List Bool
| 0 => []
| n + 1 => true :: unaryEncodeNat n
#align computability.unary_encode_nat Computability.unaryEncodeNat
/-- A unary decoding function from `List Bool` to ℕ. -/
def unaryDecodeNat : List Bool → Nat :=
List.length
#align computability.unary_decode_nat Computability.unaryDecodeNat
theorem unary_decode_encode_nat : ∀ n, unaryDecodeNat (unaryEncodeNat n) = n := fun n =>
Nat.rec rfl (fun (_m : ℕ) hm => (congr_arg Nat.succ hm.symm).symm) n
#align computability.unary_decode_encode_nat Computability.unary_decode_encode_nat
/-- A unary fin_encoding of ℕ. -/
def unaryFinEncodingNat : FinEncoding ℕ where
Γ := Bool
encode := unaryEncodeNat
decode n := some (unaryDecodeNat n)
decode_encode n := congr_arg _ (unary_decode_encode_nat n)
ΓFin := Bool.fintype
#align computability.unary_fin_encoding_nat Computability.unaryFinEncodingNat
/-- An encoding function of bool in bool. -/
def encodeBool : Bool → List Bool :=
List.ret
#align computability.encode_bool Computability.encodeBool
/-- A decoding function from `List Bool` to bool. -/
def decodeBool : List Bool → Bool
| b :: _ => b
| _ => Inhabited.default
#align computability.decode_bool Computability.decodeBool
theorem decode_encodeBool : ∀ b, decodeBool (encodeBool b) = b := fun b => Bool.casesOn b rfl rfl
#align computability.decode_encode_bool Computability.decode_encodeBool
/-- A fin_encoding of bool in bool. -/
def finEncodingBoolBool : FinEncoding Bool where
Γ := Bool
encode := encodeBool
decode x := some (decodeBool x)
decode_encode x := congr_arg _ (decode_encodeBool x)
ΓFin := Bool.fintype
#align computability.fin_encoding_bool_bool Computability.finEncodingBoolBool
instance inhabitedFinEncoding : Inhabited (FinEncoding Bool) :=
⟨finEncodingBoolBool⟩
#align computability.inhabited_fin_encoding Computability.inhabitedFinEncoding
instance inhabitedEncoding : Inhabited (Encoding Bool) :=
⟨finEncodingBoolBool.toEncoding⟩
#align computability.inhabited_encoding Computability.inhabitedEncoding
theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift.{v} #α ≤ Cardinal.lift.{u} #(List e.Γ) :=
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
| refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _) | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
| Mathlib.Computability.Encoding.247_0.rxHMk1LMmv2SbJ8 | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ | Mathlib_Computability_Encoding |
α : Type u
e : Encoding α
inst✝ : Encodable e.Γ
⊢ lift.{u, v} #(List e.Γ) ≤ lift.{v, u} ℵ₀ | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat]
#align computability.encoding_nat_Γ' Computability.encodingNatΓ'
/-- A binary fin_encoding of ℕ in Γ'. -/
def finEncodingNatΓ' : FinEncoding ℕ :=
⟨encodingNatΓ', Γ'.fintype⟩
#align computability.fin_encoding_nat_Γ' Computability.finEncodingNatΓ'
/-- A unary encoding function of ℕ in bool. -/
def unaryEncodeNat : Nat → List Bool
| 0 => []
| n + 1 => true :: unaryEncodeNat n
#align computability.unary_encode_nat Computability.unaryEncodeNat
/-- A unary decoding function from `List Bool` to ℕ. -/
def unaryDecodeNat : List Bool → Nat :=
List.length
#align computability.unary_decode_nat Computability.unaryDecodeNat
theorem unary_decode_encode_nat : ∀ n, unaryDecodeNat (unaryEncodeNat n) = n := fun n =>
Nat.rec rfl (fun (_m : ℕ) hm => (congr_arg Nat.succ hm.symm).symm) n
#align computability.unary_decode_encode_nat Computability.unary_decode_encode_nat
/-- A unary fin_encoding of ℕ. -/
def unaryFinEncodingNat : FinEncoding ℕ where
Γ := Bool
encode := unaryEncodeNat
decode n := some (unaryDecodeNat n)
decode_encode n := congr_arg _ (unary_decode_encode_nat n)
ΓFin := Bool.fintype
#align computability.unary_fin_encoding_nat Computability.unaryFinEncodingNat
/-- An encoding function of bool in bool. -/
def encodeBool : Bool → List Bool :=
List.ret
#align computability.encode_bool Computability.encodeBool
/-- A decoding function from `List Bool` to bool. -/
def decodeBool : List Bool → Bool
| b :: _ => b
| _ => Inhabited.default
#align computability.decode_bool Computability.decodeBool
theorem decode_encodeBool : ∀ b, decodeBool (encodeBool b) = b := fun b => Bool.casesOn b rfl rfl
#align computability.decode_encode_bool Computability.decode_encodeBool
/-- A fin_encoding of bool in bool. -/
def finEncodingBoolBool : FinEncoding Bool where
Γ := Bool
encode := encodeBool
decode x := some (decodeBool x)
decode_encode x := congr_arg _ (decode_encodeBool x)
ΓFin := Bool.fintype
#align computability.fin_encoding_bool_bool Computability.finEncodingBoolBool
instance inhabitedFinEncoding : Inhabited (FinEncoding Bool) :=
⟨finEncodingBoolBool⟩
#align computability.inhabited_fin_encoding Computability.inhabitedFinEncoding
instance inhabitedEncoding : Inhabited (Encoding Bool) :=
⟨finEncodingBoolBool.toEncoding⟩
#align computability.inhabited_encoding Computability.inhabitedEncoding
theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift.{v} #α ≤ Cardinal.lift.{u} #(List e.Γ) :=
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
| simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0] | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
| Mathlib.Computability.Encoding.247_0.rxHMk1LMmv2SbJ8 | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ | Mathlib_Computability_Encoding |
α : Type u
e : Encoding α
inst✝ : Encodable e.Γ
⊢ #(List e.Γ) ≤ ℵ₀ | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat]
#align computability.encoding_nat_Γ' Computability.encodingNatΓ'
/-- A binary fin_encoding of ℕ in Γ'. -/
def finEncodingNatΓ' : FinEncoding ℕ :=
⟨encodingNatΓ', Γ'.fintype⟩
#align computability.fin_encoding_nat_Γ' Computability.finEncodingNatΓ'
/-- A unary encoding function of ℕ in bool. -/
def unaryEncodeNat : Nat → List Bool
| 0 => []
| n + 1 => true :: unaryEncodeNat n
#align computability.unary_encode_nat Computability.unaryEncodeNat
/-- A unary decoding function from `List Bool` to ℕ. -/
def unaryDecodeNat : List Bool → Nat :=
List.length
#align computability.unary_decode_nat Computability.unaryDecodeNat
theorem unary_decode_encode_nat : ∀ n, unaryDecodeNat (unaryEncodeNat n) = n := fun n =>
Nat.rec rfl (fun (_m : ℕ) hm => (congr_arg Nat.succ hm.symm).symm) n
#align computability.unary_decode_encode_nat Computability.unary_decode_encode_nat
/-- A unary fin_encoding of ℕ. -/
def unaryFinEncodingNat : FinEncoding ℕ where
Γ := Bool
encode := unaryEncodeNat
decode n := some (unaryDecodeNat n)
decode_encode n := congr_arg _ (unary_decode_encode_nat n)
ΓFin := Bool.fintype
#align computability.unary_fin_encoding_nat Computability.unaryFinEncodingNat
/-- An encoding function of bool in bool. -/
def encodeBool : Bool → List Bool :=
List.ret
#align computability.encode_bool Computability.encodeBool
/-- A decoding function from `List Bool` to bool. -/
def decodeBool : List Bool → Bool
| b :: _ => b
| _ => Inhabited.default
#align computability.decode_bool Computability.decodeBool
theorem decode_encodeBool : ∀ b, decodeBool (encodeBool b) = b := fun b => Bool.casesOn b rfl rfl
#align computability.decode_encode_bool Computability.decode_encodeBool
/-- A fin_encoding of bool in bool. -/
def finEncodingBoolBool : FinEncoding Bool where
Γ := Bool
encode := encodeBool
decode x := some (decodeBool x)
decode_encode x := congr_arg _ (decode_encodeBool x)
ΓFin := Bool.fintype
#align computability.fin_encoding_bool_bool Computability.finEncodingBoolBool
instance inhabitedFinEncoding : Inhabited (FinEncoding Bool) :=
⟨finEncodingBoolBool⟩
#align computability.inhabited_fin_encoding Computability.inhabitedFinEncoding
instance inhabitedEncoding : Inhabited (Encoding Bool) :=
⟨finEncodingBoolBool.toEncoding⟩
#align computability.inhabited_encoding Computability.inhabitedEncoding
theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift.{v} #α ≤ Cardinal.lift.{u} #(List e.Γ) :=
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
| cases' isEmpty_or_nonempty e.Γ with h h | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
| Mathlib.Computability.Encoding.247_0.rxHMk1LMmv2SbJ8 | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ | Mathlib_Computability_Encoding |
case inl
α : Type u
e : Encoding α
inst✝ : Encodable e.Γ
h : IsEmpty e.Γ
⊢ #(List e.Γ) ≤ ℵ₀ | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat]
#align computability.encoding_nat_Γ' Computability.encodingNatΓ'
/-- A binary fin_encoding of ℕ in Γ'. -/
def finEncodingNatΓ' : FinEncoding ℕ :=
⟨encodingNatΓ', Γ'.fintype⟩
#align computability.fin_encoding_nat_Γ' Computability.finEncodingNatΓ'
/-- A unary encoding function of ℕ in bool. -/
def unaryEncodeNat : Nat → List Bool
| 0 => []
| n + 1 => true :: unaryEncodeNat n
#align computability.unary_encode_nat Computability.unaryEncodeNat
/-- A unary decoding function from `List Bool` to ℕ. -/
def unaryDecodeNat : List Bool → Nat :=
List.length
#align computability.unary_decode_nat Computability.unaryDecodeNat
theorem unary_decode_encode_nat : ∀ n, unaryDecodeNat (unaryEncodeNat n) = n := fun n =>
Nat.rec rfl (fun (_m : ℕ) hm => (congr_arg Nat.succ hm.symm).symm) n
#align computability.unary_decode_encode_nat Computability.unary_decode_encode_nat
/-- A unary fin_encoding of ℕ. -/
def unaryFinEncodingNat : FinEncoding ℕ where
Γ := Bool
encode := unaryEncodeNat
decode n := some (unaryDecodeNat n)
decode_encode n := congr_arg _ (unary_decode_encode_nat n)
ΓFin := Bool.fintype
#align computability.unary_fin_encoding_nat Computability.unaryFinEncodingNat
/-- An encoding function of bool in bool. -/
def encodeBool : Bool → List Bool :=
List.ret
#align computability.encode_bool Computability.encodeBool
/-- A decoding function from `List Bool` to bool. -/
def decodeBool : List Bool → Bool
| b :: _ => b
| _ => Inhabited.default
#align computability.decode_bool Computability.decodeBool
theorem decode_encodeBool : ∀ b, decodeBool (encodeBool b) = b := fun b => Bool.casesOn b rfl rfl
#align computability.decode_encode_bool Computability.decode_encodeBool
/-- A fin_encoding of bool in bool. -/
def finEncodingBoolBool : FinEncoding Bool where
Γ := Bool
encode := encodeBool
decode x := some (decodeBool x)
decode_encode x := congr_arg _ (decode_encodeBool x)
ΓFin := Bool.fintype
#align computability.fin_encoding_bool_bool Computability.finEncodingBoolBool
instance inhabitedFinEncoding : Inhabited (FinEncoding Bool) :=
⟨finEncodingBoolBool⟩
#align computability.inhabited_fin_encoding Computability.inhabitedFinEncoding
instance inhabitedEncoding : Inhabited (Encoding Bool) :=
⟨finEncodingBoolBool.toEncoding⟩
#align computability.inhabited_encoding Computability.inhabitedEncoding
theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift.{v} #α ≤ Cardinal.lift.{u} #(List e.Γ) :=
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
cases' isEmpty_or_nonempty e.Γ with h h
· | simp only [Cardinal.mk_le_aleph0] | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
cases' isEmpty_or_nonempty e.Γ with h h
· | Mathlib.Computability.Encoding.247_0.rxHMk1LMmv2SbJ8 | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ | Mathlib_Computability_Encoding |
case inr
α : Type u
e : Encoding α
inst✝ : Encodable e.Γ
h : Nonempty e.Γ
⊢ #(List e.Γ) ≤ ℵ₀ | /-
Copyright (c) 2020 Pim Spelier, Daan van Gent. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Pim Spelier, Daan van Gent
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Num.Lemmas
import Mathlib.SetTheory.Cardinal.Ordinal
#align_import computability.encoding from "leanprover-community/mathlib"@"b6395b3a5acd655b16385fa0cdbf1961d6c34b3e"
/-!
# Encodings
This file contains the definition of a (finite) encoding, a map from a type to
strings in an alphabet, used in defining computability by Turing machines.
It also contains several examples:
## Examples
- `finEncodingNatBool` : a binary encoding of ℕ in a simple alphabet.
- `finEncodingNatΓ'` : a binary encoding of ℕ in the alphabet used for TM's.
- `unaryFinEncodingNat` : a unary encoding of ℕ
- `finEncodingBoolBool` : an encoding of bool.
-/
universe u v
open Cardinal
namespace Computability
/-- An encoding of a type in a certain alphabet, together with a decoding. -/
structure Encoding (α : Type u) where
Γ : Type v
encode : α → List Γ
decode : List Γ → Option α
decode_encode : ∀ x, decode (encode x) = some x
#align computability.encoding Computability.Encoding
theorem Encoding.encode_injective {α : Type u} (e : Encoding α) : Function.Injective e.encode := by
refine' fun _ _ h => Option.some_injective _ _
rw [← e.decode_encode, ← e.decode_encode, h]
#align computability.encoding.encode_injective Computability.Encoding.encode_injective
/-- An encoding plus a guarantee of finiteness of the alphabet. -/
structure FinEncoding (α : Type u) extends Encoding.{u, 0} α where
ΓFin : Fintype Γ
#align computability.fin_encoding Computability.FinEncoding
instance Γ.fintype {α : Type u} (e : FinEncoding α) : Fintype e.toEncoding.Γ :=
e.ΓFin
#align computability.Γ.fintype Computability.Γ.fintype
/-- A standard Turing machine alphabet, consisting of blank,bit0,bit1,bra,ket,comma. -/
inductive Γ'
| blank
| bit (b : Bool)
| bra
| ket
| comma
deriving DecidableEq
#align computability.Γ' Computability.Γ'
-- Porting note: A handler for `Fintype` had not been implemented yet.
instance Γ'.fintype : Fintype Γ' :=
⟨⟨{.blank, .bit true, .bit false, .bra, .ket, .comma}, by decide⟩,
by intro; cases_type* Γ' Bool <;> decide⟩
#align computability.Γ'.fintype Computability.Γ'.fintype
instance inhabitedΓ' : Inhabited Γ' :=
⟨Γ'.blank⟩
#align computability.inhabited_Γ' Computability.inhabitedΓ'
/-- The natural inclusion of bool in Γ'. -/
def inclusionBoolΓ' : Bool → Γ' :=
Γ'.bit
#align computability.inclusion_bool_Γ' Computability.inclusionBoolΓ'
/-- An arbitrary section of the natural inclusion of bool in Γ'. -/
def sectionΓ'Bool : Γ' → Bool
| Γ'.bit b => b
| _ => Inhabited.default
#align computability.section_Γ'_bool Computability.sectionΓ'Bool
theorem leftInverse_section_inclusion : Function.LeftInverse sectionΓ'Bool inclusionBoolΓ' :=
fun x => Bool.casesOn x rfl rfl
#align computability.left_inverse_section_inclusion Computability.leftInverse_section_inclusion
theorem inclusionBoolΓ'_injective : Function.Injective inclusionBoolΓ' :=
Function.HasLeftInverse.injective (Exists.intro sectionΓ'Bool leftInverse_section_inclusion)
#align computability.inclusion_bool_Γ'_injective Computability.inclusionBoolΓ'_injective
/-- An encoding function of the positive binary numbers in bool. -/
def encodePosNum : PosNum → List Bool
| PosNum.one => [true]
| PosNum.bit0 n => false :: encodePosNum n
| PosNum.bit1 n => true :: encodePosNum n
#align computability.encode_pos_num Computability.encodePosNum
/-- An encoding function of the binary numbers in bool. -/
def encodeNum : Num → List Bool
| Num.zero => []
| Num.pos n => encodePosNum n
#align computability.encode_num Computability.encodeNum
/-- An encoding function of ℕ in bool. -/
def encodeNat (n : ℕ) : List Bool :=
encodeNum n
#align computability.encode_nat Computability.encodeNat
/-- A decoding function from `List Bool` to the positive binary numbers. -/
def decodePosNum : List Bool → PosNum
| false :: l => PosNum.bit0 (decodePosNum l)
| true :: l => ite (l = []) PosNum.one (PosNum.bit1 (decodePosNum l))
| _ => PosNum.one
#align computability.decode_pos_num Computability.decodePosNum
/-- A decoding function from `List Bool` to the binary numbers. -/
def decodeNum : List Bool → Num := fun l => ite (l = []) Num.zero <| decodePosNum l
#align computability.decode_num Computability.decodeNum
/-- A decoding function from `List Bool` to ℕ. -/
def decodeNat : List Bool → Nat := fun l => decodeNum l
#align computability.decode_nat Computability.decodeNat
theorem encodePosNum_nonempty (n : PosNum) : encodePosNum n ≠ [] :=
PosNum.casesOn n (List.cons_ne_nil _ _) (fun _m => List.cons_ne_nil _ _) fun _m =>
List.cons_ne_nil _ _
#align computability.encode_pos_num_nonempty Computability.encodePosNum_nonempty
theorem decode_encodePosNum : ∀ n, decodePosNum (encodePosNum n) = n := by
intro n
induction' n with m hm m hm <;> unfold encodePosNum decodePosNum
· rfl
· rw [hm]
exact if_neg (encodePosNum_nonempty m)
· exact congr_arg PosNum.bit0 hm
#align computability.decode_encode_pos_num Computability.decode_encodePosNum
theorem decode_encodeNum : ∀ n, decodeNum (encodeNum n) = n := by
intro n
cases' n with n <;> unfold encodeNum decodeNum
· rfl
rw [decode_encodePosNum n]
rw [PosNum.cast_to_num]
exact if_neg (encodePosNum_nonempty n)
#align computability.decode_encode_num Computability.decode_encodeNum
theorem decode_encodeNat : ∀ n, decodeNat (encodeNat n) = n := by
intro n
conv_rhs => rw [← Num.to_of_nat n]
exact congr_arg ((↑) : Num → ℕ) (decode_encodeNum n)
#align computability.decode_encode_nat Computability.decode_encodeNat
/-- A binary encoding of ℕ in bool. -/
def encodingNatBool : Encoding ℕ where
Γ := Bool
encode := encodeNat
decode n := some (decodeNat n)
decode_encode n := congr_arg _ (decode_encodeNat n)
#align computability.encoding_nat_bool Computability.encodingNatBool
/-- A binary fin_encoding of ℕ in bool. -/
def finEncodingNatBool : FinEncoding ℕ :=
⟨encodingNatBool, Bool.fintype⟩
#align computability.fin_encoding_nat_bool Computability.finEncodingNatBool
/-- A binary encoding of ℕ in Γ'. -/
def encodingNatΓ' : Encoding ℕ where
Γ := Γ'
encode x := List.map inclusionBoolΓ' (encodeNat x)
decode x := some (decodeNat (List.map sectionΓ'Bool x))
decode_encode x :=
congr_arg _ <| by
-- Porting note: `rw` can't unify `g ∘ f` with `fun x => g (f x)`, used `LeftInverse.id`
-- instead.
rw [List.map_map, leftInverse_section_inclusion.id, List.map_id, decode_encodeNat]
#align computability.encoding_nat_Γ' Computability.encodingNatΓ'
/-- A binary fin_encoding of ℕ in Γ'. -/
def finEncodingNatΓ' : FinEncoding ℕ :=
⟨encodingNatΓ', Γ'.fintype⟩
#align computability.fin_encoding_nat_Γ' Computability.finEncodingNatΓ'
/-- A unary encoding function of ℕ in bool. -/
def unaryEncodeNat : Nat → List Bool
| 0 => []
| n + 1 => true :: unaryEncodeNat n
#align computability.unary_encode_nat Computability.unaryEncodeNat
/-- A unary decoding function from `List Bool` to ℕ. -/
def unaryDecodeNat : List Bool → Nat :=
List.length
#align computability.unary_decode_nat Computability.unaryDecodeNat
theorem unary_decode_encode_nat : ∀ n, unaryDecodeNat (unaryEncodeNat n) = n := fun n =>
Nat.rec rfl (fun (_m : ℕ) hm => (congr_arg Nat.succ hm.symm).symm) n
#align computability.unary_decode_encode_nat Computability.unary_decode_encode_nat
/-- A unary fin_encoding of ℕ. -/
def unaryFinEncodingNat : FinEncoding ℕ where
Γ := Bool
encode := unaryEncodeNat
decode n := some (unaryDecodeNat n)
decode_encode n := congr_arg _ (unary_decode_encode_nat n)
ΓFin := Bool.fintype
#align computability.unary_fin_encoding_nat Computability.unaryFinEncodingNat
/-- An encoding function of bool in bool. -/
def encodeBool : Bool → List Bool :=
List.ret
#align computability.encode_bool Computability.encodeBool
/-- A decoding function from `List Bool` to bool. -/
def decodeBool : List Bool → Bool
| b :: _ => b
| _ => Inhabited.default
#align computability.decode_bool Computability.decodeBool
theorem decode_encodeBool : ∀ b, decodeBool (encodeBool b) = b := fun b => Bool.casesOn b rfl rfl
#align computability.decode_encode_bool Computability.decode_encodeBool
/-- A fin_encoding of bool in bool. -/
def finEncodingBoolBool : FinEncoding Bool where
Γ := Bool
encode := encodeBool
decode x := some (decodeBool x)
decode_encode x := congr_arg _ (decode_encodeBool x)
ΓFin := Bool.fintype
#align computability.fin_encoding_bool_bool Computability.finEncodingBoolBool
instance inhabitedFinEncoding : Inhabited (FinEncoding Bool) :=
⟨finEncodingBoolBool⟩
#align computability.inhabited_fin_encoding Computability.inhabitedFinEncoding
instance inhabitedEncoding : Inhabited (Encoding Bool) :=
⟨finEncodingBoolBool.toEncoding⟩
#align computability.inhabited_encoding Computability.inhabitedEncoding
theorem Encoding.card_le_card_list {α : Type u} (e : Encoding.{u, v} α) :
Cardinal.lift.{v} #α ≤ Cardinal.lift.{u} #(List e.Γ) :=
Cardinal.lift_mk_le'.2 ⟨⟨e.encode, e.encode_injective⟩⟩
#align computability.encoding.card_le_card_list Computability.Encoding.card_le_card_list
theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
cases' isEmpty_or_nonempty e.Γ with h h
· simp only [Cardinal.mk_le_aleph0]
· | rw [Cardinal.mk_list_eq_aleph0] | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ := by
refine' Cardinal.lift_le.1 (e.card_le_card_list.trans _)
simp only [Cardinal.lift_aleph0, Cardinal.lift_le_aleph0]
cases' isEmpty_or_nonempty e.Γ with h h
· simp only [Cardinal.mk_le_aleph0]
· | Mathlib.Computability.Encoding.247_0.rxHMk1LMmv2SbJ8 | theorem Encoding.card_le_aleph0 {α : Type u} (e : Encoding.{u, v} α) [Encodable e.Γ] :
#α ≤ ℵ₀ | Mathlib_Computability_Encoding |
ι : Type u_1
c : ComplexShape ι
⊢ symm (symm c) = c | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
| ext | @[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
| Mathlib.Algebra.Homology.ComplexShape.99_0.XSrMOWOP54vJcCl | @[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c | Mathlib_Algebra_Homology_ComplexShape |
case Rel.h.h.a
ι : Type u_1
c : ComplexShape ι
x✝¹ x✝ : ι
⊢ Rel (symm (symm c)) x✝¹ x✝ ↔ Rel c x✝¹ x✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
| simp | @[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
| Mathlib.Algebra.Homology.ComplexShape.99_0.XSrMOWOP54vJcCl | @[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ j✝ j'✝ : ι
w : Relation.Comp c₁.Rel c₂.Rel i✝ j✝
w' : Relation.Comp c₁.Rel c₂.Rel i✝ j'✝
⊢ j✝ = j'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
| obtain ⟨k, w₁, w₂⟩ := w | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ j✝ j'✝ : ι
w' : Relation.Comp c₁.Rel c₂.Rel i✝ j'✝
k : ι
w₁ : Rel c₁ i✝ k
w₂ : Rel c₂ k j✝
⊢ j✝ = j'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
| obtain ⟨k', w₁', w₂'⟩ := w' | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro.intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ j✝ j'✝ k : ι
w₁ : Rel c₁ i✝ k
w₂ : Rel c₂ k j✝
k' : ι
w₁' : Rel c₁ i✝ k'
w₂' : Rel c₂ k' j'✝
⊢ j✝ = j'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
| rw [c₁.next_eq w₁ w₁'] at w₂ | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro.intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ j✝ j'✝ k : ι
w₁ : Rel c₁ i✝ k
k' : ι
w₂ : Rel c₂ k' j✝
w₁' : Rel c₁ i✝ k'
w₂' : Rel c₂ k' j'✝
⊢ j✝ = j'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
| exact c₂.next_eq w₂ w₂' | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ i'✝ j✝ : ι
w : Relation.Comp c₁.Rel c₂.Rel i✝ j✝
w' : Relation.Comp c₁.Rel c₂.Rel i'✝ j✝
⊢ i✝ = i'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
| obtain ⟨k, w₁, w₂⟩ := w | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ i'✝ j✝ : ι
w' : Relation.Comp c₁.Rel c₂.Rel i'✝ j✝
k : ι
w₁ : Rel c₁ i✝ k
w₂ : Rel c₂ k j✝
⊢ i✝ = i'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
| obtain ⟨k', w₁', w₂'⟩ := w' | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro.intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ i'✝ j✝ k : ι
w₁ : Rel c₁ i✝ k
w₂ : Rel c₂ k j✝
k' : ι
w₁' : Rel c₁ i'✝ k'
w₂' : Rel c₂ k' j✝
⊢ i✝ = i'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
| rw [c₂.prev_eq w₂ w₂'] at w₁ | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
case intro.intro.intro.intro
ι : Type u_1
c₁ c₂ : ComplexShape ι
i✝ i'✝ j✝ k : ι
w₂ : Rel c₂ k j✝
k' : ι
w₁ : Rel c₁ i✝ k'
w₁' : Rel c₁ i'✝ k'
w₂' : Rel c₂ k' j✝
⊢ i✝ = i'✝ | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
| exact c₁.prev_eq w₁ w₁' | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
| Mathlib.Algebra.Homology.ComplexShape.109_0.XSrMOWOP54vJcCl | /-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i : ι
⊢ Subsingleton { j // Rel c i j } | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
| constructor | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
| Mathlib.Algebra.Homology.ComplexShape.128_0.XSrMOWOP54vJcCl | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq
ι : Type u_1
c : ComplexShape ι
i : ι
⊢ ∀ (a b : { j // Rel c i j }), a = b | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
| rintro ⟨j, rij⟩ ⟨k, rik⟩ | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
| Mathlib.Algebra.Homology.ComplexShape.128_0.XSrMOWOP54vJcCl | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq.mk.mk
ι : Type u_1
c : ComplexShape ι
i j : ι
rij : Rel c i j
k : ι
rik : Rel c i k
⊢ { val := j, property := rij } = { val := k, property := rik } | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
| congr | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
| Mathlib.Algebra.Homology.ComplexShape.128_0.XSrMOWOP54vJcCl | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq.mk.mk.e_val
ι : Type u_1
c : ComplexShape ι
i j : ι
rij : Rel c i j
k : ι
rik : Rel c i k
⊢ j = k | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
| exact c.next_eq rij rik | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
| Mathlib.Algebra.Homology.ComplexShape.128_0.XSrMOWOP54vJcCl | instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
j : ι
⊢ Subsingleton { i // Rel c i j } | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
| constructor | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
| Mathlib.Algebra.Homology.ComplexShape.134_0.XSrMOWOP54vJcCl | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq
ι : Type u_1
c : ComplexShape ι
j : ι
⊢ ∀ (a b : { i // Rel c i j }), a = b | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
| rintro ⟨i, rik⟩ ⟨j, rjk⟩ | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
| Mathlib.Algebra.Homology.ComplexShape.134_0.XSrMOWOP54vJcCl | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq.mk.mk
ι : Type u_1
c : ComplexShape ι
j✝ i : ι
rik : Rel c i j✝
j : ι
rjk : Rel c j j✝
⊢ { val := i, property := rik } = { val := j, property := rjk } | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
| congr | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
| Mathlib.Algebra.Homology.ComplexShape.134_0.XSrMOWOP54vJcCl | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
case allEq.mk.mk.e_val
ι : Type u_1
c : ComplexShape ι
j✝ i : ι
rik : Rel c i j✝
j : ι
rjk : Rel c j j✝
⊢ i = j | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
| exact c.prev_eq rik rjk | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
| Mathlib.Algebra.Homology.ComplexShape.134_0.XSrMOWOP54vJcCl | instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ next c i = j | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
| apply c.next_eq _ h | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
| Mathlib.Algebra.Homology.ComplexShape.154_0.XSrMOWOP54vJcCl | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ Rel c i (next c i) | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
| rw [next] | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
| Mathlib.Algebra.Homology.ComplexShape.154_0.XSrMOWOP54vJcCl | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ Rel c i (if h : ∃ j, Rel c i j then Exists.choose h else i) | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
| rw [dif_pos] | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
| Mathlib.Algebra.Homology.ComplexShape.154_0.XSrMOWOP54vJcCl | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ Rel c i (Exists.choose ?hc)
case hc ι : Type u_1 c : ComplexShape ι i j : ι h : Rel c i j ⊢ ∃ j, Rel c i j | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
rw [dif_pos]
| exact Exists.choose_spec ⟨j, h⟩ | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
rw [dif_pos]
| Mathlib.Algebra.Homology.ComplexShape.154_0.XSrMOWOP54vJcCl | theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ prev c j = i | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
rw [dif_pos]
exact Exists.choose_spec ⟨j, h⟩
#align complex_shape.next_eq' ComplexShape.next_eq'
theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
| apply c.prev_eq _ h | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
| Mathlib.Algebra.Homology.ComplexShape.161_0.XSrMOWOP54vJcCl | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ Rel c (prev c j) j | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
rw [dif_pos]
exact Exists.choose_spec ⟨j, h⟩
#align complex_shape.next_eq' ComplexShape.next_eq'
theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
apply c.prev_eq _ h
| rw [prev, dif_pos] | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
apply c.prev_eq _ h
| Mathlib.Algebra.Homology.ComplexShape.161_0.XSrMOWOP54vJcCl | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i | Mathlib_Algebra_Homology_ComplexShape |
ι : Type u_1
c : ComplexShape ι
i j : ι
h : Rel c i j
⊢ Rel c (Exists.choose ?hc) j
case hc ι : Type u_1 c : ComplexShape ι i j : ι h : Rel c i j ⊢ ∃ i, Rel c i j | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Logic.Relation
#align_import algebra.homology.complex_shape from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23"
/-!
# Shapes of homological complexes
We define a structure `ComplexShape ι` for describing the shapes of homological complexes
indexed by a type `ι`.
This is intended to capture chain complexes and cochain complexes, indexed by either `ℕ` or `ℤ`,
as well as more exotic examples.
Rather than insisting that the indexing type has a `succ` function
specifying where differentials should go,
inside `c : ComplexShape` we have `c.Rel : ι → ι → Prop`,
and when we define `HomologicalComplex`
we only allow nonzero differentials `d i j` from `i` to `j` if `c.Rel i j`.
Further, we require that `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Convenience functions `c.next` and `c.prev` provide these related elements
when they exist, and return their input otherwise.
This design aims to avoid certain problems arising from dependent type theory.
In particular we never have to ensure morphisms `d i : X i ⟶ X (succ i)` compose as
expected (which would often require rewriting by equations in the indexing type).
Instead such identities become separate proof obligations when verifying that a
complex we've constructed is of the desired shape.
If `α` is an `AddRightCancelSemigroup`, then we define `up α : ComplexShape α`,
the shape appropriate for cohomology, so `d : X i ⟶ X j` is nonzero only when `j = i + 1`,
as well as `down α : ComplexShape α`, appropriate for homology,
so `d : X i ⟶ X j` is nonzero only when `i = j + 1`.
(Later we'll introduce `CochainComplex` and `ChainComplex` as abbreviations for
`HomologicalComplex` with one of these shapes baked in.)
-/
open Classical
noncomputable section
/-- A `c : ComplexShape ι` describes the shape of a chain complex,
with chain groups indexed by `ι`.
Typically `ι` will be `ℕ`, `ℤ`, or `Fin n`.
There is a relation `Rel : ι → ι → Prop`,
and we will only allow a non-zero differential from `i` to `j` when `Rel i j`.
There are axioms which imply `{ j // c.Rel i j }` and `{ i // c.Rel i j }` are subsingletons.
This means that the shape consists of some union of lines, rays, intervals, and circles.
Below we define `c.next` and `c.prev` which provide these related elements.
-/
@[ext]
structure ComplexShape (ι : Type*) where
/-- Nonzero differentials `X i ⟶ X j` shall be allowed
on homological complexes when `Rel i j` holds. -/
Rel : ι → ι → Prop
/-- There is at most one nonzero differential from `X i`. -/
next_eq : ∀ {i j j'}, Rel i j → Rel i j' → j = j'
/-- There is at most one nonzero differential to `X j`. -/
prev_eq : ∀ {i i' j}, Rel i j → Rel i' j → i = i'
#align complex_shape ComplexShape
#align complex_shape.ext ComplexShape.ext
#align complex_shape.ext_iff ComplexShape.ext_iff
namespace ComplexShape
variable {ι : Type*}
/-- The complex shape where only differentials from each `X.i` to itself are allowed.
This is mostly only useful so we can describe the relation of "related in `k` steps" below.
-/
@[simps]
def refl (ι : Type*) : ComplexShape ι where
Rel i j := i = j
next_eq w w' := w.symm.trans w'
prev_eq w w' := w.trans w'.symm
#align complex_shape.refl ComplexShape.refl
#align complex_shape.refl_rel ComplexShape.refl_Rel
/-- The reverse of a `ComplexShape`.
-/
@[simps]
def symm (c : ComplexShape ι) : ComplexShape ι where
Rel i j := c.Rel j i
next_eq w w' := c.prev_eq w w'
prev_eq w w' := c.next_eq w w'
#align complex_shape.symm ComplexShape.symm
#align complex_shape.symm_rel ComplexShape.symm_Rel
@[simp]
theorem symm_symm (c : ComplexShape ι) : c.symm.symm = c := by
ext
simp
#align complex_shape.symm_symm ComplexShape.symm_symm
theorem symm_bijective :
Function.Bijective (ComplexShape.symm : ComplexShape ι → ComplexShape ι) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
/-- The "composition" of two `ComplexShape`s.
We need this to define "related in k steps" later.
-/
@[simp]
def trans (c₁ c₂ : ComplexShape ι) : ComplexShape ι where
Rel := Relation.Comp c₁.Rel c₂.Rel
next_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₁.next_eq w₁ w₁'] at w₂
exact c₂.next_eq w₂ w₂'
prev_eq w w' := by
obtain ⟨k, w₁, w₂⟩ := w
obtain ⟨k', w₁', w₂'⟩ := w'
rw [c₂.prev_eq w₂ w₂'] at w₁
exact c₁.prev_eq w₁ w₁'
#align complex_shape.trans ComplexShape.trans
instance subsingleton_next (c : ComplexShape ι) (i : ι) : Subsingleton { j // c.Rel i j } := by
constructor
rintro ⟨j, rij⟩ ⟨k, rik⟩
congr
exact c.next_eq rij rik
instance subsingleton_prev (c : ComplexShape ι) (j : ι) : Subsingleton { i // c.Rel i j } := by
constructor
rintro ⟨i, rik⟩ ⟨j, rjk⟩
congr
exact c.prev_eq rik rjk
/-- An arbitrary choice of index `j` such that `Rel i j`, if such exists.
Returns `i` otherwise.
-/
def next (c : ComplexShape ι) (i : ι) : ι :=
if h : ∃ j, c.Rel i j then h.choose else i
#align complex_shape.next ComplexShape.next
/-- An arbitrary choice of index `i` such that `Rel i j`, if such exists.
Returns `j` otherwise.
-/
def prev (c : ComplexShape ι) (j : ι) : ι :=
if h : ∃ i, c.Rel i j then h.choose else j
#align complex_shape.prev ComplexShape.prev
theorem next_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.next i = j := by
apply c.next_eq _ h
rw [next]
rw [dif_pos]
exact Exists.choose_spec ⟨j, h⟩
#align complex_shape.next_eq' ComplexShape.next_eq'
theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
apply c.prev_eq _ h
rw [prev, dif_pos]
| exact Exists.choose_spec (⟨i, h⟩ : ∃ k, c.Rel k j) | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i := by
apply c.prev_eq _ h
rw [prev, dif_pos]
| Mathlib.Algebra.Homology.ComplexShape.161_0.XSrMOWOP54vJcCl | theorem prev_eq' (c : ComplexShape ι) {i j : ι} (h : c.Rel i j) : c.prev j = i | Mathlib_Algebra_Homology_ComplexShape |
α : Type u_1
x : ℤˣ
⊢ x ∈ {1, -1} | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by | cases Int.units_eq_one_or x | instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by | Mathlib.Data.Fintype.Units.20_0.6sF1mNVGQq4PLsW | instance UnitsInt.fintype : Fintype ℤˣ | Mathlib_Data_Fintype_Units |
case inl
α : Type u_1
x : ℤˣ
h✝ : x = 1
⊢ x ∈ {1, -1} | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> | simp [*] | instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> | Mathlib.Data.Fintype.Units.20_0.6sF1mNVGQq4PLsW | instance UnitsInt.fintype : Fintype ℤˣ | Mathlib_Data_Fintype_Units |
case inr
α : Type u_1
x : ℤˣ
h✝ : x = -1
⊢ x ∈ {1, -1} | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> | simp [*] | instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> | Mathlib.Data.Fintype.Units.20_0.6sF1mNVGQq4PLsW | instance UnitsInt.fintype : Fintype ℤˣ | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card α = card αˣ + 1 | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
| rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)] | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
| Mathlib.Data.Fintype.Units.37_0.6sF1mNVGQq4PLsW | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card { a // a ≠ 0 } + 1 = card α | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
| have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α))) | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
| Mathlib.Data.Fintype.Units.37_0.6sF1mNVGQq4PLsW | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
this : card ({ a // a = 0 } ⊕ { a // ¬a = 0 }) = card α
⊢ card { a // a ≠ 0 } + 1 = card α | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
| rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
| Mathlib.Data.Fintype.Units.37_0.6sF1mNVGQq4PLsW | theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
⊢ Nat.card α = Nat.card αˣ + 1 | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
| have : Fintype α := Fintype.ofFinite α | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
| Mathlib.Data.Fintype.Units.43_0.6sF1mNVGQq4PLsW | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
this : Fintype α
⊢ Nat.card α = Nat.card αˣ + 1 | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
have : Fintype α := Fintype.ofFinite α
| classical
rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one] | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
have : Fintype α := Fintype.ofFinite α
| Mathlib.Data.Fintype.Units.43_0.6sF1mNVGQq4PLsW | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
this : Fintype α
⊢ Nat.card α = Nat.card αˣ + 1 | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
have : Fintype α := Fintype.ofFinite α
classical
| rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one] | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
have : Fintype α := Fintype.ofFinite α
classical
| Mathlib.Data.Fintype.Units.43_0.6sF1mNVGQq4PLsW | theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 | Mathlib_Data_Fintype_Units |
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card αˣ = card α - 1 | /-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Units
import Mathlib.SetTheory.Cardinal.Finite
#align_import data.fintype.units from "leanprover-community/mathlib"@"509de852e1de55e1efa8eacfa11df0823f26f226"
/-!
# fintype instances relating to units
-/
variable {α : Type*}
instance UnitsInt.fintype : Fintype ℤˣ :=
⟨{1, -1}, fun x ↦ by cases Int.units_eq_one_or x <;> simp [*]⟩
#align units_int.fintype UnitsInt.fintype
@[simp]
theorem UnitsInt.univ : (Finset.univ : Finset ℤˣ) = {1, -1} := rfl
#align units_int.univ UnitsInt.univ
@[simp]
theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
#align fintype.card_units_int Fintype.card_units_int
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
theorem Fintype.card_eq_card_units_add_one [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card α = Fintype.card αˣ + 1 := by
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
theorem Nat.card_eq_card_units_add_one [GroupWithZero α] [Finite α] :
Nat.card α = Nat.card αˣ + 1 := by
have : Fintype α := Fintype.ofFinite α
classical
rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one]
theorem Fintype.card_units [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card αˣ = Fintype.card α - 1 := by
| rw [@Fintype.card_eq_card_units_add_one α, Nat.add_sub_cancel] | theorem Fintype.card_units [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card αˣ = Fintype.card α - 1 := by
| Mathlib.Data.Fintype.Units.49_0.6sF1mNVGQq4PLsW | theorem Fintype.card_units [GroupWithZero α] [Fintype α] [DecidableEq α] :
Fintype.card αˣ = Fintype.card α - 1 | Mathlib_Data_Fintype_Units |
θ : ℂ
⊢ cos θ = 0 ↔ ∃ k, θ = (2 * ↑k + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
| have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
| rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub] | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ cexp (θ * I - -θ * I) = -1 ↔ cexp (2 * θ * I) = -1 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
| congr 3 | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ cexp (θ * I - -θ * I) = -1 ↔ cexp (2 * θ * I) = -1 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; | ring_nf | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1
⊢ cos θ = 0 ↔ ∃ k, θ = (2 * ↑k + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
| rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm] | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1
⊢ (∃ n, 2 * I * θ = ↑π * I + ↑n * (2 * ↑π * I)) ↔ ∃ k, θ = (2 * ↑k + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
| refine' exists_congr fun x => _ | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1
x : ℤ
⊢ 2 * I * θ = ↑π * I + ↑x * (2 * ↑π * I) ↔ θ = (2 * ↑x + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
| refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero) | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1
x : ℤ
⊢ ↑π * I + ↑x * (2 * ↑π * I) = 2 * I * ((2 * ↑x + 1) * ↑π / 2) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
| field_simp | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : (cexp (θ * I) + cexp (-θ * I)) / 2 = 0 ↔ cexp (2 * θ * I) = -1
x : ℤ
⊢ (↑π * I + ↑x * (2 * ↑π * I)) * 2 = 2 * I * ((2 * ↑x + 1) * ↑π) | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; | ring | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.31_0.wRglntQQQHH0e1R | theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ cos θ ≠ 0 ↔ ∀ (k : ℤ), θ ≠ (2 * ↑k + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
| rw [← not_exists, not_iff_not, cos_eq_zero_iff] | theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.42_0.wRglntQQQHH0e1R | theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ sin θ = 0 ↔ ∃ k, θ = ↑k * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
| rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff] | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ (∃ k, θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2) ↔ ∃ k, θ = ↑k * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
| constructor | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case mp
θ : ℂ
⊢ (∃ k, θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2) → ∃ k, θ = ↑k * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· | rintro ⟨k, hk⟩ | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case mp.intro
θ : ℂ
k : ℤ
hk : θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2
⊢ ∃ k, θ = ↑k * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
| use k + 1 | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case h
θ : ℂ
k : ℤ
hk : θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2
⊢ θ = ↑(k + 1) * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
| field_simp [eq_add_of_sub_eq hk] | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case h
θ : ℂ
k : ℤ
hk : θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2
⊢ (2 * ↑k + 1) * ↑π + ↑π = (↑k + 1) * ↑π * 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
| ring | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case mpr
θ : ℂ
⊢ (∃ k, θ = ↑k * ↑π) → ∃ k, θ - ↑π / 2 = (2 * ↑k + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· | rintro ⟨k, rfl⟩ | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case mpr.intro
k : ℤ
⊢ ∃ k_1, ↑k * ↑π - ↑π / 2 = (2 * ↑k_1 + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
| use k - 1 | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case h
k : ℤ
⊢ ↑k * ↑π - ↑π / 2 = (2 * ↑(k - 1) + 1) * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
| field_simp | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
case h
k : ℤ
⊢ ↑k * ↑π * 2 - ↑π = (2 * (↑k - 1) + 1) * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
| ring | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.46_0.wRglntQQQHH0e1R | theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ sin θ ≠ 0 ↔ ∀ (k : ℤ), θ ≠ ↑k * ↑π | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
| rw [← not_exists, not_iff_not, sin_eq_zero_iff] | theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.59_0.wRglntQQQHH0e1R | theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ tan θ = 0 ↔ ∃ k, θ = ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
| have h := (sin_two_mul θ).symm | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.63_0.wRglntQQQHH0e1R | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : 2 * sin θ * cos θ = sin (2 * θ)
⊢ tan θ = 0 ↔ ∃ k, θ = ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
| rw [mul_assoc] at h | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.63_0.wRglntQQQHH0e1R | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : 2 * (sin θ * cos θ) = sin (2 * θ)
⊢ tan θ = 0 ↔ ∃ k, θ = ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
| rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm] | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.63_0.wRglntQQQHH0e1R | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
h : 2 * (sin θ * cos θ) = sin (2 * θ)
⊢ sin (θ * 2) / 2 = 0 / 2 ↔ ∃ k, θ = ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm]
| simpa only [zero_div, zero_mul, Ne.def, not_false_iff, field_simps] using
sin_eq_zero_iff | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm]
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.63_0.wRglntQQQHH0e1R | theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
θ : ℂ
⊢ tan θ ≠ 0 ↔ ∀ (k : ℤ), θ ≠ ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm]
simpa only [zero_div, zero_mul, Ne.def, not_false_iff, field_simps] using
sin_eq_zero_iff
#align complex.tan_eq_zero_iff Complex.tan_eq_zero_iff
theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π / 2 := by
| rw [← not_exists, not_iff_not, tan_eq_zero_iff] | theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π / 2 := by
| Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.72_0.wRglntQQQHH0e1R | theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π / 2 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
n : ℤ
⊢ ∃ k, ↑n * ↑π / 2 = ↑k * ↑π / 2 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm]
simpa only [zero_div, zero_mul, Ne.def, not_false_iff, field_simps] using
sin_eq_zero_iff
#align complex.tan_eq_zero_iff Complex.tan_eq_zero_iff
theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π / 2 := by
rw [← not_exists, not_iff_not, tan_eq_zero_iff]
#align complex.tan_ne_zero_iff Complex.tan_ne_zero_iff
theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 :=
tan_eq_zero_iff.mpr (by | use n | theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 :=
tan_eq_zero_iff.mpr (by | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.76_0.wRglntQQQHH0e1R | theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
x y : ℂ
⊢ cos x - cos y = 0 ↔ -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 | /-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import Mathlib.Algebra.QuadraticDiscriminant
import Mathlib.Analysis.Convex.SpecificFunctions.Deriv
#align_import analysis.special_functions.trigonometric.complex from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
/-!
# Complex trigonometric functions
Basic facts and derivatives for the complex trigonometric functions.
Several facts about the real trigonometric functions have the proofs deferred here, rather than
`Analysis.SpecialFunctions.Trigonometric.Basic`,
as they are most easily proved by appealing to the corresponding fact for complex trigonometric
functions, or require additional imports which are not available in that file.
-/
noncomputable section
namespace Complex
open Set Filter
open scoped Real
theorem cos_eq_zero_iff {θ : ℂ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * π / 2 := by
have h : (exp (θ * I) + exp (-θ * I)) / 2 = 0 ↔ exp (2 * θ * I) = -1 := by
rw [@div_eq_iff _ _ (exp (θ * I) + exp (-θ * I)) 2 0 two_ne_zero, zero_mul,
add_eq_zero_iff_eq_neg, neg_eq_neg_one_mul, ← div_eq_iff (exp_ne_zero _), ← exp_sub]
congr 3; ring_nf
rw [cos, h, ← exp_pi_mul_I, exp_eq_exp_iff_exists_int, mul_right_comm]
refine' exists_congr fun x => _
refine' (iff_of_eq <| congr_arg _ _).trans (mul_right_inj' <| mul_ne_zero two_ne_zero I_ne_zero)
field_simp; ring
#align complex.cos_eq_zero_iff Complex.cos_eq_zero_iff
theorem cos_ne_zero_iff {θ : ℂ} : cos θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ (2 * k + 1) * π / 2 := by
rw [← not_exists, not_iff_not, cos_eq_zero_iff]
#align complex.cos_ne_zero_iff Complex.cos_ne_zero_iff
theorem sin_eq_zero_iff {θ : ℂ} : sin θ = 0 ↔ ∃ k : ℤ, θ = k * π := by
rw [← Complex.cos_sub_pi_div_two, cos_eq_zero_iff]
constructor
· rintro ⟨k, hk⟩
use k + 1
field_simp [eq_add_of_sub_eq hk]
ring
· rintro ⟨k, rfl⟩
use k - 1
field_simp
ring
#align complex.sin_eq_zero_iff Complex.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : ℂ} : sin θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π := by
rw [← not_exists, not_iff_not, sin_eq_zero_iff]
#align complex.sin_ne_zero_iff Complex.sin_ne_zero_iff
theorem tan_eq_zero_iff {θ : ℂ} : tan θ = 0 ↔ ∃ k : ℤ, θ = k * π / 2 := by
have h := (sin_two_mul θ).symm
rw [mul_assoc] at h
rw [tan, div_eq_zero_iff, ← mul_eq_zero, ← zero_mul (1 / 2 : ℂ), mul_one_div,
CancelDenoms.cancel_factors_eq_div h two_ne_zero, mul_comm]
simpa only [zero_div, zero_mul, Ne.def, not_false_iff, field_simps] using
sin_eq_zero_iff
#align complex.tan_eq_zero_iff Complex.tan_eq_zero_iff
theorem tan_ne_zero_iff {θ : ℂ} : tan θ ≠ 0 ↔ ∀ k : ℤ, θ ≠ k * π / 2 := by
rw [← not_exists, not_iff_not, tan_eq_zero_iff]
#align complex.tan_ne_zero_iff Complex.tan_ne_zero_iff
theorem tan_int_mul_pi_div_two (n : ℤ) : tan (n * π / 2) = 0 :=
tan_eq_zero_iff.mpr (by use n)
#align complex.tan_int_mul_pi_div_two Complex.tan_int_mul_pi_div_two
theorem cos_eq_cos_iff {x y : ℂ} : cos x = cos y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x :=
calc
cos x = cos y ↔ cos x - cos y = 0 := sub_eq_zero.symm
_ ↔ -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 := by | rw [cos_sub_cos] | theorem cos_eq_cos_iff {x y : ℂ} : cos x = cos y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x :=
calc
cos x = cos y ↔ cos x - cos y = 0 := sub_eq_zero.symm
_ ↔ -2 * sin ((x + y) / 2) * sin ((x - y) / 2) = 0 := by | Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex.80_0.wRglntQQQHH0e1R | theorem cos_eq_cos_iff {x y : ℂ} : cos x = cos y ↔ ∃ k : ℤ, y = 2 * k * π + x ∨ y = 2 * k * π - x | Mathlib_Analysis_SpecialFunctions_Trigonometric_Complex |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.